Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Change version of reference-api dependency to 2.0.1-SNAPSHOT
  2. Change version of workflowmodel-api dendency to 2.0.1-SNAPSHOT
  3. Add dependency for jackson-databind

    Code Block
    languagehtml/xml
    <dependency>
    	<groupId>com.fasterxml.jackson.core</groupId>
    	<artifactId>jackson-databind</artifactId>
    	<version>2.2.3</version>
    </dependency>
  4. Update any test dependencies, such as:
    1. activity-test-utils to 2.0.1-SNAPSHOT
    2. workflowmodel-impl to 2.0.1-SNAPSHOT
  5. Add maven-bundle-plugin plugin (unless already added to parent pom) 

    Code Block
    languagehtml/xml
     <plugins>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.3.7</version>
            <extensions>true</extensions>
        </plugin>
    </plugins>
  6. Change packaging type to bundle 

    Code Block
    languagehtml/xml
    <packaging>bundle</packaging>
schema.json

The JSON schema file specifies the configuration properties required by the activity.

  1. Add schema.json file to the project resources directory

     

    Code Block
    languagehtml/xml
    {
        "$schema": "http://json-schema.org/draft-03/schema#",
        "id": "http://example.com/2013/activity/example.schema.json",
        "title": "Example activity configuration",
        "type": "object",
        "properties": {
            "@context": {
                "description": "JSON-LD context for interpreting the configuration as RDF",
                "required": true,
                "enum": ["http://example.com/2013/activity/example.context.json"]
            }
        }
    }
  2. Add a property entry for each of the properties in the ExampleActivityConfigBean class

    Code Block
    languagehtml/xml
    {
        "$schema": "http://json-schema.org/draft-03/schema#",
        "id": "http://example.com/2013/activity/example.schema.json",
        "title": "Example activity configuration",
        "type": "object",
        "properties": {
            "@context": {
                "description": "JSON-LD context for interpreting the configuration as RDF",
                "required": true,
                "enum": ["http://example.com/2013/activity/example.context.json"]
            },
            "exampleString": {
                "title": "Example String",
                "description": "An example string property",
                "type": "string",
                "required": true
            },
            "exampleUri": {
                "title": "Example URI",
                "description": "An example uri property",
                "type": "string",
                "required": true
            }
        }
    }
ExampleActivityFactory.java

An ActivityFactory is a new interface for Taverna 3 that is used by the Taverna Platform to create instances of activities.

  1. Add new class ExampleActivityFactory 

     

    Code Block
    languagejava
    public class ExampleActivityFactory implements ActivityFactory {
    
    	private Edits edits;
    
    	@Override
    	public ExampleActivity createActivity() {
    		return new ExampleActivity();
    	}
    
    	@Override
    	public URI getActivityType() {
    		return URI.create(ExampleActivity.ACTIVITY_TYPE);
    	}
    
    	@Override
    	public JsonNode getActivityConfigurationSchema() {
    		ObjectMapper objectMapper = new ObjectMapper();
    
    		try {
    			return objectMapper.readTree(getClass().getResource("/schema.json"));
    		} catch (IOException e) {
    			return objectMapper.createObjectNode();
    		}
    
    	}
    
    	@Override
    	public Set<ActivityInputPort> getInputPorts(JsonNode configuration) {
    		Set<ActivityInputPort> inputPorts = new HashSet<>();
    		return inputPorts;
    	}
    
    	@Override
    	public Set<ActivityOutputPort> getOutputPorts(JsonNode configuration) {
    		Set<ActivityOutputPort> outputPorts = new HashSet<>();
    		return outputPorts;
    	}
    
    	public void setEdits(Edits edits) {
    		this.edits = edits;
    	}
    
    }
  2. Move any port creation code from ExampleActivity to ExampleActivityFactory. Note that port creation code is split into separate methods for inputs and outputs.

    Code Block
    languagejava
    	@Override
    	public Set<ActivityInputPort> getInputPorts(JsonNode configuration) {
    		Set<ActivityInputPort> inputPorts = new HashSet<>();
    
    		// Hard coded input port, expecting a single String
    		inputPorts.add(edits.createActivityInputPort(IN_FIRST_INPUT, 0, true, null, String.class));
    
    		// Optional ports depending on configuration
    
    		if (configuration.get("exampleString").asText().equals("specialCase")) {
    			// depth 1, ie. list of binary byte[] arrays
    			inputPorts.add(edits.createActivityInputPort(IN_EXTRA_DATA, 1, true, null, byte[].class));
    		}
    
    		return inputPorts;
    	}
    
    	@Override
    	public Set<ActivityOutputPort> getOutputPorts(JsonNode configuration) {
    		Set<ActivityOutputPort> outputPorts = new HashSet<>();
    
    		// Optional ports depending on configuration
    		if (configuration.get("exampleString").asText().equals("specialCase")) {
    			outputPorts.add(edits.createActivityOutputPort(OUT_REPORT, 0, 0));
    		}
    
    		// Single value output port (depth 0)
    		outputPorts.add(edits.createActivityOutputPort(OUT_SIMPLE_OUTPUT, 0, 0));
    		// Output port with list of values (depth 1)
    		outputPorts.add(edits.createActivityOutputPort(OUT_MORE_OUTPUTS, 1, 1));
    
    		return outputPorts;
    	}

...

ExampleActivityConfigBean.java

The config bean has been replaced by JSON configuration and is no longer used.

  1. Delete this file.
META-INF/services

The SPI configurations have been replaced by the Spring configurations.

  1. Delete this directory