Java Code Examples for org.activiti.engine.impl.persistence.entity.ExecutionEntity#getVariable()
The following examples show how to use
org.activiti.engine.impl.persistence.entity.ExecutionEntity#getVariable() .
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: ProcessStartExecutionListener.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void notify(DelegateExecution execution) throws Exception { // Add the workflow ID String instanceId = BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, execution.getId()); execution.setVariable(WorkflowConstants.PROP_WORKFLOW_INSTANCE_ID, instanceId); if(tenantService.isEnabled() || !deployWorkflowsInTenant) { // Add tenant as variable to the process. This will allow task-queries to filter out tasks that // are not part of the calling user's domain execution.setVariable(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain()); } // MNT-9713 if (execution instanceof ExecutionEntity) { ExecutionEntity exc = (ExecutionEntity) execution; if (exc.getSuperExecutionId() != null && exc.getVariable(ActivitiConstants.PROP_START_TASK_END_DATE) == null) { exc.setVariable(ActivitiConstants.PROP_START_TASK_END_DATE, new Date()); } } }
Example 2
Source File: CounterSignCmd.java From lemon with Apache License 2.0 | 6 votes |
/** * <li>给串行实例集合中添加一个审批人 */ private void addSequentialInstance() { ExecutionEntity execution = getActivieExecutions().get(0); if (getActivity().getProperty("type").equals("subProcess")) { if (!execution.isActive() && execution.isEnded() && ((execution.getExecutions() == null) || (execution .getExecutions().size() == 0))) { execution.setActive(true); } } Collection<String> col = (Collection<String>) execution .getVariable(collectionVariableName); col.add(assignee); execution.setVariable(collectionVariableName, col); setLoopVariable(execution, "nrOfInstances", (Integer) execution.getVariableLocal("nrOfInstances") + 1); }
Example 3
Source File: CounterSignCmd.java From lemon with Apache License 2.0 | 6 votes |
/** * 删除串行列表中移除未完成的用户(当前执行的用户无法移除) */ private void removeSequentialInstance() { ExecutionEntity executionEntity = getActivieExecutions().get(0); Collection<String> col = (Collection<String>) executionEntity .getVariable(collectionVariableName); log.info("移除前审批列表 : {}", col.toString()); col.remove(assignee); executionEntity.setVariable(collectionVariableName, col); setLoopVariable(executionEntity, "nrOfInstances", (Integer) executionEntity.getVariableLocal("nrOfInstances") - 1); // 如果串行要删除的人是当前active执行, if (executionEntity.getVariableLocal(collectionElementVariableName) .equals(assignee)) { throw new ActivitiException("当前正在执行的实例,无法移除!"); } log.info("移除后审批列表 : {}", col.toString()); }
Example 4
Source File: FormPropertyHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public FormProperty createFormProperty(ExecutionEntity execution) { FormPropertyImpl formProperty = new FormPropertyImpl(this); Object modelValue = null; if (execution != null) { if (variableName != null || variableExpression == null) { final String varName = variableName != null ? variableName : id; if (execution.hasVariable(varName)) { modelValue = execution.getVariable(varName); } else if (defaultExpression != null) { modelValue = defaultExpression.getValue(execution); } } else { modelValue = variableExpression.getValue(execution); } } else { // Execution is null, the form-property is used in a start-form. // Default value // should be available (ACT-1028) even though no execution is // available. if (defaultExpression != null) { modelValue = defaultExpression.getValue(NoExecutionVariableScope.getSharedInstance()); } } if (modelValue instanceof String) { formProperty.setValue((String) modelValue); } else if (type != null) { String formValue = type.convertModelValueToFormValue(modelValue); formProperty.setValue(formValue); } else if (modelValue != null) { formProperty.setValue(modelValue.toString()); } return formProperty; }
Example 5
Source File: GetExecutionVariableCmd.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public Object execute(CommandContext commandContext) { if (executionId == null) { throw new ActivitiIllegalArgumentException("executionId is null"); } if (variableName == null) { throw new ActivitiIllegalArgumentException("variableName is null"); } ExecutionEntity execution = commandContext.getExecutionEntityManager().findById(executionId); if (execution == null) { throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class); } if (Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, execution.getProcessDefinitionId())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); return activiti5CompatibilityHandler.getExecutionVariable(executionId, variableName, isLocal); } Object value; if (isLocal) { value = execution.getVariableLocal(variableName, false); } else { value = execution.getVariable(variableName, false); } return value; }
Example 6
Source File: DefaultContextAssociationManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public Object getVariable(String variableName) { ExecutionEntity execution = getExecutionFromContext(); if (execution != null) { return execution.getVariable(variableName); } else { return getScopedAssociation().getVariable(variableName); } }
Example 7
Source File: DefaultContextAssociationManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void setVariable(String variableName, Object value) { ExecutionEntity execution = getExecutionFromContext(); if (execution != null) { execution.setVariable(variableName, value); execution.getVariable(variableName); } else { getScopedAssociation().setVariable(variableName, value); } }
Example 8
Source File: FormPropertyHandler.java From flowable-engine with Apache License 2.0 | 5 votes |
public FormProperty createFormProperty(ExecutionEntity execution) { FormPropertyImpl formProperty = new FormPropertyImpl(this); Object modelValue = null; if (execution != null) { if (variableName != null || variableExpression == null) { final String varName = variableName != null ? variableName : id; if (execution.hasVariable(varName)) { modelValue = execution.getVariable(varName); } else if (defaultExpression != null) { modelValue = defaultExpression.getValue(execution); } } else { modelValue = variableExpression.getValue(execution); } } else { // Execution is null, the form-property is used in a start-form. Default value // should be available (ACT-1028) even though no execution is available. if (defaultExpression != null) { modelValue = defaultExpression.getValue(NoExecutionVariableScope.getSharedInstance()); } } if (modelValue instanceof String) { formProperty.setValue((String) modelValue); } else if (type != null) { String formValue = type.convertModelValueToFormValue(modelValue); formProperty.setValue(formValue); } else if (modelValue != null) { formProperty.setValue(modelValue.toString()); } return formProperty; }
Example 9
Source File: GetExecutionVariableCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public Object execute(CommandContext commandContext) { if (executionId == null) { throw new ActivitiIllegalArgumentException("executionId is null"); } if (variableName == null) { throw new ActivitiIllegalArgumentException("variableName is null"); } ExecutionEntity execution = commandContext .getExecutionEntityManager() .findExecutionById(executionId); if (execution == null) { throw new ActivitiObjectNotFoundException("execution " + executionId + " doesn't exist", Execution.class); } Object value; if (isLocal) { value = execution.getVariableLocal(variableName, false); } else { value = execution.getVariable(variableName, false); } return value; }
Example 10
Source File: TaskNotificationListener.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void notify(DelegateTask task) { // Determine whether we need to send the workflow notification or not ExecutionEntity executionEntity = ((ExecutionEntity)task.getExecution()).getProcessInstance(); Boolean value = (Boolean)executionEntity.getVariable(WorkflowNotificationUtils.PROP_SEND_EMAIL_NOTIFICATIONS); if (Boolean.TRUE.equals(value) == true) { NodeRef workflowPackage = null; ActivitiScriptNode scriptNode = (ActivitiScriptNode)executionEntity.getVariable(WorkflowNotificationUtils.PROP_PACKAGE); if (scriptNode != null) { workflowPackage = scriptNode.getNodeRef(); } // Determine whether the task is pooled or not String[] authorities = null; boolean isPooled = false; if (task.getAssignee() == null) { // Task is pooled isPooled = true; // Get the pool of user/groups for this task List<IdentityLinkEntity> identities = ((TaskEntity)task).getIdentityLinks(); List<String> temp = new ArrayList<String>(identities.size()); for (IdentityLinkEntity item : identities) { String group = item.getGroupId(); if (group != null) { temp.add(group); } String user = item.getUserId(); if (user != null) { temp.add(user); } } authorities = temp.toArray(new String[temp.size()]); } else { // Get the assigned user or group authorities = new String[]{task.getAssignee()}; } String title = null; String taskFormKey = getFormKey(task); // Fetch definition and extract name again. Possible that the default is used if the provided is missing TypeDefinition typeDefinition = propertyConverter.getWorkflowObjectFactory().getTaskTypeDefinition(taskFormKey, false); taskFormKey = typeDefinition.getName().toPrefixString(); if (taskFormKey != null) { String processDefinitionKey = ((ProcessDefinition) ((TaskEntity)task).getExecution().getProcessDefinition()).getKey(); String defName = propertyConverter.getWorkflowObjectFactory().buildGlobalId(processDefinitionKey); title = propertyConverter.getWorkflowObjectFactory().getTaskTitle(typeDefinition, defName, task.getName(), taskFormKey.replace(":", "_")); } if (title == null) { if (task.getName() != null) { title = task.getName(); } else { title = taskFormKey.replace(":", "_"); } } // Make sure a description is present String description = task.getDescription(); if (description == null || description.length() == 0) { // use the task title as the description description = title; } // Send email notification workflowNotificationUtils.sendWorkflowAssignedNotificationEMail( ActivitiConstants.ENGINE_ID + "$" + task.getId(), title, description, task.getDueDate(), Integer.valueOf(task.getPriority()), workflowPackage, authorities, isPooled); } }
Example 11
Source File: AuthenticatedTimerJobHandler.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@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); } }