From ce8cfcde32b56477f80be5980e5954f5bebdbb69 Mon Sep 17 00:00:00 2001 From: YuanHu Date: Tue, 20 Mar 2018 10:34:09 +0800 Subject: Refactor. Extract Method. Issue-ID: SDC-1079 Change-Id: I77dafb1acf0fdd1f8a94aaa2492d2d458d1dbb22 Signed-off-by: YuanHu --- .../resources/WorkflowModelerResource.java | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'sdc-workflow-designer-server/src') 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 fc3a2b37..317d59d4 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 @@ -105,13 +105,8 @@ public class WorkflowModelerResource { 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(); - + String bpmn = buildBPMN(srcUri, processName); + FileCommonUtils.write(WORKFLOW_XML_TEMP_FILE_NAME, bpmn); return Response.status(Response.Status.OK).entity(json).build(); @@ -124,4 +119,21 @@ public class WorkflowModelerResource { } } + /** + * + * @param srcUri + * @param processName + * @return + * @throws IOException + * @throws Exception + */ + 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(); + } + } -- cgit 1.2.3-korg