scheme.setName("Rest Mandatory Workflow "+salt);
scheme.setDescription("testing rest save content");
scheme.setCreationDate(new Date());
APILocator.getWorkflowAPI().saveScheme(scheme);
WorkflowStep step1=new WorkflowStep();
step1.setCreationDate(new Date());
step1.setEnableEscalation(false);
step1.setMyOrder(1);
step1.setName("Step 1");
step1.setResolved(false);
step1.setSchemeId(scheme.getId());
APILocator.getWorkflowAPI().saveStep(step1);
WorkflowStep step2=new WorkflowStep();
step2.setCreationDate(new Date());
step2.setEnableEscalation(false);
step2.setMyOrder(2);
step2.setName("Step 2");
step2.setResolved(false);
step2.setSchemeId(scheme.getId());
APILocator.getWorkflowAPI().saveStep(step2);
WorkflowStep step3=new WorkflowStep();
step3.setCreationDate(new Date());
step3.setEnableEscalation(false);
step3.setMyOrder(3);
step3.setName("Step 3");
step3.setResolved(true);
step3.setSchemeId(scheme.getId());
APILocator.getWorkflowAPI().saveStep(step3);
// Save as Draft Step1 -> Step1
WorkflowAction saveDraft=new WorkflowAction();
saveDraft.setId(UUIDGenerator.generateUuid());
saveDraft.setName("Save as Draft");
saveDraft.setOrder(1);
saveDraft.setNextStep(step1.getId());
saveDraft.setRequiresCheckout(true);
saveDraft.setStepId(step1.getId());
saveDraft.setNextAssign(APILocator.getRoleAPI().loadCMSAnonymousRole().getId());
APILocator.getWorkflowAPI().saveAction(saveDraft,
Arrays.asList(new Permission[] {
new Permission(
saveDraft.getPermissionType(),
saveDraft.getId(),
APILocator.getRoleAPI().loadCMSAnonymousRole().getId(),
PermissionAPI.PERMISSION_USE) }));
// Save as Draft Step1 -> Step1
WorkflowAction escalate=new WorkflowAction();
escalate.setId(UUIDGenerator.generateUuid());
escalate.setName("Save and Assign");
escalate.setOrder(2);
escalate.setNextStep(step1.getId());
escalate.setRequiresCheckout(true);
escalate.setStepId(step1.getId());
escalate.setAssignable(true);
escalate.setCommentable(true);
escalate.setNextAssign(APILocator.getRoleAPI().loadCMSAnonymousRole().getId());
APILocator.getWorkflowAPI().saveAction(escalate,
Arrays.asList(new Permission[] {
new Permission(
escalate.getPermissionType(),
escalate.getId(),
APILocator.getRoleAPI().loadCMSAnonymousRole().getId(),
PermissionAPI.PERMISSION_USE) }));
// Send for review Step1 -> Step2
WorkflowAction sendReview=new WorkflowAction();
sendReview.setId(UUIDGenerator.generateUuid());
sendReview.setName("Send for review");
sendReview.setOrder(3);
sendReview.setNextStep(step2.getId());
sendReview.setRequiresCheckout(false);
sendReview.setStepId(step1.getId());
sendReview.setNextAssign(APILocator.getRoleAPI().loadCMSAnonymousRole().getId());
APILocator.getWorkflowAPI().saveAction(sendReview,
Arrays.asList(new Permission[] {
new Permission(
sendReview.getPermissionType(),
sendReview.getId(),
APILocator.getRoleAPI().loadCMSAnonymousRole().getId(),
PermissionAPI.PERMISSION_USE) }));
// reject Step2 -> Step1
WorkflowAction reject=new WorkflowAction();
reject.setId(UUIDGenerator.generateUuid());
reject.setName("Reject");
reject.setOrder(1);
reject.setNextStep(step1.getId());
reject.setRequiresCheckout(false);
reject.setStepId(step2.getId());
reject.setNextAssign(APILocator.getRoleAPI().loadCMSAnonymousRole().getId());
APILocator.getWorkflowAPI().saveAction(reject,
Arrays.asList(new Permission[] {
new Permission(
reject.getPermissionType(),
reject.getId(),
APILocator.getRoleAPI().loadCMSAnonymousRole().getId(),
PermissionAPI.PERMISSION_USE) }));
// publish Step2 -> Step3
WorkflowAction publish=new WorkflowAction();
publish.setId(UUIDGenerator.generateUuid());
publish.setName("Publish");
publish.setOrder(2);
publish.setNextStep(step3.getId());
publish.setRequiresCheckout(false);
publish.setStepId(step2.getId());
publish.setNextAssign(APILocator.getRoleAPI().loadCMSAnonymousRole().getId());
APILocator.getWorkflowAPI().saveAction(publish,
Arrays.asList(new Permission[] {