setPropertyValue(PROPERTY_FORMURI_VIEW, userTask.getFormUriView(), propertiesNode);
}
@Override
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
UserTask task = Bpmn2Factory.eINSTANCE.createUserTask();// UserTask();
//任务主题
JsonNode processSubject = JsonConverterUtil.getProperty(PROPERTY_USERTASK_SUBJECT, elementNode);
if(processSubject != null && StringUtils.isNotEmpty(processSubject.asText())) {
TaskSubject taskSubject = FixFlowFactory.eINSTANCE.createTaskSubject();
Expression subjectExpression = FixFlowFactory.eINSTANCE.createExpression();
subjectExpression.setName(processSubject.asText());
subjectExpression.setValue(processSubject.asText());
taskSubject.setExpression(subjectExpression);
taskSubject.setId("TaskSubject_1");
BpmnModelUtil.addExtensionElement(task, FixFlowPackage.Literals.DOCUMENT_ROOT__TASK_SUBJECT, taskSubject);
}
//任务类型
JsonNode taskTypeNode = getProperty(PROPERTY_USERTASK_TASKTYPE, elementNode);
if(taskTypeNode != null){
BpmnModelUtil.addExtensionAttribute(task, FixFlowPackage.Literals.DOCUMENT_ROOT__TASK_TYPE, taskTypeNode.asText());
}
//任务优先级
JsonNode taskPriorityNode = getProperty(PROPERTY_PRIORITY, elementNode);
if(taskPriorityNode != null){
TaskPriority taskPriority = FixFlowFactory.eINSTANCE.createTaskPriority();
Expression taskPriorityExpression = FixFlowFactory.eINSTANCE.createExpression();
taskPriorityExpression.setName(taskPriorityNode.asText());
taskPriorityExpression.setValue(taskPriorityNode.asText());
taskPriority.setExpression(taskPriorityExpression);
BpmnModelUtil.addExtensionElement(task, FixFlowPackage.Literals.DOCUMENT_ROOT__TASK_PRIORITY, taskPriority);
}
//任务命令
JsonNode taskCommandNode = getProperty(PROPERTY_TASKCOMMAND, elementNode);
if(taskCommandNode != null){
JsonNode itemsNode = taskCommandNode.get(EDITOR_PROPERTIES_GENERAL_ITEMS);
if(itemsNode !=null){
Iterator<JsonNode> taskcommandIterator = itemsNode.getElements();
while(taskcommandIterator.hasNext()) {
JsonNode taskCommandItemNode = taskcommandIterator.next();
TaskCommand taskCommand = FixFlowFactory.eINSTANCE.createTaskCommand();
String commandName = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_NAME).asText();
String commandId = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_ID).asText();
String commandType = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_TYPE).asText();
String isSaveData = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_IS_SAVEDATA).asText();
String isSimulation = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_IS_SIMULATION_RUN).asText();
String isVerify = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_IS_VERIFICATION).asText();
String paraExpression = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_PARA_EXPRESSION).asText();
String expression = taskCommandItemNode.get(PROPERTY_TASKCOMMAND_EXPRESSION).asText();
taskCommand.setCommandType(commandType);
taskCommand.setId(commandId);
taskCommand.setName(commandName);
taskCommand.setIsSimulationRun(isSimulation);
taskCommand.setIsSaveData(isSaveData);
taskCommand.setIsVerification(isVerify);
//执行表达式
Expression expression2 = FixFlowFactory.eINSTANCE.createExpression();
expression2.setName(expression);
expression2.setValue(expression);
taskCommand.setExpression(expression2);
//参数表达式
Expression expression3 = FixFlowFactory.eINSTANCE.createExpression();
expression3.setName(paraExpression);
expression3.setValue(paraExpression);
taskCommand.setParameterExpression(expression3);
BpmnModelUtil.addExtensionElement(task, FixFlowPackage.Literals.DOCUMENT_ROOT__TASK_COMMAND, taskCommand);
}
}
}
//默认表单
JsonNode usertaskFormUri = JsonConverterUtil.getProperty(PROPERTY_FORMURI, elementNode);
if(usertaskFormUri != null && StringUtil.isNotEmpty(usertaskFormUri.asText())){
FormUri formUri = FixFlowFactory.eINSTANCE.createFormUri();
Expression expression = FixFlowFactory.eINSTANCE.createExpression();
expression.setName(usertaskFormUri.asText());
expression.setValue(usertaskFormUri.asText());
formUri.setExpression(expression);
BpmnModelUtil.addExtensionElement(task, FixFlowPackage.Literals.DOCUMENT_ROOT__FORM_URI, formUri);
}
//浏览表单
JsonNode usertaskFormUriView = JsonConverterUtil.getProperty(PROPERTY_FORMURI_VIEW, elementNode);
if(usertaskFormUriView != null && StringUtil.isNotEmpty(usertaskFormUriView.asText())){
FormUriView formUri = FixFlowFactory.eINSTANCE.createFormUriView();
Expression expression = FixFlowFactory.eINSTANCE.createExpression();
expression.setName(usertaskFormUriView.asText());
expression.setValue(usertaskFormUriView.asText());
formUri.setExpression(expression);
BpmnModelUtil.addExtensionElement(task, FixFlowPackage.Literals.DOCUMENT_ROOT__FORM_URI_VIEW, formUri);
}
//分配策略
JsonNode policyTypeNode = getProperty(PROPERTY_USERTASK_POLICYTYPE, elementNode);
if(policyTypeNode != null){
AssignPolicyType assignPolicyType = FixFlowFactory.eINSTANCE.createAssignPolicyType();
assignPolicyType.setId(policyTypeNode.asText());
String expressionBody = getPropertyValueAsString(PROPERTY_USERTASK_ASSIGNEXPRESSION, elementNode);
if(StringUtil.isNotEmpty(expressionBody)){
Expression policyExpression = FixFlowFactory.eINSTANCE.createExpression();
policyExpression.setValue(expressionBody);
policyExpression.setName(expressionBody);
assignPolicyType.setExpression(policyExpression);
}
BpmnModelUtil.addExtensionElement(task, FixFlowPackage.Literals.DOCUMENT_ROOT__ASSIGN_POLICY_TYPE, assignPolicyType);
}
//转换处理人
JsonNode assignmentNode = getProperty(PROPERTY_USERTASK_ASSIGNMENT, elementNode);
if(assignmentNode != null) {
JsonNode itemsNode = assignmentNode.get(EDITOR_PROPERTIES_GENERAL_ITEMS);
if(itemsNode != null) {
Iterator<JsonNode> assignmentIterator = itemsNode.getElements();
while (assignmentIterator.hasNext()) {
JsonNode assignmentItemNode = assignmentIterator.next();
PotentialOwner potentialOwner = Bpmn2Factory.eINSTANCE.createPotentialOwner();
String resourceType = assignmentItemNode.get(PROPERTY_USERTASK_RESOURCE_TYPE).asText();
String includeExclusion = "INCLUDE";
String isContainSub = assignmentItemNode.get(PROPERTY_USERTASK_RESOURCE_IS_CONTAINSSUB).asText();
String resourceName = assignmentItemNode.get(PROPERTY_USERTASK_RESOURCE_NAME).asText();
String expressionBody = assignmentItemNode.get(PROPERTY_USERTASK_RESOURCE_EXPRESSION).asText();
BpmnModelUtil.addExtensionAttribute(potentialOwner, FixFlowPackage.Literals.DOCUMENT_ROOT__RESOURCE_TYPE, resourceType);
BpmnModelUtil.addExtensionAttribute(potentialOwner, FixFlowPackage.Literals.DOCUMENT_ROOT__INCLUDE_EXCLUSION, includeExclusion);
BpmnModelUtil.addExtensionAttribute(potentialOwner, FixFlowPackage.Literals.DOCUMENT_ROOT__IS_CONTAINS_SUB, isContainSub);
ResourceAssignmentExpression resourceAssignmentExpression = Bpmn2Factory.eINSTANCE.createResourceAssignmentExpression();
potentialOwner.setName(resourceName);
FormalExpression formalExpression = Bpmn2Factory.eINSTANCE.createFormalExpression();
formalExpression.setBody(expressionBody);
formalExpression.setId(expressionBody);
resourceAssignmentExpression.setExpression(formalExpression);
potentialOwner.setResourceAssignmentExpression(resourceAssignmentExpression);
task.getResources().add(potentialOwner);
}
}
}
return task;
}