Java Code Examples for org.activiti.engine.impl.pvm.PvmActivity#getProperty()

The following examples show how to use org.activiti.engine.impl.pvm.PvmActivity#getProperty() . 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: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private WorkflowTask getTaskForTimer(Job job, ProcessInstance processInstance, Execution jobExecution) 
{
    if (job instanceof TimerEntity) 
    {
        ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
        List<String> activeActivityIds = runtimeService.getActiveActivityIds(jobExecution.getId());
        
        if(activeActivityIds.size() == 1)
        {
            PvmActivity targetActivity = def.findActivity(activeActivityIds.get(0));
            if(targetActivity != null)
            {
                // Only get tasks of active activity is a user-task 
                String activityType = (String) targetActivity.getProperty(ActivitiConstants.NODE_TYPE);
                if(ActivitiConstants.USER_TASK_NODE_TYPE.equals(activityType))
                {
                    Task task = taskService.createTaskQuery().executionId(job.getExecutionId()).singleResult();
                    return typeConverter.convert(task);
                }
            }
        }
    }
    return null;
}
 
Example 2
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @param activity PvmActivity
 * @param key String
 * @param forceIsTaskNode boolean
 * @return WorkflowNode
 */
private WorkflowNode getNode(PvmActivity activity, String key, boolean forceIsTaskNode)
{
    String name = activity.getId();
     String defaultTitle = (String) activity.getProperty(ActivitiConstants.NODE_NAME);
     String defaultDescription = (String) activity.getProperty(ActivitiConstants.NODE_DESCRIPTION);
     String type = (String) activity.getProperty(ActivitiConstants.NODE_TYPE);
     boolean isTaskNode = forceIsTaskNode || ActivitiConstants.USER_TASK_NODE_TYPE.equals(type);
     
     if(defaultTitle == null)
     {
     	defaultTitle = name;
     }
     if(defaultDescription == null)
     {
     	defaultDescription = name;
     }
    WorkflowTransition transition = getDefaultTransition(key, name);
    return factory.createNode(name, key, defaultTitle, defaultDescription, type, isTaskNode, transition);
}
 
Example 3
Source File: SubProcessActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    ActivityExecution activityExecution = (ActivityExecution) execution;
    PvmActivity activity = activityExecution.getActivity();
    ActivityImpl initialActivity = (ActivityImpl) activity.getProperty(BpmnParse.PROPERTYNAME_INITIAL);

    if (initialActivity == null) {
        throw new ActivitiException("No initial activity found for subprocess "
                + activityExecution.getActivity().getId());
    }

    // initialize the template-defined data objects as variables
    initializeDataObjects(activityExecution, activity);

    if (initialActivity.getActivityBehavior() != null
            && initialActivity.getActivityBehavior() instanceof NoneStartEventActivityBehavior) { // embedded subprocess: only none start allowed
        ((ExecutionEntity) execution).setActivity(initialActivity);
        Context.getCommandContext().getHistoryManager().recordActivityStart((ExecutionEntity) execution);
    }

    activityExecution.executeActivity(initialActivity);
}
 
Example 4
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean isUserTask(PvmActivity currentActivity)
{
    // TODO: Validate if this is the best way to find out an activity is a usertask
    String type = (String) currentActivity.getProperty(ActivitiConstants.NODE_TYPE);
    if(type != null && type.equals(ActivitiConstants.USER_TASK_NODE_TYPE))
    {
        return true;
    }
    return false;
}
 
Example 5
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean isSubProcess(PvmActivity currentActivity)
{
    String type = (String) currentActivity.getProperty(ActivitiConstants.NODE_TYPE);
    if(type != null && type.equals(ActivitiConstants.SUB_PROCESS_NODE_TYPE))
    {
        return true;
    }
    return false;
}
 
Example 6
Source File: EmbeddedSubProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void timerFires(ActivityExecution execution, String signalName, Object signalData) throws Exception {
    PvmActivity timerActivity = execution.getActivity();
    boolean isInterrupting = (Boolean) timerActivity.getProperty("isInterrupting");
    List<ActivityExecution> recyclableExecutions;
    if (isInterrupting) {
        recyclableExecutions = removeAllExecutions(execution);
    } else {
        recyclableExecutions = Collections.EMPTY_LIST;
    }
    execution.takeAll(timerActivity.getOutgoingTransitions(), recyclableExecutions);
}
 
