-
Notifications
You must be signed in to change notification settings - Fork 14
Transactional Process API
Created By: Mohammed Abdelal Last Edited: May 28, 2020 1:29 PM
-
transactional
: Support for transactional algorithm repositories -
transactional-rest
: Extension of the OGC API - Processes with transactional support
To initialize an Algorithm Configuration you need to implement TransactionalAlgorithmConfigurer
that used to configure a TransactionalAlgorithmConfiguration
.
TransactionalAlgorithmConfigurer
is an interface that has one method called configure and it receives a parameter from type TransactionalAlgorithmConfiguration
which is used to add initial deployed application Packages.
Example:
@Configuration
public class InitialAlgorithmConfiguration implements TransactionalAlgorithmConfigurer {
private static final String STRING_REPLACE
= "https://raw.githubusercontent.com/mohammedsaad/string-replace/master/src/main/resources/application-package.json";
@Override
public void configure(TransactionalAlgorithmConfiguration configuration) {
configuration.addAlgorithmFromResource(STRING_REPLACE);
}
}
This InitialAlgorithmConfiguration
will be Autowired from spring in a set of TransactionalAlgorithmConfigurers
in a class called TransactionalAlgorithmRegistryImpl
.
@Autowired(required = false)
public void setConfigurers(Set<TransactionalAlgorithmConfigurer> configurers) {
this.configurers = Optional.ofNullable(configurers).orElseGet(Collections::emptySet);
}
TransactionalApi
Interface is an Extension of ProcessesApi
for transactional operations.
it includes the following operations :
Transactional API endpoints
endpoint | Method | URL | description |
---|---|---|---|
undeployProcess | delete | /processes/{processId} | |
deployProcess | post | /processes/ | The description of the new process (Json node that will be decoded to Application Packeage) |
updateProcess | put | /processes/{processId} | The description of the new process (Json node that will be decoded to Application Packeage) |
TransactionalApiImpl
implimenting the TransaltionalApi
and has dependency injection of the TransactionalAlgorithmRegistry
. TransactionalAlgorithmRegistry
instance of the initialized algorithm is used to register and unregister the given Process.
Examples :
@Override
public void undeployProcess(String id) throws ProcessNotFoundException, UndeletableProcessException {
registration.unregister(id);
}
@Override
public ResponseEntity<?> deployProcess(JsonNode request)
throws DuplicateProcessException, UnsupportedProcessException {
return ResponseEntity.created(getProcessURL(registration.register(decode(request)))).build();
}
The same is happening with UpdateProcess
@Override
public void updateProcess(String id, JsonNode request)
throws ProcessNotFoundException,
UnsupportedProcessException,
UndeletableProcessException {
OwsCode processIdFromPath = new OwsCode(id);
ApplicationPackage applicationPackage = decode(request);
OwsCode processId = applicationPackage
.getProcessDescription()
.getProcessDescription()
.getId();
if (!processId.equals(processIdFromPath)) {
throw new UnsupportedProcessException(
String.format("mismatching process identifiers %s vs. %s",
processIdFromPath.getValue(),
processId.getValue()));
}
registration.update(applicationPackage);
}
Request:
- request for deleting a process :
DELETE <http://localhost:8080/rest/processes/org.n52.docker.StringReplace> HTTP/1.1
Content-Type: application/json
Response:
the response to the previous request will contain a Header with status 204 No Content.
- request for adding a process :
POST <http://localhost:8080/rest/processes> HTTP/1.1
Content-Type: application/json
- request body :
{
"processDescription": {
"process": {
"id": "org.n52.project.tb15.eopad.NdviCalculation",
"title": "Calculation of NDVI using the SNAP toolbox for Sentinel-2",
"description": "Calculation of NDVI using the SNAP toolbox for Sentinel-2",
"version": "1.0.0",
"keywords": ["Vegetation", "NDVI"],
"inputs": [
{
"id": "source",
"title": "Source Input Image (sentinel-2 product in SAFE format)",
"description": "Source Input Image (sentinel-2 product in SAFE format). Either provided inline, by reference or by product ID",
"minOccurs": 1,
"maxOccurs": 1,
"input": {
"formats": [
{
"mimeType": "text/plain",
"default": true
},
{
"mimeType": "application/zip",
"default": false
}
]
}
},
{
"id": "red_source_band",
"title": "the band to be used for the red band",
"minOccurs": 0,
"maxOccurs": 1,
"input": {
"literalDataDomains": [
{
"default": true,
"dataType": { "name": "integer" },
"valueDefinition": [
{
"minimumValue": "1",
"maximumValue": "13",
"rangeClosure": "closed"
}
]
}
]
}
},
{
"id": "nir_source_band",
"title": "the band to be used for the near-infrared band",
"minOccurs": 0,
"maxOccurs": 1,
"input": {
"literalDataDomains": [
{
"default": true,
"dataType": { "name": "integer" },
"valueDefinition": [
{
"minimumValue": "1",
"maximumValue": "13",
"rangeClosure": "closed"
}
]
}
]
}
},
{
"id": "red_factor",
"title": "the factor of the NRI",
"minOccurs": 0,
"maxOccurs": 1,
"input": {
"literalDataDomains": [
{
"default": true,
"defaultValue": "1.0",
"dataType": { "name": "float" },
"valueDefinition": [
{
"minimumValue": "0.0",
"rangeClosure": "closed"
}
]
}
]
}
},
{
"id": "nir_factor",
"title": "the factor of the NIR",
"minOccurs": 0,
"maxOccurs": 1,
"input": {
"literalDataDomains": [
{
"default": true,
"defaultValue": "1.0",
"dataType": { "name": "float" },
"valueDefinition": [
{
"minimumValue": "0.0",
"rangeClosure": "closed"
}
]
}
]
}
},
{
"id": "cloud_coverage",
"title": "The cloud coverage of the scene.",
"minOccurs": 0,
"maxOccurs": 1,
"input": {
"literalDataDomains": [
{
"default": true,
"dataType": { "name": "float" },
"valueDefinition": [
{
"minimumValue": "0.0",
"maximumValue": "100.0",
"rangeClosure": "closed"
}
]
}
]
}
},
{
"id": "max_cloud_coverage",
"title": "The maximum cloud coverage of the scene.",
"minOccurs": 0,
"maxOccurs": 1,
"input": {
"literalDataDomains": [
{
"default": true,
"dataType": { "name": "float" },
"valueDefinition": [
{
"minimumValue": "0.0",
"maximumValue": "100.0",
"rangeClosure": "closed"
}
]
}
]
}
}
],
"outputs": [
{
"id": "raster",
"title": "The raster of the resulting NDVI calculation",
"output": {
"formats": [
{
"mimeType": "image/geotiff",
"default": true
}
]
}
}
]
},
"jobControlOptions": ["async-execute"],
"outputTransmission": ["reference"]
},
"immediateDeployment": true,
"executionUnit": [
{
"unit": {
"type": "docker",
"image": "52north/testbed-eopad-ndvi:latest"
}
}
],
"deploymentProfileName": "http://www.opengis.net/profiles/eoc/dockerizedApplication"
}
the response to the previous request will contain a Header with status 201 created.
- request for Updating a process :
PUT <http://localhost:8080/rest/processes/org.n52.project.tb15.eopad.NdviCalculation> HTTP/1.1
Content-Type: application/json
- request body :
{
"processDescription": {
"process": {
"id": "org.n52.project.tb15.eopad.NdviCalculation",
"title": "Calculation of NDVI using the SNAP toolbox for Sentinel-2",
"description": "Calculation of NDVI using the SNAP toolbox for Sentinel-2",
"version": "1.0.0",
"keywords": ["Vegetation", "NDVI"],
"inputs": [
{
"id": "source",
"title": "Source Input Image (sentinel-2 product in SAFE format)",
"description": "Source Input Image (sentinel-2 product in SAFE format). Either provided inline, by reference or by product ID",
"minOccurs": 1,
"maxOccurs": 1,
"input": {
"formats": [
{
"mimeType": "text/plain",
"default": true
},
{
"mimeType": "application/zip",
"default": false
}
]
}
},
{
"id": "red_source_band",
"title": "the band to be used for the red band",
"minOccurs": 0,
"maxOccurs": 1,
"input": {
"literalDataDomains": [
{
"default": true,
"dataType": { "name": "integer" },
"valueDefinition": [
{
"minimumValue": "1",
"maximumValue": "13",
"rangeClosure": "closed"
}
]
}
]
}
},
{
"id": "nir_source_band",
"title": "the band to be used for the near-infrared band",
"minOccurs": 0,
"maxOccurs": 1,
"input": {
"literalDataDomains": [
{
"default": true,
"dataType": { "name": "integer" },
"valueDefinition": [
{
"minimumValue": "1",
"maximumValue": "13",
"rangeClosure": "closed"
}
]
}
]
}
},
{
"id": "red_factor",
"title": "the factor of the NRI",
"minOccurs": 0,
"maxOccurs": 1,
"input": {
"literalDataDomains": [
{
"default": true,
"defaultValue": "1.0",
"dataType": { "name": "float" },
"valueDefinition": [
{
"minimumValue": "0.0",
"rangeClosure": "closed"
}
]
}
]
}
},
{
"id": "nir_factor",
"title": "the factor of the NIR",
"minOccurs": 0,
"maxOccurs": 1,
"input": {
"literalDataDomains": [
{
"default": true,
"defaultValue": "1.0",
"dataType": { "name": "float" },
"valueDefinition": [
{
"minimumValue": "0.0",
"rangeClosure": "closed"
}
]
}
]
}
},
{
"id": "cloud_coverage",
"title": "The cloud coverage of the scene.",
"minOccurs": 0,
"maxOccurs": 1,
"input": {
"literalDataDomains": [
{
"default": true,
"dataType": { "name": "float" },
"valueDefinition": [
{
"minimumValue": "0.0",
"maximumValue": "100.0",
"rangeClosure": "closed"
}
]
}
]
}
},
{
"id": "max_cloud_coverage",
"title": "The maximum cloud coverage of the scene.",
"minOccurs": 0,
"maxOccurs": 1,
"input": {
"literalDataDomains": [
{
"default": true,
"dataType": { "name": "float" },
"valueDefinition": [
{
"minimumValue": "0.0",
"maximumValue": "100.0",
"rangeClosure": "closed"
}
]
}
]
}
}
],
"outputs": [
{
"id": "raster",
"title": "The raster of the resulting NDVI calculation",
"output": {
"formats": [
{
"mimeType": "image/geotiff",
"default": true
}
]
}
}
]
},
"jobControlOptions": ["async-execute"],
"outputTransmission": ["reference"]
},
"immediateDeployment": true,
"executionUnit": [
{
"unit": {
"type": "docker",
"image": "52north/testbed-eopad-ndvi:latest"
}
}
],
"deploymentProfileName": "http://www.opengis.net/profiles/eoc/dockerizedApplication"
}
the response to the previous request will contain a Header with status 204 No Content.