/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r
import org.slf4j.LoggerFactory;\r
\r
public class Config {\r
- private static Logger log = LoggerFactory.getLogger(Config.class);\r
- private static String configFilePath = "bpmn.config.properties";\r
- public static String HANDLER_ClASS = "handlerClass";\r
- public static String TEMPLATE_PATH = "templatePath";\r
- \r
- public static Properties PROPERTIES = load();\r
- \r
- public static Properties load() {\r
- Properties properties = new Properties();\r
- InputStream in = null;\r
- try {\r
- in = Config.class.getClassLoader().getResourceAsStream(configFilePath);\r
- properties.load(in);\r
- } catch (FileNotFoundException e) {\r
- log.error(configFilePath, e);\r
- } catch (IOException e) {\r
- log.error(configFilePath, e);\r
- } catch (Exception e) {\r
- log.error(configFilePath, e);\r
- } finally {\r
- if(in != null) {\r
- try {\r
- in.close();\r
- } catch (IOException e) {\r
- log.error(configFilePath, e);\r
- }\r
- }\r
- }\r
- \r
- return properties;\r
- }\r
+ private static Logger log = LoggerFactory.getLogger(Config.class);\r
+ private static String configFilePath = "bpmn.config.properties";\r
+ public static String HANDLER_ClASS = "handlerClass";\r
+ public static String TEMPLATE_PATH = "templatePath";\r
+\r
+ public static Properties PROPERTIES = load();\r
+\r
+ public static Properties load() {\r
+ Properties properties = new Properties();\r
+ InputStream in = null;\r
+ try {\r
+ in = Config.class.getClassLoader().getResourceAsStream(configFilePath);\r
+ properties.load(in);\r
+ } catch (FileNotFoundException e) {\r
+ log.error(configFilePath, e);\r
+ } catch (IOException e) {\r
+ log.error(configFilePath, e);\r
+ } catch (Exception e) {\r
+ log.error(configFilePath, e);\r
+ } finally {\r
+ if (in != null) {\r
+ try {\r
+ in.close();\r
+ } catch (IOException e) {\r
+ log.error(configFilePath, e);\r
+ }\r
+ }\r
+ }\r
+\r
+ return properties;\r
+ }\r
}\r
/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r
/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r
import java.util.List;\r
\r
public class Element {\r
- private String id;\r
- private String name;\r
- private String type;\r
- private String documentation;\r
- private Position position;\r
- private List<String> connections;\r
- \r
- public String getId() {\r
- return id;\r
- }\r
- public Position getPosition() {\r
- return position;\r
- }\r
- public void setPosition(Position position) {\r
- this.position = position;\r
- }\r
- public List<String> getConnections() {\r
- return connections;\r
- }\r
- public void setConnections(List<String> connections) {\r
- this.connections = connections;\r
- }\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
- public String getName() {\r
- return name;\r
- }\r
- public void setName(String name) {\r
- this.name = name;\r
- }\r
- public String getDocumentation() {\r
- return documentation;\r
- }\r
- public void setDocumentation(String documentation) {\r
- this.documentation = documentation;\r
- }\r
- public String getType() {\r
- return type;\r
- }\r
- public void setType(String type) {\r
- this.type = type;\r
- }\r
- \r
+ private String id;\r
+ private String name;\r
+ private String type;\r
+ private String documentation;\r
+ private Position position;\r
+ private List<String> connections;\r
+\r
+ public String getId() {\r
+ return id;\r
+ }\r
+\r
+ public Position getPosition() {\r
+ return position;\r
+ }\r
+\r
+ public void setPosition(Position position) {\r
+ this.position = position;\r
+ }\r
+\r
+ public List<String> getConnections() {\r
+ return connections;\r
+ }\r
+\r
+ public void setConnections(List<String> connections) {\r
+ this.connections = connections;\r
+ }\r
+\r
+ public void setId(String id) {\r
+ this.id = id;\r
+ }\r
+\r
+ public String getName() {\r
+ return name;\r
+ }\r
+\r
+ public void setName(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+ public String getDocumentation() {\r
+ return documentation;\r
+ }\r
+\r
+ public void setDocumentation(String documentation) {\r
+ this.documentation = documentation;\r
+ }\r
+\r
+ public String getType() {\r
+ return type;\r
+ }\r
+\r
+ public void setType(String type) {\r
+ this.type = type;\r
+ }\r
+\r
}\r
/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r
/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r
/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r
package org.onap.sdc.workflowdesigner.model;\r
\r
public class Position {\r
- private int left;\r
- private int top;\r
- \r
- public int getLeft() {\r
- return left;\r
- }\r
- public void setLeft(int left) {\r
- this.left = left;\r
- }\r
- public int getTop() {\r
- return top;\r
- }\r
- public void setTop(int top) {\r
- this.top = top;\r
- }\r
+ private int left;\r
+ private int top;\r
+\r
+ public int getLeft() {\r
+ return left;\r
+ }\r
+\r
+ public void setLeft(int left) {\r
+ this.left = left;\r
+ }\r
+\r
+ public int getTop() {\r
+ return top;\r
+ }\r
+\r
+ public void setTop(int top) {\r
+ this.top = top;\r
+ }\r
}\r
/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r
* Contributors:\r
* ZTE - initial API and implementation and/or initial documentation\r
*/\r
-\r
package org.onap.sdc.workflowdesigner.model;\r
\r
import java.util.ArrayList;\r
import java.util.List;\r
\r
public class Process {\r
- private String id;\r
- private boolean isExecutable;\r
- private List<Element> elementList = new ArrayList<Element>();\r
- private List<SequenceFlow> sequenceFlowList = new ArrayList<SequenceFlow>();\r
- \r
- public Process(String id) {\r
- this.id = id;\r
- }\r
- \r
- public String getId() {\r
- return id;\r
- }\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
- public boolean isExecutable() {\r
- return isExecutable;\r
- }\r
- public void setExecutable(boolean isExecutable) {\r
- this.isExecutable = isExecutable;\r
- }\r
- public List<Element> getElementList() {\r
- return elementList;\r
- }\r
- public void setElementList(List<Element> elementList) {\r
- this.elementList = elementList;\r
- }\r
- public List<SequenceFlow> getSequenceFlowList() {\r
- return sequenceFlowList;\r
- }\r
- public void setSequenceFlowList(List<SequenceFlow> sequenceFlowList) {\r
- this.sequenceFlowList = sequenceFlowList;\r
- }\r
+ private String id;\r
+ private boolean isExecutable;\r
+ private List<Element> elementList = new ArrayList<Element>();\r
+ private List<SequenceFlow> sequenceFlowList = new ArrayList<SequenceFlow>();\r
+\r
+ public Process(String id) {\r
+ this.id = id;\r
+ }\r
+\r
+ public String getId() {\r
+ return id;\r
+ }\r
+\r
+ public void setId(String id) {\r
+ this.id = id;\r
+ }\r
+\r
+ public boolean isExecutable() {\r
+ return isExecutable;\r
+ }\r
+\r
+ public void setExecutable(boolean isExecutable) {\r
+ this.isExecutable = isExecutable;\r
+ }\r
+\r
+ public List<Element> getElementList() {\r
+ return elementList;\r
+ }\r
+\r
+ public void setElementList(List<Element> elementList) {\r
+ this.elementList = elementList;\r
+ }\r
+\r
+ public List<SequenceFlow> getSequenceFlowList() {\r
+ return sequenceFlowList;\r
+ }\r
+\r
+ public void setSequenceFlowList(List<SequenceFlow> sequenceFlowList) {\r
+ this.sequenceFlowList = sequenceFlowList;\r
+ }\r
\r
}\r
/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r
package org.onap.sdc.workflowdesigner.model;\r
\r
public class SequenceFlow {\r
- private String id = "";\r
- private String name;\r
- private String sourceRef;\r
- private String targetRef;\r
- private String documentation;\r
- private String condition;\r
- \r
- public String getId() {\r
- return id;\r
- }\r
- public void setId(String id) {\r
- this.id = id;\r
- }\r
- public String getName() {\r
- return name;\r
- }\r
- public void setName(String name) {\r
- this.name = name;\r
- }\r
- public String getSourceRef() {\r
- return sourceRef;\r
- }\r
- public void setSourceRef(String sourceRef) {\r
- this.sourceRef = sourceRef;\r
- }\r
- public String getTargetRef() {\r
- return targetRef;\r
- }\r
- public void setTargetRef(String targetRef) {\r
- this.targetRef = targetRef;\r
- }\r
- public String getDocumentation() {\r
- return documentation;\r
- }\r
- public void setDocumentation(String documentation) {\r
- this.documentation = documentation;\r
- }\r
-\r
- public String getCondition() {\r
- return condition;\r
- }\r
-\r
- public void setCondition(String condition) {\r
- this.condition = condition;\r
- }\r
- \r
+ private String id = "";\r
+ private String name;\r
+ private String sourceRef;\r
+ private String targetRef;\r
+ private String documentation;\r
+ private String condition;\r
+\r
+ public String getId() {\r
+ return id;\r
+ }\r
+\r
+ public void setId(String id) {\r
+ this.id = id;\r
+ }\r
+\r
+ public String getName() {\r
+ return name;\r
+ }\r
+\r
+ public void setName(String name) {\r
+ this.name = name;\r
+ }\r
+\r
+ public String getSourceRef() {\r
+ return sourceRef;\r
+ }\r
+\r
+ public void setSourceRef(String sourceRef) {\r
+ this.sourceRef = sourceRef;\r
+ }\r
+\r
+ public String getTargetRef() {\r
+ return targetRef;\r
+ }\r
+\r
+ public void setTargetRef(String targetRef) {\r
+ this.targetRef = targetRef;\r
+ }\r
+\r
+ public String getDocumentation() {\r
+ return documentation;\r
+ }\r
+\r
+ public void setDocumentation(String documentation) {\r
+ this.documentation = documentation;\r
+ }\r
+\r
+ public String getCondition() {\r
+ return condition;\r
+ }\r
+\r
+ public void setCondition(String condition) {\r
+ this.condition = condition;\r
+ }\r
+\r
}\r
/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r
/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r
\r
public class Bpmn4ToscaJsonParser {\r
\r
- private static Logger log = LoggerFactory.getLogger(Bpmn4ToscaJsonParser.class);\r
- \r
- private static ObjectMapper MAPPER = new ObjectMapper();\r
- \r
- static {\r
- MAPPER.enable(SerializationFeature.INDENT_OUTPUT);\r
- MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);\r
- }\r
- \r
- public Process parse(String processName, URI jsonFileUrl) throws JsonParseException, JsonMappingException, MalformedURLException, IOException {\r
- Process process = new Process(processName);\r
-\r
- JsonNode rootNode = MAPPER.readValue(jsonFileUrl.toURL(), JsonNode.class);\r
-\r
- log.debug("Creating Process models...");\r
- JsonNode nodes = rootNode.get("nodes");\r
- if(nodes == null) {\r
- return process;\r
- }\r
- \r
- Iterator<JsonNode> iter = nodes.iterator();\r
- while (iter.hasNext()) {\r
- JsonNode jsonNode = (JsonNode) iter.next();\r
-\r
- // get element\r
- Element element = createElementFromJson(jsonNode);\r
- process.getElementList().add(element);\r
- \r
- // get sequence flows \r
+ private static Logger log = LoggerFactory.getLogger(Bpmn4ToscaJsonParser.class);\r
+\r
+ private static ObjectMapper MAPPER = new ObjectMapper();\r
+\r
+ static {\r
+ MAPPER.enable(SerializationFeature.INDENT_OUTPUT);\r
+ MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);\r
+ }\r
+\r
+ public Process parse(String processName, URI jsonFileUrl)\r
+ throws JsonParseException, JsonMappingException, MalformedURLException, IOException {\r
+ Process process = new Process(processName);\r
+\r
+ JsonNode rootNode = MAPPER.readValue(jsonFileUrl.toURL(), JsonNode.class);\r
+\r
+ log.debug("Creating Process models...");\r
+ JsonNode nodes = rootNode.get("nodes");\r
+ if (nodes == null) {\r
+ return process;\r
+ }\r
+\r
+ Iterator<JsonNode> iter = nodes.iterator();\r
+ while (iter.hasNext()) {\r
+ JsonNode jsonNode = (JsonNode) iter.next();\r
+\r
+ // get element\r
+ Element element = createElementFromJson(jsonNode);\r
+ process.getElementList().add(element);\r
+\r
+ // get sequence flows\r
List<SequenceFlow> flowList = getSequenceFlows(jsonNode);\r
process.getSequenceFlowList().addAll(flowList);\r
- }\r
+ }\r
+\r
+ return process;\r
\r
- return process;\r
+ }\r
\r
- }\r
- \r
- private List<SequenceFlow> getSequenceFlows(JsonNode jsonNode) {\r
+ private List<SequenceFlow> getSequenceFlows(JsonNode jsonNode) {\r
List<SequenceFlow> flowList = new ArrayList<SequenceFlow>();\r
JsonNode sequenceFlowNodes = jsonNode.get("sequenceFlows");\r
- \r
+\r
Iterator<JsonNode> iter = sequenceFlowNodes.iterator();\r
while (iter.hasNext()) {\r
JsonNode connectionEntry = (JsonNode) iter.next();\r
flow.setCondition(condition);\r
flowList.add(flow);\r
}\r
- \r
+\r
return flowList;\r
}\r
- \r
- private String getValueFromJsonNode(JsonNode jsonNode, String key) {\r
+\r
+ private String getValueFromJsonNode(JsonNode jsonNode, String key) {\r
return jsonNode.get(key) == null ? null : jsonNode.get(key).asText();\r
}\r
- \r
- protected Element createElementFromJson(JsonNode jsonNode) throws JsonParseException, JsonMappingException, IOException {\r
- String jsonObject = jsonNode.toString();\r
+\r
+ protected Element createElementFromJson(JsonNode jsonNode)\r
+ throws JsonParseException, JsonMappingException, IOException {\r
+ String jsonObject = jsonNode.toString();\r
Element element;\r
- \r
+\r
String nodeType = getValueFromJsonNode(jsonNode, "type");\r
switch (nodeType) {\r
case "startEvent":\r
}\r
\r
return element;\r
- }\r
- \r
+ }\r
+\r
}\r
/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r
/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r
/**\r
* Copyright (c) 2017 ZTE Corporation.\r
* All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * and the Apache License 2.0 which both accompany this distribution,\r
+ * are made available under the Apache License, Version 2.0\r
+ * and the Eclipse Public License v1.0 which both accompany this distribution,\r
* and are available at http://www.eclipse.org/legal/epl-v10.html\r
* and http://www.apache.org/licenses/LICENSE-2.0\r
*\r