aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-server
diff options
context:
space:
mode:
authorLvbo163 <lv.bo163@zte.com.cn>2017-09-26 15:03:13 +0800
committerLvbo163 <lv.bo163@zte.com.cn>2017-09-26 15:16:28 +0800
commit3694205db52ef2b3db5a869ae9e6c3568e616bad (patch)
tree26fb1d99af14540f8c43dfd9befeb45f60fbef27 /sdc-workflow-designer-server
parent4467f07bc4a5e54f34de0bf326688d55aa836acb (diff)
Write data to workflow template
Issue-ID: SDC-398 Change-Id: Ia5cec2af1f9f2018b42933d48628a42fbefb29b5 Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-server')
-rw-r--r--sdc-workflow-designer-server/pom.xml6
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/writer/BpmnPlanArtefactWriter.java64
-rw-r--r--sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_template.xml12
3 files changed, 82 insertions, 0 deletions
diff --git a/sdc-workflow-designer-server/pom.xml b/sdc-workflow-designer-server/pom.xml
index d28ff81b..3ba7f3b9 100644
--- a/sdc-workflow-designer-server/pom.xml
+++ b/sdc-workflow-designer-server/pom.xml
@@ -28,6 +28,7 @@
<properties>
<slf4j.version>1.7.25</slf4j.version>
<jackson.version>2.9.1</jackson.version>
+ <velocity.version>1.6.2</velocity.version>
</properties>
<dependencies>
<dependency>
@@ -45,5 +46,10 @@
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>${velocity.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/writer/BpmnPlanArtefactWriter.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/writer/BpmnPlanArtefactWriter.java
new file mode 100644
index 00000000..c39b0bba
--- /dev/null
+++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/writer/BpmnPlanArtefactWriter.java
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2017 ZTE Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and the Apache License 2.0 which both accompany this distribution,
+ * and are available at http://www.eclipse.org/legal/epl-v10.html
+ * and http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Contributors:
+ * ZTE - initial API and implementation and/or initial documentation
+ */
+package org.onap.sdc.workflowdesigner.writer;
+
+import java.io.StringWriter;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.onap.sdc.workflowdesigner.config.Config;
+import org.onap.sdc.workflowdesigner.model.Process;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BpmnPlanArtefactWriter {
+
+ private Process process;
+
+ public static String TEMPLATE_PATH = Config.PROPERTIES.getProperty(Config.TEMPLATE_PATH);
+
+ private static Logger log = LoggerFactory.getLogger(BpmnPlanArtefactWriter.class);
+
+ public BpmnPlanArtefactWriter(Process process) throws Exception {
+ this.process = process;
+ Velocity.init();
+ }
+
+ public String completePlanTemplate() throws ResourceNotFoundException, ParseErrorException, Exception {
+ log.debug("Completing BPMN process template...");
+
+ VelocityContext context = new VelocityContext();
+
+ VelocityEngine ve = new VelocityEngine();
+ ve.setProperty("resource.loader", "class");
+ ve.setProperty("class.resource.loader.class",
+ "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
+ Template planTemplate = ve.getTemplate(TEMPLATE_PATH + "bpmn_template.xml");
+
+ context.put("process", process);
+ context.put("templatePath", TEMPLATE_PATH);
+ StringWriter planWriter = new StringWriter();
+ planTemplate.merge(context, planWriter);
+
+ String bpmnProcessContent = planWriter.toString();
+
+ log.debug("Completed BPMN process template" + bpmnProcessContent);
+
+ return bpmnProcessContent;
+
+ }
+
+}
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
new file mode 100644
index 00000000..7783ece8
--- /dev/null
+++ b/sdc-workflow-designer-server/src/main/resources/bpmn-templates/bpmn_template.xml
@@ -0,0 +1,12 @@
+<?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">
+
+ </process>
+</definitions>
+