@Test public final void testSaveTarget() { when(target4000.getState()).thenReturn(1); when(target4000.getOriginalState()).thenReturn(1); underTest.save(target4000); verify(targetDao).save(target4000, null); }
public void save(Target aTarget, List<GroupMemberDTO> parents) { boolean newSchedulesAddedByNonOwner = false; boolean wasHarvestNowSelected = aTarget.isHarvestNow(); if (aTarget.isDirty() && aTarget.getOriginalState() == Target.STATE_APPROVED && !authMgr.hasPrivilege(aTarget, Privilege.APPROVE_TARGET)) { log.debug("Target state changed to nominated due to changes"); aTarget.changeState(Target.STATE_NOMINATED); } if ((aTarget.getOriginalState() == Target.STATE_PENDING || aTarget.getOriginalState() == Target.STATE_REINSTATED || aTarget .getOriginalState() == Target.STATE_NOMINATED) && aTarget.getState() == Target.STATE_APPROVED) { aTarget.setSelectionDate(new Date()); } int numActiveTIsPrevious = targetInstanceDao.countActiveTIsForTarget(aTarget.getOid()); for (Schedule schedule : aTarget.getRemovedSchedules()) { targetInstanceDao.deleteScheduledInstances(schedule); schedule.setTargetInstances(new HashSet<TargetInstance>()); targetInstanceDao.save(schedule); } List<Schedule> newSchedules = new LinkedList<Schedule>(); for (Schedule schedule : aTarget.getSchedules()) { if(schedule.isNew()) { newSchedules.add(schedule); schedule.setSavedInThisSession(true); if (!schedule.getOwningUser().equals(aTarget.getOwningUser())) { newSchedulesAddedByNonOwner = true; } } else { if(schedule.isSavedInThisSession()){ targetInstanceDao.deleteScheduledInstances(schedule); schedule.setTargetInstances(new HashSet<TargetInstance>()); targetInstanceDao.save(schedule); } } } if(aTarget.getState()==Target.STATE_COMPLETED && newSchedules.size()!=0) { aTarget.changeState(Target.STATE_APPROVED); } AbstractTargetDTO originalTarget = null; if (!aTarget.isNew()) { originalTarget = targetDao.loadAbstractTargetDTO(aTarget.getOid()); } Set<AbstractTargetDTO> origParents = Collections.EMPTY_SET; if (!aTarget.isNew()) { origParents = targetDao.getAncestorDTOs(aTarget.getOid()); } log.debug("Saving Target"); int originalState = aTarget.getOriginalState(); targetDao.save(aTarget, parents); for (Annotation anno : aTarget.getAnnotations()) { anno.setObjectOid(aTarget.getOid()); } annotationDAO.saveAnnotations(aTarget.getAnnotations()); annotationDAO.deleteAnnotations(aTarget.getDeletedAnnotations()); aTarget = targetDao.reloadTarget(aTarget.getOid()); log.debug("End of Save Target"); if (originalState != aTarget.getState()) { String newState = messageSource.getMessage("target.state_" + aTarget.getState(), null, Locale.getDefault()); auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_STATE_CHANGE, "Target " + aTarget.getName() + " has changed into state '" + newState + "'"); } for (Schedule schedule : newSchedules) { auditor.audit(Schedule.class.getName(), schedule.getOid(), Auditor.ACTION_NEW_SCHEDULE, "New Schedule Created on Target " + aTarget.getName()); } if (originalTarget != null) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_UPDATE_TARGET, "Target " + aTarget.getName() + " has been updated"); if (!originalTarget.getOwnerOid().equals(aTarget.getOwningUser().getOid())) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_CHANGE_OWNER, "Target " + aTarget.getName() + " has been given to " + aTarget.getOwningUser().getNiceName()); } if (originalTarget.getProfileOid()!=null && aTarget.getProfile() != null && !originalTarget.getProfileOid().equals(aTarget.getProfile().getOid())) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_CHANGE_PROFILE, "Target " + aTarget.getName() + " is now using profile " + aTarget.getProfile().getName()); } } if (originalState != aTarget.getState()) { if (aTarget.getState() == Target.STATE_NOMINATED) { intrayManager.generateTask(Privilege.APPROVE_TARGET, MessageType.TASK_APPROVE_TARGET, aTarget); } if (aTarget.getState() == Target.STATE_APPROVED || aTarget.getState() == Target.STATE_REJECTED) { intrayManager.deleteTask(aTarget.getOid(), aTarget.getResourceType(), MessageType.TASK_APPROVE_TARGET); } if (aTarget.getState() == Target.STATE_APPROVED && aTarget.isRunOnApproval()) { TargetInstance ti = new TargetInstance(); ti.setTarget(aTarget); ti.setSchedule(null); ti.setScheduledTime(new Date()); ti.setOwner(aTarget.getOwner()); ti.setUseAQA(aTarget.isUseAQA()); ti.setAllowOptimize(aTarget.isAllowOptimize()); targetInstanceDao.save(ti); } } if (aTarget.getState() == Target.STATE_APPROVED && wasHarvestNowSelected) { TargetInstance ti = new TargetInstance(); ti.setTarget(aTarget); ti.setSchedule(null); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, 5); ti.setScheduledTime(cal.getTime()); ti.setOwner(aTarget.getOwner()); ti.setUseAQA(aTarget.isUseAQA()); ti.setAllowOptimize(aTarget.isAllowOptimize()); targetInstanceDao.save(ti); } if (originalTarget != null) { if (!originalTarget.getOwnerOid().equals(aTarget.getOwningUser().getOid())) { intrayManager.generateNotification(aTarget.getOwningUser().getOid(), MessageType.CATEGORY_MISC, MessageType.DELEGATE_TARGET, aTarget); Long remoteUserObjectOid = AuthUtil.getRemoteUserObject().getOid(); if (originalTarget.getOwnerOid() != remoteUserObjectOid) { intrayManager.generateNotification(originalTarget.getOwnerOid(), MessageType.CATEGORY_MISC, MessageType.TRANSFER_TARGET, aTarget); } } } if (aTarget.isSchedulable()) { log.debug("Staying in Schedulable State - scheduling new schedules"); for (Schedule schedule : aTarget.getSchedules()) { processSchedule(schedule); } } else { unschedule(aTarget); } if (numActiveTIsPrevious > 0 && targetInstanceDao.countActiveTIsForTarget(aTarget.getOid()) == 0 && aTarget.getOriginalState() == Target.STATE_APPROVED && aTarget.getState() == Target.STATE_APPROVED) { aTarget.changeState(Target.STATE_COMPLETED); } if (newSchedulesAddedByNonOwner) { intrayManager.generateNotification(aTarget.getOwningUser().getOid(), MessageType.CATEGORY_MISC, MessageType.TARGET_SCHEDULE_ADDED, aTarget); } updateTargetGroupStatus(aTarget); if (parents != null) { for (GroupMemberDTO dto : parents) { if (dto.getSaveState() == SAVE_STATE.DELETED) { updateTargetGroupStatus(targetDao.loadGroup(dto.getParentOid())); } } } if (parents != null) { for (GroupMemberDTO dto : parents) { switch (dto.getSaveState()) { case NEW: TargetGroup grp = targetDao.loadGroup(dto.getParentOid()); GroupEventPropagator gep = new GroupEventPropagator(this, instanceManager, grp, aTarget); gep.runEventChain(); break; case DELETED: TargetGroup grp2 = targetDao.loadGroup(dto.getParentOid()); MembersRemovedEventPropagator mrep = new MembersRemovedEventPropagator(this, instanceManager, grp2, aTarget); mrep.runEventChain(); break; } } } if (sendGroupUpdateNotifications && AuthUtil.getRemoteUserObject() != null) { String userName = AuthUtil.getRemoteUserObject().getNiceName(); Set<AbstractTargetDTO> newParents = targetDao.getAncestorDTOs(aTarget.getOid()); Set<AbstractTargetDTO> addedParents = new HashSet<AbstractTargetDTO>(newParents); addedParents.removeAll(origParents); Set<AbstractTargetDTO> removedParents = new HashSet<AbstractTargetDTO>(origParents); removedParents.removeAll(newParents); HashMap<Long, GroupChangeNotification> changes = getChanges(addedParents, removedParents); generateChangeMessageNotifications(aTarget, userName, changes); } }
TargetManagerImpl implements TargetManager { public void save(Target aTarget, List<GroupMemberDTO> parents) { boolean newSchedulesAddedByNonOwner = false; boolean wasHarvestNowSelected = aTarget.isHarvestNow(); if (aTarget.isDirty() && aTarget.getOriginalState() == Target.STATE_APPROVED && !authMgr.hasPrivilege(aTarget, Privilege.APPROVE_TARGET)) { log.debug("Target state changed to nominated due to changes"); aTarget.changeState(Target.STATE_NOMINATED); } if ((aTarget.getOriginalState() == Target.STATE_PENDING || aTarget.getOriginalState() == Target.STATE_REINSTATED || aTarget .getOriginalState() == Target.STATE_NOMINATED) && aTarget.getState() == Target.STATE_APPROVED) { aTarget.setSelectionDate(new Date()); } int numActiveTIsPrevious = targetInstanceDao.countActiveTIsForTarget(aTarget.getOid()); for (Schedule schedule : aTarget.getRemovedSchedules()) { targetInstanceDao.deleteScheduledInstances(schedule); schedule.setTargetInstances(new HashSet<TargetInstance>()); targetInstanceDao.save(schedule); } List<Schedule> newSchedules = new LinkedList<Schedule>(); for (Schedule schedule : aTarget.getSchedules()) { if(schedule.isNew()) { newSchedules.add(schedule); schedule.setSavedInThisSession(true); if (!schedule.getOwningUser().equals(aTarget.getOwningUser())) { newSchedulesAddedByNonOwner = true; } } else { if(schedule.isSavedInThisSession()){ targetInstanceDao.deleteScheduledInstances(schedule); schedule.setTargetInstances(new HashSet<TargetInstance>()); targetInstanceDao.save(schedule); } } } if(aTarget.getState()==Target.STATE_COMPLETED && newSchedules.size()!=0) { aTarget.changeState(Target.STATE_APPROVED); } AbstractTargetDTO originalTarget = null; if (!aTarget.isNew()) { originalTarget = targetDao.loadAbstractTargetDTO(aTarget.getOid()); } Set<AbstractTargetDTO> origParents = Collections.EMPTY_SET; if (!aTarget.isNew()) { origParents = targetDao.getAncestorDTOs(aTarget.getOid()); } log.debug("Saving Target"); int originalState = aTarget.getOriginalState(); targetDao.save(aTarget, parents); for (Annotation anno : aTarget.getAnnotations()) { anno.setObjectOid(aTarget.getOid()); } annotationDAO.saveAnnotations(aTarget.getAnnotations()); annotationDAO.deleteAnnotations(aTarget.getDeletedAnnotations()); aTarget = targetDao.reloadTarget(aTarget.getOid()); log.debug("End of Save Target"); if (originalState != aTarget.getState()) { String newState = messageSource.getMessage("target.state_" + aTarget.getState(), null, Locale.getDefault()); auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_STATE_CHANGE, "Target " + aTarget.getName() + " has changed into state '" + newState + "'"); } for (Schedule schedule : newSchedules) { auditor.audit(Schedule.class.getName(), schedule.getOid(), Auditor.ACTION_NEW_SCHEDULE, "New Schedule Created on Target " + aTarget.getName()); } if (originalTarget != null) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_UPDATE_TARGET, "Target " + aTarget.getName() + " has been updated"); if (!originalTarget.getOwnerOid().equals(aTarget.getOwningUser().getOid())) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_CHANGE_OWNER, "Target " + aTarget.getName() + " has been given to " + aTarget.getOwningUser().getNiceName()); } if (originalTarget.getProfileOid()!=null && aTarget.getProfile() != null && !originalTarget.getProfileOid().equals(aTarget.getProfile().getOid())) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_CHANGE_PROFILE, "Target " + aTarget.getName() + " is now using profile " + aTarget.getProfile().getName()); } } if (originalState != aTarget.getState()) { if (aTarget.getState() == Target.STATE_NOMINATED) { intrayManager.generateTask(Privilege.APPROVE_TARGET, MessageType.TASK_APPROVE_TARGET, aTarget); } if (aTarget.getState() == Target.STATE_APPROVED || aTarget.getState() == Target.STATE_REJECTED) { intrayManager.deleteTask(aTarget.getOid(), aTarget.getResourceType(), MessageType.TASK_APPROVE_TARGET); } if (aTarget.getState() == Target.STATE_APPROVED && aTarget.isRunOnApproval()) { TargetInstance ti = new TargetInstance(); ti.setTarget(aTarget); ti.setSchedule(null); ti.setScheduledTime(new Date()); ti.setOwner(aTarget.getOwner()); ti.setUseAQA(aTarget.isUseAQA()); ti.setAllowOptimize(aTarget.isAllowOptimize()); targetInstanceDao.save(ti); } } if (aTarget.getState() == Target.STATE_APPROVED && wasHarvestNowSelected) { TargetInstance ti = new TargetInstance(); ti.setTarget(aTarget); ti.setSchedule(null); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, 5); ti.setScheduledTime(cal.getTime()); ti.setOwner(aTarget.getOwner()); ti.setUseAQA(aTarget.isUseAQA()); ti.setAllowOptimize(aTarget.isAllowOptimize()); targetInstanceDao.save(ti); } if (originalTarget != null) { if (!originalTarget.getOwnerOid().equals(aTarget.getOwningUser().getOid())) { intrayManager.generateNotification(aTarget.getOwningUser().getOid(), MessageType.CATEGORY_MISC, MessageType.DELEGATE_TARGET, aTarget); Long remoteUserObjectOid = AuthUtil.getRemoteUserObject().getOid(); if (originalTarget.getOwnerOid() != remoteUserObjectOid) { intrayManager.generateNotification(originalTarget.getOwnerOid(), MessageType.CATEGORY_MISC, MessageType.TRANSFER_TARGET, aTarget); } } } if (aTarget.isSchedulable()) { log.debug("Staying in Schedulable State - scheduling new schedules"); for (Schedule schedule : aTarget.getSchedules()) { processSchedule(schedule); } } else { unschedule(aTarget); } if (numActiveTIsPrevious > 0 && targetInstanceDao.countActiveTIsForTarget(aTarget.getOid()) == 0 && aTarget.getOriginalState() == Target.STATE_APPROVED && aTarget.getState() == Target.STATE_APPROVED) { aTarget.changeState(Target.STATE_COMPLETED); } if (newSchedulesAddedByNonOwner) { intrayManager.generateNotification(aTarget.getOwningUser().getOid(), MessageType.CATEGORY_MISC, MessageType.TARGET_SCHEDULE_ADDED, aTarget); } updateTargetGroupStatus(aTarget); if (parents != null) { for (GroupMemberDTO dto : parents) { if (dto.getSaveState() == SAVE_STATE.DELETED) { updateTargetGroupStatus(targetDao.loadGroup(dto.getParentOid())); } } } if (parents != null) { for (GroupMemberDTO dto : parents) { switch (dto.getSaveState()) { case NEW: TargetGroup grp = targetDao.loadGroup(dto.getParentOid()); GroupEventPropagator gep = new GroupEventPropagator(this, instanceManager, grp, aTarget); gep.runEventChain(); break; case DELETED: TargetGroup grp2 = targetDao.loadGroup(dto.getParentOid()); MembersRemovedEventPropagator mrep = new MembersRemovedEventPropagator(this, instanceManager, grp2, aTarget); mrep.runEventChain(); break; } } } if (sendGroupUpdateNotifications && AuthUtil.getRemoteUserObject() != null) { String userName = AuthUtil.getRemoteUserObject().getNiceName(); Set<AbstractTargetDTO> newParents = targetDao.getAncestorDTOs(aTarget.getOid()); Set<AbstractTargetDTO> addedParents = new HashSet<AbstractTargetDTO>(newParents); addedParents.removeAll(origParents); Set<AbstractTargetDTO> removedParents = new HashSet<AbstractTargetDTO>(origParents); removedParents.removeAll(newParents); HashMap<Long, GroupChangeNotification> changes = getChanges(addedParents, removedParents); generateChangeMessageNotifications(aTarget, userName, changes); } } }
TargetManagerImpl implements TargetManager { public void save(Target aTarget, List<GroupMemberDTO> parents) { boolean newSchedulesAddedByNonOwner = false; boolean wasHarvestNowSelected = aTarget.isHarvestNow(); if (aTarget.isDirty() && aTarget.getOriginalState() == Target.STATE_APPROVED && !authMgr.hasPrivilege(aTarget, Privilege.APPROVE_TARGET)) { log.debug("Target state changed to nominated due to changes"); aTarget.changeState(Target.STATE_NOMINATED); } if ((aTarget.getOriginalState() == Target.STATE_PENDING || aTarget.getOriginalState() == Target.STATE_REINSTATED || aTarget .getOriginalState() == Target.STATE_NOMINATED) && aTarget.getState() == Target.STATE_APPROVED) { aTarget.setSelectionDate(new Date()); } int numActiveTIsPrevious = targetInstanceDao.countActiveTIsForTarget(aTarget.getOid()); for (Schedule schedule : aTarget.getRemovedSchedules()) { targetInstanceDao.deleteScheduledInstances(schedule); schedule.setTargetInstances(new HashSet<TargetInstance>()); targetInstanceDao.save(schedule); } List<Schedule> newSchedules = new LinkedList<Schedule>(); for (Schedule schedule : aTarget.getSchedules()) { if(schedule.isNew()) { newSchedules.add(schedule); schedule.setSavedInThisSession(true); if (!schedule.getOwningUser().equals(aTarget.getOwningUser())) { newSchedulesAddedByNonOwner = true; } } else { if(schedule.isSavedInThisSession()){ targetInstanceDao.deleteScheduledInstances(schedule); schedule.setTargetInstances(new HashSet<TargetInstance>()); targetInstanceDao.save(schedule); } } } if(aTarget.getState()==Target.STATE_COMPLETED && newSchedules.size()!=0) { aTarget.changeState(Target.STATE_APPROVED); } AbstractTargetDTO originalTarget = null; if (!aTarget.isNew()) { originalTarget = targetDao.loadAbstractTargetDTO(aTarget.getOid()); } Set<AbstractTargetDTO> origParents = Collections.EMPTY_SET; if (!aTarget.isNew()) { origParents = targetDao.getAncestorDTOs(aTarget.getOid()); } log.debug("Saving Target"); int originalState = aTarget.getOriginalState(); targetDao.save(aTarget, parents); for (Annotation anno : aTarget.getAnnotations()) { anno.setObjectOid(aTarget.getOid()); } annotationDAO.saveAnnotations(aTarget.getAnnotations()); annotationDAO.deleteAnnotations(aTarget.getDeletedAnnotations()); aTarget = targetDao.reloadTarget(aTarget.getOid()); log.debug("End of Save Target"); if (originalState != aTarget.getState()) { String newState = messageSource.getMessage("target.state_" + aTarget.getState(), null, Locale.getDefault()); auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_STATE_CHANGE, "Target " + aTarget.getName() + " has changed into state '" + newState + "'"); } for (Schedule schedule : newSchedules) { auditor.audit(Schedule.class.getName(), schedule.getOid(), Auditor.ACTION_NEW_SCHEDULE, "New Schedule Created on Target " + aTarget.getName()); } if (originalTarget != null) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_UPDATE_TARGET, "Target " + aTarget.getName() + " has been updated"); if (!originalTarget.getOwnerOid().equals(aTarget.getOwningUser().getOid())) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_CHANGE_OWNER, "Target " + aTarget.getName() + " has been given to " + aTarget.getOwningUser().getNiceName()); } if (originalTarget.getProfileOid()!=null && aTarget.getProfile() != null && !originalTarget.getProfileOid().equals(aTarget.getProfile().getOid())) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_CHANGE_PROFILE, "Target " + aTarget.getName() + " is now using profile " + aTarget.getProfile().getName()); } } if (originalState != aTarget.getState()) { if (aTarget.getState() == Target.STATE_NOMINATED) { intrayManager.generateTask(Privilege.APPROVE_TARGET, MessageType.TASK_APPROVE_TARGET, aTarget); } if (aTarget.getState() == Target.STATE_APPROVED || aTarget.getState() == Target.STATE_REJECTED) { intrayManager.deleteTask(aTarget.getOid(), aTarget.getResourceType(), MessageType.TASK_APPROVE_TARGET); } if (aTarget.getState() == Target.STATE_APPROVED && aTarget.isRunOnApproval()) { TargetInstance ti = new TargetInstance(); ti.setTarget(aTarget); ti.setSchedule(null); ti.setScheduledTime(new Date()); ti.setOwner(aTarget.getOwner()); ti.setUseAQA(aTarget.isUseAQA()); ti.setAllowOptimize(aTarget.isAllowOptimize()); targetInstanceDao.save(ti); } } if (aTarget.getState() == Target.STATE_APPROVED && wasHarvestNowSelected) { TargetInstance ti = new TargetInstance(); ti.setTarget(aTarget); ti.setSchedule(null); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, 5); ti.setScheduledTime(cal.getTime()); ti.setOwner(aTarget.getOwner()); ti.setUseAQA(aTarget.isUseAQA()); ti.setAllowOptimize(aTarget.isAllowOptimize()); targetInstanceDao.save(ti); } if (originalTarget != null) { if (!originalTarget.getOwnerOid().equals(aTarget.getOwningUser().getOid())) { intrayManager.generateNotification(aTarget.getOwningUser().getOid(), MessageType.CATEGORY_MISC, MessageType.DELEGATE_TARGET, aTarget); Long remoteUserObjectOid = AuthUtil.getRemoteUserObject().getOid(); if (originalTarget.getOwnerOid() != remoteUserObjectOid) { intrayManager.generateNotification(originalTarget.getOwnerOid(), MessageType.CATEGORY_MISC, MessageType.TRANSFER_TARGET, aTarget); } } } if (aTarget.isSchedulable()) { log.debug("Staying in Schedulable State - scheduling new schedules"); for (Schedule schedule : aTarget.getSchedules()) { processSchedule(schedule); } } else { unschedule(aTarget); } if (numActiveTIsPrevious > 0 && targetInstanceDao.countActiveTIsForTarget(aTarget.getOid()) == 0 && aTarget.getOriginalState() == Target.STATE_APPROVED && aTarget.getState() == Target.STATE_APPROVED) { aTarget.changeState(Target.STATE_COMPLETED); } if (newSchedulesAddedByNonOwner) { intrayManager.generateNotification(aTarget.getOwningUser().getOid(), MessageType.CATEGORY_MISC, MessageType.TARGET_SCHEDULE_ADDED, aTarget); } updateTargetGroupStatus(aTarget); if (parents != null) { for (GroupMemberDTO dto : parents) { if (dto.getSaveState() == SAVE_STATE.DELETED) { updateTargetGroupStatus(targetDao.loadGroup(dto.getParentOid())); } } } if (parents != null) { for (GroupMemberDTO dto : parents) { switch (dto.getSaveState()) { case NEW: TargetGroup grp = targetDao.loadGroup(dto.getParentOid()); GroupEventPropagator gep = new GroupEventPropagator(this, instanceManager, grp, aTarget); gep.runEventChain(); break; case DELETED: TargetGroup grp2 = targetDao.loadGroup(dto.getParentOid()); MembersRemovedEventPropagator mrep = new MembersRemovedEventPropagator(this, instanceManager, grp2, aTarget); mrep.runEventChain(); break; } } } if (sendGroupUpdateNotifications && AuthUtil.getRemoteUserObject() != null) { String userName = AuthUtil.getRemoteUserObject().getNiceName(); Set<AbstractTargetDTO> newParents = targetDao.getAncestorDTOs(aTarget.getOid()); Set<AbstractTargetDTO> addedParents = new HashSet<AbstractTargetDTO>(newParents); addedParents.removeAll(origParents); Set<AbstractTargetDTO> removedParents = new HashSet<AbstractTargetDTO>(origParents); removedParents.removeAll(newParents); HashMap<Long, GroupChangeNotification> changes = getChanges(addedParents, removedParents); generateChangeMessageNotifications(aTarget, userName, changes); } }  }
TargetManagerImpl implements TargetManager { public void save(Target aTarget, List<GroupMemberDTO> parents) { boolean newSchedulesAddedByNonOwner = false; boolean wasHarvestNowSelected = aTarget.isHarvestNow(); if (aTarget.isDirty() && aTarget.getOriginalState() == Target.STATE_APPROVED && !authMgr.hasPrivilege(aTarget, Privilege.APPROVE_TARGET)) { log.debug("Target state changed to nominated due to changes"); aTarget.changeState(Target.STATE_NOMINATED); } if ((aTarget.getOriginalState() == Target.STATE_PENDING || aTarget.getOriginalState() == Target.STATE_REINSTATED || aTarget .getOriginalState() == Target.STATE_NOMINATED) && aTarget.getState() == Target.STATE_APPROVED) { aTarget.setSelectionDate(new Date()); } int numActiveTIsPrevious = targetInstanceDao.countActiveTIsForTarget(aTarget.getOid()); for (Schedule schedule : aTarget.getRemovedSchedules()) { targetInstanceDao.deleteScheduledInstances(schedule); schedule.setTargetInstances(new HashSet<TargetInstance>()); targetInstanceDao.save(schedule); } List<Schedule> newSchedules = new LinkedList<Schedule>(); for (Schedule schedule : aTarget.getSchedules()) { if(schedule.isNew()) { newSchedules.add(schedule); schedule.setSavedInThisSession(true); if (!schedule.getOwningUser().equals(aTarget.getOwningUser())) { newSchedulesAddedByNonOwner = true; } } else { if(schedule.isSavedInThisSession()){ targetInstanceDao.deleteScheduledInstances(schedule); schedule.setTargetInstances(new HashSet<TargetInstance>()); targetInstanceDao.save(schedule); } } } if(aTarget.getState()==Target.STATE_COMPLETED && newSchedules.size()!=0) { aTarget.changeState(Target.STATE_APPROVED); } AbstractTargetDTO originalTarget = null; if (!aTarget.isNew()) { originalTarget = targetDao.loadAbstractTargetDTO(aTarget.getOid()); } Set<AbstractTargetDTO> origParents = Collections.EMPTY_SET; if (!aTarget.isNew()) { origParents = targetDao.getAncestorDTOs(aTarget.getOid()); } log.debug("Saving Target"); int originalState = aTarget.getOriginalState(); targetDao.save(aTarget, parents); for (Annotation anno : aTarget.getAnnotations()) { anno.setObjectOid(aTarget.getOid()); } annotationDAO.saveAnnotations(aTarget.getAnnotations()); annotationDAO.deleteAnnotations(aTarget.getDeletedAnnotations()); aTarget = targetDao.reloadTarget(aTarget.getOid()); log.debug("End of Save Target"); if (originalState != aTarget.getState()) { String newState = messageSource.getMessage("target.state_" + aTarget.getState(), null, Locale.getDefault()); auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_STATE_CHANGE, "Target " + aTarget.getName() + " has changed into state '" + newState + "'"); } for (Schedule schedule : newSchedules) { auditor.audit(Schedule.class.getName(), schedule.getOid(), Auditor.ACTION_NEW_SCHEDULE, "New Schedule Created on Target " + aTarget.getName()); } if (originalTarget != null) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_UPDATE_TARGET, "Target " + aTarget.getName() + " has been updated"); if (!originalTarget.getOwnerOid().equals(aTarget.getOwningUser().getOid())) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_CHANGE_OWNER, "Target " + aTarget.getName() + " has been given to " + aTarget.getOwningUser().getNiceName()); } if (originalTarget.getProfileOid()!=null && aTarget.getProfile() != null && !originalTarget.getProfileOid().equals(aTarget.getProfile().getOid())) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_CHANGE_PROFILE, "Target " + aTarget.getName() + " is now using profile " + aTarget.getProfile().getName()); } } if (originalState != aTarget.getState()) { if (aTarget.getState() == Target.STATE_NOMINATED) { intrayManager.generateTask(Privilege.APPROVE_TARGET, MessageType.TASK_APPROVE_TARGET, aTarget); } if (aTarget.getState() == Target.STATE_APPROVED || aTarget.getState() == Target.STATE_REJECTED) { intrayManager.deleteTask(aTarget.getOid(), aTarget.getResourceType(), MessageType.TASK_APPROVE_TARGET); } if (aTarget.getState() == Target.STATE_APPROVED && aTarget.isRunOnApproval()) { TargetInstance ti = new TargetInstance(); ti.setTarget(aTarget); ti.setSchedule(null); ti.setScheduledTime(new Date()); ti.setOwner(aTarget.getOwner()); ti.setUseAQA(aTarget.isUseAQA()); ti.setAllowOptimize(aTarget.isAllowOptimize()); targetInstanceDao.save(ti); } } if (aTarget.getState() == Target.STATE_APPROVED && wasHarvestNowSelected) { TargetInstance ti = new TargetInstance(); ti.setTarget(aTarget); ti.setSchedule(null); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, 5); ti.setScheduledTime(cal.getTime()); ti.setOwner(aTarget.getOwner()); ti.setUseAQA(aTarget.isUseAQA()); ti.setAllowOptimize(aTarget.isAllowOptimize()); targetInstanceDao.save(ti); } if (originalTarget != null) { if (!originalTarget.getOwnerOid().equals(aTarget.getOwningUser().getOid())) { intrayManager.generateNotification(aTarget.getOwningUser().getOid(), MessageType.CATEGORY_MISC, MessageType.DELEGATE_TARGET, aTarget); Long remoteUserObjectOid = AuthUtil.getRemoteUserObject().getOid(); if (originalTarget.getOwnerOid() != remoteUserObjectOid) { intrayManager.generateNotification(originalTarget.getOwnerOid(), MessageType.CATEGORY_MISC, MessageType.TRANSFER_TARGET, aTarget); } } } if (aTarget.isSchedulable()) { log.debug("Staying in Schedulable State - scheduling new schedules"); for (Schedule schedule : aTarget.getSchedules()) { processSchedule(schedule); } } else { unschedule(aTarget); } if (numActiveTIsPrevious > 0 && targetInstanceDao.countActiveTIsForTarget(aTarget.getOid()) == 0 && aTarget.getOriginalState() == Target.STATE_APPROVED && aTarget.getState() == Target.STATE_APPROVED) { aTarget.changeState(Target.STATE_COMPLETED); } if (newSchedulesAddedByNonOwner) { intrayManager.generateNotification(aTarget.getOwningUser().getOid(), MessageType.CATEGORY_MISC, MessageType.TARGET_SCHEDULE_ADDED, aTarget); } updateTargetGroupStatus(aTarget); if (parents != null) { for (GroupMemberDTO dto : parents) { if (dto.getSaveState() == SAVE_STATE.DELETED) { updateTargetGroupStatus(targetDao.loadGroup(dto.getParentOid())); } } } if (parents != null) { for (GroupMemberDTO dto : parents) { switch (dto.getSaveState()) { case NEW: TargetGroup grp = targetDao.loadGroup(dto.getParentOid()); GroupEventPropagator gep = new GroupEventPropagator(this, instanceManager, grp, aTarget); gep.runEventChain(); break; case DELETED: TargetGroup grp2 = targetDao.loadGroup(dto.getParentOid()); MembersRemovedEventPropagator mrep = new MembersRemovedEventPropagator(this, instanceManager, grp2, aTarget); mrep.runEventChain(); break; } } } if (sendGroupUpdateNotifications && AuthUtil.getRemoteUserObject() != null) { String userName = AuthUtil.getRemoteUserObject().getNiceName(); Set<AbstractTargetDTO> newParents = targetDao.getAncestorDTOs(aTarget.getOid()); Set<AbstractTargetDTO> addedParents = new HashSet<AbstractTargetDTO>(newParents); addedParents.removeAll(origParents); Set<AbstractTargetDTO> removedParents = new HashSet<AbstractTargetDTO>(origParents); removedParents.removeAll(newParents); HashMap<Long, GroupChangeNotification> changes = getChanges(addedParents, removedParents); generateChangeMessageNotifications(aTarget, userName, changes); } }  boolean getAllowMultiplePrimarySeeds(); void setAllowMultiplePrimarySeeds(boolean allowMultiplePrimarySeeds); void save(Target aTarget, List<GroupMemberDTO> parents); void save(Target aTarget); void save(TargetGroup aTargetGroup); void save(TargetGroup aTargetGroup, List<GroupMemberDTO> parents); void scheduleTargetGroup(TargetGroup aGroup); int[] getNextStates(Target aTarget); Target load(Long oid); Target load(Long oid, boolean loadFully); List<Permission> getQuickPickPermissions(Target aTarget); Pagination findPermissionsBySiteTitle(Target aTarget, String aSiteTitle, int aPageNumber); Pagination findPermissionsByUrl(Target aTarget, String aUrl, int aPageNumber); Permission loadPermission(TargetEditorContext ctx, String identity); Permission loadPermission(Long oid); boolean isNameOk(AbstractTarget aTarget); void setTargetDao(TargetDAO targetDao); void setAuthMgr(AuthorityManager authMgr); void setSiteDao(SiteDAO siteDao); List<Annotation> getAnnotations(AbstractTarget aTarget); void setAnnotationDAO(AnnotationDAO annotationDAO); boolean isTargetHarvestable(TargetInstance aTargetInstance); boolean isTargetUsingAQA(Long targetOid); boolean allowStateChange(Target aTarget, int nextState); TargetGroup loadGroup(Long oid); TargetGroup loadGroup(Long oid, boolean loadFully); Pagination getMembers(TargetGroup aTargetGroup, int pageNum, int pageSize); Pagination getParents(AbstractTarget aTarget, int pageNum, int pageSize); Pagination getAbstractTargetDTOs(String name, int pageNumber, int pageSize); Pagination getGroupDTOs(String name, int pageNumber, int pageSize); Pagination getSubGroupParentDTOs(String name, int pageNumber, int pageSize); Pagination getNonSubGroupDTOs(String name, int pageNumber, int pageSize); GroupMemberDTO createGroupMemberDTO(TargetGroup group, Long childOid); GroupMemberDTO createGroupMemberDTO(Long groupOid, Target child); Pagination searchGroups(int pageNumber, int pageSize, Long searchOid, String name, String owner, String agency,
			String memberOf, String groupType, boolean nondisplayonly); void setTargetInstanceDao(TargetInstanceDAO targetInstanceDao); void processSchedulesJob(); void processSchedule(Schedule aSchedule); void processBatchSchedule(Schedule aSchedule); void createTargetInstances(AbstractTarget aTarget, Schedule aSchedule, boolean checkAgency); Set<Seed> getSeeds(TargetInstance aTargetInstance); Set<Seed> getSeeds(AbstractTarget aTarget, Long agencyOid); int countTargets(User aUser); int countTargetGroups(User aUser); TargetInstanceManager getInstanceManager(); void setInstanceManager(TargetInstanceManager instanceManager); InTrayManager getIntrayManager(); void setIntrayManager(InTrayManager intrayManager); Set<Long> getAncestorOids(AbstractTarget child); boolean isDuplicateMember(TargetGroup group, Long memberOid); AbstractTarget loadAbstractTarget(Long oid); boolean isSendGroupUpdateNotifications(); void setSendGroupUpdateNotifications(boolean sendGroupUpdateNotifications); void endDateGroups(); int transferSeeds(Permission fromPermission, Permission toPermission); Pagination searchPermissions(PermissionCriteria aPermissionCriteria); List<TargetGroup> getActiveParentGroups(TargetInstance aTargetInstance); Collection<PermissionSeedDTO> getActivePermissions(TargetInstance aTargetInstance); void setAuditor(Auditor auditor); void setMessageSource(MessageSource messageSource); Target copy(Target aTarget); TargetGroup copy(TargetGroup aTargetGroup); void deleteTarget(Target aTarget); boolean deleteTargetGroup(TargetGroup aTargetGroup); List<GroupMemberDTO> getParents(final AbstractTarget aTarget); void setBusinessObjectFactory(BusinessObjectFactory businessObjectFactory); void setSubGroupParentTypesList(WCTTreeSet subGroupParentTypesList); void setSubGroupTypeName(String subGroupTypeName); @Override void moveTargets(TargetGroup sourceGroup, TargetGroup targetGroup, List<Long> targetsToMove); }
