summaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-server
diff options
context:
space:
mode:
authorYuanHu <yuan.hu1@zte.com.cn>2018-03-21 10:06:57 +0800
committerYuanHu <yuan.hu1@zte.com.cn>2018-03-21 10:06:57 +0800
commitb3c577ab841bcba502ade66dfbd2521537cee0b5 (patch)
tree5d9c915726677f25e1a8a34715d45a0851243949 /sdc-workflow-designer-server
parent6989bde42302cb914776aaf318a2c9b5f9c15c8e (diff)
Sava Workflow Artifact to SDC
Sava Workflow Artifact to SDC Issue-ID: SDC-1004 Change-Id: Ifab77db0d3b739304c0eff283aef3d382f6bf4bb Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-server')
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/WorkflowArtifactInfo.java10
-rw-r--r--sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/resources/WorkflowModelerResource.java33
2 files changed, 29 insertions, 14 deletions
diff --git a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/WorkflowArtifactInfo.java b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/WorkflowArtifactInfo.java
index 23c8f860..e2cab05e 100644
--- a/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/WorkflowArtifactInfo.java
+++ b/sdc-workflow-designer-server/src/main/java/org/onap/sdc/workflowdesigner/externalservice/sdc/entity/WorkflowArtifactInfo.java
@@ -28,19 +28,11 @@ public class WorkflowArtifactInfo implements Serializable {
private String payloadData;
-
- /**
- * @param artifactName
- * @param description
- * @param artifactType
- * @param payloadData
- */
- public WorkflowArtifactInfo(String artifactName, String description, String artifactType,
+ public WorkflowArtifactInfo(String artifactName, String description,
String payloadData) {
super();
this.artifactName = artifactName;
this.description = description;
- this.artifactType = artifactType;
this.payloadData = payloadData;
}
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 317d59d4..f6f1699a 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
@@ -27,9 +27,14 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.eclipse.jetty.http.HttpStatus;
+import org.onap.sdc.workflowdesigner.common.WorkflowDesignerException;
+import org.onap.sdc.workflowdesigner.externalservice.sdc.SDCServiceProxy;
+import org.onap.sdc.workflowdesigner.externalservice.sdc.entity.WorkflowArtifactInfo;
import org.onap.sdc.workflowdesigner.model.Process;
import org.onap.sdc.workflowdesigner.parser.Bpmn4ToscaJsonParser;
+import org.onap.sdc.workflowdesigner.resources.entity.WorkflowInfo;
import org.onap.sdc.workflowdesigner.utils.FileCommonUtils;
+import org.onap.sdc.workflowdesigner.utils.JsonUtils;
import org.onap.sdc.workflowdesigner.utils.RestUtils;
import org.onap.sdc.workflowdesigner.writer.BpmnPlanArtefactWriter;
import org.slf4j.Logger;
@@ -51,7 +56,7 @@ 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";
@@ -83,8 +88,8 @@ public class WorkflowModelerResource {
}
}
-
-
+
+
@Path("/{id}")
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@@ -107,8 +112,9 @@ public class WorkflowModelerResource {
String processName = "plan_" + UUID.randomUUID().toString();
String bpmn = buildBPMN(srcUri, processName);
+ save2SDC(json, bpmn);
FileCommonUtils.write(WORKFLOW_XML_TEMP_FILE_NAME, bpmn);
-
+
return Response.status(Response.Status.OK).entity(json).build();
} catch (IOException e) {
logger.error("save workflow failed.", e);
@@ -119,6 +125,23 @@ public class WorkflowModelerResource {
}
}
+
+
+ /**
+ * @param json
+ * @param bpmn
+ * @throws WorkflowDesignerException
+ */
+ private void save2SDC(String json, String bpmn) throws WorkflowDesignerException {
+ WorkflowInfo workflowInfo = JsonUtils.fromJson(json, WorkflowInfo.class);
+ WorkflowArtifactInfo workflowArtifactInfo =
+ new WorkflowArtifactInfo(workflowInfo.getName(), workflowInfo.getDescription(), bpmn);
+
+ SDCServiceProxy sdcProxy = new SDCServiceProxy();
+ sdcProxy.saveWorkflowArtifact(workflowInfo.getUuid(), workflowInfo.getOperationId(),
+ workflowInfo.getId(), workflowArtifactInfo);
+ }
+
/**
*
* @param srcUri
@@ -130,7 +153,7 @@ public class WorkflowModelerResource {
private String buildBPMN(URI srcUri, String processName) throws IOException, Exception {
Bpmn4ToscaJsonParser parser = new Bpmn4ToscaJsonParser();
Process process = parser.parse(processName, srcUri);
-
+
// transform bpmn template
BpmnPlanArtefactWriter writer = new BpmnPlanArtefactWriter(process);
return writer.completePlanTemplate();