Search in sources :

Example 6 with WorkflowTransition

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

the class ManageTaskDialog method getAdditionalButtons.

@Override
public List<DialogButtonConfig> getAdditionalButtons() {
    List<DialogButtonConfig> buttons = null;
    if (this.getWorkflowTask() != null) {
        // get the transitions available from this task and
        // show them in the dialog as additional buttons
        this.transitions = this.getWorkflowTask().path.node.transitions;
        boolean isPooledTask = isPooledTask();
        if (isPooledTask || this.transitions != null) {
            buttons = new ArrayList<DialogButtonConfig>(this.transitions.length + 1);
            if (isPooledTask) {
                if (this.taskNode.getProperties().get(ContentModel.PROP_OWNER) == null) {
                    buttons.add(new DialogButtonConfig("button_take_ownership", null, "take_ownership", "#{DialogManager.bean.takeOwnership}", "false", null));
                } else {
                    buttons.add(new DialogButtonConfig("button_return_to_pool", null, "return_ownership", "#{DialogManager.bean.returnOwnership}", "false", null));
                }
            }
            if (this.transitions != null) {
                Object hiddenTransitions = this.taskNode.getProperties().get(WorkflowModel.PROP_HIDDEN_TRANSITIONS);
                for (WorkflowTransition trans : this.transitions) {
                    if (hiddenTransitions == null || (hiddenTransitions instanceof String && ((String) hiddenTransitions).equals("")) || (hiddenTransitions instanceof String && !((String) hiddenTransitions).equals(trans.id)) || (hiddenTransitions instanceof List<?>) && !((List<?>) hiddenTransitions).contains(trans.id)) {
                        if (this.taskNode.getProperties().get(ContentModel.PROP_OWNER) != null) {
                            buttons.add(new DialogButtonConfig(ID_PREFIX + trans.title, trans.title, null, "#{DialogManager.bean.transition}", "false", null));
                        }
                    }
                }
            }
        }
    }
    return buttons;
}
Also used : DialogButtonConfig(org.alfresco.web.config.DialogsConfigElement.DialogButtonConfig) WorkflowTransition(org.alfresco.service.cmr.workflow.WorkflowTransition)

Example 7 with WorkflowTransition

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

the class AbstractWorkflowRestApiTest method checkWorkflowTaskDefinition.

private void checkWorkflowTaskDefinition(WorkflowTaskDefinition wfDefinition, JSONObject definition) throws Exception {
    assertNotNull(definition);
    assertEquals(wfDefinition.getId(), definition.getString("id"));
    assertTrue(definition.has("url"));
    JSONObject type = definition.getJSONObject("type");
    TypeDefinition startType = (wfDefinition).getMetadata();
    assertNotNull(type);
    assertEquals(startType.getName().toPrefixString(), type.getString("name"));
    assertEquals(startType.getTitle(this.dictionaryService), type.getString("title"));
    assertEquals(startType.getDescription(this.dictionaryService), type.getString("description"));
    assertTrue(type.has("url"));
    JSONObject node = definition.getJSONObject("node");
    WorkflowNode startNode = wfDefinition.getNode();
    assertNotNull(node);
    assertEquals(startNode.getName(), node.getString("name"));
    assertEquals(startNode.getTitle(), node.getString("title"));
    assertEquals(startNode.getDescription(), node.getString("description"));
    assertEquals(startNode.isTaskNode(), node.getBoolean("isTaskNode"));
    JSONArray transitions = node.getJSONArray("transitions");
    WorkflowTransition[] startTransitions = startNode.getTransitions();
    assertNotNull(transitions);
    assertEquals(startTransitions.length, transitions.length());
    for (int i = 0; i < transitions.length(); i++) {
        JSONObject transition = transitions.getJSONObject(i);
        WorkflowTransition startTransition = startTransitions[i];
        assertNotNull(transition);
        if (startTransition.getId() == null) {
            assertEquals("", transition.getString("id"));
        } else {
            assertEquals(startTransition.getId(), transition.getString("id"));
        }
        assertEquals(startTransition.getTitle(), transition.getString("title"));
        assertEquals(startTransition.getDescription(), transition.getString("description"));
        assertEquals(startTransition.isDefault(), transition.getBoolean("isDefault"));
        assertTrue(transition.has("isHidden"));
    }
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) WorkflowTransition(org.alfresco.service.cmr.workflow.WorkflowTransition) WorkflowNode(org.alfresco.service.cmr.workflow.WorkflowNode) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition)

Aggregations

WorkflowTransition (org.alfresco.service.cmr.workflow.WorkflowTransition)7 WorkflowNode (org.alfresco.service.cmr.workflow.WorkflowNode)3 WorkflowTask (org.alfresco.service.cmr.workflow.WorkflowTask)3 Serializable (java.io.Serializable)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)2 WorkflowInstance (org.alfresco.service.cmr.workflow.WorkflowInstance)2 List (java.util.List)1 ResourceBundle (java.util.ResourceBundle)1 FacesContext (javax.faces.context.FacesContext)1 ResponseWriter (javax.faces.context.ResponseWriter)1 UserTransaction (javax.transaction.UserTransaction)1 WorkflowDefinition (org.alfresco.service.cmr.workflow.WorkflowDefinition)1 WorkflowTaskDefinition (org.alfresco.service.cmr.workflow.WorkflowTaskDefinition)1 WorkflowTaskQuery (org.alfresco.service.cmr.workflow.WorkflowTaskQuery)1 QName (org.alfresco.service.namespace.QName)1 DialogButtonConfig (org.alfresco.web.config.DialogsConfigElement.DialogButtonConfig)1