TargetManagerImpl implements TargetManager { public void save(Target aTarget, List<GroupMemberDTO> parents) { boolean newSchedulesAddedByNonOwner = false; boolean wasHarvestNowSelected = aTarget.isHarvestNow(); if (aTarget.isDirty() && aTarget.getOriginalState() == Target.STATE_APPROVED && !authMgr.hasPrivilege(aTarget, Privilege.APPROVE_TARGET)) { log.debug("Target state changed to nominated due to changes"); aTarget.changeState(Target.STATE_NOMINATED); } if ((aTarget.getOriginalState() == Target.STATE_PENDING || aTarget.getOriginalState() == Target.STATE_REINSTATED || aTarget .getOriginalState() == Target.STATE_NOMINATED) && aTarget.getState() == Target.STATE_APPROVED) { aTarget.setSelectionDate(new Date()); } int numActiveTIsPrevious = targetInstanceDao.countActiveTIsForTarget(aTarget.getOid()); for (Schedule schedule : aTarget.getRemovedSchedules()) { targetInstanceDao.deleteScheduledInstances(schedule); schedule.setTargetInstances(new HashSet<TargetInstance>()); targetInstanceDao.save(schedule); } List<Schedule> newSchedules = new LinkedList<Schedule>(); for (Schedule schedule : aTarget.getSchedules()) { if(schedule.isNew()) { newSchedules.add(schedule); schedule.setSavedInThisSession(true); if (!schedule.getOwningUser().equals(aTarget.getOwningUser())) { newSchedulesAddedByNonOwner = true; } } else { if(schedule.isSavedInThisSession()){ targetInstanceDao.deleteScheduledInstances(schedule); schedule.setTargetInstances(new HashSet<TargetInstance>()); targetInstanceDao.save(schedule); } } } if(aTarget.getState()==Target.STATE_COMPLETED && newSchedules.size()!=0) { aTarget.changeState(Target.STATE_APPROVED); } AbstractTargetDTO originalTarget = null; if (!aTarget.isNew()) { originalTarget = targetDao.loadAbstractTargetDTO(aTarget.getOid()); } Set<AbstractTargetDTO> origParents = Collections.EMPTY_SET; if (!aTarget.isNew()) { origParents = targetDao.getAncestorDTOs(aTarget.getOid()); } log.debug("Saving Target"); int originalState = aTarget.getOriginalState(); targetDao.save(aTarget, parents); for (Annotation anno : aTarget.getAnnotations()) { anno.setObjectOid(aTarget.getOid()); } annotationDAO.saveAnnotations(aTarget.getAnnotations()); annotationDAO.deleteAnnotations(aTarget.getDeletedAnnotations()); aTarget = targetDao.reloadTarget(aTarget.getOid()); log.debug("End of Save Target"); if (originalState != aTarget.getState()) { String newState = messageSource.getMessage("target.state_" + aTarget.getState(), null, Locale.getDefault()); auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_STATE_CHANGE, "Target " + aTarget.getName() + " has changed into state '" + newState + "'"); } for (Schedule schedule : newSchedules) { auditor.audit(Schedule.class.getName(), schedule.getOid(), Auditor.ACTION_NEW_SCHEDULE, "New Schedule Created on Target " + aTarget.getName()); } if (originalTarget != null) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_UPDATE_TARGET, "Target " + aTarget.getName() + " has been updated"); if (!originalTarget.getOwnerOid().equals(aTarget.getOwningUser().getOid())) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_CHANGE_OWNER, "Target " + aTarget.getName() + " has been given to " + aTarget.getOwningUser().getNiceName()); } if (originalTarget.getProfileOid()!=null && aTarget.getProfile() != null && !originalTarget.getProfileOid().equals(aTarget.getProfile().getOid())) { auditor.audit(Target.class.getName(), aTarget.getOid(), Auditor.ACTION_TARGET_CHANGE_PROFILE, "Target " + aTarget.getName() + " is now using profile " + aTarget.getProfile().getName()); } } if (originalState != aTarget.getState()) { if (aTarget.getState() == Target.STATE_NOMINATED) { intrayManager.generateTask(Privilege.APPROVE_TARGET, MessageType.TASK_APPROVE_TARGET, aTarget); } if (aTarget.getState() == Target.STATE_APPROVED || aTarget.getState() == Target.STATE_REJECTED) { intrayManager.deleteTask(aTarget.getOid(), aTarget.getResourceType(), MessageType.TASK_APPROVE_TARGET); } if (aTarget.getState() == Target.STATE_APPROVED && aTarget.isRunOnApproval()) { TargetInstance ti = new TargetInstance(); ti.setTarget(aTarget); ti.setSchedule(null); ti.setScheduledTime(new Date()); ti.setOwner(aTarget.getOwner()); ti.setUseAQA(aTarget.isUseAQA()); ti.setAllowOptimize(aTarget.isAllowOptimize()); targetInstanceDao.save(ti); } } if (aTarget.getState() == Target.STATE_APPROVED && wasHarvestNowSelected) { TargetInstance ti = new TargetInstance(); ti.setTarget(aTarget); ti.setSchedule(null); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, 5); ti.setScheduledTime(cal.getTime()); ti.setOwner(aTarget.getOwner()); ti.setUseAQA(aTarget.isUseAQA()); ti.setAllowOptimize(aTarget.isAllowOptimize()); targetInstanceDao.save(ti); } if (originalTarget != null) { if (!originalTarget.getOwnerOid().equals(aTarget.getOwningUser().getOid())) { intrayManager.generateNotification(aTarget.getOwningUser().getOid(), MessageType.CATEGORY_MISC, MessageType.DELEGATE_TARGET, aTarget); Long remoteUserObjectOid = AuthUtil.getRemoteUserObject().getOid(); if (originalTarget.getOwnerOid() != remoteUserObjectOid) { intrayManager.generateNotification(originalTarget.getOwnerOid(), MessageType.CATEGORY_MISC, MessageType.TRANSFER_TARGET, aTarget); } } } if (aTarget.isSchedulable()) { log.debug("Staying in Schedulable State - scheduling new schedules"); for (Schedule schedule : aTarget.getSchedules()) { processSchedule(schedule); } } else { unschedule(aTarget); } if (numActiveTIsPrevious > 0 && targetInstanceDao.countActiveTIsForTarget(aTarget.getOid()) == 0 && aTarget.getOriginalState() == Target.STATE_APPROVED && aTarget.getState() == Target.STATE_APPROVED) { aTarget.changeState(Target.STATE_COMPLETED); } if (newSchedulesAddedByNonOwner) { intrayManager.generateNotification(aTarget.getOwningUser().getOid(), MessageType.CATEGORY_MISC, MessageType.TARGET_SCHEDULE_ADDED, aTarget); } updateTargetGroupStatus(aTarget); if (parents != null) { for (GroupMemberDTO dto : parents) { if (dto.getSaveState() == SAVE_STATE.DELETED) { updateTargetGroupStatus(targetDao.loadGroup(dto.getParentOid())); } } } if (parents != null) { for (GroupMemberDTO dto : parents) { switch (dto.getSaveState()) { case NEW: TargetGroup grp = targetDao.loadGroup(dto.getParentOid()); GroupEventPropagator gep = new GroupEventPropagator(this, instanceManager, grp, aTarget); gep.runEventChain(); break; case DELETED: TargetGroup grp2 = targetDao.loadGroup(dto.getParentOid()); MembersRemovedEventPropagator mrep = new MembersRemovedEventPropagator(this, instanceManager, grp2, aTarget); mrep.runEventChain(); break; } } } if (sendGroupUpdateNotifications && AuthUtil.getRemoteUserObject() != null) { String userName = AuthUtil.getRemoteUserObject().getNiceName(); Set<AbstractTargetDTO> newParents = targetDao.getAncestorDTOs(aTarget.getOid()); Set<AbstractTargetDTO> addedParents = new HashSet<AbstractTargetDTO>(newParents); addedParents.removeAll(origParents); Set<AbstractTargetDTO> removedParents = new HashSet<AbstractTargetDTO>(origParents); removedParents.removeAll(newParents); HashMap<Long, GroupChangeNotification> changes = getChanges(addedParents, removedParents); generateChangeMessageNotifications(aTarget, userName, changes); } }  boolean getAllowMultiplePrimarySeeds(); void setAllowMultiplePrimarySeeds(boolean allowMultiplePrimarySeeds); void save(Target aTarget, List<GroupMemberDTO> parents); void save(Target aTarget); void save(TargetGroup aTargetGroup); void save(TargetGroup aTargetGroup, List<GroupMemberDTO> parents); void scheduleTargetGroup(TargetGroup aGroup); int[] getNextStates(Target aTarget); Target load(Long oid); Target load(Long oid, boolean loadFully); List<Permission> getQuickPickPermissions(Target aTarget); Pagination findPermissionsBySiteTitle(Target aTarget, String aSiteTitle, int aPageNumber); Pagination findPermissionsByUrl(Target aTarget, String aUrl, int aPageNumber); Permission loadPermission(TargetEditorContext ctx, String identity); Permission loadPermission(Long oid); boolean isNameOk(AbstractTarget aTarget); void setTargetDao(TargetDAO targetDao); void setAuthMgr(AuthorityManager authMgr); void setSiteDao(SiteDAO siteDao); List<Annotation> getAnnotations(AbstractTarget aTarget); void setAnnotationDAO(AnnotationDAO annotationDAO); boolean isTargetHarvestable(TargetInstance aTargetInstance); boolean isTargetUsingAQA(Long targetOid); boolean allowStateChange(Target aTarget, int nextState); TargetGroup loadGroup(Long oid); TargetGroup loadGroup(Long oid, boolean loadFully); Pagination getMembers(TargetGroup aTargetGroup, int pageNum, int pageSize); Pagination getParents(AbstractTarget aTarget, int pageNum, int pageSize); Pagination getAbstractTargetDTOs(String name, int pageNumber, int pageSize); Pagination getGroupDTOs(String name, int pageNumber, int pageSize); Pagination getSubGroupParentDTOs(String name, int pageNumber, int pageSize); Pagination getNonSubGroupDTOs(String name, int pageNumber, int pageSize); GroupMemberDTO createGroupMemberDTO(TargetGroup group, Long childOid); GroupMemberDTO createGroupMemberDTO(Long groupOid, Target child); Pagination searchGroups(int pageNumber, int pageSize, Long searchOid, String name, String owner, String agency,
			String memberOf, String groupType, boolean nondisplayonly); void setTargetInstanceDao(TargetInstanceDAO targetInstanceDao); void processSchedulesJob(); void processSchedule(Schedule aSchedule); void processBatchSchedule(Schedule aSchedule); void createTargetInstances(AbstractTarget aTarget, Schedule aSchedule, boolean checkAgency); Set<Seed> getSeeds(TargetInstance aTargetInstance); Set<Seed> getSeeds(AbstractTarget aTarget, Long agencyOid); int countTargets(User aUser); int countTargetGroups(User aUser); TargetInstanceManager getInstanceManager(); void setInstanceManager(TargetInstanceManager instanceManager); InTrayManager getIntrayManager(); void setIntrayManager(InTrayManager intrayManager); Set<Long> getAncestorOids(AbstractTarget child); boolean isDuplicateMember(TargetGroup group, Long memberOid); AbstractTarget loadAbstractTarget(Long oid); boolean isSendGroupUpdateNotifications(); void setSendGroupUpdateNotifications(boolean sendGroupUpdateNotifications); void endDateGroups(); int transferSeeds(Permission fromPermission, Permission toPermission); Pagination searchPermissions(PermissionCriteria aPermissionCriteria); List<TargetGroup> getActiveParentGroups(TargetInstance aTargetInstance); Collection<PermissionSeedDTO> getActivePermissions(TargetInstance aTargetInstance); void setAuditor(Auditor auditor); void setMessageSource(MessageSource messageSource); Target copy(Target aTarget); TargetGroup copy(TargetGroup aTargetGroup); void deleteTarget(Target aTarget); boolean deleteTargetGroup(TargetGroup aTargetGroup); List<GroupMemberDTO> getParents(final AbstractTarget aTarget); void setBusinessObjectFactory(BusinessObjectFactory businessObjectFactory); void setSubGroupParentTypesList(WCTTreeSet subGroupParentTypesList); void setSubGroupTypeName(String subGroupTypeName); @Override void moveTargets(TargetGroup sourceGroup, TargetGroup targetGroup, List<Long> targetsToMove);  }