aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-server/src
diff options
context:
space:
mode:
authorYuanHu <yuan.hu1@zte.com.cn>2018-03-15 16:17:00 +0800
committerYuanHu <yuan.hu1@zte.com.cn>2018-03-16 09:07:21 +0800
commit0246959aeb2bd4cb04e00649a0378a846116fbf9 (patch)
tree9d5a26ff5e3203a81b72f231197ee0d63f41c87a /sdc-workflow-designer-server/src
parent9d5b872a75cdfcad2a97a702e56a46730a653734 (diff)
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 <yuan.hu1@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-server/src')
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/Element.java13
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/RestServiceTask.java26
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/ScriptTask.java2
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/ServiceTask.java28
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/model/StartEvent.java7
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParser.java43
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/parser/JsonKeys.java102
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java37
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_dataObject_template.xml10
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_endEvent_template.xml5
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_errorEndEvent_template.xml7
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_errorStartEvent_template.xml7
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_exclusiveGateway_template.xml3
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_intermediateCatchEvent_template.xml27
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_parallelGateway_template.xml1
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_restTask_template.xml66
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_scriptTask_template.xml6
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_serviceTask_template.xml38
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_element_startEvent_template.xml16
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_sequenceFlow_template.xml6
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_template.xml47
-rw-r--r--sdc-workflow-designer-server/src/test/java/org/onap/sdc/workflowdesigner/parser/Bpmn4ToscaJsonParserTest.java35
-rw-r--r--sdc-workflow-designer-server/src/test/resources/workflow/template-test.bpmn20.xml23
-rw-r--r--sdc-workflow-designer-server/src/test/resources/workflow/workflow.json42
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<String> produces;
private List<String> consumes;
private List<Parameter> 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<Parameter> inputs;
+ private List<Parameter> outputs;
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public List<Parameter> getInputs() {
+ return inputs;
+ }
+
+ public void setInputs(List<Parameter> inputs) {
+ this.inputs = inputs;
+ }
+
+ public List<Parameter> getOutputs() {
+ return outputs;
+ }
+ public void setOutputs(List<Parameter> 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<Parameter> parameters;
+ @JsonProperty("parameters")
+ private List<Parameter> parameters;
public List<Parameter> 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<SequenceFlow> getSequenceFlows(JsonNode jsonNode) {
List<SequenceFlow> flowList = new ArrayList<SequenceFlow>();
- JsonNode sequenceFlowNodes = jsonNode.get(JsonKeys.SEQUENCE_FLOWS);
+ String elementId = getValueFromJsonNode(jsonNode, JsonKeys.ID);
+ JsonNode connectionsNode = jsonNode.get(JsonKeys.CONNECTIONS);
- Iterator<JsonNode> iter = sequenceFlowNodes.iterator();
+ Iterator<JsonNode> 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 @@
-<dataObject id="${dataObject.id}" name="${dataObject.name}">
- <extensionElements>
- <activiti:value><![CDATA[${dataObject.value}]]></activiti:value>
- </extensionElements>
-</dataObject>
+ <dataObject id="${dataObject.id}" name="${dataObject.name}">
+ <extensionElements>
+ <activiti:value><![CDATA[${dataObject.value}]]></activiti:value>
+ </extensionElements>
+ </dataObject> \ 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 @@
-
-<endEvent id="${element.id}" name="${element.name}">
-</endEvent>
+ <endEvent id="${element.id}" name="${element.name}">
+ </endEvent> \ 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 @@
-
-<endEvent id="${element.id}" name="${element.name}">
- <errorEventDefinition errorRef="${element.parameter.value}" />
-</endEvent>
+ <endEvent id="${element.id}" name="${element.name}">
+ <errorEventDefinition errorRef="${element.parameter.value}" />
+ </endEvent> \ 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 @@
-
-<startEvent id="${element.id}" name="${element.name}">
- <errorEventDefinition errorRef="${element.parameter.value}" />
-</startEvent>
+ <startEvent id="${element.id}" name="${element.name}">
+ <errorEventDefinition errorRef="${element.parameter.value}" />
+ </startEvent> \ 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 @@
-
-<exclusiveGateway id="${element.id}" name="${element.name}"></exclusiveGateway> \ No newline at end of file
+ <exclusiveGateway id="${element.id}" name="${element.name}"></exclusiveGateway> \ 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 @@
-
-<intermediateCatchEvent id="${element.id}" name="${element.name}">
- <timerEventDefinition>
- #if (${element.timerEventDefinition.timeDuration})
- <timeDuration><![CDATA[${element.timerEventDefinition.timeDuration}]]></timeDuration>
- #end
- #if (${element.timerEventDefinition.timeDate})
- <timeDate><![CDATA[${element.timerEventDefinition.timeDate}]]></timeDate>
- #end
- #if (${element.timerEventDefinition.timeCycle})
- <timeCycle><![CDATA[${element.timerEventDefinition.timeCycle}]]></timeCycle>
- #end
- </timerEventDefinition>
-</intermediateCatchEvent>
+ <intermediateCatchEvent id="${element.id}" name="${element.name}">
+ <timerEventDefinition>
+#if (${element.timerEventDefinition.timeDuration})
+ <timeDuration><![CDATA[${element.timerEventDefinition.timeDuration}]]></timeDuration>
+#end
+#if (${element.timerEventDefinition.timeDate})
+ <timeDate><![CDATA[${element.timerEventDefinition.timeDate}]]></timeDate>
+#end
+#if (${element.timerEventDefinition.timeCycle})
+ <timeCycle><![CDATA[${element.timerEventDefinition.timeCycle}]]></timeCycle>
+#end
+ </timerEventDefinition>
+ </intermediateCatchEvent> \ 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 @@
-
<parallelGateway id="${element.id}" name="${element.name}"></parallelGateway> \ 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 @@
-
-<serviceTask id="${element.id}" name="${element.name}" activiti:class="${element.handler}">
- <extensionElements>
- <activiti:field name="url">
- <activiti:string><![CDATA[$!{element.url}]]></activiti:string>
- </activiti:field>
- <activiti:field name="name">
- <activiti:string><![CDATA[$!{element.serviceName}]]></activiti:string>
- </activiti:field>
- <activiti:field name="version">
- <activiti:string><![CDATA[$!{element.serviceVersion}]]></activiti:string>
- </activiti:field>
- <activiti:field name="path">
- <activiti:string><![CDATA[$!{element.path}]]></activiti:string>
- </activiti:field>
- <activiti:field name="method">
- <activiti:string><![CDATA[$!{element.method}]]></activiti:string>
- </activiti:field>
- #if (${element.produces})
- <activiti:field name="accept">
- <activiti:string><![CDATA[${element.produces}]]></activiti:string>
- </activiti:field>
- #end
- #if (${element.consumes})
- <activiti:field name="contentType">
- <activiti:string><![CDATA[${element.consumes}]]></activiti:string>
- </activiti:field>
- #end
- <activiti:field name="parameters">
- <activiti:string><![CDATA[${element.parameters}]]></activiti:string>
- </activiti:field>
- </extensionElements>
-</serviceTask>
+ <serviceTask id="${element.id}" name="${element.name}"
+ activiti:class="${element.handler}">
+ <extensionElements>
+ <activiti:field name="url">
+ <activiti:string><![CDATA[$!{element.baseUrl}]]></activiti:string>
+ </activiti:field>
+ <activiti:field name="name">
+ <activiti:string><![CDATA[$!{element.serviceName}]]></activiti:string>
+ </activiti:field>
+ <activiti:field name="version">
+ <activiti:string><![CDATA[$!{element.serviceVersion}]]></activiti:string>
+ </activiti:field>
+ <activiti:field name="path">
+ <activiti:string><![CDATA[$!{element.path}]]></activiti:string>
+ </activiti:field>
+ <activiti:field name="method">
+ <activiti:string><![CDATA[$!{element.method}]]></activiti:string>
+ </activiti:field>
+#if (${element.produces})
+ <activiti:field name="accept">
+ <activiti:string><![CDATA[${element.produces}]]></activiti:string>
+ </activiti:field>
+#end
+#if (${element.consumes})
+ <activiti:field name="contentType">
+ <activiti:string><![CDATA[${element.consumes}]]></activiti:string>
+ </activiti:field>
+#end
+ <activiti:field name="parameters">
+ <activiti:string><![CDATA[${element.parameters}]]></activiti:string>
+ </activiti:field>
+ </extensionElements>
+ </serviceTask> \ 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 @@
-<scriptTask id="${element.id}" name="${element.name}" scriptFormat="${element.scriptFormat}" activiti:autoStoreVariables="false">
- <script><![CDATA[${element.script}]]></script>
-</scriptTask>
+ <scriptTask id="${element.id}" name="${element.name}" scriptFormat="${element.scriptFormat}" activiti:autoStoreVariables="false">
+ <script><![CDATA[${element.script}]]></script>
+ </scriptTask> \ 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 @@
-
-<serviceTask id="${element.id}" name="${element.name}" activiti:class="${element.handler}">
- <extensionElements>
- <activiti:field name="uri">
- <activiti:string><![CDATA[${element.url}]]></activiti:string>
- </activiti:field>
- <activiti:field name="method">
- <activiti:string><![CDATA[${element.method}]]></activiti:string>
- </activiti:field>
- #if (${element.produces})
- <activiti:field name="accept">
- <activiti:string><![CDATA[${element.produces}]]></activiti:string>
- </activiti:field>
- #end
- #if (${element.consumes})
- <activiti:field name="contentType">
- <activiti:string><![CDATA[${element.consumes}]]></activiti:string>
- </activiti:field>
- #end
- <activiti:field name="parameters">
- <activiti:string><![CDATA[${element.parameters}]]></activiti:string>
- </activiti:field>
- </extensionElements>
-</serviceTask>
+ <serviceTask id="${element.id}" name="${element.name}" activiti:class="${element.className}">
+ <extensionElements>
+#foreach( $input in ${element.inputs} )
+ <activiti:field name="${input.name}">
+ <activiti:string><![CDATA[${input.value}]]></activiti:string>
+ </activiti:field>
+#end
+#foreach( $output in ${element.outputs} )
+ <activiti:field name="${output.name}">
+ <activiti:string><![CDATA[${output.value}]]></activiti:string>
+ </activiti:field>
+#end
+ </extensionElements>
+ </serviceTask> \ 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 @@
-
-<startEvent id="${element.id}" name="${element.name}">
- <extensionElements>
- #foreach( $param in ${element.parameters} )
- <activiti:formProperty id="${param.name}"
- name="${param.name}" default="${param.value}" type="string"></activiti:formProperty>
- #end
- </extensionElements>
-</startEvent>
+ <startEvent id="${element.id}" name="${element.name}">
+ <extensionElements>
+#foreach( $param in ${element.parameters} )
+ <activiti:formProperty id="${param.name}" name="${param.name}" default="${param.value}" type="string"></activiti:formProperty>
+#end
+ </extensionElements>
+ </startEvent> \ 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 @@
-<sequenceFlow id="${sequenceFlow.id}" sourceRef="${sequenceFlow.sourceRef}" targetRef="${sequenceFlow.targetRef}">
+ <sequenceFlow id="${sequenceFlow.id}" sourceRef="${sequenceFlow.sourceRef}" targetRef="${sequenceFlow.targetRef}">
#if(${sequenceFlow.condition} && ${sequenceFlow.condition} != '')
- <conditionExpression xsi:type="tFormalExpression"><![CDATA[${sequenceFlow.condition}]]></conditionExpression>
+ <conditionExpression xsi:type="tFormalExpression"><![CDATA[${sequenceFlow.condition}]]></conditionExpression>
#end
-</sequenceFlow> \ No newline at end of file
+ </sequenceFlow> \ 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" )
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
- 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">
- <process id="${process.id}" isExecutable="true">
- <!-- dataObjects -->
- #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">
+ <process id="${process.id}" isExecutable="true">
+ <!-- dataObjects -->
+#foreach( $dataObject in $process.dataObjectList)
+#parse("${templatePath}bpmn_dataObject_template.xml")
- <!-- Perform bpmn elements -->
- #foreach( $element in $process.elementList)
- #parse(
- "${templatePath}bpmn_element_${element.type}_template.xml"
- )
- #end
+#end
+
+ <!-- Perform bpmn elements -->
+#foreach( $element in $process.elementList)
+#parse("${templatePath}bpmn_element_${element.type}_template.xml")
+
+#end
<!-- Perform bpmn sequence flow -->
- #foreach( $sequenceFlow in $process.sequenceFlowList)
- #parse(
- "${templatePath}bpmn_sequenceFlow_template.xml"
- )
- #end
- </process>
-</definitions>
+#foreach( $sequenceFlow in $process.sequenceFlowList)
+#parse("${templatePath}bpmn_sequenceFlow_template.xml")
+#end
+
+ </process>
+</definitions>
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 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
- 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">
- <process id="templateTest" isExecutable="true">
- <!-- dataObjects -->
-
- <!-- Perform bpmn elements -->
-
+ 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">
+ <process id="templateTest" isExecutable="true">
+ <!-- dataObjects -->
+
+ <!-- Perform bpmn elements -->
+
<!-- Perform bpmn sequence flow -->
- </process>
-</definitions>
+ </process>
+</definitions>
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