/** * @param activityOid * @param targetActivityOid */ public ActivityInstanceDTO relocateActivity(long activityOid, String activityId) { // TODO - not performant - check if this step can be avoided. List<TransitionTarget> targets = serviceFactoryUtils .getWorkflowService() .getAdHocTransitionTargets( activityOid, TransitionOptions.DEFAULT, ScanDirection.BACKWARD); List<ActivityInstanceDTO> list = new ArrayList<ActivityInstanceDTO>(); if (null != targets) { for (TransitionTarget target : targets) { if (target.getActivityId().equals(activityId)) { ActivityInstance activityInstance = activityInstanceUtils.getActivityInstance(target.getActivityInstanceOid()); if (org.eclipse.stardust.ui.web.viewscommon.utils.ActivityInstanceUtils .isRelocationEligible(activityInstance)) { if (activityInstance.getActivity().isInteractive() && activityInstance.getState().equals(ActivityInstanceState.Suspended)) { serviceFactoryUtils.getWorkflowService().activate(target.getActivityInstanceOid()); } } TransitionReport report = serviceFactoryUtils.getWorkflowService().performAdHocTransition(target, false); return DTOBuilder.build(report.getTargetActivityInstance(), ActivityInstanceDTO.class); } } } return null; }
/** * @param oid * @return */ public List<ActivityInstanceDTO> getAllRelocationTargets(long oid) { List<TransitionTarget> targets = serviceFactoryUtils .getWorkflowService() .getAdHocTransitionTargets(oid, TransitionOptions.DEFAULT, ScanDirection.BACKWARD); List<ActivityInstanceDTO> list = new ArrayList<ActivityInstanceDTO>(); if (null != targets) { for (TransitionTarget target : targets) { // TODO - needs a new transition target DTO? ActivityInstanceDTO dto = new ActivityInstanceDTO(); dto.activity = new ActivityDTO(); dto.activity.name = target.getActivityName(); dto.activity.id = target.getActivityId(); list.add(dto); } } return list; }