Java Code Examples for org.activiti.engine.impl.pvm.process.ActivityImpl#setProperty()
The following examples show how to use
org.activiti.engine.impl.pvm.process.ActivityImpl#setProperty() .
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: AbstractBpmnParseHandler.java From flowable-engine with Apache License 2.0 | 6 votes |
public ActivityImpl createActivityOnScope(BpmnParse bpmnParse, FlowElement flowElement, String xmlLocalName, ScopeImpl scopeElement) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Parsing activity {}", flowElement.getId()); } ActivityImpl activity = scopeElement.createActivity(flowElement.getId()); bpmnParse.setCurrentActivity(activity); activity.setProperty("name", flowElement.getName()); activity.setProperty("documentation", flowElement.getDocumentation()); if (flowElement instanceof Activity) { Activity modelActivity = (Activity) flowElement; activity.setProperty("default", modelActivity.getDefaultFlow()); if (modelActivity.isForCompensation()) { activity.setProperty(PROPERTYNAME_IS_FOR_COMPENSATION, true); } } else if (flowElement instanceof Gateway) { activity.setProperty("default", ((Gateway) flowElement).getDefaultFlow()); } activity.setProperty("type", xmlLocalName); return activity; }
Example 2
Source File: AbstractBpmnParseHandler.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void createAssociation(BpmnParse bpmnParse, Association association, ScopeImpl parentScope) { BpmnModel bpmnModel = bpmnParse.getBpmnModel(); if (bpmnModel.getArtifact(association.getSourceRef()) != null || bpmnModel.getArtifact(association.getTargetRef()) != null) { // connected to a text annotation so skipping it return; } ActivityImpl sourceActivity = parentScope.findActivity(association.getSourceRef()); ActivityImpl targetActivity = parentScope.findActivity(association.getTargetRef()); // an association may reference elements that are not parsed as activities (like for instance // text annotations so do not throw an exception if sourceActivity or targetActivity are null) // However, we make sure they reference 'something': if (sourceActivity == null) { // bpmnModel.addProblem("Invalid reference sourceRef '" + association.getSourceRef() + "' of association element ", association.getId()); } else if (targetActivity == null) { // bpmnModel.addProblem("Invalid reference targetRef '" + association.getTargetRef() + "' of association element ", association.getId()); } else { if (sourceActivity.getProperty("type").equals("compensationBoundaryCatch")) { Object isForCompensation = targetActivity.getProperty(PROPERTYNAME_IS_FOR_COMPENSATION); if (isForCompensation == null || !(Boolean) isForCompensation) { LOGGER.warn("compensation boundary catch must be connected to element with isForCompensation=true"); } else { ActivityImpl compensatedActivity = sourceActivity.getParentActivity(); compensatedActivity.setProperty(BpmnParse.PROPERTYNAME_COMPENSATION_HANDLER_ID, targetActivity.getId()); } } } }
Example 3
Source File: SubProcessParseHandler.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override protected void executeParse(BpmnParse bpmnParse, SubProcess subProcess) { ActivityImpl activity = createActivityOnScope(bpmnParse, subProcess, BpmnXMLConstants.ELEMENT_SUBPROCESS, bpmnParse.getCurrentScope()); activity.setAsync(subProcess.isAsynchronous()); activity.setExclusive(!subProcess.isNotExclusive()); boolean triggeredByEvent = false; if (subProcess instanceof EventSubProcess) { triggeredByEvent = true; } activity.setProperty("triggeredByEvent", triggeredByEvent); // event subprocesses are not scopes activity.setScope(!triggeredByEvent); activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createSubprocActivityBehavior(subProcess)); bpmnParse.setCurrentScope(activity); bpmnParse.setCurrentSubProcess(subProcess); bpmnParse.processFlowElements(subProcess.getFlowElements()); processArtifacts(bpmnParse, subProcess.getArtifacts(), activity); // no data objects for event subprocesses if (!(subProcess instanceof EventSubProcess)) { // parse out any data objects from the template in order to set up the necessary process variables Map<String, Object> variables = processDataObjects(bpmnParse, subProcess.getDataObjects(), activity); activity.setVariables(variables); } bpmnParse.removeCurrentScope(); bpmnParse.removeCurrentSubProcess(); }
Example 4
Source File: CancelEventDefinitionParseHandler.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override protected void executeParse(BpmnParse bpmnParse, CancelEventDefinition cancelEventDefinition) { if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { ActivityImpl activity = bpmnParse.getCurrentActivity(); activity.setProperty("type", "cancelBoundaryCatch"); activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCancelBoundaryEventActivityBehavior(cancelEventDefinition)); } }
Example 5
Source File: UserTaskParseHandler.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override protected void executeParse(BpmnParse bpmnParse, UserTask userTask) { ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, userTask, BpmnXMLConstants.ELEMENT_TASK_USER); activity.setAsync(userTask.isAsynchronous()); activity.setExclusive(!userTask.isNotExclusive()); TaskDefinition taskDefinition = parseTaskDefinition(bpmnParse, userTask, userTask.getId(), (ProcessDefinitionEntity) bpmnParse.getCurrentScope().getProcessDefinition()); activity.setProperty(PROPERTY_TASK_DEFINITION, taskDefinition); activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createUserTaskActivityBehavior(userTask, taskDefinition)); }
Example 6
Source File: MultiInstanceActivityCreator.java From openwebflow with BSD 2-Clause "Simplified" License | 5 votes |
private ActivityImpl createMultiInstanceActivity(ProcessEngine processEngine, ProcessDefinitionEntity processDefinition, String processInstanceId, String prototypeActivityId, String cloneActivityId, boolean isSequential, List<String> assignees) { ActivityImpl prototypeActivity = ProcessDefinitionUtils.getActivity(processEngine, processDefinition.getId(), prototypeActivityId); //拷贝listener,executionListeners会激活历史记录的保存 ActivityImpl clone = cloneActivity(processDefinition, prototypeActivity, cloneActivityId, "executionListeners", "properties"); //拷贝所有后向链接 for (PvmTransition trans : prototypeActivity.getOutgoingTransitions()) { clone.createOutgoingTransition(trans.getId()).setDestination((ActivityImpl) trans.getDestination()); } MultiInstanceActivityBehavior multiInstanceBehavior = isSequential ? new SequentialMultiInstanceBehavior(clone, (TaskActivityBehavior) prototypeActivity.getActivityBehavior()) : new ParallelMultiInstanceBehavior( clone, (TaskActivityBehavior) prototypeActivity.getActivityBehavior()); clone.setActivityBehavior(multiInstanceBehavior); clone.setScope(true); clone.setProperty("multiInstance", isSequential ? "sequential" : "parallel"); //设置多实例节点属性 multiInstanceBehavior.setLoopCardinalityExpression(new FixedValue(assignees.size())); multiInstanceBehavior.setCollectionExpression(new FixedValue(assignees)); return clone; }
Example 7
Source File: AbstractActivityBpmnParseHandler.java From flowable-engine with Apache License 2.0 | 4 votes |
protected void createMultiInstanceLoopCharacteristics(BpmnParse bpmnParse, Activity modelActivity) { MultiInstanceLoopCharacteristics loopCharacteristics = modelActivity.getLoopCharacteristics(); // Activity Behavior MultiInstanceActivityBehavior miActivityBehavior = null; ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(modelActivity.getId()); if (activity == null) { throw new ActivitiException("Activity " + modelActivity.getId() + " needed for multi instance cannot bv found"); } if (loopCharacteristics.isSequential()) { miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createSequentialMultiInstanceBehavior( activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior()); } else { miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createParallelMultiInstanceBehavior( activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior()); } // ActivityImpl settings activity.setScope(true); activity.setProperty("multiInstance", loopCharacteristics.isSequential() ? "sequential" : "parallel"); activity.setActivityBehavior(miActivityBehavior); ExpressionManager expressionManager = bpmnParse.getExpressionManager(); // loop cardinality if (StringUtils.isNotEmpty(loopCharacteristics.getLoopCardinality())) { miActivityBehavior.setLoopCardinalityExpression(expressionManager.createExpression(loopCharacteristics.getLoopCardinality())); } // completion condition if (StringUtils.isNotEmpty(loopCharacteristics.getCompletionCondition())) { miActivityBehavior.setCompletionConditionExpression(expressionManager.createExpression(loopCharacteristics.getCompletionCondition())); } // activiti:collection if (StringUtils.isNotEmpty(loopCharacteristics.getInputDataItem())) { if (loopCharacteristics.getInputDataItem().contains("{")) { miActivityBehavior.setCollectionExpression(expressionManager.createExpression(loopCharacteristics.getInputDataItem())); } else { miActivityBehavior.setCollectionVariable(loopCharacteristics.getInputDataItem()); } } // activiti:elementVariable if (StringUtils.isNotEmpty(loopCharacteristics.getElementVariable())) { miActivityBehavior.setCollectionElementVariable(loopCharacteristics.getElementVariable()); } // activiti:elementIndexVariable if (StringUtils.isNotEmpty(loopCharacteristics.getElementIndexVariable())) { miActivityBehavior.setCollectionElementIndexVariable(loopCharacteristics.getElementIndexVariable()); } }
Example 8
Source File: EndEventParseHandler.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override protected void executeParse(BpmnParse bpmnParse, EndEvent endEvent) { ActivityImpl endEventActivity = createActivityOnCurrentScope(bpmnParse, endEvent, BpmnXMLConstants.ELEMENT_EVENT_END); EventDefinition eventDefinition = null; if (!endEvent.getEventDefinitions().isEmpty()) { eventDefinition = endEvent.getEventDefinitions().get(0); } // Error end event if (eventDefinition instanceof org.flowable.bpmn.model.ErrorEventDefinition) { org.flowable.bpmn.model.ErrorEventDefinition errorDefinition = (org.flowable.bpmn.model.ErrorEventDefinition) eventDefinition; if (bpmnParse.getBpmnModel().containsErrorRef(errorDefinition.getErrorCode())) { String errorCode = bpmnParse.getBpmnModel().getErrors().get(errorDefinition.getErrorCode()); if (StringUtils.isEmpty(errorCode)) { LOGGER.warn("errorCode is required for an error event {}", endEvent.getId()); } endEventActivity.setProperty("type", "errorEndEvent"); errorDefinition.setErrorCode(errorCode); } endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createErrorEndEventActivityBehavior(endEvent, errorDefinition)); // Cancel end event } else if (eventDefinition instanceof CancelEventDefinition) { ScopeImpl scope = bpmnParse.getCurrentScope(); if (scope.getProperty("type") == null || !scope.getProperty("type").equals("transaction")) { LOGGER.warn("end event with cancelEventDefinition only supported inside transaction subprocess (id={})", endEvent.getId()); } else { endEventActivity.setProperty("type", "cancelEndEvent"); endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCancelEndEventActivityBehavior(endEvent)); } // Terminate end event } else if (eventDefinition instanceof TerminateEventDefinition) { endEventActivity.setAsync(endEvent.isAsynchronous()); endEventActivity.setExclusive(!endEvent.isNotExclusive()); endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createTerminateEndEventActivityBehavior(endEvent)); // None end event } else if (eventDefinition == null) { endEventActivity.setAsync(endEvent.isAsynchronous()); endEventActivity.setExclusive(!endEvent.isNotExclusive()); endEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createNoneEndEventActivityBehavior(endEvent)); } }
Example 9
Source File: ErrorEventDefinitionParseHandler.java From flowable-engine with Apache License 2.0 | 3 votes |
public void createBoundaryErrorEventDefinition(ErrorEventDefinition errorEventDefinition, boolean interrupting, ActivityImpl activity, ActivityImpl nestedErrorEventActivity) { nestedErrorEventActivity.setProperty("type", "boundaryError"); ScopeImpl catchingScope = nestedErrorEventActivity.getParent(); ((ActivityImpl) catchingScope).setScope(true); org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition definition = new org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition(nestedErrorEventActivity.getId()); definition.setErrorCode(errorEventDefinition.getErrorCode()); addErrorEventDefinition(definition, catchingScope); }
Example 10
Source File: CompensateEventDefinitionParseHandler.java From flowable-engine with Apache License 2.0 | 3 votes |
@Override protected void executeParse(BpmnParse bpmnParse, CompensateEventDefinition eventDefinition) { ScopeImpl scope = bpmnParse.getCurrentScope(); if (StringUtils.isNotEmpty(eventDefinition.getActivityRef())) { if (scope.findActivity(eventDefinition.getActivityRef()) == null) { LOGGER.warn("Invalid attribute value for 'activityRef': no activity with id '{}' in current scope {}", eventDefinition.getActivityRef(), scope.getId()); } } org.activiti.engine.impl.bpmn.parser.CompensateEventDefinition compensateEventDefinition = new org.activiti.engine.impl.bpmn.parser.CompensateEventDefinition(); compensateEventDefinition.setActivityRef(eventDefinition.getActivityRef()); compensateEventDefinition.setWaitForCompletion(eventDefinition.isWaitForCompletion()); ActivityImpl activity = bpmnParse.getCurrentActivity(); if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent) { activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowCompensationEventActivityBehavior((ThrowEvent) bpmnParse.getCurrentFlowElement(), compensateEventDefinition)); } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) { BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement(); boolean interrupting = boundaryEvent.isCancelActivity(); activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity)); activity.setProperty("type", "compensationBoundaryCatch"); } else { // What to do? } }