Search in sources :

Example 1 with WorkflowService

use of org.alfresco.service.cmr.workflow.WorkflowService in project acs-community-packaging by Alfresco.

the class EndTaskCommand method execute.

/**
 * @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
 */
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties) {
    String taskId = (String) properties.get(PROP_TASK_ID);
    if (taskId == null) {
        throw new IllegalArgumentException("Unable to execute EndTaskCommand - mandatory parameter not supplied: " + PROP_TASK_ID);
    }
    String transition = (String) properties.get(PROP_TRANSITION);
    // end task
    WorkflowService workflowService = serviceRegistry.getWorkflowService();
    return workflowService.endTask(taskId, transition);
}
Also used : WorkflowService(org.alfresco.service.cmr.workflow.WorkflowService)

Example 2 with WorkflowService

use of org.alfresco.service.cmr.workflow.WorkflowService in project acs-community-packaging by Alfresco.

the class UINodeWorkflowInfo method encodeBegin.

@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
    if (!isRendered())
        return;
    // get the node to display the information for
    Node node = getValue();
    if (node != null) {
        // get the services we need
        NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
        DictionaryService ddService = Repository.getServiceRegistry(context).getDictionaryService();
        WorkflowService workflowService = Repository.getServiceRegistry(context).getWorkflowService();
        ResponseWriter out = context.getResponseWriter();
        ResourceBundle bundle = Application.getBundle(context);
        // render simple workflow info
        renderSimpleWorkflowInfo(context, node, nodeService, ddService, out, bundle);
        // render advanced workflow info
        renderAdvancedWorkflowInfo(context, node, nodeService, ddService, workflowService, out, bundle);
    }
}
Also used : DictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService) WorkflowService(org.alfresco.service.cmr.workflow.WorkflowService) ResponseWriter(javax.faces.context.ResponseWriter) Node(org.alfresco.web.bean.repository.Node) NodeService(org.alfresco.service.cmr.repository.NodeService) ResourceBundle(java.util.ResourceBundle)

Example 3 with WorkflowService

use of org.alfresco.service.cmr.workflow.WorkflowService in project acs-community-packaging by Alfresco.

the class WorkflowUtil method isTaskEditable.

public static boolean isTaskEditable(String taskId, ServletContext sc) {
    if (taskId == null || taskId.isEmpty()) {
        return false;
    }
    ServiceRegistry serviceRegistry = Repository.getServiceRegistry(sc);
    String username = serviceRegistry.getAuthenticationService().getCurrentUserName();
    WorkflowService workflowService = serviceRegistry.getWorkflowService();
    WorkflowTask task = workflowService.getTaskById(taskId);
    return workflowService.isTaskEditable(task, username);
}
Also used : WorkflowService(org.alfresco.service.cmr.workflow.WorkflowService) WorkflowTask(org.alfresco.service.cmr.workflow.WorkflowTask) ServiceRegistry(org.alfresco.service.ServiceRegistry)

Example 4 with WorkflowService

use of org.alfresco.service.cmr.workflow.WorkflowService in project acs-community-packaging by Alfresco.

the class WorkflowDefinitionImageServlet method doGet.

/* (non-Javadoc)
     * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // retrieve workflow definition id
    String uri = request.getRequestURI();
    uri = uri.substring(request.getContextPath().length());
    StringTokenizer t = new StringTokenizer(uri, "/");
    if (t.countTokens() != 2) {
        throw new WorkflowException("Workflow Definition Image servlet does not contain workflow definition id : " + uri);
    }
    // skip servlet name
    t.nextToken();
    String workflowDefinitionId = t.nextToken();
    // retrieve workflow definition image
    WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
    WorkflowService workflowService = (WorkflowService) wc.getBean(ServiceRegistry.WORKFLOW_SERVICE.getLocalName());
    byte[] definitionImage = workflowService.getDefinitionImage(workflowDefinitionId);
    // stream out through response
    OutputStream out = response.getOutputStream();
    out.write(definitionImage);
    out.flush();
}
Also used : StringTokenizer(java.util.StringTokenizer) WorkflowService(org.alfresco.service.cmr.workflow.WorkflowService) WorkflowException(org.alfresco.service.cmr.workflow.WorkflowException) OutputStream(java.io.OutputStream) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Example 5 with WorkflowService

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;
}
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)

Aggregations

WorkflowService (org.alfresco.service.cmr.workflow.WorkflowService)14 Serializable (java.io.Serializable)7 WorkflowTask (org.alfresco.service.cmr.workflow.WorkflowTask)5 ArrayList (java.util.ArrayList)4 Scriptable (org.mozilla.javascript.Scriptable)4 HashMap (java.util.HashMap)3 ValueConverter (org.alfresco.repo.jscript.ValueConverter)3 WorkflowInstance (org.alfresco.service.cmr.workflow.WorkflowInstance)3 WorkflowPath (org.alfresco.service.cmr.workflow.WorkflowPath)3 QName (org.alfresco.service.namespace.QName)3 Map (java.util.Map)2 DictionaryService (org.alfresco.service.cmr.dictionary.DictionaryService)2 NodeService (org.alfresco.service.cmr.repository.NodeService)2 PersonService (org.alfresco.service.cmr.security.PersonService)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 ScriptableObject (org.mozilla.javascript.ScriptableObject)2 OutputStream (java.io.OutputStream)1 List (java.util.List)1 Properties (java.util.Properties)1 ResourceBundle (java.util.ResourceBundle)1