Search in sources :

Example 1 with WorkflowDefinition

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

the class StartWorkflowWizard method getWorkflowDefinitionImageUrl.

/**
 * Returns the URL to the Workflow Definition Image of the current task
 *
 * @return  the url
 */
public String getWorkflowDefinitionImageUrl() {
    String url = null;
    if (selectedWorkflow != null) {
        WorkflowDefinition def = getWorkflows().get(selectedWorkflow);
        url = "/workflowdefinitionimage/" + def.id;
    }
    return url;
}
Also used : WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition)

Example 2 with WorkflowDefinition

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

the class StartWorkflowWizard method getPackageActionGroup.

/**
 * Returns the action group the current task uses for the workflow package
 *
 * @return action group id
 */
public String getPackageActionGroup() {
    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_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 3 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 4 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 5 with WorkflowDefinition

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

the class WorkflowInstancesGet method buildModel.

@Override
protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache) {
    WorkflowInstanceQuery workflowInstanceQuery = new WorkflowInstanceQuery();
    Map<String, String> params = req.getServiceMatch().getTemplateVars();
    // state is not included into filters list as it will be taken into account before filtering
    WorkflowState state = getState(req);
    // get filter param values
    Map<QName, Object> filters = new HashMap<QName, Object>(9);
    if (req.getParameter(PARAM_INITIATOR) != null)
        filters.put(QNAME_INITIATOR, personService.getPerson(req.getParameter(PARAM_INITIATOR)));
    if (req.getParameter(PARAM_PRIORITY) != null)
        filters.put(WorkflowModel.PROP_WORKFLOW_PRIORITY, req.getParameter(PARAM_PRIORITY));
    String excludeParam = req.getParameter(PARAM_EXCLUDE);
    if (excludeParam != null && excludeParam.length() > 0) {
        workflowInstanceQuery.setExcludedDefinitions(Arrays.asList(StringUtils.tokenizeToStringArray(excludeParam, ",")));
    }
    // process all the date related parameters
    Map<DatePosition, Date> dateParams = new HashMap<DatePosition, Date>();
    Date dueBefore = getDateFromRequest(req, PARAM_DUE_BEFORE);
    if (dueBefore != null) {
        dateParams.put(DatePosition.BEFORE, dueBefore);
    }
    Date dueAfter = getDateFromRequest(req, PARAM_DUE_AFTER);
    if (dueAfter != null) {
        dateParams.put(DatePosition.AFTER, dueAfter);
    }
    if (dateParams.isEmpty()) {
        if (req.getParameter(PARAM_DUE_BEFORE) != null || req.getParameter(PARAM_DUE_AFTER) != null) {
            filters.put(WorkflowModel.PROP_WORKFLOW_DUE_DATE, null);
        }
    } else {
        filters.put(WorkflowModel.PROP_WORKFLOW_DUE_DATE, dateParams);
    }
    workflowInstanceQuery.setStartBefore(getDateFromRequest(req, PARAM_STARTED_BEFORE));
    workflowInstanceQuery.setStartAfter(getDateFromRequest(req, PARAM_STARTED_AFTER));
    workflowInstanceQuery.setEndBefore(getDateFromRequest(req, PARAM_COMPLETED_BEFORE));
    workflowInstanceQuery.setEndAfter(getDateFromRequest(req, PARAM_COMPLETED_AFTER));
    // determine if there is a definition id to filter by
    String workflowDefinitionId = params.get(VAR_DEFINITION_ID);
    if (workflowDefinitionId == null) {
        workflowDefinitionId = req.getParameter(PARAM_DEFINITION_ID);
    }
    // default workflow state to ACTIVE if not supplied
    if (state == null) {
        state = WorkflowState.ACTIVE;
    }
    workflowInstanceQuery.setActive(state == WorkflowState.ACTIVE);
    workflowInstanceQuery.setCustomProps(filters);
    List<WorkflowInstance> workflows = new ArrayList<WorkflowInstance>();
    int total = 0;
    // MNT-9074 My Tasks fails to render if tasks quantity is excessive
    int maxItems = getIntParameter(req, PARAM_MAX_ITEMS, DEFAULT_MAX_ITEMS);
    int skipCount = getIntParameter(req, PARAM_SKIP_COUNT, DEFAULT_SKIP_COUNT);
    if (workflowDefinitionId == null && req.getParameter(PARAM_DEFINITION_NAME) != null) {
        /**
         * If we are searching by workflow definition name then there may be many workflow definition instances.
         */
        int workingSkipCount = skipCount;
        /**
         * Yes there could be multiple process definitions with that definition name
         */
        String definitionName = req.getParameter(PARAM_DEFINITION_NAME);
        List<WorkflowDefinition> defs = workflowService.getAllDefinitionsByName(definitionName);
        int itemsToQuery = maxItems;
        for (WorkflowDefinition def : defs) {
            workflowDefinitionId = def.getId();
            workflowInstanceQuery.setWorkflowDefinitionId(workflowDefinitionId);
            if (maxItems < 0 || itemsToQuery > 0) {
                workflows.addAll(workflowService.getWorkflows(workflowInstanceQuery, itemsToQuery, workingSkipCount));
            }
            if (maxItems > 0) {
                itemsToQuery = maxItems - workflows.size();
            }
            total += (int) workflowService.countWorkflows(workflowInstanceQuery);
            if (workingSkipCount > 0) {
                workingSkipCount = skipCount - total;
                if (workingSkipCount < 0) {
                    workingSkipCount = 0;
                }
            }
        }
    } else {
        /**
         * This is the old single task implementation
         */
        if (workflowDefinitionId != null) {
            workflowInstanceQuery.setWorkflowDefinitionId(workflowDefinitionId);
        }
        workflows.addAll(workflowService.getWorkflows(workflowInstanceQuery, maxItems, skipCount));
        total = (int) workflowService.countWorkflows(workflowInstanceQuery);
    }
    List<Map<String, Object>> results = new ArrayList<Map<String, Object>>(total);
    // init empty list
    results.addAll(Arrays.asList((Map<String, Object>[]) new Map[total]));
    for (WorkflowInstance workflow : workflows) {
        // set to special index
        results.set(skipCount, modelBuilder.buildSimple(workflow));
        skipCount++;
    }
    // create and return results, paginated if necessary
    return createResultModel(req, "workflowInstances", results);
}
Also used : HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) WorkflowDefinition(org.alfresco.service.cmr.workflow.WorkflowDefinition) WorkflowInstance(org.alfresco.service.cmr.workflow.WorkflowInstance) Date(java.util.Date) WorkflowInstanceQuery(org.alfresco.service.cmr.workflow.WorkflowInstanceQuery) DatePosition(org.alfresco.service.cmr.workflow.WorkflowInstanceQuery.DatePosition) HashMap(java.util.HashMap) Map(java.util.Map)

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