Search in sources :

Example 16 with WorkflowDefinition

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

the class StartWorkflowWizard method initializeWorkflows.

private void initializeWorkflows() {
    // NOTE: we don't cache the list of startable workflows as they could get
    // updated, in which case we need the latest instance id, they could
    // theoretically also get removed.
    this.availableWorkflows = new ArrayList<SelectItem>(4);
    this.workflows = new HashMap<String, WorkflowDefinition>(4);
    List<String> configuredInvitationWorkflows = this.getInvitationServiceWorkflowNames();
    List<String> excludedWorkflows = this.getExcludedWorkflows();
    List<WorkflowDefinition> workflowDefs = this.getWorkflowService().getDefinitions();
    for (WorkflowDefinition workflowDef : workflowDefs) {
        String name = workflowDef.name;
        if (configuredInvitationWorkflows.contains(name) == false && excludedWorkflows.contains(name) == false) {
            // add the workflow if it is not a WCM specific workflow
            String label = workflowDef.title;
            if (workflowDef.description != null && workflowDef.description.length() > 0) {
                label = label + " (" + workflowDef.description + ")";
            }
            this.availableWorkflows.add(new SelectItem(workflowDef.id, label));
            this.workflows.put(workflowDef.id, workflowDef);
        }
    }
    // disable the next button if there are no workflows
    if (this.availableWorkflows.size() == 0) {
        this.nextButtonDisabled = true;
    }
}
Also used : SelectItem(javax.faces.model.SelectItem) WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition)

Example 17 with WorkflowDefinition

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

the class StartWorkflowWizard method next.

@Override
public String next() {
    String stepName = Application.getWizardManager().getCurrentStepName();
    if ("options".equals(stepName) && (this.selectedWorkflow.equals(this.previouslySelectedWorkflow) == false)) {
        // retrieve the start task for the selected workflow, get the task
        // definition and create a transient node to allow the property
        // sheet to collect the required data.
        WorkflowDefinition flowDef = this.getWorkflows().get(this.selectedWorkflow);
        if (logger.isDebugEnabled())
            logger.debug("Selected workflow: " + flowDef);
        WorkflowTaskDefinition taskDef = flowDef.getStartTaskDefinition();
        if (taskDef != null) {
            if (logger.isDebugEnabled())
                logger.debug("Start task definition: " + taskDef);
            // create an instance of a task from the data dictionary
            this.startTaskNode = TransientNode.createNew(getDictionaryService(), taskDef.metadata, "task_" + System.currentTimeMillis(), null);
        }
        // we also need to reset the resources list so that the actions get re-evaluated
        resetRichList();
    }
    return null;
}
Also used : WorkflowTaskDefinition(org.alfresco.service.cmr.workflow.WorkflowTaskDefinition) WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition)

Example 18 with WorkflowDefinition

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

the class StartWorkflowWizard method getContainerTitle.

@Override
public String getContainerTitle() {
    String wizTitle = null;
    ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
    String stepName = Application.getWizardManager().getCurrentStepName();
    if ("choose-workflow".equals(stepName) == false && this.selectedWorkflow != null) {
        String titlePattern = bundle.getString("start_named_workflow_wizard");
        WorkflowDefinition workflowDef = this.getWorkflows().get(this.selectedWorkflow);
        wizTitle = MessageFormat.format(titlePattern, new Object[] { workflowDef.title });
    } else {
        wizTitle = bundle.getString("start_workflow_wizard");
    }
    return wizTitle;
}
Also used : WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition) ResourceBundle(java.util.ResourceBundle)

Example 19 with WorkflowDefinition

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

the class StartWorkflowWizard method getPackageItemActionGroup.

/**
 * Returns the action group the current task uses for each workflow package item
 *
 * @return action group id
 */
public String getPackageItemActionGroup() {
    String actionGroup = null;
    WorkflowDefinition flowDef = this.getWorkflows().get(this.selectedWorkflow);
    WorkflowTaskDefinition taskDef = flowDef.getStartTaskDefinition();
    if (taskDef != null) {
        PropertyDefinition propDef = taskDef.metadata.getProperties().get(WorkflowModel.PROP_PACKAGE_ITEM_ACTION_GROUP);
        if (propDef != null) {
            actionGroup = propDef.getDefaultValue();
        }
    }
    return actionGroup;
}
Also used : WorkflowTaskDefinition(org.alfresco.service.cmr.workflow.WorkflowTaskDefinition) WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition) PropertyDefinition(org.alfresco.service.cmr.dictionary.PropertyDefinition)

Example 20 with WorkflowDefinition

use of org.alfresco.service.cmr.workflow.WorkflowDefinition in project alfresco-remote-api by Alfresco.

the class WorkflowDefinitionGet method buildModel.

@Override
protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) {
    Map<String, String> params = req.getServiceMatch().getTemplateVars();
    // Get the definition id from the params
    String workflowDefinitionId = params.get(PARAM_WORKFLOW_DEFINITION_ID);
    WorkflowDefinition workflowDefinition = workflowService.getDefinitionById(workflowDefinitionId);
    // Workflow definition is not found, 404
    if (workflowDefinition == null) {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find workflow definition with id: " + workflowDefinitionId);
    }
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("workflowDefinition", modelBuilder.buildDetailed(workflowDefinition));
    return model;
}
Also used : WebScriptException(org.springframework.extensions.webscripts.WebScriptException) HashMap(java.util.HashMap) WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition)

Aggregations

WorkflowDefinition (org.alfresco.service.cmr.workflow.WorkflowDefinition)31 HashMap (java.util.HashMap)19 Date (java.util.Date)18 WorkflowPath (org.alfresco.service.cmr.workflow.WorkflowPath)16 QName (org.alfresco.service.namespace.QName)16 Serializable (java.io.Serializable)15 WorkflowTask (org.alfresco.service.cmr.workflow.WorkflowTask)14 GetRequest (org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)13 JSONObject (org.json.JSONObject)12 Response (org.springframework.extensions.webscripts.TestWebScriptServer.Response)12 JSONArray (org.json.JSONArray)9 WorkflowInstance (org.alfresco.service.cmr.workflow.WorkflowInstance)8 Calendar (java.util.Calendar)6 WorkflowTaskDefinition (org.alfresco.service.cmr.workflow.WorkflowTaskDefinition)5 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 NodeRef (org.alfresco.service.cmr.repository.NodeRef)3 DeleteRequest (org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest)3 PutRequest (org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest)3 PropertyDefinition (org.alfresco.service.cmr.dictionary.PropertyDefinition)2