Commit 808994ac authored by michael.simon's avatar michael.simon
Browse files

add group change event

parent 88de291c
......@@ -10,6 +10,7 @@
******************************************************************************/
package edu.kit.scc.webreg.service.impl;
import java.util.HashSet;
import java.util.List;
import javax.ejb.Stateless;
......@@ -20,11 +21,16 @@ import org.slf4j.Logger;
import edu.kit.scc.webreg.dao.BaseDao;
import edu.kit.scc.webreg.dao.LocalGroupDao;
import edu.kit.scc.webreg.dao.ServiceGroupFlagDao;
import edu.kit.scc.webreg.entity.EventType;
import edu.kit.scc.webreg.entity.GroupEntity;
import edu.kit.scc.webreg.entity.LocalGroupEntity;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.ServiceGroupFlagEntity;
import edu.kit.scc.webreg.entity.ServiceGroupStatus;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.event.EventSubmitter;
import edu.kit.scc.webreg.event.MultipleGroupEvent;
import edu.kit.scc.webreg.exc.EventSubmitException;
import edu.kit.scc.webreg.service.LocalGroupService;
import edu.kit.scc.webreg.service.group.LocalGroupCreator;
......@@ -45,6 +51,9 @@ public class LocalGroupServiceImpl extends BaseServiceImpl<LocalGroupEntity, Lon
@Inject
private ServiceGroupFlagDao groupFlagDao;
@Inject
private EventSubmitter eventSubmitter;
@Override
public LocalGroupEntity createNew(ServiceEntity service) {
return creator.createNew(service);
......@@ -54,6 +63,8 @@ public class LocalGroupServiceImpl extends BaseServiceImpl<LocalGroupEntity, Lon
public void createServiceGroupFlagsBulk(ServiceEntity fromService, ServiceEntity toService, String filterRegex) {
List<ServiceGroupFlagEntity> fromFlagList = groupFlagDao.findLocalGroupsForService(fromService);
HashSet<GroupEntity> allChangedGroups = new HashSet<GroupEntity>();
for (ServiceGroupFlagEntity fromFlag : fromFlagList) {
if (fromFlag.getGroup() instanceof LocalGroupEntity) {
LocalGroupEntity group = (LocalGroupEntity) fromFlag.getGroup();
......@@ -69,6 +80,7 @@ public class LocalGroupServiceImpl extends BaseServiceImpl<LocalGroupEntity, Lon
groupFlag.setStatus(ServiceGroupStatus.DIRTY);
groupFlag = groupFlagDao.persist(groupFlag);
allChangedGroups.add(group);
}
else {
logger.info("Skipping group flags for group {} and service {}, they already exist", group.getName(), toService.getShortName());
......@@ -79,6 +91,13 @@ public class LocalGroupServiceImpl extends BaseServiceImpl<LocalGroupEntity, Lon
}
}
}
MultipleGroupEvent mge = new MultipleGroupEvent(allChangedGroups);
try {
eventSubmitter.submit(mge, EventType.GROUP_UPDATE, "bulk-job");
} catch (EventSubmitException e) {
logger.warn("Exeption", e);
}
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment