Permalink
Browse files

process import now also handles Jenkins task properly

  • Loading branch information...
1 parent 167ad6a commit 317383d963eb94df89f439258c600b6a9a8104c1 mspring committed Feb 23, 2013
@@ -40,7 +40,7 @@ public static void fillJsonTypes(Map<String,
public static void fillBpmnTypes(Map<Class<? extends BaseElement>,
Class<? extends BaseBpmnJsonConverter>> convertersToJsonMap) {
- convertersToJsonMap.put(ServiceTask.class, JenkinsTaskJsonConverter.class);
+ // Because the Jenkins Task is mapped to a ServiceTask, the ServiceTaskJsonConverter has to map back
}
@Override
@@ -50,15 +50,24 @@ protected String getStencilId(FlowElement flowElement) {
@Override
protected void convertElementToJson(ObjectNode propertiesNode, FlowElement flowElement) {
- System.out.println("************** JenkinsTaskJsonConverter.convertElementToJson");
- System.out.println("flowElement.getClass() --> "+flowElement.getClass());
-
- // TODO implement convertElementToJson
+ ServiceTask serviceTask = (ServiceTask)flowElement;
+
+ for (FieldExtension extension : serviceTask.getFieldExtensions()) {
+ ObjectNode propertyItemNode = objectMapper.createObjectNode();
+ String fn = extension.getFieldName();
+ String val = extension.getStringValue();
+
+ // TODO should have a better way to map these attributes!
+ if (XML_JENKINSTASK_JOB_NAME.equals(fn)){
+ propertiesNode.put(JSON_JENKINSTASK_JOB_NAME,val);
+ }else if (XML_JENKINSTASK_MANUAL_LAUNCH_MODE.equals(fn)){
+ propertiesNode.put(JSON_JENKINSTASK_MANUAL_LAUNCH_MODE,val);
+ }
+ }
}
@Override
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
- System.out.println("************** JenkinsTaskJsonConverter.convertJsonToElement");
ServiceTask task = new ServiceTask();
task.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
@@ -44,6 +44,10 @@ public static void fillBpmnTypes(Map<Class<? extends BaseElement>, Class<? exten
}
protected String getStencilId(FlowElement flowElement) {
+ // TODO should have a better mapper in place
+ if ((flowElement instanceof ServiceTask) && JenkinsTaskJsonConverter.XML_JENKINSTASK_DELEGATE_CLASS.equals(((ServiceTask) flowElement).getImplementation())){
+ return new JenkinsTaskJsonConverter().getStencilId(flowElement);
+ }
return STENCIL_TASK_SERVICE;
}
@@ -73,6 +77,11 @@ protected void convertElementToJson(ObjectNode propertiesNode, FlowElement flowE
addFieldExtensions(serviceTask.getFieldExtensions(), propertiesNode);
}
+
+ // TODO should have a better mapper in place
+ if (JenkinsTaskJsonConverter.XML_JENKINSTASK_DELEGATE_CLASS.equals(serviceTask.getImplementation())){
+ new JenkinsTaskJsonConverter().convertElementToJson(propertiesNode,flowElement);
+ }
}
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {

0 comments on commit 317383d

Please sign in to comment.