Example 7
Source File: EventScopeCreatingSubprocess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void timerFires(ActivityExecution execution, String signalName, Object signalData) throws Exception {
    PvmActivity timerActivity = execution.getActivity();
    boolean isInterrupting = (Boolean) timerActivity.getProperty("isInterrupting");
    List<ActivityExecution> recyclableExecutions;
    if (isInterrupting) {
        recyclableExecutions = removeAllExecutions(execution);
    } else {
        recyclableExecutions = Collections.EMPTY_LIST;
    }
    execution.takeAll(timerActivity.getOutgoingTransitions(), recyclableExecutions);
}
 
Example 8
Source File: AuthenticatedTimerJobHandler.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void execute(final JobEntity job, final String configuration, final ExecutionEntity execution,
            final CommandContext commandContext) 
{
    String userName = null;
    String tenantToRunIn = (String) execution.getVariable(ActivitiConstants.VAR_TENANT_DOMAIN);
    if(tenantToRunIn != null && tenantToRunIn.trim().length() == 0)
    {
        tenantToRunIn = null;
    }
    
    final ActivitiScriptNode initiatorNode = (ActivitiScriptNode) execution.getVariable(WorkflowConstants.PROP_INITIATOR);
    
    // Extracting the properties from the initiatornode should be done in correct tennant or as administrator, since we don't 
    // know who started the workflow yet (We can't access node-properties when no valid authentication context is set up).
    if(tenantToRunIn != null)
    {
        userName = TenantUtil.runAsTenant(new TenantRunAsWork<String>()
        {
            @Override
            public String doWork() throws Exception
            {
                return getInitiator(initiatorNode);
            }
        }, tenantToRunIn);
    }
    else
    {
        // No tenant on worklfow, run as admin in default tenant
        userName = AuthenticationUtil.runAs(new RunAsWork<String>()
        {
            @SuppressWarnings("synthetic-access")
            public String doWork() throws Exception
            {
                return getInitiator(initiatorNode);
            }
        }, AuthenticationUtil.getSystemUserName());
    }
    
    // Fall back to task assignee, if no initiator is found
    if(userName == null)
    {
        PvmActivity targetActivity = execution.getActivity();
        if (targetActivity != null)
        {
            // Only try getting active task, if execution timer is waiting on is a userTask
            String activityType = (String) targetActivity.getProperty(ActivitiConstants.NODE_TYPE);
            if (ActivitiConstants.USER_TASK_NODE_TYPE.equals(activityType))
            {
                Task task = new TaskQueryImpl(commandContext)
                .executionId(execution.getId())
                .executeSingleResult(commandContext);
                
                if (task != null && task.getAssignee() != null)
                {
                    userName = task.getAssignee();
                }
            }
        }
    }
    
    // When no task assignee is set, nor the initiator, use system user to run job
    if (userName == null)
    {
        userName = AuthenticationUtil.getSystemUserName();
        tenantToRunIn = null;
    }
    
    if(tenantToRunIn != null)
    {
        TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>()
        {
            @Override
            public Void doWork() throws Exception
            {
                wrappedHandler.execute(job, configuration, execution, commandContext);
                return null;
            }
        }, userName, tenantToRunIn);
    }
    else
    {
        // Execute the timer without tenant
        AuthenticationUtil.runAs(new RunAsWork<Void>()
        {
            @SuppressWarnings("synthetic-access")
            public Void doWork() throws Exception
            {
                wrappedHandler.execute(job, configuration, execution, commandContext);
                return null;
            }
        }, userName);
    }
}
 
Example 9
Source File: RollbackTaskCmd.java    From lemon with Apache License 2.0 4 votes vote down vote up
/**
 * 判断是否会签.
 */
public boolean isMultiInstance(PvmActivity pvmActivity) {
    return pvmActivity.getProperty("multiInstance") != null;
}