Java Code Examples for org.alfresco.service.cmr.workflow.WorkflowInstance#getId()
The following examples show how to use
org.alfresco.service.cmr.workflow.WorkflowInstance#getId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkflowPackageImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Extend(traitAPI=WorkflowPackageTrait.class,extensionAPI=WorkflowPackageExtension.class) public boolean setWorkflowForPackage(WorkflowInstance instance) { NodeRef packageNode = instance.getWorkflowPackage(); if(packageNode==null) return false; Serializable pckgInstanceId = nodeService.getProperty(packageNode, WorkflowModel.PROP_WORKFLOW_INSTANCE_ID); if(pckgInstanceId != null) { if(pckgInstanceId.equals(instance.getId())) { return false; } String msg = messageService.getMessage(ERR_PACKAGE_ALREADY_ASSOCIATED, packageNode, instance.getId(), pckgInstanceId); throw new WorkflowException(msg); } if (nodeService.hasAspect(packageNode, WorkflowModel.ASPECT_WORKFLOW_PACKAGE)==false) { createPackage(packageNode); } String definitionId = instance.getDefinition().getId(); String definitionName = instance.getDefinition().getName(); String instanceId = instance.getId(); nodeService.setProperty(packageNode, WorkflowModel.PROP_WORKFLOW_DEFINITION_ID, definitionId); nodeService.setProperty(packageNode, WorkflowModel.PROP_WORKFLOW_DEFINITION_NAME, definitionName); nodeService.setProperty(packageNode, WorkflowModel.PROP_WORKFLOW_INSTANCE_ID, instanceId); return true; }
Example 2
Source File: AbstractWorkflowServiceIntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private void checkWorkflows(List<WorkflowInstance> workflows, String... expectedIds) { assertEquals(expectedIds.length, workflows.size()); List<String> expIds = Arrays.asList(expectedIds); for (WorkflowInstance workflow : workflows) { String workflowId = workflow.getId(); assertTrue("The id: "+workflowId +" was not expected! Expected Ids: "+expIds, expIds.contains(workflowId)); } }
Example 3
Source File: WorkflowModelBuilder.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
private String getUrl(WorkflowInstance workflowInstance) { return "api/workflow-instances/" + workflowInstance.getId(); }
Example 4
Source File: WorkflowModelBuilder.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
private String getDiagramUrl(WorkflowInstance workflowInstance) { return "api/workflow-instances/" + workflowInstance.getId() + "/diagram"; }
Example 5
Source File: AbstractWorkflowRestApiTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 4 votes |
public void testWorkflowInstanceDelete() throws Exception { //Start workflow as USER1 and assign task to USER2. personManager.setUser(USER1); WorkflowDefinition adhocDef = workflowService.getDefinitionByName(getAdhocWorkflowDefinitionName()); Map<QName, Serializable> params = new HashMap<QName, Serializable>(); params.put(WorkflowModel.ASSOC_ASSIGNEE, personManager.get(USER2)); Date dueDate = new Date(); params.put(WorkflowModel.PROP_DUE_DATE, dueDate); params.put(WorkflowModel.PROP_PRIORITY, 1); params.put(WorkflowModel.ASSOC_PACKAGE, packageRef); params.put(WorkflowModel.PROP_CONTEXT, packageRef); WorkflowPath adhocPath = workflowService.startWorkflow(adhocDef.getId(), params); WorkflowTask startTask = workflowService.getTasksForWorkflowPath(adhocPath.getId()).get(0); startTask = workflowService.endTask(startTask.getId(), null); WorkflowInstance adhocInstance = startTask.getPath().getInstance(); // attempt to delete workflow as a user that is not the initiator personManager.setUser(USER3); String instanceId = adhocInstance.getId(); sendRequest(new DeleteRequest(URL_WORKFLOW_INSTANCES + "/" + instanceId), Status.STATUS_FORBIDDEN); // make sure workflow instance is still present assertNotNull(workflowService.getWorkflowById(instanceId)); // now delete as initiator of workflow personManager.setUser(USER1); sendRequest(new DeleteRequest(URL_WORKFLOW_INSTANCES + "/" + instanceId), Status.STATUS_OK); WorkflowInstance instance = workflowService.getWorkflowById(instanceId); if (instance != null) { assertFalse("The deleted workflow is still active!", instance.isActive()); } List<WorkflowInstance> instances = workflowService.getActiveWorkflows(adhocInstance.getDefinition().getId()); for (WorkflowInstance activeInstance : instances) { assertFalse(instanceId.equals(activeInstance.getId())); } // Try deleting an non-existent workflow instance, should result in 404 sendRequest(new DeleteRequest(URL_WORKFLOW_INSTANCES + "/" + instanceId), Status.STATUS_NOT_FOUND); }