Java Code Examples for org.alfresco.service.cmr.action.Action#getParameterValues()

The following examples show how to use org.alfresco.service.cmr.action.Action#getParameterValues() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public ActionImpl(Action action, String actionDefinitionName)
{
    super(action.getId(), action.getParameterValues());
    this.actionDefinitionName = actionDefinitionName;
    this.actionConditions = action.getActionConditions();
    this.compensatingAction = action.getCompensatingAction();
    this.createdDate = action.getCreatedDate();
    this.creator = action.getCreator();
    this.description = action.getDescription();
    this.trackStatus = action.getTrackStatus();
    this.executeAsynchronously = action.getExecuteAsychronously();
    this.modifiedDate = action.getModifiedDate();
    this.modifier = action.getModifier();
    this.nodeRef = action.getNodeRef();
    this.title = action.getTitle();
    this.executionStartDate = action.getExecutionStartDate();
    this.executionEndDate = action.getExecutionEndDate();
    this.executionStatus = action.getExecutionStatus();
    this.executionFailureMessage = action.getExecutionFailureMessage();
    if (action instanceof ActionImpl)
    {
        ActionImpl actionImpl = (ActionImpl) action;
        this.executionInstance = actionImpl.getExecutionInstance();
        this.runAsUserName = actionImpl.getRunAsUser();
        this.tenantId = actionImpl.getTenantId();
        this.actionChain = actionImpl.actionChain;
    }
}
 
Example 2
Source File: BaseRuleTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void checkRule(Rule rule)
{
    // Check the basic details of the rule
    assertEquals(this.ruleType.getName(), rule.getRuleTypes().get(0));
    assertEquals(TITLE, rule.getTitle());
    assertEquals(DESCRIPTION, rule.getDescription());

    Action ruleAction = rule.getAction();
    assertNotNull(ruleAction);
    
    // Check conditions
    List<ActionCondition> ruleConditions = ruleAction.getActionConditions();
    assertNotNull(ruleConditions);
    assertEquals(1, ruleConditions.size());
    assertEquals(CONDITION_DEF_NAME, ruleConditions.get(0)
            .getActionConditionDefinitionName());
    Map<String, Serializable> condParams = ruleConditions.get(0)
            .getParameterValues();
    assertNotNull(condParams);
    assertEquals(1, condParams.size());
    assertTrue(condParams.containsKey(COND_PROP_NAME_1));
    assertEquals(COND_PROP_VALUE_1, condParams.get(COND_PROP_NAME_1));

    // Check the actions
    assertEquals(ACTION_DEF_NAME, ruleAction.getActionDefinitionName());
    Map<String, Serializable> actionParams = ruleAction.getParameterValues();
    assertNotNull(actionParams);
    assertEquals(1, actionParams.size());
    assertTrue(actionParams.containsKey(ACTION_PROP_NAME_1));
    assertEquals(ACTION_PROP_VALUE_1, actionParams.get(ACTION_PROP_NAME_1));
}
 
Example 3
Source File: ExtendedMailActionExecutor.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public MimeMessageHelper prepareEmail(Action ruleAction, NodeRef actionedUponNodeRef, Pair<String, Locale> recipient,
            Pair<InternetAddress, Locale> sender)
{
    parameterValues = ruleAction.getParameterValues();
    return super.prepareEmail(ruleAction, actionedUponNodeRef, recipient, sender);
}
 
Example 4
Source File: StartWorkflowActionExecuter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) 
{
    // retrieve workflow definition
    String workflowName = (String)ruleAction.getParameterValue(PARAM_WORKFLOW_NAME);
    WorkflowDefinition def = workflowService.getDefinitionByName(workflowName);
    
    // create workflow package to contain actioned upon node
    NodeRef workflowPackage = (NodeRef)ruleAction.getParameterValue(WorkflowModel.ASSOC_PACKAGE.toPrefixString(namespaceService));
    workflowPackage = workflowService.createPackage(workflowPackage);
    ChildAssociationRef childAssoc = nodeService.getPrimaryParent(actionedUponNodeRef);
    nodeService.addChild(workflowPackage, actionedUponNodeRef, WorkflowModel.ASSOC_PACKAGE_CONTAINS, childAssoc.getQName());
    
    // build map of workflow start task parameters
    Map<String, Serializable> paramValues = ruleAction.getParameterValues();
    Map<QName, Serializable> workflowParameters = new HashMap<QName, Serializable>();
    workflowParameters.put(WorkflowModel.ASSOC_PACKAGE, workflowPackage);
    for (Map.Entry<String, Serializable> entry : paramValues.entrySet())
    {
        if (!entry.getKey().equals(PARAM_WORKFLOW_NAME))
        {
            QName qname = QName.createQName(entry.getKey(), namespaceService);
            Serializable value = entry.getValue();
            workflowParameters.put(qname, value);
        }
    }

    // provide a default context, if one is not specified
    Serializable context = workflowParameters.get(WorkflowModel.PROP_CONTEXT);
    if (context == null)
    {
        workflowParameters.put(WorkflowModel.PROP_CONTEXT, childAssoc.getParentRef());
    }

    // start the workflow
    WorkflowPath path = workflowService.startWorkflow(def.getId(), workflowParameters);

    // determine whether to auto-end the start task
    Boolean endStartTask = (Boolean)ruleAction.getParameterValue(PARAM_END_START_TASK);
    String startTaskTransition = (String)ruleAction.getParameterValue(PARAM_START_TASK_TRANSITION);
    endStartTask = (endStartTask == null) ? true : false;
    
    // auto-end the start task with the provided transition (if one)
    if (endStartTask)
    {
        List<WorkflowTask> tasks = workflowService.getTasksForWorkflowPath(path.getId());
        for (WorkflowTask task : tasks)
        {
            workflowService.endTask(task.getId(), startTaskTransition);
        }
    }
}