Search in sources :

Example 1 with ValueConverter

use of org.alfresco.repo.jscript.ValueConverter 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;
}
Also used : Serializable(java.io.Serializable) WorkflowService(org.alfresco.service.cmr.workflow.WorkflowService) ArrayList(java.util.ArrayList) WorkflowTask(org.alfresco.service.cmr.workflow.WorkflowTask) Scriptable(org.mozilla.javascript.Scriptable) ValueConverter(org.alfresco.repo.jscript.ValueConverter)

Example 2 with ValueConverter

use of org.alfresco.repo.jscript.ValueConverter 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);
}
Also used : Serializable(java.io.Serializable) WorkflowService(org.alfresco.service.cmr.workflow.WorkflowService) ArrayList(java.util.ArrayList) WorkflowTask(org.alfresco.service.cmr.workflow.WorkflowTask) Scriptable(org.mozilla.javascript.Scriptable) ValueConverter(org.alfresco.repo.jscript.ValueConverter)

Example 3 with ValueConverter

use of org.alfresco.repo.jscript.ValueConverter in project alfresco-repository by Alfresco.

the class WorkflowManager method getLatestDefinitions.

/**
 * Gets the latest versions of the deployed, workflow definitions
 *
 * @return the latest versions of the deployed workflow definitions
 */
public Scriptable getLatestDefinitions() {
    List<WorkflowDefinition> cmrDefinitions = services.getWorkflowService().getDefinitions();
    ArrayList<Serializable> workflowDefs = new ArrayList<Serializable>();
    for (WorkflowDefinition cmrDefinition : cmrDefinitions) {
        workflowDefs.add(new JscriptWorkflowDefinition(cmrDefinition, services, getScope()));
    }
    return (Scriptable) new ValueConverter().convertValueForScript(services, getScope(), null, workflowDefs);
}
Also used : Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition) Scriptable(org.mozilla.javascript.Scriptable) ValueConverter(org.alfresco.repo.jscript.ValueConverter)

Example 4 with ValueConverter

use of org.alfresco.repo.jscript.ValueConverter in project alfresco-repository by Alfresco.

the class JscriptWorkflowInstance method getPaths.

/**
 * Get all paths for the specified workflow instance
 */
public Scriptable getPaths() {
    WorkflowService workflowService = serviceRegistry.getWorkflowService();
    List<WorkflowPath> cmrPaths = workflowService.getWorkflowPaths(this.id);
    ArrayList<Serializable> paths = new ArrayList<Serializable>();
    for (WorkflowPath cmrPath : cmrPaths) {
        paths.add(new JscriptWorkflowPath(cmrPath, this.serviceRegistry, this.scope));
    }
    Scriptable pathsScriptable = (Scriptable) new ValueConverter().convertValueForScript(this.serviceRegistry, this.scope, null, paths);
    return pathsScriptable;
}
Also used : Serializable(java.io.Serializable) WorkflowService(org.alfresco.service.cmr.workflow.WorkflowService) ArrayList(java.util.ArrayList) WorkflowPath(org.alfresco.service.cmr.workflow.WorkflowPath) Scriptable(org.mozilla.javascript.Scriptable) ValueConverter(org.alfresco.repo.jscript.ValueConverter)

Example 5 with ValueConverter

use of org.alfresco.repo.jscript.ValueConverter in project alfresco-repository by Alfresco.

the class WorkflowManager method getAllDefinitions.

/**
 * Gets all versions of the deployed workflow definitions
 *
 * @return all versions of the deployed workflow definitions
 */
public Scriptable getAllDefinitions() {
    List<WorkflowDefinition> cmrDefinitions = services.getWorkflowService().getAllDefinitions();
    ArrayList<Serializable> workflowDefs = new ArrayList<Serializable>();
    for (WorkflowDefinition cmrDefinition : cmrDefinitions) {
        workflowDefs.add(new JscriptWorkflowDefinition(cmrDefinition, services, getScope()));
    }
    return (Scriptable) new ValueConverter().convertValueForScript(services, getScope(), null, workflowDefs);
}
Also used : Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition) Scriptable(org.mozilla.javascript.Scriptable) ValueConverter(org.alfresco.repo.jscript.ValueConverter)

Aggregations

Serializable (java.io.Serializable)6 ArrayList (java.util.ArrayList)6 ValueConverter (org.alfresco.repo.jscript.ValueConverter)6 Scriptable (org.mozilla.javascript.Scriptable)6 WorkflowService (org.alfresco.service.cmr.workflow.WorkflowService)3 WorkflowTask (org.alfresco.service.cmr.workflow.WorkflowTask)3 WorkflowDefinition (org.alfresco.service.cmr.workflow.WorkflowDefinition)2 WorkflowPath (org.alfresco.service.cmr.workflow.WorkflowPath)1