Switch to side-by-side view

--- a/src/main/java/net/timbusproject/extractors/modules/tavernaextractor/TavernaExtractor.java
+++ b/src/main/java/net/timbusproject/extractors/modules/tavernaextractor/TavernaExtractor.java
@@ -368,11 +368,7 @@
         desktop.setName("Machine");
 
         // adding XRN
-        MachineID machineID = new MachineID();
-        IProperty property = factory.createProperty();
-        property.setKey("XRN");
-        property.setValue(machineID.getXRN());
-        desktop.getProperties().add(property);
+        ArchiUtils.addProperty(desktop ,"XRN", new MachineID().getXRN());
 
         infrastructureFolder.getElements().add(desktop);
 
@@ -626,29 +622,20 @@
                 externalProviders);
 
         String type = null;
-        IProperty prop = factory.createProperty();
         IProperty locationProp = factory.createProperty();
         if (a instanceof WSDLActivity) {
-
             LOGGER.debug("WSDL Service found = " + processor.getLocalName());
             type = "SOAP";
             WSDLActivity wsdlActivity = (WSDLActivity) a;
-            prop.setKey("WSDL_Location");
-            prop.setValue(wsdlActivity.getConfiguration().getWsdl());
-            externalNode.getProperties().add(prop);
-
+            ArchiUtils.addProperty(externalNode, "WSDL_Location", wsdlActivity.getConfiguration().getWsdl());
             locationProp = createDepProperties(WSDLActivity.class);
         }
 
         if (a instanceof RESTActivity) {
-
             LOGGER.debug("RESTful Service found = " + processor.getLocalName());
             type = "HTTP";
             RESTActivity restActivity = (RESTActivity) a;
-            prop.setKey("URL");
-            prop.setValue(restActivity.getConfiguration().getUrlSignature());
-            externalNode.getProperties().add(prop);
-
+            ArchiUtils.addProperty(externalNode, "URL", restActivity.getConfiguration().getUrlSignature());
             locationProp = createDepProperties(RESTActivity.class);
         }
 
@@ -929,10 +916,8 @@
             ArchiUtils.initRelation(factory.createCompositionRelationship(), desktop, toolAsArtifact,
                     relationsFolder, relations);
 
-            IProperty commandProperty = factory.createProperty();
-            commandProperty.setKey("Command");
-            commandProperty.setValue(externalInvocation.getConfiguration().getUseCaseDescription().getCommand());
-            toolAsArtifact.getProperties().add(commandProperty);
+            ArchiUtils.addProperty(toolAsArtifact, "Command", externalInvocation.getConfiguration()
+                    .getUseCaseDescription().getCommand());
         }
     }
 
@@ -1058,15 +1043,8 @@
         String ex = c.getXpathExpression() != null ? c.getXpathExpression() : "NO_EXPRESSION_AVAILABLE";
         String doc = c.getXmlDocument() != null ? c.getXmlDocument() : "NO_XML_DOCUMENT_AVAILABLE";
 
-        IProperty property = factory.createProperty();
-        property.setKey("expression");
-        property.setValue(ex);
-        script.getProperties().add(property);
-
-        IProperty property_document = factory.createProperty();
-        property_document.setKey("document");
-        property_document.setValue(doc);
-        script.getProperties().add(property_document);
+        ArchiUtils.addProperty(script, "expression",ex);
+        ArchiUtils.addProperty(script, "document", doc);
 
         ArchiUtils.initRelation(factory.createCompositionRelationship(), workflowFile, script, relationsFolder,
                 relations);
@@ -1220,11 +1198,7 @@
 
                 // Do the license checking
                 String fileName = this.getTavernaHomeLib() + File.separator + item;
-
-                IProperty jarLocation = factory.createProperty();
-                jarLocation.setKey("hasSourceLocation");
-                jarLocation.setValue(fileName);
-                beanshellScriptDep.getProperties().add(jarLocation);
+                ArchiUtils.addProperty(beanshellScriptDep, "hasSourceLocation", fileName);
 
                 // do proper checking whether the file exists !
                 Path pathToDep = Paths.get(fileName);
@@ -1785,69 +1759,32 @@
     }
 
     private IProperty createDepProperties(Class clazz) {
-
-        IProperty property = factory.createProperty();
-        property.setKey("hasSourceLocation");
-        property.setValue(getJarLocationOfClass(clazz).getPath().replaceFirst("/", ""));
-        return property;
+        return createDepProperties(getJarLocationOfClass(clazz).getPath().replaceFirst("/", ""));
     }
 
     private IProperty createDepProperties(String pathToJar) {
-
-        IProperty property = factory.createProperty();
-        property.setKey("hasSourceLocation");
-        property.setValue(pathToJar);
-        return property;
+        return ArchiUtils.createProperty("hasSourceLocation", pathToJar);
     }
 
     private List<IProperty> createPropertiesOutOfXMLMechanism(ExternalToolActivityConfigurationBean configuration) {
-
         List<IProperty> props = new ArrayList<IProperty>();
-
         try {
             Document document = DocumentHelper.parseText(configuration.getMechanismXML());
-
-            IProperty hostProperty = factory.createProperty();
-            hostProperty.setKey("Host");
-            hostProperty.setValue(document.selectSingleNode("//host").getText());
-            props.add(hostProperty);
-
-            IProperty portProperty = factory.createProperty();
-            portProperty.setKey("Port");
-            portProperty.setValue(document.selectSingleNode("//port").getText());
-            props.add(portProperty);
-
+            props.add(ArchiUtils.createProperty("Host",document.selectSingleNode("//host").getText()));
+            props.add(ArchiUtils.createProperty("Port",document.selectSingleNode("//port").getText()));
         } catch (DocumentException e) {
             LOGGER.error("ERROR parsing external tool invocation mechanism. " + e.getMessage());
         }
 
-        IProperty commandProperty = factory.createProperty();
-        commandProperty.setKey("Command");
-        commandProperty.setValue(configuration.getUseCaseDescription().getCommand());
-        props.add(commandProperty);
-
+        props.add(ArchiUtils.createProperty("Command", configuration.getUseCaseDescription().getCommand()));
         return props;
     }
 
     private List<IProperty> createPropertiesOutOfRshellConfig(RshellActivityConfigurationBean configuration) {
-
         List<IProperty> props = new ArrayList<IProperty>();
-
-        IProperty hostProperty = factory.createProperty();
-        hostProperty.setKey("Host");
-        hostProperty.setValue(configuration.getConnectionSettings().getHost());
-        props.add(hostProperty);
-
-        IProperty portProperty = factory.createProperty();
-        portProperty.setKey("Port");
-        portProperty.setValue("" + configuration.getConnectionSettings().getPort());
-        props.add(portProperty);
-
-        IProperty scriptProperty = factory.createProperty();
-        scriptProperty.setKey("Script");
-        scriptProperty.setValue(configuration.getScript());
-        props.add(scriptProperty);
-
+        props.add(ArchiUtils.createProperty("Host", configuration.getConnectionSettings().getHost()));
+        props.add(ArchiUtils.createProperty("Port", String.valueOf(configuration.getConnectionSettings().getPort())));
+        props.add(ArchiUtils.createProperty("Script", configuration.getScript()));
         return props;
     }