Java Code Examples for org.activiti.engine.impl.task.TaskDefinition#getTaskFormHandler()

The following examples show how to use org.activiti.engine.impl.task.TaskDefinition#getTaskFormHandler() . 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: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private String getFormKey(TaskDefinition taskDefinition) 
{
	 TaskFormHandler handler = taskDefinition.getTaskFormHandler();
     if(handler != null && handler instanceof DefaultTaskFormHandler)
     {
         // We cast to DefaultTaskFormHandler since we do not configure our own
         return ((DefaultTaskFormHandler)handler).getFormKey().getExpressionText();
     }
     return null;
}
 
Example 2
Source File: RuntimeActivityCreatorSupport.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected TaskDefinition cloneTaskDefinition(TaskDefinition taskDefinition)
{
	TaskDefinition newTaskDefinition = new TaskDefinition(taskDefinition.getTaskFormHandler());
	BeanUtils.copyProperties(taskDefinition, newTaskDefinition);
	return newTaskDefinition;
}
 
Example 3
Source File: FindFirstTaskFormCmd.java    From lemon with Apache License 2.0 4 votes vote down vote up
public FirstTaskForm execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration().getDeploymentManager()
            .findDeployedProcessDefinitionById(processDefinitionId);

    if (processDefinitionEntity == null) {
        throw new IllegalArgumentException(
                "cannot find processDefinition : " + processDefinitionId);
    }

    if (processDefinitionEntity.hasStartFormKey()) {
        return this.findStartEventForm(processDefinitionEntity);
    }

    ActivityImpl startActivity = processDefinitionEntity.getInitial();

    if (startActivity.getOutgoingTransitions().size() != 1) {
        throw new IllegalStateException(
                "start activity outgoing transitions cannot more than 1, now is : "
                        + startActivity.getOutgoingTransitions().size());
    }

    PvmTransition pvmTransition = startActivity.getOutgoingTransitions()
            .get(0);
    PvmActivity targetActivity = pvmTransition.getDestination();

    if (!"userTask".equals(targetActivity.getProperty("type"))) {
        logger.info("first activity is not userTask, just skip");

        return new FirstTaskForm();
    }

    FirstTaskForm firstTaskForm = new FirstTaskForm();
    firstTaskForm.setProcessDefinitionId(processDefinitionId);
    firstTaskForm.setExists(true);
    firstTaskForm.setTaskForm(true);

    String taskDefinitionKey = targetActivity.getId();
    logger.debug("activityId : {}", targetActivity.getId());
    firstTaskForm.setActivityId(taskDefinitionKey);

    TaskDefinition taskDefinition = processDefinitionEntity
            .getTaskDefinitions().get(taskDefinitionKey);

    Expression expression = taskDefinition.getAssigneeExpression();

    if (expression != null) {
        String expressionText = expression.getExpressionText();
        logger.debug("{}", expressionText);
        logger.debug("{}", startActivity.getProperties());
        logger.debug("{}", processDefinitionEntity.getProperties());
        firstTaskForm.setAssignee(expressionText);
    } else {
        logger.info("cannot find expression : {}, {}", processDefinitionId,
                taskDefinitionKey);
    }

    String initiatorVariableName = (String) processDefinitionEntity
            .getProperty(BpmnParse.PROPERTYNAME_INITIATOR_VARIABLE_NAME);
    firstTaskForm.setInitiatorName(initiatorVariableName);

    DefaultFormHandler formHandler = (DefaultFormHandler) taskDefinition
            .getTaskFormHandler();

    if (formHandler.getFormKey() != null) {
        String formKey = formHandler.getFormKey().getExpressionText();
        firstTaskForm.setFormKey(formKey);
    } else {
        logger.info("cannot find formKey from xml : {}, {}",
                processDefinitionId, taskDefinitionKey);
    }

    return firstTaskForm;
}