use of org.activiti.engine.impl.pvm.PvmTransition in project Activiti by Activiti.
the class While method execute.
public void execute(ActivityExecution execution) throws Exception {
PvmTransition more = execution.getActivity().findOutgoingTransition("more");
PvmTransition done = execution.getActivity().findOutgoingTransition("done");
Integer value = (Integer) execution.getVariable(variableName);
if (value == null) {
execution.setVariable(variableName, from);
execution.take(more);
} else {
value = value + 1;
if (value < to) {
execution.setVariable(variableName, value);
execution.take(more);
} else {
execution.take(done);
}
}
}
use of org.activiti.engine.impl.pvm.PvmTransition in project Activiti by Activiti.
the class EventScopeCreatingSubprocess method lastExecutionEnded.
/*
* Incoming execution is transformed into an event scope,
* new, non-concurrent execution leaves activity
*/
@SuppressWarnings("unchecked")
public void lastExecutionEnded(ActivityExecution execution) {
ActivityExecution outgoingExecution = execution.getParent().createExecution();
outgoingExecution.setConcurrent(false);
((InterpretableExecution) outgoingExecution).setActivity((ActivityImpl) execution.getActivity());
// eventscope execution
execution.setConcurrent(false);
execution.setActive(false);
((InterpretableExecution) execution).setEventScope(true);
List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
if (outgoingTransitions.isEmpty()) {
outgoingExecution.end();
} else {
outgoingExecution.takeAll(outgoingTransitions, Collections.EMPTY_LIST);
}
}
use of org.activiti.engine.impl.pvm.PvmTransition in project Activiti by Activiti.
the class Noop method execute.
public void execute(ActivityExecution execution) throws Exception {
PvmTransition transition = execution.getActivity().getOutgoingTransitions().get(0);
execution.take(transition);
}
use of org.activiti.engine.impl.pvm.PvmTransition in project my_curd by qinyou.
the class DiagramUtils method getActivity.
private static void getActivity(ActivityImpl activity, JSONArray activityArray, JSONArray sequenceFlowArray, Map<String, JSONObject> subProcessInstanceMap) {
JSONObject activityJSON = new JSONObject();
String multiInstance = (String) activity.getProperty("multiInstance");
if (multiInstance != null && !"sequential".equals(multiInstance)) {
multiInstance = "parallel";
}
ActivityBehavior activityBehavior = activity.getActivityBehavior();
boolean collapsed = activityBehavior instanceof CallActivityBehavior;
Boolean expanded = (Boolean) activity.getProperty("isExpanded");
if (expanded != null) {
collapsed = !expanded;
}
Boolean isInterrupting = null;
if (activityBehavior instanceof BoundaryEventActivityBehavior) {
isInterrupting = ((BoundaryEventActivityBehavior) activityBehavior).isInterrupting();
}
JSONArray errorEventDefinitionsArray;
for (PvmTransition sequenceFlow : activity.getOutgoingTransitions()) {
String flowName = (String) sequenceFlow.getProperty("name");
boolean isConditional = sequenceFlow.getProperty("condition") != null && !((String) activity.getProperty("type")).toLowerCase().contains("gateway");
boolean isDefault = sequenceFlow.getId().equals(activity.getProperty("default")) && ((String) activity.getProperty("type")).toLowerCase().contains("gateway");
List<Integer> waypoints = ((TransitionImpl) sequenceFlow).getWaypoints();
errorEventDefinitionsArray = new JSONArray();
JSONArray yPointArray = new JSONArray();
for (int i = 0; i < waypoints.size(); i += 2) {
errorEventDefinitionsArray.add((Integer) waypoints.get(i));
yPointArray.add(waypoints.get(i + 1));
}
JSONObject flowJSON = new JSONObject();
flowJSON.put("id", sequenceFlow.getId());
flowJSON.put("name", flowName);
flowJSON.put("flow", "(" + sequenceFlow.getSource().getId() + ")--" + sequenceFlow.getId() + "-->(" + sequenceFlow.getDestination().getId() + ")");
if (isConditional) {
flowJSON.put("isConditional", isConditional);
}
if (isDefault) {
flowJSON.put("isDefault", isDefault);
}
flowJSON.put("xPointArray", errorEventDefinitionsArray);
flowJSON.put("yPointArray", yPointArray);
String conditionText = (String) sequenceFlow.getProperty("conditionText");
if (conditionText != null) {
flowJSON.put("conditionText", conditionText);
}
sequenceFlowArray.add(flowJSON);
}
JSONArray nestedActivityArray = new JSONArray();
for (ActivityImpl nestedActivity : activity.getActivities()) {
nestedActivityArray.add(nestedActivity.getId());
}
Map<String, Object> properties = activity.getProperties();
JSONObject propertiesJSON = new JSONObject();
while (true) {
for (String key : activity.getProperties().keySet()) {
Object prop = properties.get(key);
if (prop instanceof String) {
propertiesJSON.put(key, prop);
} else if (prop instanceof Integer) {
propertiesJSON.put(key, prop);
} else if (prop instanceof Boolean) {
propertiesJSON.put(key, prop);
} else if ("initial".equals(key)) {
ActivityImpl act = (ActivityImpl) prop;
propertiesJSON.put(key, act.getId());
} else {
JSONObject errorEventDefinitionJSON;
if ("timerDeclarations".equals(key)) {
List<TimerDeclarationImpl> errorEventDefinitions = (List<TimerDeclarationImpl>) properties.get(key);
errorEventDefinitionsArray = new JSONArray();
if (errorEventDefinitions != null) {
for (TimerDeclarationImpl timerDeclaration : errorEventDefinitions) {
errorEventDefinitionJSON = new JSONObject();
errorEventDefinitionJSON.put("isExclusive", timerDeclaration.isExclusive());
if (timerDeclaration.getRepeat() != null) {
errorEventDefinitionJSON.put("repeat", timerDeclaration.getRepeat());
}
errorEventDefinitionJSON.fluentPut("retries", String.valueOf(timerDeclaration.getRetries())).fluentPut("type", timerDeclaration.getJobHandlerType()).fluentPut("configuration", timerDeclaration.getJobHandlerConfiguration());
errorEventDefinitionsArray.add(errorEventDefinitionJSON);
}
}
if (errorEventDefinitionsArray.size() > 0) {
propertiesJSON.put(key, errorEventDefinitionsArray);
}
} else if ("eventDefinitions".equals(key)) {
List<EventSubscriptionDeclaration> errorEventDefinitions = (List<EventSubscriptionDeclaration>) properties.get(key);
errorEventDefinitionsArray = new JSONArray();
if (errorEventDefinitions != null) {
for (EventSubscriptionDeclaration eventDefinition : errorEventDefinitions) {
errorEventDefinitionJSON = new JSONObject();
if (eventDefinition.getActivityId() != null) {
errorEventDefinitionJSON.put("activityId", eventDefinition.getActivityId());
}
errorEventDefinitionJSON.put("eventName", eventDefinition.getEventName());
errorEventDefinitionJSON.put("eventType", eventDefinition.getEventType());
errorEventDefinitionJSON.put("isAsync", eventDefinition.isAsync());
errorEventDefinitionJSON.put("isStartEvent", eventDefinition.isStartEvent());
errorEventDefinitionsArray.add(errorEventDefinitionJSON);
}
}
if (errorEventDefinitionsArray.size() > 0) {
propertiesJSON.put(key, errorEventDefinitionsArray);
}
} else if ("errorEventDefinitions".equals(key)) {
List<ErrorEventDefinition> errorEventDefinitions = (List<ErrorEventDefinition>) properties.get(key);
errorEventDefinitionsArray = new JSONArray();
if (errorEventDefinitions != null) {
for (ErrorEventDefinition errorEventDefinition : errorEventDefinitions) {
errorEventDefinitionJSON = new JSONObject();
// 此处 原 判断为null使用 objectNode.putNull("errorCode"), putNull
errorEventDefinitionJSON.put("errorCode", errorEventDefinition.getErrorCode());
errorEventDefinitionJSON.put("handlerActivityId", errorEventDefinition.getHandlerActivityId());
errorEventDefinitionsArray.add(errorEventDefinitionJSON);
}
}
if (errorEventDefinitionsArray.size() > 0) {
propertiesJSON.put(key, errorEventDefinitionsArray);
}
}
}
}
if ("callActivity".equals(properties.get("type"))) {
CallActivityBehavior callActivityBehavior = null;
if (activityBehavior instanceof CallActivityBehavior) {
callActivityBehavior = (CallActivityBehavior) activityBehavior;
}
if (callActivityBehavior != null) {
propertiesJSON.put("processDefinitonKey", callActivityBehavior.getProcessDefinitonKey());
JSONArray processInstanceArray = new JSONArray();
if (StringUtils.isNotEmpty(callActivityBehavior.getProcessDefinitonKey())) {
ProcessDefinition lastProcessDefinition = (ProcessDefinition) ActivitiUtils.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey(callActivityBehavior.getProcessDefinitonKey()).latestVersion().singleResult();
if (lastProcessDefinition != null) {
JSONObject processInstanceJSON = new JSONObject().fluentPut("processDefinitionId", lastProcessDefinition.getId()).fluentPut("processDefinitionKey", lastProcessDefinition.getKey()).fluentPut("processDefinitionName", lastProcessDefinition.getName());
processInstanceArray.add(processInstanceJSON);
}
}
if (processInstanceArray.size() > 0) {
propertiesJSON.put("processDefinitons", processInstanceArray);
}
}
}
if ("userTask".equals(properties.get("type"))) {
// 放入用户任务 办理人、候选组、候选人信息
TaskDefinition definition = (TaskDefinition) activity.getProperty("taskDefinition");
if (definition.getAssigneeExpression() != null) {
// log.info("assignee Value: {}",definition.getAssigneeExpression().getValue());
propertiesJSON.put("assignee", definition.getAssigneeExpression().getExpressionText());
}
if (definition.getCandidateGroupIdExpressions().size() > 0) {
Set<String> texts = new HashSet<>();
definition.getCandidateGroupIdExpressions().forEach(expression -> {
texts.add(expression.getExpressionText());
});
propertiesJSON.put("candidateGroups", texts);
}
if (definition.getCandidateUserIdExpressions().size() > 0) {
Set<String> texts = new HashSet<>();
definition.getCandidateUserIdExpressions().forEach(expression -> {
texts.add(expression.getExpressionText());
});
propertiesJSON.put("candidateUsers", texts);
}
}
activityJSON.put("activityId", activity.getId());
activityJSON.put("properties", propertiesJSON);
if (multiInstance != null) {
activityJSON.put("multiInstance", multiInstance);
}
if (collapsed) {
activityJSON.put("collapsed", collapsed);
}
if (nestedActivityArray.size() > 0) {
activityJSON.put("nestedActivities", nestedActivityArray);
}
if (isInterrupting != null) {
activityJSON.put("isInterrupting", isInterrupting);
}
activityJSON.fluentPut("x", activity.getX()).fluentPut("y", activity.getY()).fluentPut("width", activity.getWidth()).fluentPut("height", activity.getHeight());
activityArray.add(activityJSON);
for (ActivityImpl nestedActivity : activity.getActivities()) {
getActivity(nestedActivity, activityArray, sequenceFlowArray, subProcessInstanceMap);
}
return;
}
}
Aggregations