use of org.alfresco.service.cmr.workflow.WorkflowService in project alfresco-repository by Alfresco.
the class JscriptWorkflowPath method getTasks.
/**
* Get all tasks associated with this workflow path
*
* @return all the tasks associated with this workflow path instance
*/
public Scriptable getTasks() {
WorkflowService workflowService = serviceRegistry.getWorkflowService();
List<WorkflowTask> cmrTasks = workflowService.getTasksForWorkflowPath(id);
ArrayList<Serializable> tasks = new ArrayList<Serializable>();
for (WorkflowTask cmrTask : cmrTasks) {
tasks.add(new JscriptWorkflowTask(cmrTask, this.serviceRegistry, this.scope));
}
Scriptable tasksScriptable = (Scriptable) new ValueConverter().convertValueForScript(this.serviceRegistry, scope, null, tasks);
return tasksScriptable;
}
use of org.alfresco.service.cmr.workflow.WorkflowService in project alfresco-repository by Alfresco.
the class WorkflowManager method getAssignedTasksByState.
/**
* Get tasks assigned to the current user, filtered by workflow task state.
* Only tasks having the specified state will be returned.
*
* @param state workflow task state to filter assigned tasks by
* @return the list of assigned tasks, filtered by state
*/
private Scriptable getAssignedTasksByState(WorkflowTaskState state) {
WorkflowService workflowService = services.getWorkflowService();
String currentUser = services.getAuthenticationService().getCurrentUserName();
List<WorkflowTask> cmrAssignedTasks = workflowService.getAssignedTasks(currentUser, state);
ArrayList<Serializable> assignedTasks = new ArrayList<Serializable>();
for (WorkflowTask cmrTask : cmrAssignedTasks) {
assignedTasks.add(new JscriptWorkflowTask(cmrTask, services, getScope()));
}
return (Scriptable) new ValueConverter().convertValueForScript(services, getScope(), null, assignedTasks);
}
use of org.alfresco.service.cmr.workflow.WorkflowService in project alfresco-repository by Alfresco.
the class JscriptWorkflowDefinition method getActiveInstances.
/**
* Get active workflow instances of this workflow definition
*
* @return the active workflow instances spawned from this workflow definition
*/
public synchronized Scriptable getActiveInstances() {
WorkflowService workflowService = this.serviceRegistry.getWorkflowService();
List<WorkflowInstance> cmrWorkflowInstances = workflowService.getActiveWorkflows(this.id);
ArrayList<Serializable> activeInstances = new ArrayList<Serializable>();
for (WorkflowInstance cmrWorkflowInstance : cmrWorkflowInstances) {
activeInstances.add(new JscriptWorkflowInstance(cmrWorkflowInstance, this.serviceRegistry, this.scope));
}
Scriptable activeInstancesScriptable = (Scriptable) getValueConverter().convertValueForScript(this.serviceRegistry, this.scope, null, activeInstances);
return activeInstancesScriptable;
}
use of org.alfresco.service.cmr.workflow.WorkflowService in project alfresco-remote-api by Alfresco.
the class WorkflowModelBuilderTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
namespaceService = new NamespaceServiceMemoryImpl();
namespaceService.registerNamespace("test", URI);
namespaceService.registerNamespace(NamespaceService.CONTENT_MODEL_PREFIX, NamespaceService.CONTENT_MODEL_1_0_URI);
namespaceService.registerNamespace(NamespaceService.BPM_MODEL_PREFIX, NamespaceService.BPM_MODEL_1_0_URI);
personService = mock(PersonService.class);
when(personService.getPerson(userName)).thenReturn(person);
when(personService.personExists(userName)).thenReturn(true);
nodeService = mock(NodeService.class);
Map<QName, Serializable> personProps = new HashMap<QName, Serializable>();
personProps.put(ContentModel.PROP_USERNAME, userName);
personProps.put(ContentModel.PROP_FIRSTNAME, firstName);
personProps.put(ContentModel.PROP_LASTNAME, lastName);
when(nodeService.getProperties(person)).thenReturn(personProps);
when(nodeService.getProperty(person, ContentModel.PROP_USERNAME)).thenReturn(userName);
when(nodeService.getProperty(person, ContentModel.PROP_FIRSTNAME)).thenReturn(firstName);
when(nodeService.getProperty(person, ContentModel.PROP_LASTNAME)).thenReturn(lastName);
workflowService = mock(WorkflowService.class);
dictionaryService = mock(DictionaryService.class);
authenticationService = mock(AuthenticationService.class);
builder = new WorkflowModelBuilder(namespaceService, nodeService, authenticationService, personService, workflowService, dictionaryService);
}
use of org.alfresco.service.cmr.workflow.WorkflowService in project alfresco-repository by Alfresco.
the class ScriptNode method getActiveWorkflows.
// ------------------------------------------------------------------------------
// Workflow methods
/**
* Get active workflow instances this node belongs to
*
* @return the active workflow instances this node belongs to
*/
public Scriptable getActiveWorkflows() {
if (this.activeWorkflows == null) {
WorkflowService workflowService = this.services.getWorkflowService();
List<WorkflowInstance> workflowInstances = workflowService.getWorkflowsForContent(this.nodeRef, true);
Object[] jsWorkflowInstances = new Object[workflowInstances.size()];
int index = 0;
for (WorkflowInstance workflowInstance : workflowInstances) {
jsWorkflowInstances[index++] = new JscriptWorkflowInstance(workflowInstance, this.services, this.scope);
}
this.activeWorkflows = Context.getCurrentContext().newArray(this.scope, jsWorkflowInstances);
}
return this.activeWorkflows;
}
Aggregations