From 0246959aeb2bd4cb04e00649a0378a846116fbf9 Mon Sep 17 00:00:00 2001 From: YuanHu Date: Thu, 15 Mar 2018 16:17:00 +0800 Subject: [PATCH] Generate bpmn for extend activities Modify BPMN Convertor to support conversion of extend activities. Change copyright year from 2017 to 2017-2018 Issue-ID: SDC-679 Change-Id: I835fee3901302d53a948e50d2c2a03736f524e4b Signed-off-by: YuanHu --- .../onap/sdc/workflowdesigner/model/Element.java | 13 ++- .../workflowdesigner/model/RestServiceTask.java | 26 +++--- .../sdc/workflowdesigner/model/ScriptTask.java | 2 +- .../sdc/workflowdesigner/model/ServiceTask.java | 28 ++++++ .../sdc/workflowdesigner/model/StartEvent.java | 7 +- .../parser/Bpmn4ToscaJsonParser.java | 43 +++------ .../onap/sdc/workflowdesigner/parser/JsonKeys.java | 102 ++++++++++++++++----- .../resources/WorkflowModelerResource.java | 37 ++++++-- .../bpmn-templates/bpmn_dataObject_template.xml | 10 +- .../bpmn_element_endEvent_template.xml | 5 +- .../bpmn_element_errorEndEvent_template.xml | 7 +- .../bpmn_element_errorStartEvent_template.xml | 7 +- .../bpmn_element_exclusiveGateway_template.xml | 3 +- ...pmn_element_intermediateCatchEvent_template.xml | 27 +++--- .../bpmn_element_parallelGateway_template.xml | 1 - .../bpmn_element_restTask_template.xml | 66 ++++++------- .../bpmn_element_scriptTask_template.xml | 6 +- .../bpmn_element_serviceTask_template.xml | 38 +++----- .../bpmn_element_startEvent_template.xml | 16 ++-- .../bpmn-templates/bpmn_sequenceFlow_template.xml | 6 +- .../resources/bpmn-templates/bpmn_template.xml | 47 +++++----- .../parser/Bpmn4ToscaJsonParserTest.java | 35 +++---- .../resources/workflow/template-test.bpmn20.xml | 23 +++-- .../src/test/resources/workflow/workflow.json | 42 ++++++--- 24 files changed, 342 insertions(+), 255 deletions(-) diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/Element.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/Element.java index 6420a160..762d480b 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/Element.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/Element.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 ZTE Corporation. + * Copyright (c) 2017-2018 ZTE Corporation. * All rights reserved. This program and the accompanying materials * are made available under the Apache License, Version 2.0 * and the Eclipse Public License v1.0 which both accompany this distribution, @@ -15,7 +15,16 @@ import java.util.List; public class Element { public enum TYPE { - startEvent, endEvent, errorStartEvent, errorEndEvent, serviceTask, scriptTask, exclusiveGateway, parallelGateway, restTask, intermediateCatchEvent + startEvent, + endEvent, + errorStartEvent, + errorEndEvent, + serviceTask, + scriptTask, + exclusiveGateway, + parallelGateway, + restTask, + intermediateCatchEvent }; private String id; diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/RestServiceTask.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/RestServiceTask.java index 173c4da5..8a8da55a 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/RestServiceTask.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/RestServiceTask.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 ZTE Corporation. + * Copyright (c) 2017-2018 ZTE Corporation. * All rights reserved. This program and the accompanying materials * are made available under the Apache License, Version 2.0 * and the Eclipse Public License v1.0 which both accompany this distribution, @@ -18,29 +18,29 @@ import org.onap.sdc.workflowdesigner.config.Config; public class RestServiceTask extends ServiceTask { private static String handler = Config.PROPERTIES.getProperty(Config.HANDLER_ClASS); - private String restConfigId; - public String getRestConfigId() { - return restConfigId; - } - public void setRestConfigId(String restConfigId) { - this.restConfigId = restConfigId; - } +// private String restConfigId; +// public String getRestConfigId() { +// return restConfigId; +// } +// public void setRestConfigId(String restConfigId) { +// this.restConfigId = restConfigId; +// } private List produces; private List consumes; private List parameters; - private String url; + private String baseUrl; private String serviceName; private String serviceVersion; private String path; private String method; - public String getUrl() { - return url; + public String getBaseUrl() { + return baseUrl; } - public void setUrl(String url) { - this.url = url; + public void setBaseUrl(String url) { + this.baseUrl = url; } public String getMethod() { diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/ScriptTask.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/ScriptTask.java index 01d224c8..3ccba04e 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/ScriptTask.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/ScriptTask.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 ZTE Corporation. + * Copyright (c) 2017-2018 ZTE Corporation. * All rights reserved. This program and the accompanying materials * are made available under the Apache License, Version 2.0 * and the Eclipse Public License v1.0 which both accompany this distribution, diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/ServiceTask.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/ServiceTask.java index 407ca059..90bc5d0e 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/ServiceTask.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/ServiceTask.java @@ -11,6 +11,34 @@ */ package org.onap.sdc.workflowdesigner.model; +import java.util.List; + public class ServiceTask extends Element { + private String className; + private List inputs; + private List outputs; + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public List getInputs() { + return inputs; + } + + public void setInputs(List inputs) { + this.inputs = inputs; + } + + public List getOutputs() { + return outputs; + } + public void setOutputs(List outputs) { + this.outputs = outputs; + } } diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/StartEvent.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/StartEvent.java index a78c8dd3..b24b0e22 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/StartEvent.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/StartEvent.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 ZTE Corporation. + * Copyright (c) 2017-2018 ZTE Corporation. * All rights reserved. This program and the accompanying materials * are made available under the Apache License, Version 2.0 * and the Eclipse Public License v1.0 which both accompany this distribution, @@ -13,8 +13,11 @@ package org.onap.sdc.workflowdesigner.model; import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + public class StartEvent extends Element { - private List parameters; + @JsonProperty("parameters") + private List parameters; public List getParameters() { return parameters; diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java index d214b389..e98acfb7 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 ZTE Corporation. + * Copyright (c) 2017-2018 ZTE Corporation. * All rights reserved. This program and the accompanying materials * are made available under the Apache License, Version 2.0 * and the Eclipse Public License v1.0 which both accompany this distribution, @@ -65,7 +65,12 @@ public class Bpmn4ToscaJsonParser { JsonNode rootNode = MAPPER.readValue(jsonFileUrl.toURL(), JsonNode.class); log.debug("Creating Process models..."); - JsonNode nodes = rootNode.get(JsonKeys.NODES); +// JsonNode nodes = rootNode.get(JsonKeys.NODES); + JsonNode data = rootNode.get(JsonKeys.DATA); + if(null == data) { + return process; + } + JsonNode nodes = data.get(JsonKeys.NODES); if (nodes == null) { return process; } @@ -133,17 +138,17 @@ public class Bpmn4ToscaJsonParser { private List getSequenceFlows(JsonNode jsonNode) { List flowList = new ArrayList(); - JsonNode sequenceFlowNodes = jsonNode.get(JsonKeys.SEQUENCE_FLOWS); + String elementId = getValueFromJsonNode(jsonNode, JsonKeys.ID); + JsonNode connectionsNode = jsonNode.get(JsonKeys.CONNECTIONS); - Iterator iter = sequenceFlowNodes.iterator(); + Iterator iter = connectionsNode.iterator(); while (iter.hasNext()) { JsonNode connectionEntry = (JsonNode) iter.next(); - String sourceRef = getValueFromJsonNode(connectionEntry, JsonKeys.SOURCE_REF); String targetRef = getValueFromJsonNode(connectionEntry, JsonKeys.TARGET_REF); String condition = getValueFromJsonNode(connectionEntry, JsonKeys.CONDITION); SequenceFlow flow = new SequenceFlow(); - flow.setId(sourceRef + targetRef); - flow.setSourceRef(sourceRef); + flow.setId(elementId + targetRef); + flow.setSourceRef(elementId); flow.setTargetRef(targetRef); flow.setCondition(condition); flowList.add(flow); @@ -183,7 +188,8 @@ public class Bpmn4ToscaJsonParser { element = MAPPER.readValue(jsonObject, ServiceTask.class); break; case "restTask": - element = this.createRestServiceTask(jsonObject); + // element = this.createRestServiceTask(jsonObject); + element = MAPPER.readValue(jsonObject, RestServiceTask.class); break; case "scriptTask": element = MAPPER.readValue(jsonObject, ScriptTask.class); @@ -202,27 +208,6 @@ public class Bpmn4ToscaJsonParser { return element; } - private RestServiceTask createRestServiceTask(String jsonObject) throws JsonParseException, JsonMappingException, IOException { - RestServiceTask restServiceTask = MAPPER.readValue(jsonObject, RestServiceTask.class); - - // add baseUrl to relative url - String restConfigId = restServiceTask.getRestConfigId(); - JsonNode restConfig = this.restConfigMap.get(restConfigId); - - if(restConfig != null) { // while create a new rest task and didnot set method, the restconfig info may be null - restServiceTask.setUrl(getValueFromJsonNode(restConfig, JsonKeys.MICROSERVICE_URL)); - restServiceTask.setServiceName(getValueFromJsonNode(restConfig, JsonKeys.MICROSERVICE_NAME)); - restServiceTask.setServiceVersion(getValueFromJsonNode(restConfig, JsonKeys.MICROSERVICE_VERSION)); - } - - for(Parameter parameter : restServiceTask.getParameters()) { - if("body".equals(parameter.getPosition())) { - parameter.setValueSource(null); - } - } - - return restServiceTask; - } private String getValueFromJsonNode(JsonNode jsonNode, String key) { return jsonNode.get(key) == null ? null : jsonNode.get(key).asText(); diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java index 2237d8dd..92390395 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 ZTE Corporation. + * Copyright (c) 2017-2018 ZTE Corporation. * All rights reserved. This program and the accompanying materials * are made available under the Apache License, Version 2.0 * and the Eclipse Public License v1.0 which both accompany this distribution, @@ -12,27 +12,81 @@ package org.onap.sdc.workflowdesigner.parser; public interface JsonKeys { - // workflow keys - public static final String NODES = "nodes"; - public static final String CONFIGS = "configs"; - - // configs keys - public static final String REST_CONFIGS = "restConfigs"; - public static final String TYPE = "type"; - - // workflow node keys - public static final String SEQUENCE_FLOWS = "sequenceFlows"; - - // sequence flow keys - public static final String SOURCE_REF = "sourceRef"; - public static final String TARGET_REF = "targetRef"; - public static final String CONDITION = "condition"; - - - // microservice info - public static final String MICROSERVICE_URL = "url"; - public static final String MICROSERVICE_NAME = "name"; - public static final String MICROSERVICE_VERSION = "version"; - - public static final String ID = "id"; + + + /* + * Field names of BPMN4Tosca Model + */ + public static final String DATA = "data"; + public static final String NODES = "nodes"; + public static final String REST_CONFIGS = "restConfigs"; + public static final String CONFIGS = "configs"; + + + // microservice info + public static final String MICROSERVICE_URL = "url"; + public static final String MICROSERVICE_NAME = "name"; + public static final String MICROSERVICE_VERSION = "version"; + + public static final String NAME = "name"; + + public static final String ID = "id"; + + public static final String TYPE = "type"; + + public static final String INPUT = "input"; + + public static final String OUTPUT = "output"; + + public static final String VALUE = "value"; + + public static final String NODE_TEMPLATE = "node_template"; + + public static final String NODE_OPERATION = "node_operation"; + + public static final String NODE_INTERFACE_NAME = "interface"; + + public static final String CONNECTIONS = "connection"; + + public static final String SOURCE_REF = "sourceRef"; + + public static final String TARGET_REF = "targetRef"; + + public static final String CONDITIONS = "conditions"; + + public static final String CONDITION = "condition"; + + public static final String DEFAULT = "default"; + + + /* + * Exclusive-Gateway, Event, Management-Task Types + * + */ + public static final String NODE_TYPE_MGMT_TASK = "ToscaNodeManagementTask"; + + public static final String NODE_TYPE_START_EVENT = "StartEvent"; + + public static final String NODE_TYPE_END_EVENT = "EndEvent"; + + public static final String NODE_TYPE_GATEWAY_EXCLUSIVE = "ExclusiveGateway"; + + public static final String NODE_TYPE_GATEWAY_EXCLUSIVE_END = "ExclusiveGatewayEnd"; + + + /* + * Parameter Types + */ + public static final String PARAM_TYPE_VALUE_STRING = "string"; + + public static final String PARAM_TYPE_VALUE_TOPOLOGY = "topology"; + + public static final String PARAM_TYPE_VALUE_PLAN = "plan"; + + public static final String PARAM_TYPE_VALUE_CONCAT = "concat"; + + public static final String PARAM_TYPE_VALUE_IA = "implementation_artifact"; + + public static final String PARAM_TYPE_VALUE_DA = "deployment_artifact"; + } diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java index 2ad4aeae..db9b80d3 100644 --- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java +++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 ZTE Corporation. + * Copyright (c) 2017-2018 ZTE Corporation. * All rights reserved. This program and the accompanying materials * are made available under the Apache License, Version 2.0 * and the Eclipse Public License v1.0 which both accompany this distribution, @@ -13,6 +13,9 @@ package org.onap.sdc.workflowdesigner.resources; import java.io.IOException; +import java.net.URI; +import java.nio.file.Paths; +import java.util.UUID; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -24,8 +27,11 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.eclipse.jetty.http.HttpStatus; +import org.onap.sdc.workflowdesigner.model.Process; +import org.onap.sdc.workflowdesigner.parser.Bpmn4ToscaJsonParser; import org.onap.sdc.workflowdesigner.utils.FileCommonUtils; import org.onap.sdc.workflowdesigner.utils.RestUtils; +import org.onap.sdc.workflowdesigner.writer.BpmnPlanArtefactWriter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,9 +51,12 @@ import io.swagger.annotations.ApiResponses; @Api(tags = {"Workflow Modeler"}) public class WorkflowModelerResource { private static final Logger logger = LoggerFactory.getLogger(WorkflowModelerResource.class); + + private static final String WORKFLOW_JSON_TEMP_FILE_NAME = "temp_workflow.json"; + private static final String WORKFLOW_XML_TEMP_FILE_NAME = "temp_workflow.xml"; + /** - * test function. * * @return Response */ @@ -70,11 +79,13 @@ public class WorkflowModelerResource { String json = FileCommonUtils.readString(filePath); return Response.status(Response.Status.OK).entity(json).build(); } catch (IOException e) { - logger.error("getServiceTemplateById failed.", e); + logger.error("get workflow failed.", e); throw RestUtils.newInternalServerErrorException(e); } } + + @Path("/{id}") @PUT @Consumes(MediaType.APPLICATION_JSON) @@ -90,12 +101,26 @@ public class WorkflowModelerResource { @Timed public Response saveModel(@ApiParam(value = "id") @PathParam("id") String id, @ApiParam(value = "Model Content", required = true) String json) { - String filePath = "model.json"; try { - FileCommonUtils.write(filePath, json); + FileCommonUtils.write(WORKFLOW_JSON_TEMP_FILE_NAME, json); + + URI srcUri = Paths.get(".", WORKFLOW_JSON_TEMP_FILE_NAME).toUri(); + String processName = "plan_" + UUID.randomUUID().toString(); + Bpmn4ToscaJsonParser parser = new Bpmn4ToscaJsonParser(); + Process process = parser.parse(processName, srcUri); + + // transform bpmn template + BpmnPlanArtefactWriter writer = new BpmnPlanArtefactWriter(process); + String bpmn = writer.completePlanTemplate(); + + FileCommonUtils.write(WORKFLOW_XML_TEMP_FILE_NAME, bpmn); + return Response.status(Response.Status.OK).entity(json).build(); } catch (IOException e) { - logger.error("getServiceTemplateById failed.", e); + logger.error("save workflow failed.", e); + throw RestUtils.newInternalServerErrorException(e); + } catch (Exception e) { + logger.error("convert workflow from json to bpmn failed.", e); throw RestUtils.newInternalServerErrorException(e); } } diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_dataObject_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_dataObject_template.xml index 6e0721e5..255e77ef 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_dataObject_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_dataObject_template.xml @@ -1,5 +1,5 @@ - - - - - + + + + + \ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_endEvent_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_endEvent_template.xml index 223542c4..8eb62f6f 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_endEvent_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_endEvent_template.xml @@ -1,3 +1,2 @@ - - - + + \ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_errorEndEvent_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_errorEndEvent_template.xml index aef14d92..aecfbdfd 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_errorEndEvent_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_errorEndEvent_template.xml @@ -1,4 +1,3 @@ - - - - + + + \ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_errorStartEvent_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_errorStartEvent_template.xml index 56b08479..d73ee333 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_errorStartEvent_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_errorStartEvent_template.xml @@ -1,4 +1,3 @@ - - - - + + + \ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_exclusiveGateway_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_exclusiveGateway_template.xml index d9ab4613..68fc388e 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_exclusiveGateway_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_exclusiveGateway_template.xml @@ -1,2 +1 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_intermediateCatchEvent_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_intermediateCatchEvent_template.xml index cb952098..ee591857 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_intermediateCatchEvent_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_intermediateCatchEvent_template.xml @@ -1,14 +1,13 @@ - - - - #if (${element.timerEventDefinition.timeDuration}) - - #end - #if (${element.timerEventDefinition.timeDate}) - - #end - #if (${element.timerEventDefinition.timeCycle}) - - #end - - + + +#if (${element.timerEventDefinition.timeDuration}) + +#end +#if (${element.timerEventDefinition.timeDate}) + +#end +#if (${element.timerEventDefinition.timeCycle}) + +#end + + \ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_parallelGateway_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_parallelGateway_template.xml index 2766601b..b3e5164b 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_parallelGateway_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_parallelGateway_template.xml @@ -1,2 +1 @@ - \ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_restTask_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_restTask_template.xml index 7f26177a..051c0edb 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_restTask_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_restTask_template.xml @@ -1,33 +1,33 @@ - - - - - - - - - - - - - - - - - - - #if (${element.produces}) - - - - #end - #if (${element.consumes}) - - - - #end - - - - - + + + + + + + + + + + + + + + + + +#if (${element.produces}) + + + +#end +#if (${element.consumes}) + + + +#end + + + + + \ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_scriptTask_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_scriptTask_template.xml index d50e4c4b..2d9f6915 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_scriptTask_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_scriptTask_template.xml @@ -1,3 +1,3 @@ - - - + + + \ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_serviceTask_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_serviceTask_template.xml index f5d63a23..29933108 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_serviceTask_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_serviceTask_template.xml @@ -1,24 +1,14 @@ - - - - - - - - - - #if (${element.produces}) - - - - #end - #if (${element.consumes}) - - - - #end - - - - - + + +#foreach( $input in ${element.inputs} ) + + + +#end +#foreach( $output in ${element.outputs} ) + + + +#end + + \ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_startEvent_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_startEvent_template.xml index 18053155..150e26b3 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_startEvent_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_startEvent_template.xml @@ -1,9 +1,7 @@ - - - - #foreach( $param in ${element.parameters} ) - - #end - - + + +#foreach( $param in ${element.parameters} ) + +#end + + \ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_sequenceFlow_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_sequenceFlow_template.xml index e95721fc..d659eab0 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_sequenceFlow_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_sequenceFlow_template.xml @@ -1,5 +1,5 @@ - + #if(${sequenceFlow.condition} && ${sequenceFlow.condition} != '') - + #end - \ No newline at end of file + \ No newline at end of file diff --git a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_template.xml b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_template.xml index 66a5f1a7..d336740f 100644 --- a/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_template.xml +++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_template.xml @@ -1,31 +1,28 @@ +#set( $bpelvar = "$bpelvar" ) - - - #foreach( $dataObject in $process.dataObjectList) - #parse( - "${templatePath}bpmn_dataObject_template.xml" - ) - #end + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" + xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" + xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" + expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test"> + + +#foreach( $dataObject in $process.dataObjectList) +#parse("${templatePath}bpmn_dataObject_template.xml") - - #foreach( $element in $process.elementList) - #parse( - "${templatePath}bpmn_element_${element.type}_template.xml" - ) - #end +#end + + +#foreach( $element in $process.elementList) +#parse("${templatePath}bpmn_element_${element.type}_template.xml") + +#end - #foreach( $sequenceFlow in $process.sequenceFlowList) - #parse( - "${templatePath}bpmn_sequenceFlow_template.xml" - ) - #end - - +#foreach( $sequenceFlow in $process.sequenceFlowList) +#parse("${templatePath}bpmn_sequenceFlow_template.xml") +#end + + + diff --git a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParserTest.java b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParserTest.java index 1f56efbf..318301d2 100644 --- a/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParserTest.java +++ b/sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParserTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 ZTE Corporation. + * Copyright (c) 2017-2018 ZTE Corporation. * All rights reserved. This program and the accompanying materials * are made available under the Apache License, Version 2.0 * and the Eclipse Public License v1.0 which both accompany this distribution, @@ -23,10 +23,10 @@ import java.util.List; import org.junit.Test; import org.onap.sdc.workflowdesigner.model.Element; -import org.onap.sdc.workflowdesigner.model.EndEvent; +import org.onap.sdc.workflowdesigner.model.Position; import org.onap.sdc.workflowdesigner.model.Process; +import org.onap.sdc.workflowdesigner.model.ScriptTask; import org.onap.sdc.workflowdesigner.model.SequenceFlow; -import org.onap.sdc.workflowdesigner.model.StartEvent; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -112,24 +112,17 @@ public class Bpmn4ToscaJsonParserTest { private static Process createReferenceProcess() { Process process = new Process(PROCESS_NAME); - - StartEvent startEvent = new StartEvent(); - startEvent.setDocumentation(""); - startEvent.setId("node0"); - startEvent.setName("startEvent"); - process.getElementList().add(startEvent); - - EndEvent endEvent = new EndEvent(); - endEvent.setDocumentation(""); - endEvent.setId("node1"); - endEvent.setName("endEvent"); - process.getElementList().add(endEvent); - - SequenceFlow flow2 = new SequenceFlow(); - flow2.setId("node0node1"); - flow2.setSourceRef("node0"); - flow2.setTargetRef("node1"); - process.getSequenceFlowList().add(flow2); + + ScriptTask scriptTask = new ScriptTask(); + scriptTask.setId("scriptTask"); + scriptTask.setName("Script Task"); + Position position = new Position(); + position.setLeft(328); + position.setTop(134); + scriptTask.setPosition(position); + scriptTask.setScript(""); + scriptTask.setScriptFormat("JavaScript"); + process.getElementList().add(scriptTask); return process; } diff --git a/sdc-workflow-designer-server/src/test/resources/workflow/template-test.bpmn20.xml b/sdc-workflow-designer-server/src/test/resources/workflow/template-test.bpmn20.xml index 589ab715..5c022a2e 100644 --- a/sdc-workflow-designer-server/src/test/resources/workflow/template-test.bpmn20.xml +++ b/sdc-workflow-designer-server/src/test/resources/workflow/template-test.bpmn20.xml @@ -1,16 +1,15 @@ - - - - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" + xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" + xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" + expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test"> + + + + + - - + + diff --git a/sdc-workflow-designer-server/src/test/resources/workflow/workflow.json b/sdc-workflow-designer-server/src/test/resources/workflow/workflow.json index 2042810f..1fa3d10e 100644 --- a/sdc-workflow-designer-server/src/test/resources/workflow/workflow.json +++ b/sdc-workflow-designer-server/src/test/resources/workflow/workflow.json @@ -1,16 +1,28 @@ -{"nodes":[ - { - "sequenceFlows":[ - {"condition":"","sourceRef":"node0","targetRef":"node1"} - ], - "parameters":[],"id":"node0","name":"startEvent","type":"startEvent","parentId":"root", - "position":{"width":30,"height":30,"left":468,"top":55} - }, - { - "sequenceFlows":[], - "input":[],"output":[],"template":{},"id":"node1","name":"endEvent", - "type":"endEvent","parentId":"root", - "position":{"width":252.08334350585938,"height":46.66666793823242,"left":432,"top":167} - }], -"configs":{"restConfigs":[]} +{ + "id":"id12345", + "name":"test", + "scene":"abcd", + "data":{ + "nodes":[ + { + "id":"scriptTask", + "type":"scriptTask", + "typeId":"apds_script", + "icon":"apds_script", + "name":"Script Task", + "parentId":"root", + "position":{ + "left":328, + "top":134, + "width":56, + "height":56 + }, + "connection":[ + + ], + "scriptFormat":"JavaScript", + "script":"" + } + ] + } } \ No newline at end of file -- 2.16.6