Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Koller2018-07-25 07:47:10 +0000
committerMatthias Koller2018-07-25 07:47:10 +0000
commitfe43a237820ea2186513ebf4b93bfa455338b310 (patch)
treee66f036d219aca620051004a85eb5265a8b6d34c
parentc0b640bc843b87a85bec89f5285e3dffdc514e00 (diff)
parent64c3b3fb7939b47b6b5915f30a7d77960534351c (diff)
downloadorg.eclipse.mdm.nucleus-fe43a237820ea2186513ebf4b93bfa455338b310.tar.gz
org.eclipse.mdm.nucleus-fe43a237820ea2186513ebf4b93bfa455338b310.tar.xz
org.eclipse.mdm.nucleus-fe43a237820ea2186513ebf4b93bfa455338b310.zip
Merge remote-tracking branch 'origin/anehmer/restapi' into dev
Conflicts: org.eclipse.mdm.businessobjects/build.gradle Signed-off-by: Matthias Koller <m.koller@peak-solution.de>
-rw-r--r--README.md195
-rw-r--r--org.eclipse.mdm.application/src/main/webconfig/web.xml2
-rw-r--r--org.eclipse.mdm.businessobjects/build.gradle8
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogAttributeResource.java229
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogComponentResource.java202
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogSensorAttributeResource.java232
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogSensorResource.java220
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/EnvironmentResource.java49
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/NestedTemplateAttributeResource.java229
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/NestedTemplateComponentResource.java224
-rwxr-xr-xorg.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/PhysicalDimensionResource.java186
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ProjectResource.java87
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/QuantityResource.java194
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ResourceConstants.java114
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateAttributeResource.java216
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateComponentResource.java220
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateRootResource.java204
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateSensorAttributeResource.java190
-rwxr-xr-xorg.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateSensorResource.java224
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateTestResource.java183
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateTestStepResource.java192
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateTestStepUsageResource.java206
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/UnitResource.java192
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ValueListResource.java188
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ValueListValueResource.java200
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/entity/MDMEntityResponse.java1
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/service/DataAccessHelper.java128
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/service/EntityService.java762
-rwxr-xr-xorg.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/EntityNotFoundException.java50
-rwxr-xr-xorg.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/ISODateDeseralizer.java70
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/RequestBody.java135
-rw-r--r--org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/ServiceUtils.java202
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogAttributeTEQResourceIntegrationTest.java70
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogAttributeTSQResourceIntegrationTest.java68
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogAttributeUUTResourceIntegrationTest.java69
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogComponentTEQResourceIntegrationTest.java45
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogComponentTSQResourceIntegrationTest.java44
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogComponentUUTResourceIntegrationTest.java45
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogSensorAttributeResourceIntegrationTest.java61
-rwxr-xr-xorg.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogSensorResourceIntegrationTest.java54
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/EntityResourceIntegrationTest.java474
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateAttributeTEQResourceIntegrationTest.java77
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateAttributeTSQResourceIntegrationTest.java76
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateAttributeUUTResourceIntegrationTest.java76
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateComponentTEQResourceIntegrationTest.java67
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateComponentTSQResourceIntegrationTest.java67
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateComponentUUTResourceIntegrationTest.java67
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/PhysicalDimensionResourceIntegrationTest.java47
-rwxr-xr-xorg.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/QuantityResourceIntegrationTest.java57
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateAttributeTEQResourceIntegrationTest.java73
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateAttributeTSQResourceIntegrationTest.java73
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateAttributeUUTResourceIntegrationTest.java73
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateComponentTEQResourceIntegrationTest.java64
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateComponentTSQResourceIntegrationTest.java64
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateComponentUUTResourceIntegrationTest.java64
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateRootTEQResourceIntegrationTest.java51
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateRootTSQResourceIntegrationTest.java51
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateRootUUTResourceIntegrationTest.java51
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateSensorAttributeResourceIntegrationTest.java93
-rwxr-xr-xorg.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateSensorResourceIntegrationTest.java83
-rwxr-xr-xorg.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateTestResourceIntegrationTest.java50
-rwxr-xr-xorg.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateTestStepResourceIntegrationTest.java79
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateTestStepUsageResourceIntegrationTest.java72
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/UnitResourceIntegrationTest.java61
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/ValueListResourceIntegrationTest.java43
-rw-r--r--org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/ValueListValueResourceIntegrationTest.java55
66 files changed, 8270 insertions, 28 deletions
diff --git a/README.md b/README.md
index 93d742b0..188570e3 100644
--- a/README.md
+++ b/README.md
@@ -121,6 +121,201 @@ MDM 5 uses SLF4J and logback for logging. The default configuration file can be
* http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/pools/POOLID
* _example: http://localhost:8080/org.eclipse.mdm.nucleus/mdm/environments/MDMDATASOURCE1/pools/123_
+**Business Object: ValueList**
+
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists/VALUELISTID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists (JSON: { "name" : "testValueList" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists/VALUELISTID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists/VALUELISTID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists/localizations
+
+**Business Object: ValueListValue**
+
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists/VALUELISTID/valuelistvalues/VALUELISTVALUEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists/VALUELISTID/valuelistvalues
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists/VALUELISTID/valuelistvalues (JSON: { "name" : "testValueListValue" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists/VALUELISTID/valuelistvalues/VALUELISTVALUEID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists/VALUELISTID/valuelistvalues/VALUELISTVALUEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists/VALUELISTID/valuelistvalues/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/valuelists/VALUELISTID/valuelistvalues/localizations
+
+**Business Object: PhysicalDimension**
+
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/physicaldimensions/PHYSICALDIMENSIONID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/physicaldimensions
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/physicaldimensions (JSON: { "name" : "testPhysicalDimension" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/physicaldimensions/PHYSICALDIMENSIONID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/physicaldimensions/PHYSICALDIMENSIONID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/physicaldimensions/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/physicaldimensions/localizations
+
+**Business Object: Unit**
+
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/units/UNITID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/units
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/units (JSON: { "name" : "testUnit", "physicaldimension" : "PHYSICALDIMENSIONID" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/units/UNITID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/units/UNITID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/units/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/units/localizations
+
+**Business Object: Quantity**
+
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/quantities/QUANTITYID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/quantities
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/quantities (JSON: { "name" : "testQuantity", "unit" : "UNITID" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/quantities/QUANTITYID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/quantities/QUANTITYID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/quantities/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/quantities/localizations
+
+**Business Object: CatalogComponent**
+
+* CONTEXTTYPE is one of [unitundertest, testsequence, testequipment]
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE/CATALOGCOMPONENTID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE (JSON: { "name" : "testCatalogComponent" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE/CATALOGCOMPONENTID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE/CATALOGCOMPONENTID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE/localizations
+
+**Business Object: CatalogAttribute**
+
+* CONTEXTTYPE is one of [unitundertest, testsequence, testequipment]
+* DATATYPE is one of [STRING, STRING_SEQUENCE, DATE, DATE_SEQUENCE, BOOLEAN, BOOLEAN_SEQUENCE, BYTE, BYTE_SEQUENCE, SHORT, SHORT_SEQUENCE, INTEGER, INTEGER_SEQUENCE, LONG, LONG_SEQUENCE, FLOAT, FLOAT_SEQUENCE, DOUBLE, DOUBLE_SEQUENCE, BYTE_STREAM, BYTE_STREAM_SEQUENCE, FLOAT_COMPLEX, FLOAT_COMPLEX_SEQUENCE, DOUBLE_COMPLEX, DOUBLE_COMPLEX_SEQUENCE, FILE_LINK, FILE_LINK_SEQUENCE]
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE/CATALOGCOMPONENTID/catattrs/CATALOGATTRIBUTEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE/CATALOGCOMPONENTID/catattrs
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE/CATALOGCOMPONENTID/catattrs (JSON: { "name" : "testCatalogAttribute", "datatype" : "DATATYPE" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE/CATALOGCOMPONENTID/catattrs/CATALOGATTRIBUTEID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE/CATALOGCOMPONENTID/catattrs/CATALOGATTRIBUTEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE/CATALOGCOMPONENTID/catattrs/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/CONTEXTTYPE/CATALOGCOMPONENTID/catattrs/localizations
+
+**Business Object: CatalogSensor**
+
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors/CATALOGSENSORID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors (JSON: { "name" : "testCatalogSensor" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors/CATALOGSENSORID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors/CATALOGSENSORID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors/localizations
+
+**Business Object: CatalogSensorAttribute**
+
+* DATATYPE is one of [STRING, STRING_SEQUENCE, DATE, DATE_SEQUENCE, BOOLEAN, BOOLEAN_SEQUENCE, BYTE, BYTE_SEQUENCE, SHORT, SHORT_SEQUENCE, INTEGER, INTEGER_SEQUENCE, LONG, LONG_SEQUENCE, FLOAT, FLOAT_SEQUENCE, DOUBLE, DOUBLE_SEQUENCE, BYTE_STREAM, BYTE_STREAM_SEQUENCE, FLOAT_COMPLEX, FLOAT_COMPLEX_SEQUENCE, DOUBLE_COMPLEX, DOUBLE_COMPLEX_SEQUENCE, FILE_LINK, FILE_LINK_SEQUENCE]
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors/CATALOGSENSORID/catsensorattrs/CATALOGATTRIBUTEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors/CATALOGSENSORID/catsensorattrs
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors/CATALOGSENSORID/catsensorattrs (JSON: { "name" : "testCatalogAttribute", "datatype" : "DATATYPE" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors/CATALOGSENSORID/catsensorattrs/CATALOGATTRIBUTEID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors/CATALOGSENSORID/catsensorattrs/CATALOGATTRIBUTEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors/CATALOGSENSORID/catsensorattrs/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/catcomps/testequipment/CATALOGCOMPONENTID/catsensors/CATALOGSENSORID/catsensorattrs/localizations
+
+**Business Object: TemplateRoot**
+
+* CONTEXTTYPE is one of [unitundertest, testsequence, testequipment]
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE (JSON: { "name" : "testTemplateRoot" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/localizations
+
+**Business Object: TemplateComponent**
+
+* CONTEXTTYPE is one of [unitundertest, testsequence, testequipment]
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps (JSON: { "name" : "testTemplateComponent", "catalogcomponent" : "CATALOGCOMPONENTID" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/localizations
+
+**Business Object: TemplateAttribute**
+
+* CONTEXTTYPE is one of [unitundertest, testsequence, testequipment]
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplattrs/TEMPLATEATTRIBUTEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplattrs
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplattrs (JSON: { "name" : "testCatalogAttribute" } (name must be identical with corresponding CatalogAttribute))
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplattrs/TEMPLATEATTRIBUTEID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplattrs/TEMPLATEATTRIBUTEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplattrs/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplattrs/localizations
+
+**Business Object: TemplateSensor**
+
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/testequipment/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplsensors/TEMPLATESENSORID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/testequipment/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplsensors
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/testequipment/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplsensors (JSON: { "name" : "testTemplateSensor", "catalogsensor" : "CATALOGSENSORID", "quantity" : "QUANTITYID" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/testequipment/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplsensors/TEMPLATESENSORID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/testequipment/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplsensors/TEMPLATESENSORID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/testequipment/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplsensors/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/testequipment/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplsensors/localizations
+
+**Business Object: TemplateSensorAttribute**
+
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/testequipment/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplsensors/TEMPLATESENSORID/tplsensorattrs/TEMPLATEATTRIBUTEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/testequipment/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplsensors/TEMPLATESENSORID/tplsensorattrs
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/testequipment/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplsensors/TEMPLATESENSORID/tplsensorattrs/TEMPLATEATTRIBUTEID (JSON: { "MimeType" : "myMimeType" })
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/testequipment/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplsensors/TEMPLATESENSORID/tplsensorattrs/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/testequipment/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplsensors/TEMPLATESENSORID/tplsensorattrs/localizations
+
+**Business Object: NestedTemplateComponent**
+
+* CONTEXTTYPE is one of [unitundertest, testsequence, testequipment]
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps/NESTEDTEMPLATECOMPONENTID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps (JSON: { "name" : "testNestedTemplateComponent", "catalogcomponent" : "CATALOGCOMPONENTID" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps/NESTEDTEMPLATECOMPONENTID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps/NESTEDTEMPLATECOMPONENTID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps/localizations
+
+**Business Object: NestedTemplateAttribute**
+
+* CONTEXTTYPE is one of [unitundertest, testsequence, testequipment]
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps/NESTEDTEMPLATECOMPONENTID/tplattrs/NESTEDTEMPLATEATTRIBUTEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps/NESTEDTEMPLATECOMPONENTID/tplattrs
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps/NESTEDTEMPLATECOMPONENTID/tplattrs (JSON: { "name" : "testCatalogAttribute" } (name must be identical with corresponding CatalogAttribute))
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps/NESTEDTEMPLATECOMPONENTID/tplattrs/NESTEDTEMPLATEATTRIBUTEID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps/NESTEDTEMPLATECOMPONENTID/tplattrs/NESTEDTEMPLATEATTRIBUTEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps/NESTEDTEMPLATECOMPONENTID/tplattrs/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplroots/CONTEXTTYPE/TEMPLATEROOTID/tplcomps/TEMPLATECOMPONENTID/tplcomps/NESTEDTEMPLATECOMPONENTID/tplattrs/localizations
+
+**Business Object: TemplateTest**
+
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests/TEMPLATETESTID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests (JSON: { "name" : "testTemplateTest" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests/TEMPLATETESTID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests/TEMPLATETESTID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests/localizations
+
+**Business Object: TemplateTestStep**
+
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplteststeps/TEMPLATETESTSTEPID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplteststeps
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplteststeps (JSON: { "name" : "testTemplateTestStep" })
+* PUT: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplteststeps/TEMPLATETESTSTEPID (JSON: { "MimeType" : "myMimeType" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplteststeps/TEMPLATETESTSTEPID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplteststeps/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tplteststeps/localizations
+
+**Business Object: TemplateTestStepUsage**
+
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests/TEMPLATETESTID/tplteststepusages/TEMPLATETESTSTEPUSAGEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests/TEMPLATETESTID/tplteststepusages
+* POST: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests/TEMPLATETESTID/tplteststepusages (JSON: { "name" : "testTemplateTestStepUsage", "tplteststep" : "TEMPLATETESTSTEPID" })
+* DELETE: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests/TEMPLATETESTID/tplteststepusages/TEMPLATETESTSTEPUSAGEID
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests/TEMPLATETESTID/tplteststepusages/searchattributes
+* GET: http://SERVER:PORT/APPLICATIONROOT/mdm/environments/SOURCENAME/tpltests/TEMPLATETESTID/tplteststepusages/localizations
**Query endpoint**
diff --git a/org.eclipse.mdm.application/src/main/webconfig/web.xml b/org.eclipse.mdm.application/src/main/webconfig/web.xml
index 49ecde64..7ef11857 100644
--- a/org.eclipse.mdm.application/src/main/webconfig/web.xml
+++ b/org.eclipse.mdm.application/src/main/webconfig/web.xml
@@ -42,7 +42,7 @@
</security-role>
<login-config>
- <auth-method>FORM</auth-method>
+ <auth-method>BASIC</auth-method>
<realm-name>MDMLoginRealm</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
diff --git a/org.eclipse.mdm.businessobjects/build.gradle b/org.eclipse.mdm.businessobjects/build.gradle
index 1bdfe490..06028490 100644
--- a/org.eclipse.mdm.businessobjects/build.gradle
+++ b/org.eclipse.mdm.businessobjects/build.gradle
@@ -16,7 +16,9 @@ apply plugin: 'antlr'
dependencies {
compile project(':org.eclipse.mdm.connector')
compile 'com.fasterxml.jackson.core:jackson-databind:2.8.6'
-
+ compile 'io.vavr:vavr:0.9.1'
+ testCompile 'org.assertj:assertj-core:3.6.2'
+ testCompile 'io.rest-assured:rest-assured:3.0.5'
testCompile 'org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:2.23.2'
testCompile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.23.2'
@@ -25,6 +27,10 @@ dependencies {
generateGrammarSource { arguments += ["-visitor"] }
+test {
+ exclude 'org/eclipse/mdm/businessobjects/boundary/integrationtest/*'
+}
+
compileJava.dependsOn(generateGrammarSource)
jar {
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogAttributeResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogAttributeResource.java
new file mode 100644
index 00000000..a6a2c5cd
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogAttributeResource.java
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_DATATYPE;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_CONTEXTTYPE;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID2;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.SL;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.CatalogAttribute;
+import org.eclipse.mdm.api.dflt.model.CatalogComponent;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+import io.vavr.collection.List;
+
+/**
+ * {@link CatalogAttribute} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/catcomps/{" + REQUESTPARAM_CONTEXTTYPE + "}/{" + REQUESTPARAM_ID
+ + "}/catattrs")
+public class CatalogAttributeResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link CatalogAttribute}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link CatalogAttribute} to load
+ * @param id
+ * id of the {@link CatalogAttribute}
+ * @return the found {@link CatalogAttribute} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String catCompId,
+ @PathParam(REQUESTPARAM_ID2) String id) {
+ return entityService
+ .find(V(sourceName), CatalogAttribute.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(catCompId))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link CatalogAttribute}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextTypeParam
+ * {@link ContextType} of the {@link CatalogAttribute} to load
+ * @param filter
+ * filter string to filter the {@link CatalogAttribute} result
+ * @return the (filtered) {@link CatalogAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String catCompId,
+ @QueryParam("filter") String filter) {
+ return entityService
+ .find(V(sourceName), CatalogComponent.class, V(catCompId),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam))
+ .map(catComp -> List.ofAll(catComp.getCatalogAttributes()))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link CatalogAttributeValue}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextTypeParam
+ * {@link ContextType} of the {@link CatalogAttribute} to load
+ * @param catCompId
+ * the identifier of the {@link CatalogComponent} to create an attribute for.
+ * @param body
+ * the body of the request containing the attributes to update
+ * The {@link CatalogAttribute} to create.
+ * @return the created {@link CatalogAttribute} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String catCompId,
+ String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), CatalogAttribute.class,
+ L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME),
+ entityService.getEnumerationValueSupplier(
+ requestBody.getStringValueSupplier(ENTITYATTRIBUTE_DATATYPE)),
+ entityService.find(V(sourceName), CatalogComponent.class, V(catCompId),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam))))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link CatalogAttribute} with all parameters set in the given
+ * JSON body of the request
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextTypeParam
+ * {@link ContextType} of the {@link CatalogAttribute} to load
+ * @param id
+ * the identifier of the {@link CatalogAttribute} to update.
+ * @param catCompId
+ * the identifier of the parent {@link CatalogComponent}.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link CatalogAttribute}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID2) String id,
+ @PathParam(REQUESTPARAM_ID) String catCompId, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName),
+ entityService.find(V(sourceName), CatalogAttribute.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(catCompId)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link CatalogAttribute}.
+ *
+ * @param id
+ * The identifier of the {@link CatalogAttribute} to delete.
+ * @return the deleted {@link CatalogAttribute }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String catCompId,
+ @PathParam(REQUESTPARAM_ID2) String id) {
+ return entityService
+ .delete(V(sourceName),
+ entityService.find(V(sourceName), CatalogAttribute.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(catCompId)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link CatalogAttribute} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), CatalogAttribute.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), CatalogAttribute.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogComponentResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogComponentResource.java
new file mode 100644
index 00000000..b32aeb6e
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogComponentResource.java
@@ -0,0 +1,202 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_CONTEXTTYPE;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.CatalogComponent;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+/**
+ * {@link CatalogComponent} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/catcomps/{" + REQUESTPARAM_CONTEXTTYPE + "}")
+public class CatalogComponentResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link CatalogComponent}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link CatalogComponent} to load
+ * @param id
+ * id of the {@link CatalogComponent}
+ * @return the found {@link CatalogComponent} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService
+ .find(V(sourceName), CatalogComponent.class, V(id), ServiceUtils.getContextTypeSupplier(contextTypeParam))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link CatalogComponent}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link CatalogComponent} to load
+ * @param filter
+ * filter string to filter the {@link CatalogComponent} result
+ * @return the (filtered) {@link CatalogComponent}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @QueryParam("filter") String filter) {
+ return entityService
+ .findAll(V(sourceName), CatalogComponent.class, filter,
+ ServiceUtils.getContextTypeSupplier(contextTypeParam))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link CatalogComponentValue}.
+ *
+ * @param body
+ * The {@link CatalogComponent} to create.
+ * @return the created {@link CatalogComponent} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), CatalogComponent.class,
+ L(ServiceUtils.getContextTypeSupplier(contextTypeParam),
+ requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link CatalogComponent} with all parameters set in the given
+ * JSON body of the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link CatalogComponent} to delete.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link CatalogComponent}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String id,
+ String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName),
+ entityService.find(V(sourceName), CatalogComponent.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link CatalogComponent}.
+ *
+ * @param id
+ * The identifier of the {@link CatalogComponent} to delete.
+ * @return the deleted {@link CatalogComponent }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService
+ .delete(V(sourceName),
+ entityService.find(V(sourceName), CatalogComponent.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link CatalogComponent} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), CatalogComponent.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), CatalogComponent.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogSensorAttributeResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogSensorAttributeResource.java
new file mode 100644
index 00000000..714009bf
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogSensorAttributeResource.java
@@ -0,0 +1,232 @@
+/*******************************************************************************
+ * Copyright (c) 2018 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Philipp Schweinbenz - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_DATATYPE;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID2;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID3;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.SL;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.CatalogAttribute;
+import org.eclipse.mdm.api.dflt.model.CatalogComponent;
+import org.eclipse.mdm.api.dflt.model.CatalogSensor;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+import io.vavr.collection.List;
+
+/**
+ * {@link CatalogAttribute} resource handling REST requests
+ *
+ * @author Philipp Schweinbenz, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/catcomps/testequipment/{" + REQUESTPARAM_ID + "}/catsensors/{"
+ + REQUESTPARAM_ID2
+ + "}/catsensorattrs")
+public class CatalogSensorAttributeResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link CatalogAttribute}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param catCompId
+ * id of the {@link CatalogComponent}
+ * @param sensorId
+ * id of the {@link CatalogSensor}
+ * @param id
+ * id of the {@link CatalogAttribute}
+ * @return the found {@link CatalogAttribute} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID3 + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String catCompId, @PathParam(REQUESTPARAM_ID2) String sensorId,
+ @PathParam(REQUESTPARAM_ID3) String id) {
+ return entityService
+ .find(V(sourceName), CatalogAttribute.class, V(id),
+ V(ContextType.TESTEQUIPMENT), SL(catCompId, sensorId))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER).getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link CatalogAttribute}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param catCompId
+ * id of the {@link CatalogComponent}
+ * @param sensorId
+ * id of the {@link CatalogSensor}
+ * @param filter
+ * filter string to filter the {@link CatalogAttribute} result
+ * @return the (filtered) {@link CatalogAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String catCompId, @PathParam(REQUESTPARAM_ID2) String sensorId,
+ @QueryParam("filter") String filter) {
+ return entityService
+ .find(V(sourceName), CatalogSensor.class, V(sensorId), V(ContextType.TESTEQUIPMENT), SL(catCompId))
+ .map(catSensor -> List.ofAll(catSensor.getCatalogAttributes()))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER).getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link CatalogAttributeValue}.
+ *
+ * @param catCompId
+ * id of the {@link CatalogComponent}
+ * @param sensorId
+ * id of the {@link CatalogSensor}
+ * @param body
+ * The {@link CatalogAttribute} to create.
+ * @return the created {@link CatalogAttribute} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String catCompId,
+ @PathParam(REQUESTPARAM_ID2) String sensorId, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), CatalogAttribute.class,
+ L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME),
+ entityService.getEnumerationValueSupplier(
+ requestBody.getStringValueSupplier(ENTITYATTRIBUTE_DATATYPE)),
+ entityService.find(V(sourceName), CatalogSensor.class, V(sensorId),
+ V(ContextType.TESTEQUIPMENT), SL(catCompId))))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER).getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link CatalogAttribute} with all parameters set in the given
+ * JSON body of the request
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param catCompId
+ * id of the {@link CatalogComponent}
+ * @param sensorId
+ * id of the {@link CatalogSensor}
+ * @param id
+ * the identifier of the {@link CatalogAttribute} to delete.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link CatalogAttribute}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID3 + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String catCompId, @PathParam(REQUESTPARAM_ID2) String sensorId,
+ @PathParam(REQUESTPARAM_ID3) String id, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName),
+ entityService.find(V(sourceName), CatalogAttribute.class, V(id),
+ V(ContextType.TESTEQUIPMENT), SL(catCompId, sensorId)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link CatalogAttribute}.
+ *
+ * @param catCompId
+ * id of the {@link CatalogComponent}
+ * @param sensorId
+ * id of the {@link CatalogSensor}
+ * @param id
+ * The identifier of the {@link CatalogAttribute} to delete.
+ * @return the deleted {@link CatalogAttribute }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID3 + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String catCompId, @PathParam(REQUESTPARAM_ID2) String sensorId,
+ @PathParam(REQUESTPARAM_ID3) String id) {
+ return entityService
+ .delete(V(sourceName),
+ entityService.find(V(sourceName), CatalogAttribute.class, V(id),
+ V(ContextType.TESTEQUIPMENT), SL(catCompId, sensorId)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK)).recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link CatalogAttribute} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), CatalogAttribute.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), CatalogAttribute.class, entityService);
+ }
+
+}
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogSensorResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogSensorResource.java
new file mode 100644
index 00000000..8d93348b
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/CatalogSensorResource.java
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID2;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.SL;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.CatalogComponent;
+import org.eclipse.mdm.api.dflt.model.CatalogSensor;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+import io.vavr.collection.List;
+
+/**
+ * {@link CatalogSensor} resource handling REST requests
+ *
+ * @author Philipp Schweinbenz, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/catcomps/testequipment/{" + REQUESTPARAM_ID
+ + "}/catsensors")
+public class CatalogSensorResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link CatalogSensor}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param catCompId
+ * id of the {@link CatalogComponent}
+ * @param id
+ * id of the {@link CatalogSensor}
+ * @return the found {@link CatalogSensor} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String catCompId, @PathParam(REQUESTPARAM_ID2) String id) {
+ return entityService
+ .find(V(sourceName), CatalogSensor.class, V(id), V(ContextType.TESTEQUIPMENT),
+ SL(catCompId))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link CatalogSensor}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param catCompId
+ * id of the {@link CatalogComponent}
+ * @param filter
+ * filter string to filter the {@link CatalogSensor} result
+ * @return the (filtered) {@link CatalogSensor}s as {@link Response}
+ */
+ // FIXME anehmer on 2017-11-17: returns all CatalogSensors and not only the ones
+ // in the superordinate CatalogComponent
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String catCompId, @QueryParam("filter") String filter) {
+ return entityService.find(V(sourceName), CatalogComponent.class, V(catCompId), V(ContextType.TESTEQUIPMENT))
+ .map(catComp -> List.ofAll(catComp.getCatalogSensors()))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link CatalogSensor}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param catCompId
+ * id of the {@link CatalogComponent}
+ * @param body
+ * The {@link CatalogSensor} to create.
+ * @return the created {@link CatalogSensor} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String catCompId, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), CatalogSensor.class,
+ L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME),
+ entityService.find(V(sourceName), CatalogComponent.class, V(catCompId),
+ V(ContextType.TESTEQUIPMENT))))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link CatalogSensor} with all parameters set in the given JSON
+ * body of the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param catCompId
+ * id of the {@link CatalogComponent}
+ * @param id
+ * the identifier of the {@link CatalogSensor} to delete.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link CatalogSensor}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String catCompId, @PathParam(REQUESTPARAM_ID2) String id, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName),
+ entityService.find(V(sourceName), CatalogSensor.class, V(id), V(ContextType.TESTEQUIPMENT),
+ SL(catCompId)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link CatalogSensor}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param catCompId
+ * id of the {@link CatalogComponent}
+ * @param id
+ * The identifier of the {@link CatalogSensor} to delete.
+ * @return the deleted {@link CatalogSensor }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String catCompId, @PathParam(REQUESTPARAM_ID2) String id) {
+ return entityService
+ .delete(V(sourceName),
+ entityService.find(V(sourceName), CatalogSensor.class, V(id), V(ContextType.TESTEQUIPMENT),
+ SL(catCompId)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link CatalogSensor} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), CatalogSensor.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), CatalogSensor.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/EnvironmentResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/EnvironmentResource.java
index e45fa1e1..f8c438ed 100644
--- a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/EnvironmentResource.java
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/EnvironmentResource.java
@@ -11,11 +11,16 @@
package org.eclipse.mdm.businessobjects.boundary;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
import java.util.List;
import java.util.Map;
import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@@ -31,10 +36,14 @@ import org.eclipse.mdm.api.base.model.Entity;
import org.eclipse.mdm.api.base.model.Environment;
import org.eclipse.mdm.businessobjects.entity.I18NResponse;
import org.eclipse.mdm.businessobjects.entity.MDMEntityResponse;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import io.vavr.control.Try;
+
/**
* {@link Environment} resource
*
@@ -49,6 +58,9 @@ public class EnvironmentResource {
@EJB
private EnvironmentService environmentService;
+ @EJB
+ private EntityService entityService;
+
/**
* delegates the request to the {@link EnvironmentService}
*
@@ -75,8 +87,8 @@ public class EnvironmentResource {
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
- @Path("/{SOURCENAME}")
- public Response getEnvironment(@PathParam("SOURCENAME") String sourceName) {
+ @Path("/{" + REQUESTPARAM_SOURCENAME + "}")
+ public Response getEnvironment(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
try {
Environment environment = this.environmentService.getEnvironment(sourceName);
return ServiceUtils.toResponse(new MDMEntityResponse(Environment.class, environment), Status.OK);
@@ -87,6 +99,31 @@ public class EnvironmentResource {
}
/**
+ * Updates the {@link Environment} with all parameters set in the given JSON
+ * body of the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link Environment}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_SOURCENAME + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName), Try.of(() -> this.environmentService.getEnvironment(sourceName)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
* delegates the request to the {@link EnvironmentService}
*
* @param sourceName
@@ -95,8 +132,8 @@ public class EnvironmentResource {
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
- @Path("/{SOURCENAME}/localizations")
- public Response localize(@PathParam("SOURCENAME") String sourceName, @QueryParam("all") boolean all) {
+ @Path("/{" + REQUESTPARAM_SOURCENAME + "}/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @QueryParam("all") boolean all) {
try {
@@ -120,8 +157,8 @@ public class EnvironmentResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
- @Path("/{SOURCENAME}/search")
- public Response search(@PathParam("SOURCENAME") String sourceName, @QueryParam("q") String query) {
+ @Path("/{" + REQUESTPARAM_SOURCENAME + "}/search")
+ public Response search(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @QueryParam("q") String query) {
List<Entity> searchResults = environmentService.search(sourceName, query);
return ServiceUtils.toResponse(new MDMEntityResponse(Environment.class, searchResults), Status.OK);
}
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/NestedTemplateAttributeResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/NestedTemplateAttributeResource.java
new file mode 100644
index 00000000..f0faf3d3
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/NestedTemplateAttributeResource.java
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_CONTEXTTYPE;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID2;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID3;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID4;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.SL;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.TemplateAttribute;
+import org.eclipse.mdm.api.dflt.model.TemplateComponent;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+import io.vavr.collection.List;
+
+/**
+ * {@link NestedTemplateAttribute} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/tplroots/{" + REQUESTPARAM_CONTEXTTYPE + "}/{" + REQUESTPARAM_ID
+ + "}/tplcomps/{" + REQUESTPARAM_ID2 + "}/tplcomps/{" + REQUESTPARAM_ID3 + "}/tplattrs")
+public class NestedTemplateAttributeResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found nested {@link TemplateAttribute}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the nested {@link TemplateAttribute} to
+ * load
+ * @param id
+ * id of the nested {@link TemplateAttribute}
+ * @return the found nested {@link TemplateAttribute} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID4 + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String parentTplCompId, @PathParam(REQUESTPARAM_ID3) String tplCompId,
+ @PathParam(REQUESTPARAM_ID4) String id) {
+ return entityService.find(V(sourceName), TemplateAttribute.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId, parentTplCompId, tplCompId))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) nested {@link TemplateAttribute}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the nested {@link TemplateAttribute} to
+ * load
+ * @param filter
+ * filter string to filter the nested {@link TemplateAttribute}
+ * result
+ * @return the (filtered) nested {@link TemplateAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String parentTplCompId, @PathParam(REQUESTPARAM_ID3) String tplCompId,
+ @QueryParam("filter") String filter) {
+ return entityService
+ .find(V(sourceName), TemplateComponent.class, V(tplCompId),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId, parentTplCompId))
+ .map(tplComp -> List.ofAll(tplComp.getTemplateAttributes()))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created nested {@link TemplateAttribute}.
+ *
+ * @param body
+ * The nested {@link TemplateAttribute} to create.
+ * @return The created nested {@link TemplateAttribute} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String parentTplCompId, @PathParam(REQUESTPARAM_ID3) String tplCompId,
+ String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), TemplateAttribute.class, L(
+ requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME),
+ entityService.find(V(sourceName), TemplateComponent.class, V(tplCompId),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId, parentTplCompId))))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link TemplateAttribute} with all parameters set in the given
+ * JSON body of the request
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the nested {@link TemplateAttribute} to delete.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated nested {@link TemplateAttribute}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID4 + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String parentTplCompId, @PathParam(REQUESTPARAM_ID3) String tplCompId,
+ @PathParam(REQUESTPARAM_ID4) String id, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName),
+ entityService.find(V(sourceName), TemplateAttribute.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam),
+ SL(tplRootId, parentTplCompId, tplCompId)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link NestedTemplateAttribute}.
+ *
+ *
+ * @param id
+ * The identifier of the {@link NestedTemplateAttribute} to delete.
+ * @return the deleted {@link NestedTemplateAttribute }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID4 + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String parentTplCompId, @PathParam(REQUESTPARAM_ID3) String tplCompId,
+ @PathParam(REQUESTPARAM_ID4) String id) {
+ return entityService
+ .delete(V(sourceName),
+ entityService.find(V(sourceName), TemplateAttribute.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam),
+ SL(tplRootId, parentTplCompId, tplCompId)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link TemplateAttribute} type.
+ *
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), TemplateAttribute.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), TemplateAttribute.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/NestedTemplateComponentResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/NestedTemplateComponentResource.java
new file mode 100644
index 00000000..2e0822f5
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/NestedTemplateComponentResource.java
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_CATALOGCOMPONENT_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_CONTEXTTYPE;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID2;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID3;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.SL;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.CatalogComponent;
+import org.eclipse.mdm.api.dflt.model.TemplateComponent;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+import io.vavr.collection.List;
+
+/**
+ * {@link TemplateComponent} resource handling REST requests for nested
+ * {@link TemplateComponent}s
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/tplroots/{" + REQUESTPARAM_CONTEXTTYPE + "}/{" + REQUESTPARAM_ID
+ + "}/tplcomps/{" + REQUESTPARAM_ID2 + "}/tplcomps")
+public class NestedTemplateComponentResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found nested {@link TemplateComponent}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link TemplateComponent} to load
+ * @param id
+ * id of the {@link TemplateComponent}
+ * @return the found {@link TemplateComponent} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID3 + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String parentTplCompId, @PathParam(REQUESTPARAM_ID3) String id) {
+ return entityService
+ .find(V(sourceName), TemplateComponent.class, V(id), ServiceUtils.getContextTypeSupplier(contextTypeParam),
+ SL(tplRootId, parentTplCompId))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) nested {@link TemplateComponent}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link TemplateComponent} to load
+ * @param filter
+ * filter string to filter the {@link TemplateComponent} result
+ * @return the (filtered) {@link TemplateComponent}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String parentTplCompId, @QueryParam("filter") String filter) {
+ return entityService
+ .find(V(sourceName), TemplateComponent.class, V(parentTplCompId),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId))
+ .map(tplComp -> List.ofAll(tplComp.getTemplateComponents()))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link TemplateComponentValue}.
+ *
+ *
+ * @param body
+ * The {@link TemplateComponent} to create.
+ * @param id
+ * the identifier of the parent {@link TemplateComponent}.
+ * @return the created {@link TemplateComponent} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String parentTplCompId, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), TemplateComponent.class,
+ L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME),
+ entityService.find(V(sourceName), TemplateComponent.class, V(parentTplCompId),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId)),
+ entityService.find(V(sourceName), CatalogComponent.class,
+ requestBody.getStringValueSupplier(ENTITYATTRIBUTE_CATALOGCOMPONENT_ID),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam))))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the nested {@link TemplateComponent} with all parameters set in the
+ * given JSON body of the request
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link TemplateComponent} to update.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link TemplateComponent}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID3 + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String parentTplCompId, @PathParam(REQUESTPARAM_ID3) String id, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName),
+ entityService.find(V(sourceName), TemplateComponent.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId, parentTplCompId)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted nested {@link TemplateComponent}.
+ *
+ * @param id
+ * The identifier of the {@link TemplateComponent} to delete.
+ * @return the deleted {@link TemplateComponent }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID3 + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String parentTplCompId, @PathParam(REQUESTPARAM_ID3) String id) {
+ return entityService
+ .delete(V(sourceName),
+ entityService.find(V(sourceName), TemplateComponent.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId, parentTplCompId)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the nested {@link TemplateComponent} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), TemplateComponent.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), TemplateComponent.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/PhysicalDimensionResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/PhysicalDimensionResource.java
new file mode 100755
index 00000000..b15e24a0
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/PhysicalDimensionResource.java
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gunnar Schmidt - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.base.model.PhysicalDimension;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+/**
+ * {@link PhysicalDimension} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/physicaldimensions")
+public class PhysicalDimensionResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link PhysicalDimension}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * id of the {@link PhysicalDimension}
+ * @return the found {@link PhysicalDimension} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.find(V(sourceName), PhysicalDimension.class, V(id))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link PhysicalDimension}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param filter
+ * filter string to filter the {@link PhysicalDimension} result
+ * @return the (filtered) {@link PhysicalDimension}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @QueryParam("filter") String filter) {
+ return entityService.findAll(V(sourceName), PhysicalDimension.class, filter)
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link PhysicalDimension}.
+ *
+ * @param body
+ * The {@link PhysicalDimension} to create.
+ * @return the created {@link PhysicalDimension} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), PhysicalDimension.class,
+ L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link PhysicalDimension} with all parameters set in the given
+ * JSON body of the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link PhysicalDimension} to update.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link PhysicalDimension}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @PathParam(REQUESTPARAM_ID) String id,
+ String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName), entityService.find(V(sourceName), PhysicalDimension.class, V(id)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link PhysicalDimension}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * The identifier of the {@link PhysicalDimension} to delete.
+ * @return the deleted {@link PhysicalDimension }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.delete(V(sourceName), entityService.find(V(sourceName), PhysicalDimension.class, V(id)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link PhysicalDimension} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), PhysicalDimension.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), PhysicalDimension.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ProjectResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ProjectResource.java
index 0a4a99b8..f49a028c 100644
--- a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ProjectResource.java
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ProjectResource.java
@@ -10,11 +10,21 @@
*******************************************************************************/
package org.eclipse.mdm.businessobjects.boundary;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
import java.util.List;
import java.util.Map;
import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@@ -32,10 +42,14 @@ import org.eclipse.mdm.businessobjects.entity.I18NResponse;
import org.eclipse.mdm.businessobjects.entity.MDMEntityResponse;
import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
import org.eclipse.mdm.businessobjects.entity.SearchAttributeResponse;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+// TODO: Use entityService (and vavr) in all Methods
+
/**
* {@link Project} resource
*
@@ -50,6 +64,9 @@ public class ProjectResource {
@EJB
private ProjectService projectService;
+ @EJB
+ private EntityService entityService;
+
/**
* delegates the request to the {@link ProjectService}
*
@@ -136,4 +153,74 @@ public class ProjectResource {
throw new WebApplicationException(e.getMessage(), e, Status.INTERNAL_SERVER_ERROR);
}
}
+
+ /**
+ * Returns the created {@link Project}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param body
+ * The {@link Project} to create.
+ * @return the created {@link Project} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), Project.class, L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link Project} with all parameters set in the given JSON body of
+ * the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link ProjectValue} to update.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link Project}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @PathParam(REQUESTPARAM_ID) String id,
+ String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName), entityService.find(V(sourceName), Project.class, V(id)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link Project}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * The identifier of the {@link Project} to delete.
+ * @return the deleted {@link ValueList }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.delete(V(sourceName), entityService.find(V(sourceName), Project.class, V(id)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
}
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/QuantityResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/QuantityResource.java
new file mode 100644
index 00000000..7cd71516
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/QuantityResource.java
@@ -0,0 +1,194 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gunnar Schmidt - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_UNIT_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_CONTEXTTYPE;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.base.model.Quantity;
+import org.eclipse.mdm.api.base.model.Unit;
+import org.eclipse.mdm.api.dflt.model.ValueListValue;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+/**
+ * {@link Quantity} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/quantities")
+public class QuantityResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link Quantity}. {@link WebApplicationException} on error.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * id of the {@link Quantity}
+ * @return the found {@link Quantity} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.find(V(sourceName), Quantity.class, V(id))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link Quantity}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param filter
+ * filter string to filter the {@link Quantity} result
+ * @return the (filtered) {@link Quantity}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @QueryParam("filter") String filter) {
+ return entityService.findAll(V(sourceName), Quantity.class, filter)
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link Unit}.
+ *
+ * @param body
+ * The {@link Unit} to create.
+ * @return the created {@link Unit} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), Quantity.class,
+ L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME),
+ entityService.find(V(sourceName), Unit.class,
+ requestBody.getStringValueSupplier(ENTITYATTRIBUTE_UNIT_ID))))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link Quantity} with all parameters set in the given JSON body
+ * of the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link Quantity} to update.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link ValueListValue}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @PathParam(REQUESTPARAM_ID) String id,
+ String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName), entityService.find(V(sourceName), Quantity.class, V(id)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link Quantity}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * The identifier of the {@link Quantity} to delete.
+ * @return the deleted {@link Quantity }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.delete(V(sourceName), entityService.find(V(sourceName), Quantity.class, V(id)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link Quantity} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), Quantity.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), Quantity.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ResourceConstants.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ResourceConstants.java
new file mode 100644
index 00000000..e528fa45
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ResourceConstants.java
@@ -0,0 +1,114 @@
+package org.eclipse.mdm.businessobjects.boundary;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Quantity;
+import org.eclipse.mdm.api.base.model.Unit;
+import org.eclipse.mdm.api.dflt.model.CatalogComponent;
+import org.eclipse.mdm.api.dflt.model.CatalogSensor;
+import org.eclipse.mdm.api.dflt.model.TemplateAttribute;
+import org.eclipse.mdm.api.dflt.model.TemplateComponent;
+import org.eclipse.mdm.api.dflt.model.TemplateRoot;
+import org.eclipse.mdm.api.dflt.model.TemplateSensor;
+import org.eclipse.mdm.api.dflt.model.TemplateTestStep;
+import org.eclipse.mdm.api.dflt.model.TemplateTestStepUsage;
+
+/**
+ * Class defining constants used by the specific Jersey resource classes.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+public final class ResourceConstants {
+ /**
+ * Parameter name holding the {@link Environment}, i.e. the source name
+ */
+ public static final String REQUESTPARAM_SOURCENAME = "SOURCENAME";
+
+ /**
+ * Parameter holding the {@link Entity}s id in the URI path
+ */
+ public static final String REQUESTPARAM_ID = "ID";
+
+ /**
+ * Parameter holding an additional {@link Entity}s id in the URI path, e.g. for
+ * a {@link TemplateComponent} when {@link REQUESTPARAM_ID} holds the id of the
+ * {@link TemplateRoot}.
+ */
+ public static final String REQUESTPARAM_ID2 = "ID2";
+
+ /**
+ * Parameter holding an additional {@link Entity}s id in the URI path, e.g. for
+ * a {@link TemplateAttribute} when {@link REQUESTPARAM_ID} holds the id of the
+ * {@link TemplateRoot} and {@link REQUESTPARAM_ID2} holds the id of the
+ * {@link TemplateComponent}.
+ */
+ public static final String REQUESTPARAM_ID3 = "ID3";
+
+ /**
+ * Parameter holding an additional {@link Entity}s id in the URI path, e.g. for
+ * a {@link TemplateAttribute} when {@link REQUESTPARAM_ID} holds the id of the
+ * {@link TemplateRoot}, {@link REQUESTPARAM_ID2} holds the id of the parent
+ * {@link TemplateComponent} and {@link REQUESTPARAM_ID3} holds the id of the
+ * nested {@link TemplateComponent}.
+ */
+ public static final String REQUESTPARAM_ID4 = "ID4";
+
+ /**
+ * Parameter holding the {@link ContextType} of the {@link Entity} in the URI
+ * path
+ */
+ public static final String REQUESTPARAM_CONTEXTTYPE = "CONTEXTTYPE";
+
+ /**
+ * Parameter holding the name of the {@link Entity} in the request body
+ */
+ public static final String ENTITYATTRIBUTE_NAME = "Name";
+
+ /**
+ * Parameter holding the {@link ValueType} of the {@link Entity} in the request
+ * body
+ */
+ public static final String ENTITYATTRIBUTE_DATATYPE = "DataType";
+
+ /**
+ * Parameter holding the id of the {@link CatalogComponent} of e.g. the
+ * {@link TemplateComponent} in the request body
+ */
+ public static final String ENTITYATTRIBUTE_CATALOGCOMPONENT_ID = "CatalogComponent";
+
+ /**
+ * Parameter holding the id of the {@link CatalogSensor} of e.g. the
+ * {@link TemplateSensor} in the request body
+ */
+ public static final String ENTITYATTRIBUTE_CATALOGSENSOR_ID = "CatalogSensor";
+
+ /**
+ * Parameter holding the id of the {@link Quantity} of e.g. the {@link Unit} in
+ * the request body
+ */
+ public static final String ENTITYATTRIBUTE_QUANTITY_ID = "Quantity";
+
+ /**
+ * Parameter holding the id of the {@link Unit} of e.g. the {@link Quantity} in
+ * the request body
+ */
+ public static final String ENTITYATTRIBUTE_UNIT_ID = "Unit";
+
+ /**
+ * Parameter holding the id of the {@link Unit} of e.g. the {@link Quantity} in
+ * the request body
+ */
+ public static final String ENTITYATTRIBUTE_PHYSICALDIMENSION_ID = "PhysicalDimension";
+
+ /**
+ * Parameter holding the id of the {@link TemplateTestStep} of e.g. the
+ * {@link TemplateTestStepUsage} in the request body
+ */
+ public static final String ENTITYATTRIBUTE_TEMPLATETESTSTEP_ID = "TemplateTestStep";
+
+ /**
+ * Just hide the default constructor
+ */
+ private ResourceConstants() {
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateAttributeResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateAttributeResource.java
new file mode 100644
index 00000000..12aea3ee
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateAttributeResource.java
@@ -0,0 +1,216 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_CONTEXTTYPE;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID2;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID3;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.SL;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.TemplateAttribute;
+import org.eclipse.mdm.api.dflt.model.TemplateComponent;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+import io.vavr.collection.List;
+
+/**
+ * {@link TemplateAttribute} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/tplroots/{" + REQUESTPARAM_CONTEXTTYPE + "}/{" + REQUESTPARAM_ID
+ + "}/tplcomps/{" + REQUESTPARAM_ID2 + "}/tplattrs")
+public class TemplateAttributeResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link TemplateAttribute}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link TemplateAttribute} to load
+ * @param id
+ * id of the {@link TemplateAttribute}
+ * @return the found {@link TemplateAttribute} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID3 + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String tplCompId, @PathParam(REQUESTPARAM_ID3) String id) {
+ return entityService
+ .find(V(sourceName), TemplateAttribute.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId, tplCompId))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link TemplateAttribute}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link TemplateAttribute} to load
+ * @param filter
+ * filter string to filter the {@link TemplateAttribute} result
+ * @return the (filtered) {@link TemplateAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String tplCompId, @QueryParam("filter") String filter) {
+ return entityService
+ .find(V(sourceName), TemplateComponent.class, V(tplCompId),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId))
+ .map(tplComp -> List.ofAll(tplComp.getTemplateAttributes()))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link TemplateAttributeValue}.
+ *
+ * @param body
+ * The {@link TemplateAttribute} to create.
+ * @return the created {@link TemplateAttribute} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String tplCompId, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), TemplateAttribute.class,
+ L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME),
+ entityService.find(V(sourceName), TemplateComponent.class, V(tplCompId),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId))))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link TemplateAttribute} with all parameters set in the given
+ * JSON body of the request
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link TemplateAttribute} to delete.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link TemplateAttribute}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID3 + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String tplCompId, @PathParam(REQUESTPARAM_ID3) String id, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName),
+ entityService.find(V(sourceName), TemplateAttribute.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId, tplCompId)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link TemplateAttribute}.
+ *
+ * @param id
+ * The identifier of the {@link TemplateAttribute} to delete.
+ * @return the deleted {@link TemplateAttribute }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID3 + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String tplCompId, @PathParam(REQUESTPARAM_ID3) String id) {
+ return entityService
+ .delete(V(sourceName),
+ entityService.find(V(sourceName), TemplateAttribute.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId, tplCompId)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link TemplateAttribute} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), TemplateAttribute.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), TemplateAttribute.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateComponentResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateComponentResource.java
new file mode 100644
index 00000000..bddd72c3
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateComponentResource.java
@@ -0,0 +1,220 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_CATALOGCOMPONENT_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_CONTEXTTYPE;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID2;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.SL;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.CatalogComponent;
+import org.eclipse.mdm.api.dflt.model.TemplateComponent;
+import org.eclipse.mdm.api.dflt.model.TemplateRoot;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+import io.vavr.collection.List;
+
+/**
+ * {@link TemplateComponent} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/tplroots/{" + REQUESTPARAM_CONTEXTTYPE + "}/{" + REQUESTPARAM_ID
+ + "}/tplcomps")
+public class TemplateComponentResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link TemplateComponent}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link TemplateComponent} to load
+ * @param id
+ * id of the {@link TemplateComponent}
+ * @return the found {@link TemplateComponent} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String id) {
+ return entityService
+ .find(V(sourceName), TemplateComponent.class, V(id), ServiceUtils.getContextTypeSupplier(contextTypeParam),
+ SL(tplRootId))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link TemplateComponent}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link TemplateComponent} to load
+ * @param filter
+ * filter string to filter the {@link TemplateComponent} result
+ * @return the (filtered) {@link TemplateComponent}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @QueryParam("filter") String filter) {
+ return entityService
+ .find(V(sourceName), TemplateRoot.class, V(tplRootId),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam))
+ .map(tplRoot -> List.ofAll(tplRoot.getTemplateComponents()))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link TemplateComponentValue}.
+ *
+ * @param body
+ * The {@link TemplateComponent} to create.
+ * @return the created {@link TemplateComponent} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), TemplateComponent.class,
+ L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME),
+ entityService.find(V(sourceName), TemplateRoot.class, V(tplRootId),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam)),
+ entityService.find(V(sourceName), CatalogComponent.class,
+ requestBody.getStringValueSupplier(ENTITYATTRIBUTE_CATALOGCOMPONENT_ID),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam))))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link TemplateComponent} with all parameters set in the given
+ * JSON body of the request
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link TemplateComponent} to update.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link TemplateComponent}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String id, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName),
+ entityService.find(V(sourceName), TemplateComponent.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link TemplateComponent}.
+ *
+ * @param id
+ * The identifier of the {@link TemplateComponent} to delete.
+ * @return the deleted {@link TemplateComponent }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String tplRootId,
+ @PathParam(REQUESTPARAM_ID2) String id) {
+ return entityService
+ .delete(V(sourceName),
+ entityService.find(V(sourceName), TemplateComponent.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam), SL(tplRootId)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link TemplateComponent} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), TemplateComponent.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), TemplateComponent.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateRootResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateRootResource.java
new file mode 100644
index 00000000..80b11b10
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateRootResource.java
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_CONTEXTTYPE;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.TemplateRoot;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+/**
+ * {@link TemplateRoot} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/tplroots/{" + REQUESTPARAM_CONTEXTTYPE + "}")
+public class TemplateRootResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link TemplateRoot}.
+ *
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link TemplateRoot} to load
+ * @param id
+ * id of the {@link TemplateRoot}
+ * @return the found {@link TemplateRoot} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService
+ .find(V(sourceName), TemplateRoot.class, V(id), ServiceUtils.getContextTypeSupplier(contextTypeParam))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link TemplateRoot}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link TemplateRoot} to load
+ * @param filter
+ * filter string to filter the {@link TemplateRoot} result
+ * @return the (filtered) {@link TemplateRoot}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @QueryParam("filter") String filter) {
+ return entityService
+ .findAll(V(sourceName), TemplateRoot.class, filter, ServiceUtils.getContextTypeSupplier(contextTypeParam))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link TemplateRootValue}.
+ *
+ * @param body
+ * The {@link TemplateRoot} to create.
+ * @return the created {@link TemplateRoot} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), TemplateRoot.class,
+ L(ServiceUtils.getContextTypeSupplier(contextTypeParam),
+ requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link TemplateRoot} with all parameters set in the given JSON
+ * body of the request
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link TemplateRoot} to delete.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link TemplateRoot}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String id,
+ String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName),
+ entityService.find(V(sourceName), TemplateRoot.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link TemplateRoot}.
+ *
+ * @param id
+ * The identifier of the {@link TemplateRoot} to delete.
+ * @return the deleted {@link TemplateRoot }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService
+ .delete(V(sourceName),
+ entityService.find(V(sourceName), TemplateRoot.class, V(id),
+ ServiceUtils.getContextTypeSupplier(contextTypeParam)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link TemplateRoot} type.
+ *
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), TemplateRoot.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), TemplateRoot.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateSensorAttributeResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateSensorAttributeResource.java
new file mode 100644
index 00000000..c2a6767a
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateSensorAttributeResource.java
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2018 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Philipp Schweinbenz - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID2;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID3;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID4;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.SL;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.TemplateAttribute;
+import org.eclipse.mdm.api.dflt.model.TemplateComponent;
+import org.eclipse.mdm.api.dflt.model.TemplateRoot;
+import org.eclipse.mdm.api.dflt.model.TemplateSensor;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+import io.vavr.collection.List;
+
+/**
+ * {@link TemplateAttribute} resource handling REST requests
+ *
+ * @author Philipp Schweinbenz, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/tplroots/testequipment/{" + REQUESTPARAM_ID + "}/tplcomps/{"
+ + REQUESTPARAM_ID2 + "}/tplsensors/{" + REQUESTPARAM_ID3 + "}/tplsensorattrs")
+public class TemplateSensorAttributeResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /*
+ * Create not implemented as TemplateSensorAttributes are created implicitly
+ * with the TemplateSensor
+ */
+
+ /**
+ * Returns the found {@link TemplateAttribute}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param tplRootId
+ * id of the {@link TemplateRoot}
+ * @param tplCompId
+ * id of the {@link TemplateComponent}
+ * @param tplSensorId
+ * id of the {@link TemplateSensor}
+ * @param id
+ * id of the {@link TemplateAttribute}
+ * @return the found {@link TemplateAttribute} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID4 + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplRootId, @PathParam(REQUESTPARAM_ID2) String tplCompId,
+ @PathParam(REQUESTPARAM_ID3) String tplSensorId, @PathParam(REQUESTPARAM_ID4) String id) {
+ return entityService
+ .find(V(sourceName), TemplateAttribute.class, V(id), V(ContextType.TESTEQUIPMENT),
+ SL(tplRootId, tplCompId, tplSensorId))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link TemplateAttribute}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param tplRootId
+ * id of the {@link TemplateRoot}
+ * @param tplCompId
+ * id of the {@link TemplateComponent}
+ * @param tplSensorId
+ * id of the {@link TemplateSensor}
+ * @param filter
+ * filter string to filter the {@link TemplateAttribute} result
+ * @return the (filtered) {@link TemplateAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplRootId, @PathParam(REQUESTPARAM_ID2) String tplCompId,
+ @PathParam(REQUESTPARAM_ID3) String tplSensorId, @QueryParam("filter") String filter) {
+ return entityService
+ .find(V(sourceName), TemplateSensor.class, V(tplSensorId),
+ V(ContextType.TESTEQUIPMENT), SL(tplRootId, tplCompId))
+ .map(tplSensor -> List.ofAll(tplSensor.getTemplateAttributes()))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link TemplateAttribute} with all parameters set in the given
+ * JSON body of the request
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param tplRootId
+ * id of the {@link TemplateRoot}
+ * @param tplCompId
+ * id of the {@link TemplateComponent}
+ * @param tplSensorId
+ * id of the {@link TemplateSensor}
+ * @param id
+ * the identifier of the {@link TemplateAttribute} to delete.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link TemplateAttribute}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID4 + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplRootId, @PathParam(REQUESTPARAM_ID2) String tplCompId,
+ @PathParam(REQUESTPARAM_ID3) String tplSensorId, @PathParam(REQUESTPARAM_ID4) String id, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName),
+ entityService.find(V(sourceName), TemplateAttribute.class, V(id), V(ContextType.TESTEQUIPMENT),
+ SL(tplRootId, tplCompId, tplSensorId)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /*
+ * Delete not implemented as TemplateSensorAttributes can't be deleted
+ */
+
+ /**
+ * Returns the search attributes for the {@link TemplateAttribute} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), TemplateAttribute.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), TemplateAttribute.class, entityService);
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateSensorResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateSensorResource.java
new file mode 100755
index 00000000..4e101cc5
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateSensorResource.java
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_CATALOGSENSOR_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_QUANTITY_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID2;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID3;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.SL;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.base.model.Quantity;
+import org.eclipse.mdm.api.dflt.model.CatalogSensor;
+import org.eclipse.mdm.api.dflt.model.TemplateComponent;
+import org.eclipse.mdm.api.dflt.model.TemplateSensor;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+import io.vavr.Lazy;
+import io.vavr.collection.List;
+
+/**
+ * {@link TemplateSensor} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/tplroots/testequipment/{" + REQUESTPARAM_ID + "}/tplcomps/{"
+ + REQUESTPARAM_ID2 + "}/tplsensors")
+public class TemplateSensorResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link TemplateSensor}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * id of the {@link TemplateSensor}
+ * @return the found {@link TemplateSensor} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID3 + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplRootId, @PathParam(REQUESTPARAM_ID2) String tplCompId,
+ @PathParam(REQUESTPARAM_ID3) String id) {
+ return entityService
+ .find(V(sourceName), TemplateSensor.class, V(id), V(ContextType.TESTEQUIPMENT), SL(tplRootId, tplCompId))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link TemplateSensor}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param filter
+ * filter string to filter the {@link TemplateSensor} result
+ * @return the (filtered) {@link TemplateSensor}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplRootId, @PathParam(REQUESTPARAM_ID2) String tplCompId,
+ @QueryParam("filter") String filter) {
+ return entityService
+ .find(V(sourceName), TemplateComponent.class, V(tplCompId), V(ContextType.TESTEQUIPMENT), SL(tplRootId))
+ .map(tplComp -> List.ofAll(tplComp.getTemplateSensors()))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link TemplateSensorValue}.
+ *
+ * @param body
+ * The {@link TemplateSensor} to create.
+ * @return the created {@link TemplateSensor} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplRootId, @PathParam(REQUESTPARAM_ID2) String tplCompId, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ // TODO anehmer on 2017-11-25: test that tplComp is only once fetched
+ // get memoized (Lazy) tplComp as it is used twiced and should only fetched once
+ Lazy<TemplateComponent> tplCompSupplier = Lazy.of(() -> entityService
+ .find(V(sourceName), TemplateComponent.class, V(tplCompId), V(ContextType.TESTEQUIPMENT), SL(tplRootId))
+ .get());
+
+ return entityService
+ .create(V(sourceName), TemplateSensor.class,
+ L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME), tplCompSupplier,
+ entityService.find(V(sourceName), CatalogSensor.class,
+ requestBody.getStringValueSupplier(ENTITYATTRIBUTE_CATALOGSENSOR_ID),
+ V(ContextType.TESTEQUIPMENT),
+ SL(tplCompSupplier.map(tplComp -> tplComp.getCatalogComponent()
+ .getID()))),
+ entityService.find(V(sourceName), Quantity.class,
+ requestBody.getStringValueSupplier(ENTITYATTRIBUTE_QUANTITY_ID))))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link TemplateSensor} with all parameters set in the given JSON
+ * body of the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link TemplateSensor} to delete.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link TemplateSensor}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID3 + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplRootId, @PathParam(REQUESTPARAM_ID2) String tplCompId,
+ @PathParam(REQUESTPARAM_ID3) String id, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName),
+ entityService.find(V(sourceName), TemplateSensor.class, V(id),
+ V(ContextType.TESTEQUIPMENT), SL(tplRootId, tplCompId)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link TemplateSensor}.
+ *
+ * @param id
+ * The identifier of the {@link TemplateSensor} to delete.
+ * @return the deleted {@link TemplateSensor }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID3 + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplRootId, @PathParam(REQUESTPARAM_ID2) String tplCompId,
+ @PathParam(REQUESTPARAM_ID3) String id) {
+ return entityService
+ .delete(V(sourceName),
+ entityService.find(V(sourceName), TemplateSensor.class, V(id),
+ V(ContextType.TESTEQUIPMENT), SL(tplRootId, tplCompId)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link TemplateSensor} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), TemplateSensor.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), TemplateSensor.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateTestResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateTestResource.java
new file mode 100644
index 00000000..4a7485d1
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateTestResource.java
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.TemplateTest;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+/**
+ * {@link TemplateTest} resource handling REST requests
+ *
+ * @author Gunnar Schmidt, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/tpltests")
+public class TemplateTestResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link TemplateTest}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * id of the {@link TemplateTest}
+ * @return the found {@link TemplateTest} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.find(V(sourceName), TemplateTest.class, V(id))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link TemplateTest}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param filter
+ * filter string to filter the {@link TemplateTest} result
+ * @return the (filtered) {@link TemplateTest}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @QueryParam("filter") String filter) {
+ return entityService.findAll(V(sourceName), TemplateTest.class, filter)
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link TemplateTestValue}.
+ *
+ * @param body
+ * The {@link TemplateTest} to create.
+ * @return the created {@link TemplateTest} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), TemplateTest.class, L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link TemplateTest} with all parameters set in the given JSON
+ * body of the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link TemplateTest} to delete.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link TemplateTest}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @PathParam(REQUESTPARAM_ID) String id,
+ String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName), entityService.find(V(sourceName), TemplateTest.class, V(id)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link TemplateTest}.
+ *
+ * @param id
+ * The identifier of the {@link TemplateTest} to delete.
+ * @return the deleted {@link TemplateTest }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.delete(V(sourceName), entityService.find(V(sourceName), TemplateTest.class, V(id)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link TemplateTest} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), TemplateTest.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), TemplateTest.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateTestStepResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateTestStepResource.java
new file mode 100644
index 00000000..1711204f
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateTestStepResource.java
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_CONTEXTTYPE;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.TemplateTestStep;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+/**
+ * {@link TemplateTestStep} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/tplteststeps")
+public class TemplateTestStepResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link TemplateTestStep}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link TemplateTestStep} to load
+ * @param id
+ * id of the {@link TemplateTestStep}
+ * @return the found {@link TemplateTestStep} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.find(V(sourceName), TemplateTestStep.class, V(id))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link TemplateTestStep}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param contextType
+ * {@link ContextType} of the {@link TemplateTestStep} to load
+ * @param filter
+ * filter string to filter the {@link TemplateTestStep} result
+ * @return the (filtered) {@link TemplateTestStep}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @QueryParam("filter") String filter) {
+ return entityService.findAll(V(sourceName), TemplateTestStep.class, filter)
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link TemplateTestStepValue}.
+ *
+ * @param body
+ * The {@link TemplateTestStep} to create.
+ * @return the created {@link TemplateTestStep} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), TemplateTestStep.class,
+ L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link TemplateTestStep} with all parameters set in the given
+ * JSON body of the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link TemplateTestStep} to delete.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link TemplateTestStep}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @PathParam(REQUESTPARAM_ID) String id,
+ String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName), entityService.find(V(sourceName), TemplateTestStep.class, V(id)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link TemplateTestStep}.
+ *
+ * @param id
+ * The identifier of the {@link TemplateTestStep} to delete.
+ * @return the deleted {@link TemplateTestStep }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_CONTEXTTYPE) String contextTypeParam, @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.delete(V(sourceName), entityService.find(V(sourceName), TemplateTestStep.class, V(id)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link TemplateTestStep} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), TemplateTestStep.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), TemplateTestStep.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateTestStepUsageResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateTestStepUsageResource.java
new file mode 100644
index 00000000..e964e6c7
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/TemplateTestStepUsageResource.java
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_TEMPLATETESTSTEP_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID2;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.SL;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.TemplateTest;
+import org.eclipse.mdm.api.dflt.model.TemplateTestStep;
+import org.eclipse.mdm.api.dflt.model.TemplateTestStepUsage;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+import io.vavr.collection.List;
+
+/**
+ * {@link TemplateTestStepUsage} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/tpltests/{" + REQUESTPARAM_ID + "}/tplteststepusages")
+public class TemplateTestStepUsageResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link TemplateTestStep}.
+ *
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * id of the {@link TemplateTestStep}
+ * @return the found {@link TemplateTestStep} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplTestId, @PathParam(REQUESTPARAM_ID2) String id) {
+ return entityService.find(V(sourceName), TemplateTestStepUsage.class, V(id), SL(tplTestId))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link TemplateTestStepUsage}s.
+ *
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param filter
+ * filter string to filter the {@link TemplateTestStepUsage} result
+ * @return the (filtered) {@link TemplateTestStepUsage}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplTestId, @QueryParam("filter") String filter) {
+ return entityService.find(V(sourceName), TemplateTest.class, V(tplTestId))
+ .map(tplTest -> List.ofAll(tplTest.getTemplateTestStepUsages()))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link TemplateTestStepUsageValue}.
+ *
+ *
+ * @param body
+ * The {@link TemplateTestStepUsage} to create.
+ * @return the created {@link TemplateTestStepUsage} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplTestId, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), TemplateTestStepUsage.class,
+ L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME),
+ entityService.find(V(sourceName), TemplateTest.class, V(tplTestId)),
+ entityService.find(V(sourceName), TemplateTestStep.class,
+ requestBody.getStringValueSupplier(ENTITYATTRIBUTE_TEMPLATETESTSTEP_ID))))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link TemplateTestUsage} with all parameters set in the given
+ * JSON body of the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link TemplateTestUsage} to delete.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link TemplateTestUsage}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplTestId, @PathParam(REQUESTPARAM_ID2) String id, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName),
+ entityService.find(V(sourceName), TemplateTestStepUsage.class, V(id), SL(tplTestId)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link TemplateTestStepUsage}.
+ *
+ *
+ * @param id
+ * The identifier of the {@link TemplateTestStepUsage} to delete.
+ * @return the deleted {@link TemplateTestStepUsage }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String tplTestId, @PathParam(REQUESTPARAM_ID2) String id) {
+ return entityService
+ .delete(V(sourceName),
+ entityService.find(V(sourceName), TemplateTestStepUsage.class, V(id), SL(tplTestId)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link TemplateTestStepUsage} type.
+ *
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), TemplateTestStepUsage.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), TemplateTestStepUsage.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/UnitResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/UnitResource.java
new file mode 100644
index 00000000..40af2719
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/UnitResource.java
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Gunnar Schmidt - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_PHYSICALDIMENSION_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.base.model.PhysicalDimension;
+import org.eclipse.mdm.api.base.model.Unit;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+/**
+ * {@link Unit} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/units")
+public class UnitResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link Unit}. {@link WebApplicationException} on error.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * id of the {@link Unit}
+ * @return the found {@link Unit} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.find(V(sourceName), Unit.class, V(id))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link Unit}s.
+ *
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param filter
+ * filter string to filter the {@link Unit} result
+ * @return the (filtered) {@link Unit}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @QueryParam("filter") String filter) {
+ return entityService.findAll(V(sourceName), Unit.class, filter)
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link Unit}.
+ *
+ *
+ * @param body
+ * The {@link Unit} to create.
+ * @return the created {@link Unit} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), Unit.class, L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME),
+ entityService.find(V(sourceName), PhysicalDimension.class,
+ requestBody.getStringValueSupplier(ENTITYATTRIBUTE_PHYSICALDIMENSION_ID))))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link Unit} with all parameters set in the given JSON body of
+ * the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link Unit} to update.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link Unit}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @PathParam(REQUESTPARAM_ID) String id,
+ String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName), entityService.find(V(sourceName), Unit.class, V(id)), requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link Unit}. {@link WebApplicationException}
+ * on error.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * The identifier of the {@link Unit} to delete.
+ * @return the deleted {@link Unit }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.delete(V(sourceName), entityService.find(V(sourceName), Unit.class, V(id)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link Unit} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), Unit.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), Unit.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ValueListResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ValueListResource.java
new file mode 100644
index 00000000..17e322f4
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ValueListResource.java
@@ -0,0 +1,188 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.ValueList;
+import org.eclipse.mdm.api.dflt.model.ValueListValue;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+/**
+ * {@link ValueList} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/valuelists")
+public class ValueListResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link ValueList}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * id of the {@link ValueList}
+ * @return the found {@link ValueList} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.find(V(sourceName), ValueList.class, V(id))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link ValueList}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param filter
+ * filter string to filter the {@link ValueList} result
+ * @return the (filtered) {@link ValueList}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @QueryParam("filter") String filter) {
+ return entityService.findAll(V(sourceName), ValueList.class, filter)
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link ValueList}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param body
+ * The {@link ValueList} to create.
+ * @return the created {@link ValueList} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), ValueList.class, L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link ValueList} with all parameters set in the given JSON body
+ * of the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link ValueListValue} to update.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link ValueList}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName, @PathParam(REQUESTPARAM_ID) String id,
+ String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName), entityService.find(V(sourceName), ValueList.class, V(id)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link ValueList}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * The identifier of the {@link ValueList} to delete.
+ * @return the deleted {@link ValueList }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String id) {
+ return entityService.delete(V(sourceName), entityService.find(V(sourceName), ValueList.class, V(id)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link ValueList} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), ValueList.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), ValueList.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ValueListValueResource.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ValueListValueResource.java
new file mode 100644
index 00000000..bad6d4fa
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/boundary/ValueListValueResource.java
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary;
+
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.ENTITYATTRIBUTE_NAME;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_ID2;
+import static org.eclipse.mdm.businessobjects.boundary.ResourceConstants.REQUESTPARAM_SOURCENAME;
+import static org.eclipse.mdm.businessobjects.service.EntityService.L;
+import static org.eclipse.mdm.businessobjects.service.EntityService.SL;
+import static org.eclipse.mdm.businessobjects.service.EntityService.V;
+
+import javax.ejb.EJB;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.eclipse.mdm.api.base.model.Environment;
+import org.eclipse.mdm.api.dflt.model.ValueList;
+import org.eclipse.mdm.api.dflt.model.ValueListValue;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.eclipse.mdm.businessobjects.utils.RequestBody;
+import org.eclipse.mdm.businessobjects.utils.ServiceUtils;
+
+import io.vavr.collection.List;
+/**
+ * {@link ValueListValue} resource handling REST requests
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Path("/environments/{" + REQUESTPARAM_SOURCENAME + "}/valuelists/{" + REQUESTPARAM_ID + "}/values")
+public class ValueListValueResource {
+
+ @EJB
+ private EntityService entityService;
+
+ /**
+ * Returns the found {@link ValueListValue}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * id of the {@link ValueListValue}
+ * @return the found {@link ValueListValue} as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response find(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String valueListId, @PathParam(REQUESTPARAM_ID2) String id) {
+ return entityService.find(V(sourceName), ValueListValue.class, V(id), SL(valueListId))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the (filtered) {@link ValueListValue}s.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param filter
+ * filter string to filter the {@link ValueListValue} result
+ * @return the (filtered) {@link ValueListValue}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response findAll(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String valueListId, @QueryParam("filter") String filter) {
+
+ return entityService.find(V(sourceName), ValueList.class, V(valueListId))
+ .map(valueList -> List.ofAll(valueList.getValueListValues()))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the created {@link ValueListValue}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param valueListId
+ * id of the {@link ValueList} to create to value for
+ * @param body
+ * The {@link ValueListValue} to create.
+ * @return the created {@link ValueListValue} as {@link Response}.
+ */
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response create(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String valueListId, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .create(V(sourceName), ValueListValue.class,
+ L(requestBody.getStringValueSupplier(ENTITYATTRIBUTE_NAME),
+ entityService.find(V(sourceName), ValueList.class, V(valueListId))))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.CREATED))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Updates the {@link ValueListValue} with all parameters set in the given JSON
+ * body of the request.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * the identifier of the {@link ValueListValue} to delete.
+ * @param body
+ * the body of the request containing the attributes to update
+ * @return the updated {@link ValueListValue}
+ */
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response update(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String valueListId, @PathParam(REQUESTPARAM_ID2) String id, String body) {
+ RequestBody requestBody = RequestBody.create(body);
+
+ return entityService
+ .update(V(sourceName), entityService.find(V(sourceName), ValueListValue.class, V(id), SL(valueListId)),
+ requestBody.getValueMapSupplier())
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Deletes and returns the deleted {@link ValueListValue}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param id
+ * The identifier of the {@link ValueListValue} to delete.
+ * @return the deleted {@link ValueListValue }s as {@link Response}
+ */
+ @DELETE
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{" + REQUESTPARAM_ID2 + "}")
+ public Response delete(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName,
+ @PathParam(REQUESTPARAM_ID) String valueListId, @PathParam(REQUESTPARAM_ID2) String id) {
+ return entityService
+ .delete(V(sourceName), entityService.find(V(sourceName), ValueListValue.class, V(id), SL(valueListId)))
+ .map(e -> ServiceUtils.buildEntityResponse(e, Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Returns the search attributes for the {@link ValueListValue} type.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the {@link SearchAttribute}s as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/searchattributes")
+ public Response getSearchAttributes(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildSearchAttributesResponse(V(sourceName), ValueListValue.class, entityService);
+ }
+
+ /**
+ * Returns a map of localization for the entity type and the attributes.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @return the I18N as {@link Response}
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/localizations")
+ public Response localize(@PathParam(REQUESTPARAM_SOURCENAME) String sourceName) {
+ return ServiceUtils.buildLocalizationResponse(V(sourceName), ValueListValue.class, entityService);
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/entity/MDMEntityResponse.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/entity/MDMEntityResponse.java
index 3579ea00..62e952d2 100644
--- a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/entity/MDMEntityResponse.java
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/entity/MDMEntityResponse.java
@@ -44,6 +44,7 @@ public class MDMEntityResponse {
* @param entries
* list of {@link MDMEntity}
*/
+ // TODO move to Vavr List
public <T extends Entity> MDMEntityResponse(Class<? extends Entity> type, List<T> businessObjects) {
this.type = type.getSimpleName();
this.data = toTransferable(businessObjects);
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/service/DataAccessHelper.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/service/DataAccessHelper.java
new file mode 100644
index 00000000..6bdb3faa
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/service/DataAccessHelper.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.service;
+
+import java.util.Arrays;
+import java.util.function.Consumer;
+
+import org.eclipse.mdm.api.base.Transaction;
+import org.eclipse.mdm.api.base.model.Deletable;
+import org.eclipse.mdm.api.base.model.Entity;
+import org.eclipse.mdm.api.dflt.EntityManager;
+import org.eclipse.mdm.businessobjects.control.MDMEntityAccessException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vavr.CheckedFunction2;
+
+/**
+ * Helper class providing functions to realize transactional data operations
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+public final class DataAccessHelper {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DataAccessHelper.class);
+
+ /**
+ * Just hide the default constructor
+ */
+ private DataAccessHelper() {
+ }
+
+ /**
+ * Returns a function that executes one transactional operation within a
+ * transaction.
+ *
+ * @return Function that executes a transactional operation on an entity within
+ * a transaction.
+ */
+ // TODO anehmer on 2017-11-22: extend this method to handle lists of objects
+ public static <T extends Entity> T execute(EntityManager em, T entity,
+ CheckedFunction2<Transaction, Entity, Entity> operation) {
+ Transaction t = null;
+ try {
+ // start transaction to persist ValueList
+ t = em.startTransaction();
+ // perform the transactional operation
+ @SuppressWarnings("unchecked")
+ T processedEntity = (T) operation.apply(t, entity);
+ // commit the transaction
+ t.commit();
+ // return the processed entity
+ return processedEntity;
+ } catch (Throwable e) {
+ if (t != null) {
+ t.abort();
+ }
+ throw new MDMEntityAccessException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Function that creates an {@link Entity} and returns it.
+ */
+ public static final CheckedFunction2<Transaction, Entity, Entity> DELETE = (transaction,
+ entity) -> {
+ if (entity instanceof Deletable) {
+ // TODO anehmer on 2017-11-22: call to delete() should return entity
+ transaction.delete(Arrays.asList((Deletable) entity));
+ }
+ // if entity cannot be deleted
+ else {
+ throw new MDMEntityAccessException("Entity to delete is no Deletable");
+ }
+ return entity;
+ };
+
+ /**
+ * Function that creates the given {@link Entity} and returns the updated
+ * entity.
+ */
+ public static final CheckedFunction2<Transaction, Entity, Entity> CREATE = (transaction,
+ entity) -> {
+ // TODO anehmer on 2017-11-22: call to create() should return entity
+ transaction.create(Arrays.asList(entity));
+ return entity;
+ };
+
+ /**
+ * Function that updates the given {@link Entity} it is executed upon and
+ * returns the updated entity.
+ */
+ public static final CheckedFunction2<Transaction, Entity, Entity> UPDATE = (transaction,
+ entity) -> {
+ // TODO anehmer on 2017-11-22: call to update() should return entity
+ transaction.update(Arrays.asList(entity));
+ return entity;
+ };
+
+ /**
+ * Handles a {@link Throwable} by loggging the exception message and rethrowing
+ * a {@link MDMEntityAccessException}
+ */
+ // TODO should be replaced in Resources by buildErrorResponse()
+ public static final Consumer<? super Throwable> rethrowAsMDMEntityAccessException = e -> {
+ // TODO anehmer on 2017-11-09: check if logging is necessary depending on how we
+ // handle error logging and client response in general
+ LOG.error(e.getMessage(), e);
+ throw new MDMEntityAccessException(e.getMessage(), e);
+ };
+
+ /**
+ * Function that handles an occurred exception without rethrowing it
+ */
+ // TODO anehmer on 2017-11-22: remove method and logger
+ public static final Consumer<? super Throwable> handleException = e -> {
+ LOG.error(e.getMessage(), e);
+ };
+}
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/service/EntityService.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/service/EntityService.java
new file mode 100644
index 00000000..7d4e77f8
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/service/EntityService.java
@@ -0,0 +1,762 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.service;
+
+import static io.vavr.API.Tuple;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import javax.ejb.EJB;
+import javax.ejb.Stateless;
+
+import org.apache.commons.lang3.NotImplementedException;
+import org.eclipse.mdm.api.base.adapter.Attribute;
+import org.eclipse.mdm.api.base.adapter.Core;
+import org.eclipse.mdm.api.base.adapter.EntityStore;
+import org.eclipse.mdm.api.base.adapter.EntityType;
+import org.eclipse.mdm.api.base.model.BaseEntity;
+import org.eclipse.mdm.api.base.model.ContextComponent;
+import org.eclipse.mdm.api.base.model.ContextRoot;
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.api.base.model.Entity;
+import org.eclipse.mdm.api.base.model.EnumRegistry;
+import org.eclipse.mdm.api.base.model.EnumerationValue;
+import org.eclipse.mdm.api.dflt.EntityManager;
+import org.eclipse.mdm.api.dflt.model.CatalogAttribute;
+import org.eclipse.mdm.api.dflt.model.CatalogComponent;
+import org.eclipse.mdm.api.dflt.model.CatalogSensor;
+import org.eclipse.mdm.api.dflt.model.EntityFactory;
+import org.eclipse.mdm.api.dflt.model.TemplateAttribute;
+import org.eclipse.mdm.api.dflt.model.TemplateComponent;
+import org.eclipse.mdm.api.dflt.model.TemplateRoot;
+import org.eclipse.mdm.api.dflt.model.TemplateSensor;
+import org.eclipse.mdm.api.dflt.model.TemplateTest;
+import org.eclipse.mdm.api.dflt.model.TemplateTestStepUsage;
+import org.eclipse.mdm.api.dflt.model.ValueList;
+import org.eclipse.mdm.api.dflt.model.ValueListValue;
+import org.eclipse.mdm.businessobjects.control.I18NActivity;
+import org.eclipse.mdm.businessobjects.control.MDMEntityAccessException;
+import org.eclipse.mdm.businessobjects.control.NavigationActivity;
+import org.eclipse.mdm.businessobjects.control.SearchActivity;
+import org.eclipse.mdm.businessobjects.entity.SearchAttribute;
+import org.eclipse.mdm.businessobjects.utils.EntityNotFoundException;
+import org.eclipse.mdm.connector.boundary.ConnectorService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import io.vavr.CheckedFunction0;
+import io.vavr.Function0;
+import io.vavr.Tuple;
+import io.vavr.Tuple2;
+import io.vavr.Value;
+import io.vavr.collection.HashMap;
+import io.vavr.collection.List;
+import io.vavr.collection.Map;
+import io.vavr.collection.Seq;
+import io.vavr.collection.Set;
+import io.vavr.collection.Stream;
+import io.vavr.control.Option;
+import io.vavr.control.Try;
+
+/**
+ * Class providing basic data access methods to {@link Entity}s.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+@Stateless
+public class EntityService {
+
+ @EJB
+ private ConnectorService connectorService;
+
+ @EJB
+ private SearchActivity searchActivity;
+
+ @EJB
+ private NavigationActivity navigationActivity;
+
+ @EJB
+ private I18NActivity i18nActivity;
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(EntityService.class);
+
+ /**
+ * Converts a {@code value} into a {@link Value}. If {@code value} is
+ * {@code null}, {@code Value.isEmpty() == true}.
+ *
+ * @param value
+ * the value to wrap in a {@link Value}
+ * @return the created {@link Value}
+ */
+ // TODO anehmer on 2017-11-26: rename to toValue()?
+ public static <T> Value<T> V(T value) {
+ return Option.of(value);
+ }
+
+ /**
+ * Converts the given string values into a {@link Seq} of {@link Value}s
+ * wrapping the value.
+ *
+ * @param value
+ * the {@link Value}s to put in a {@link Seq}
+ * @return the created {@link Seq} of {@link Value}s
+ */
+ public static Seq<Value<String>> SL(String... values) {
+ return List.of(values)
+ .map(Option::of);
+ }
+
+ /**
+ * Converts the given string {@link Value}s into a {@link Seq} of string
+ * {@link Value}s.
+ *
+ * @param value
+ * the {@link Value}s to put in a {@link Seq}
+ * @return the created {@link Seq} of {@link Value}s
+ */
+ @SafeVarargs
+ public static Seq<Value<String>> SL(Value<String>... values) {
+ return List.of(values);
+ }
+
+ /**
+ * Converts the given {@link Value}s into a {@link Seq} of {@link Value}s.
+ *
+ * @param value
+ * the {@link Value}s to put in a {@link Seq}
+ * @return the created {@link Seq} of {@link Value}s
+ */
+ @SafeVarargs
+ public static Seq<Value<?>> L(Value<?>... values) {
+ return List.of(values);
+ }
+
+ /**
+ * @see #find(Value, Class, Value, Value, Value...)
+ */
+ public <T extends Entity> Try<T> find(Value<String> sourceNameSupplier, Class<T> entityClass,
+ Value<String> idSupplier) {
+ return find(sourceNameSupplier, entityClass, idSupplier, (Value<ContextType>) null, null);
+ }
+
+ /**
+ * @see #find(Value, Class, Value, Value, Value...)
+ */
+ public <T extends Entity> Try<T> find(Value<String> sourceNameSupplier, Class<T> entityClass,
+ Value<String> idSupplier, Seq<Value<String>> parentIdSuppliers) {
+ return find(sourceNameSupplier, entityClass, idSupplier, (Value<ContextType>) null, parentIdSuppliers);
+ }
+
+ /**
+ * @see #find(Value, Class, Value, Value, Value...)
+ */
+ public <T extends Entity> Try<T> find(Value<String> sourceNameSupplier, Class<T> entityClass,
+ Value<String> idSupplier, Value<ContextType> contextTypeSupplier) {
+ return find(sourceNameSupplier, entityClass, idSupplier, contextTypeSupplier, null);
+ }
+
+ /**
+ * Returns the specified entity by given {@code entityClass} and given
+ * {@code id}. If the {@code entityClass} is either {@link CatalogAttribute},
+ * {@link TemplateCompont}, {@link TemplateAttributeAttribute} or
+ * {@link ContextComponent} the respective root entities
+ * {@link CatalogComponent}, {@link TemplateRoot} or {@link ContextRoot} are
+ * used to get the entity to find.
+ *
+ * @param sourceNameSupplier
+ * {@link Value} with the name of the source (MDM {@link Environment}
+ * name)
+ * @param entityClass
+ * entityType
+ * @param idSupplier
+ * {@link Value} with id of entity to find
+ * @param contextTypeSupplier
+ * {@link Value} with the contextType of entity to find. Can be
+ * {@code null} if {@code EntityType} has no {@code ContextType}.
+ * @param parentIdSuppliers
+ * {@link Value}s with the id(s) of parent(s). For
+ * {@link CatalogAttribute} the parentId must be the id of the
+ * {@link CatalogComponent}, for {@link TemplateComponent} it must be
+ * the id of the {@link TemplateRoot}, for {@link TemplateAttribute}
+ * it must be the id of the {@link TemplateRoot} first and also the
+ * {@link TemplateComponent}, for a nested {@link TemplateComponent}
+ * it must be the id of the {@link TemplateRoot} first and the id of
+ * the parent {@link TemplateComponent} second, for a
+ * {@link TemplateAttribute} within a nested
+ * {@link TemplateComponent} it must be the id of the
+ * {@link TemplateRoot} first, the id of the parent
+ * {@link TemplateComponent} second and the id of the
+ * {@link TemplateComponent} last and for {@link ContextComponent} it
+ * must be the id of the {@link ContextRoot}.
+ * @return {@link Try} with the found entity
+ */
+ // TODO anehmer on 2017-11-22: complete javadoc for ValueListValue and
+ // TemplateTestStepUsage
+ // TODO anehmer on 2017-11-22: add comment for parentIds for TplSensors and
+ // nested TplSensors as well as for TplSensorAttrs and nested TplSensorAttrs
+ @SuppressWarnings("unchecked")
+ public <T extends Entity> Try<T> find(Value<String> sourceNameSupplier, Class<T> entityClass,
+ Value<String> idSupplier, Value<ContextType> contextTypeSupplier, Seq<Value<String>> parentIdSuppliers) {
+
+ // validate parentIds count
+ Map<Class<?>, Integer> minParentsForEntity = HashMap.empty();
+ minParentsForEntity = minParentsForEntity.put(Tuple(CatalogAttribute.class, 1))
+ .put(Tuple(CatalogSensor.class, 1))
+ .put(Tuple(TemplateComponent.class, 1))
+ .put(Tuple(TemplateAttribute.class, 2))
+ .put(Tuple(TemplateSensor.class, 2))
+ .put(Tuple(ValueListValue.class, 1))
+ .put(Tuple(TemplateTestStepUsage.class, 1));
+
+ // return failure if number of parentIds do not correspond with the minimu
+ // required by the entity type
+ Option<Integer> minParents = minParentsForEntity.get(entityClass);
+ // TODO anehmer on 2017-11-25: add entity types to message
+ if (minParents.isDefined() && (parentIdSuppliers == null || minParents.get() > parentIdSuppliers.size())) {
+ return Try.failure(new IllegalArgumentException("ParentId(s) of " + entityClass.getSimpleName()
+ + " not set appropriately. Expected minimum: " + minParents.get()));
+ }
+
+ // if the find is contextType specific
+ if (contextTypeSupplier != null && !contextTypeSupplier.isEmpty()) {
+ if (entityClass.equals(CatalogAttribute.class)) {
+ // get CatalogAttribute from CatalogComponent
+ if (parentIdSuppliers.size() == 1) {
+ return find(sourceNameSupplier, CatalogComponent.class, parentIdSuppliers.get(0),
+ contextTypeSupplier)
+ .map(catComp -> (T) getChild(CatalogAttribute.class, idSupplier,
+ catComp::getCatalogAttributes));
+ }
+ // get the CatalogAttribute from a CatalogSensor
+ else if (parentIdSuppliers.size() == 2) {
+ return find(sourceNameSupplier, CatalogSensor.class, parentIdSuppliers.get(1), contextTypeSupplier,
+ parentIdSuppliers.dropRight(1))
+ .map(catComp -> (T) getChild(CatalogAttribute.class, idSupplier,
+ catComp::getCatalogAttributes));
+ }
+ }
+
+ // get CatalogSensor from CatalogComponent
+ else if (entityClass.equals(CatalogSensor.class)) {
+ return find(sourceNameSupplier, CatalogComponent.class, parentIdSuppliers.get(0), contextTypeSupplier)
+ .map(catComp -> (T) getChild(CatalogSensor.class, idSupplier, catComp::getCatalogSensors));
+ }
+
+ // get TemplateComponent from TemplateRoot or parent TemplateComponent(s)
+ else if (entityClass.equals(TemplateComponent.class)) {
+ // if nested TplComp has to be found
+ if (parentIdSuppliers.size() > 1) {
+ return find(sourceNameSupplier, TemplateComponent.class,
+ parentIdSuppliers.get(parentIdSuppliers.size() - 1), contextTypeSupplier,
+ parentIdSuppliers.dropRight(1))
+ .map(tplComp -> (T) getChild(TemplateComponent.class, idSupplier,
+ tplComp::getTemplateComponents));
+ }
+ // if non-nested TplComp has to be found: exit condition of recursive call
+ return find(sourceNameSupplier, TemplateRoot.class, parentIdSuppliers.get(0), contextTypeSupplier).map(
+ tplRoot -> (T) getChild(TemplateComponent.class, idSupplier, tplRoot::getTemplateComponents));
+ }
+
+ // get TemplateAttributes from TemplateComponent
+ else if (entityClass.equals(TemplateAttribute.class)) {
+ Try<TemplateComponent> tplCompTry = find(sourceNameSupplier, TemplateComponent.class,
+ parentIdSuppliers.get(parentIdSuppliers.size() - 1), contextTypeSupplier,
+ parentIdSuppliers.dropRight(1));
+ // if TemplateSensorAttribute has to be found
+ if (!tplCompTry.isFailure()) {
+ return tplCompTry.map(tplComp -> (T) getChild(TemplateAttribute.class, idSupplier,
+ tplComp::getTemplateAttributes));
+ } else {
+ return find(sourceNameSupplier, TemplateSensor.class,
+ parentIdSuppliers.get(parentIdSuppliers.size() - 1), contextTypeSupplier,
+ parentIdSuppliers.dropRight(1))
+ .map(tplComp -> (T) getChild(TemplateAttribute.class, idSupplier,
+ tplComp::getTemplateAttributes));
+ }
+ }
+
+ // get TemplateSensor from TemplateComponent
+ else if (entityClass.equals(TemplateSensor.class)) {
+ return find(sourceNameSupplier, TemplateComponent.class,
+ parentIdSuppliers.get(parentIdSuppliers.size() - 1), contextTypeSupplier,
+ parentIdSuppliers.dropRight(1)).map(
+ tplComp -> (T) getChild(TemplateSensor.class, idSupplier, tplComp::getTemplateSensors));
+ }
+
+ // get ContextComponent from ContextRoot
+ else if (entityClass.equals(ContextComponent.class)) {
+ // TODO anehmer on 2017-11-09: implement (also for nested ContextComponents)
+ throw new NotImplementedException("NOT IMPLEMENTED YET");
+ }
+
+ // get root nested entities (CatalogComponent, TemplateRoot, ContextRoot)
+ return getEntityManager(sourceNameSupplier)
+ .mapTry(em -> em.load(entityClass, contextTypeSupplier.get(), idSupplier.get()));
+ }
+
+ // get ValueListValue from ValueList
+ else if (entityClass.equals(ValueListValue.class)) {
+ return find(sourceNameSupplier, ValueList.class, parentIdSuppliers.get(0))
+ .map(valueList -> (T) getChild(ValueListValue.class, idSupplier, valueList::getValueListValues));
+ }
+
+ // get TemplateTestStepUsage from TemplateTest
+ else if (entityClass.equals(TemplateTestStepUsage.class)) {
+ return find(sourceNameSupplier, TemplateTest.class, parentIdSuppliers.get(0))
+ .map(tplTest -> (T) getChild(TemplateTestStepUsage.class, idSupplier,
+ tplTest::getTemplateTestStepUsages));
+ }
+
+ // for all other cases
+ return getEntityManager(sourceNameSupplier).map(em -> em.load(entityClass, idSupplier.get()));
+ }
+
+ /**
+ * Gets the child with the given {@code childId} or an EntityNotFoundException
+ * if the child was not found
+ *
+ * @param childClass
+ * class of child to construct exception on failure
+ * @param childIdSupplier
+ * supplier of the id of child to find
+ * @param childSupplier
+ * function that gets all children
+ * @return the found child
+ */
+ private <T extends Entity> T getChild(Class<T> childClass, Value<String> childIdSupplier,
+ Function0<java.util.List<T>> childSupplier) {
+ return Stream.ofAll(childSupplier.apply())
+ .find(childEntity -> childEntity.getID()
+ .equals(childIdSupplier.get()))
+ .getOrElseThrow(() -> new EntityNotFoundException(childClass, childIdSupplier.get()));
+ }
+
+ /**
+ * Returns a {@link Try} of all {@link Entity}s if no filter is available.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param entityClass
+ * class of the {@link Entity} to find
+ * @param filter
+ * filter string to filter the {@link Entity} result. Can be null.
+ * @return a {@link Try} of the list of found {@link Entity}s
+ */
+ // TODO anehmer on 2017-11-26: make filter Value<String>
+ public <T extends Entity> Try<List<T>> findAll(Value<String> sourceNameSupplier, Class<T> entityClass,
+ String filter) {
+ return findAll(sourceNameSupplier, entityClass, filter, null);
+ }
+
+ /**
+ * Returns a {@link Try} of the matching {@link Entity}s of the given
+ * contextType using the given filter or all {@link Entity}s of the given
+ * contextType provided by the {@code contextTypeSupplier} if no filter is
+ * available.
+ *
+ * @param sourceNameSupplier
+ * {@link Value} with the name of the source (MDM {@link Environment}
+ * name)
+ * @param entityClass
+ * class of the {@link Entity} to find
+ * @param filter
+ * filter string to filter the {@link Entity} result
+ * @param contextTypeSupplier
+ * a {@link Value} with the contextType of entity to find. Can be
+ * {@code null} if {@code EntityType} has no {@code ContextType}.
+ * @return a {@link Try} of the list of found {@link Entity}s
+ */
+ // TODO anehmer on 2017-11-26: make filter Value<String>
+ public <T extends Entity> Try<List<T>> findAll(Value<String> sourceNameSupplier, Class<T> entityClass,
+ String filter, Value<ContextType> contextTypeSupplier) {
+ // TODO anehmer on 2017-11-22: do we need to implement the navigationActivity
+ // filter shortcut like in ChannelGroupService.getChannelGroups()
+ if (filter == null || filter.trim()
+ .length() <= 0) {
+ return Try
+ .of(getLoadAllEntitiesMethod(getEntityManager(sourceNameSupplier).get(), entityClass,
+ contextTypeSupplier))
+ .map(javaList -> List.ofAll(javaList));
+ } else {
+ // TODO anehmer on 2017-11-15: not tested
+ return Try
+ .of(() -> this.searchActivity.search(connectorService.getContextByName(sourceNameSupplier.get()),
+ entityClass, filter))
+ .map(javaList -> List.ofAll(javaList));
+ }
+ }
+
+ /**
+ * Returns the method to load all entities of type {@code entityClass}. If a
+ * {@code ContextType} is given the appropriate method in
+ * {@link org.eclipse.mdm.api.dflt.EntityManager} is used
+ *
+ * @param entityManager
+ * entityManager to load entities with
+ * @param entityClass
+ * class of entites to load
+ * @param contextType
+ * {@link ContextType} of entities of null if none
+ * @return the appropriate loadAllEntities() method
+ */
+ private <T extends Entity> CheckedFunction0<java.util.List<T>> getLoadAllEntitiesMethod(EntityManager entityManager,
+ Class<T> entityClass, Value<ContextType> contextType) {
+ // if contextType is specified
+ if (contextType != null && !contextType.isEmpty()) {
+ return (() -> entityManager.loadAll(entityClass, contextType.get()));
+ }
+ return (() -> entityManager.loadAll(entityClass));
+ }
+
+ /**
+ * Creates a new {@link Entity} of type entityClass. The method searches the
+ * {@link EntityFactory} for a suitable create() method by matching the return
+ * parameter and the given entity class. If more than one method is found, the
+ * first one is taken. The argument are provided by {@link Try<Object>}s so that
+ * any exceptions thrown throughout retrieval will be wrapped in the returned
+ * {@link Try}.
+ *
+ * @param entityClass
+ * class of the {@link Entity} to create
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param argumentSuppliers
+ * varargs of {@link Try<?>s that supply the create() method
+ * arguments
+ * @return a {@link Try} with the created {@link Entity}
+ */
+ @SuppressWarnings("unchecked")
+ public <T extends Entity> Try<T> create(Value<String> sourceNameSupplier, Class<T> entityClass,
+ Seq<Value<?>> argumentSuppliers) {
+
+ // get corresponding create method for entityClass from EntityFactory
+ return Try.of(() -> connectorService.getContextByName(sourceNameSupplier.get())
+ .getEntityFactory())
+ .mapTry(factory -> (T) Stream.of(EntityFactory.class.getMethods())
+ // find method with the return type matching entityClass
+ .filter(m -> m.getReturnType()
+ .equals(entityClass))
+ .filter(m -> Arrays.asList(m.getParameterTypes())
+ // compare argument types
+ .equals(argumentSuppliers.map(s -> s.get()
+ .getClass())
+ .toJavaList()))
+ .getOrElseThrow(() -> new NoSuchMethodException(
+ "No matching create()-method found for EntityType " + entityClass.getSimpleName()
+ + " taking the parameters " + argumentSuppliers.map(s -> s.get()
+ .getClass()
+ .getName())
+ .collect(Collectors.joining(", "))))
+ // invoke with given arguments
+ .invoke(factory.get(), argumentSuppliers.map(Value::get)
+ .toJavaArray()))
+
+ // start transaction to create the entity
+ .map(e -> DataAccessHelper.execute(getEntityManager(sourceNameSupplier).get(), e,
+ DataAccessHelper.CREATE));
+ }
+
+ /**
+ * Updates the given {@link Entity} with the values of the given map provided by
+ * the {@code valueMapSupplier}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param entity
+ * the entity to update
+ * @param valueMapSupplier
+ * {@link Supplier<Map<String, Object>> of a map of values to update
+ * the entity with according to matching attribute values by name case sensitive
+ * @return a {@link Try} of the updated entity
+ */
+ public <T extends Entity> Try<T> update(Value<String> sourceNameSupplier, Try<T> entity,
+ Value<Map<String, Object>> valueMapSupplier) {
+ // return updated entity
+ return
+ // update entity values
+ entity.map(e -> updateEntityValues(e, valueMapSupplier.get(), sourceNameSupplier))
+ // persist entity
+ .map(e -> DataAccessHelper.execute(getEntityManager(sourceNameSupplier).get(), e.get(),
+ DataAccessHelper.UPDATE));
+ }
+
+ /**
+ * Deletes the given {@link Entity} {@code valueMapSupplier}.
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param entity
+ * the entity to delete
+ * @return a {@link Try} of the deleted entity
+ */
+ public <T extends Entity> Try<T> delete(Value<String> sourceNameSupplier, Try<T> entity) {
+ return entity.map(
+ e -> DataAccessHelper.execute(getEntityManager(sourceNameSupplier).get(), e, DataAccessHelper.DELETE));
+ }
+
+ /**
+ * Returns a {@link Try} of the the {@link SearchAttribute}s for the given
+ * entityClass
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param entityClass
+ * class of the {@link Entity} to get the {@link SearchAttribute}s
+ * for
+ *
+ * @return a {@link Try} with the {@link SearchAttribute}s
+ */
+ public <T extends Entity> Try<List<SearchAttribute>> getSearchAttributesSupplier(Value<String> sourceNameSupplier,
+ Class<T> entityClass) {
+ return Try.of(() -> List.ofAll(this.searchActivity
+ .listAvailableAttributes(connectorService.getContextByName(sourceNameSupplier.get()), entityClass)));
+ }
+
+ /**
+ * Returns a {@link Try} of the localized {@link Entity} type name
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param entityClass
+ * class of the {@link Entity} to be localized
+ *
+ * @return a {@link Try} with the localized {@link Entity} type name
+ */
+ public <T extends Entity> Try<Map<EntityType, String>> getLocalizeTypeSupplier(Value<String> sourceNameSupplier,
+ Class<T> entityClass) {
+ return Try.of(() -> HashMap.ofAll(this.i18nActivity.localizeType(sourceNameSupplier.get(), entityClass)));
+ }
+
+ /**
+ * Returns a {@link Try} of the localized {@link Entity} attributes
+ *
+ * @param sourceName
+ * name of the source (MDM {@link Environment} name)
+ * @param entityClass
+ * class of the {@link Entity} to be localized
+ * @return a {@link Try} with the the localized {@link Entity} attributes
+ */
+ public <T extends Entity> Try<Map<Attribute, String>> getLocalizeAttributesSupplier(
+ Value<String> sourceNameSupplier, Class<T> entityClass) {
+ return Try.of(() -> HashMap.ofAll(this.i18nActivity.localizeAttributes(sourceNameSupplier.get(), entityClass)));
+ }
+
+ /**
+ * Returns a {@link Try} of an {@link EnumerationValue} for the name supplied by
+ * the {@code enumValueNameSupplier}
+ *
+ * @param enumValueNameSupplier
+ * supplies the name of the {@link EnumerationValue} to get
+ * @return a {@link Try} with the resolved {@link EnumerationValue}
+ */
+ public Try<EnumerationValue> getEnumerationValueSupplier(Try<?> enumValueNameSupplier) {
+ return Try.of(() -> EnumRegistry.getInstance()
+ .get(EnumRegistry.VALUE_TYPE)
+ .valueOf(enumValueNameSupplier.get()
+ .toString()));
+ }
+
+ /**
+ * Gets the EntityManager from the ConnectorService with the given source name
+ * provided by the {@code sourceNameSupplier}.
+ *
+ * @param sourceNameSupplier
+ * {@link Value} with the name of the datasource to get EntityManager
+ * for
+ * @return the found EntityManager. Throws {@link MDMEntityAccessException} if
+ * not found.
+ */
+ private Try<EntityManager> getEntityManager(Value<String> sourceNameSupplier) {
+ return Try.of(() -> this.connectorService.getContextByName(sourceNameSupplier.get())
+ .getEntityManager()
+ .orElseThrow(() -> new MDMEntityAccessException("Entity manager not present")));
+ }
+
+ /**
+ * Updates the given {@link Entity} with the values from the given valueMap. All
+ * matching attributes (case sensitive) are updated as well as the referenced
+ * relations by the id of the given
+ * {@link org.eclipse.mdm.api.base.model.Entity} and the simple class name as
+ * the key (the data model attribute name is the reference, case sensitive).
+ *
+ * @param entity
+ * the entity to update
+ * @param valueMap
+ * values to update the entity with according to matching attribute
+ * names. The keys are compared case sensitive.
+ * @return a {@link Try} with the the updated entity
+ */
+ @SuppressWarnings("unchecked")
+ public <T extends Entity> Try<T> updateEntityValues(T entity, Map<String, Object> valueMap,
+ Value<String> sourceNameSupplier) {
+
+ HashMap<String, org.eclipse.mdm.api.base.model.Value> entityValues = HashMap.ofAll(entity.getValues());
+
+ // update primitive values where the key from the valueMap has a matching entity
+ // value and collect the updated keys
+ Set<String> updatedPrimitiveValues = valueMap
+ .filter((valueMapEntryKey, valueMapEntryValue) -> entityValues.containsKey(valueMapEntryKey)
+ && !(valueMapEntryValue instanceof java.util.Map))
+ .map((entityValueEntryKey, entityValueEntryValue) -> {
+ entityValues.get(entityValueEntryKey)
+ .forEach(value -> value.set(entityValueEntryValue));
+ return new Tuple2<>(entityValueEntryKey, entityValueEntryValue);
+ })
+ .keySet();
+
+ // update enumeration values
+ Set<String> updatedEnumerationValues = valueMap
+ .filter((valueMapEntryKey, valueMapEntryValue) -> entityValues.containsKey(valueMapEntryKey)
+ && (valueMapEntryValue instanceof java.util.Map))
+ .map((entityValueEntryKey, entityValueEntryValue) -> {
+ entityValues.get(entityValueEntryKey)
+ .forEach(value -> {
+ // get key-value-pairs that identify the enum und enumValue
+ String enumName = ((java.util.Map<String, String>) entityValueEntryValue)
+ .get("Enumeration");
+ String enumValueName = ((java.util.Map<String, String>) entityValueEntryValue)
+ .get("EnumerationValue");
+
+ if (enumName == null || enumValueName == null) {
+ throw new IllegalArgumentException("EnumerationValue is set by providing a map "
+ + "containing the keys 'Enumeration' and 'EnumerationValue' "
+ + "and the respective names as the values");
+ }
+
+ // find enumeration and the enumeration value
+ Option.of(EnumRegistry.getInstance()
+ // get enum
+ .get(enumName))
+ .onEmpty(() -> {
+ throw new IllegalArgumentException(
+ "Enumeration [" + enumName + "] not found");
+ })
+ // get enumValue
+ .map(enumeration -> enumeration.valueOf(enumValueName))
+ // if enumValue is not found, null is returned
+ .filter(Objects::nonNull)
+ .onEmpty(() -> {
+ throw new IllegalArgumentException("EnumerationValue [" + enumValueName
+ + "] not found in Enumeration [" + enumName + "]");
+ })
+ // set enumValue
+ .map(enumValue -> {
+ value.set(enumValue);
+ return enumValue;
+ });
+
+ });
+ return new Tuple2<>(entityValueEntryKey, entityValueEntryValue);
+ })
+ .keySet();
+
+ // update the relations and gather the updated keys
+ // use only those keys that have not been updated yet and can be resolved as
+ // class names. If so, try to update accordingly named relation with the entity
+ // found by its id given as the value
+ Set<String> updatedRelations = valueMap
+ .filter((valueMapEntryKey, valueMapEntryValue) -> !updatedPrimitiveValues.contains(valueMapEntryKey)
+ && !updatedEnumerationValues.contains(valueMapEntryKey))
+ .filter((relatedEntityClassName, relatedEntityId) -> {
+ EntityStore store = getMutableStore(entity);
+
+ ContextType contextType = null;
+ // determine if class has a context type
+ for (ContextType ct : ContextType.values()) {
+ int index = relatedEntityClassName.toUpperCase()
+ .indexOf(ct.name());
+ if (index > 0) {
+ contextType = ct;
+ // cut out ContextType
+ relatedEntityClassName = relatedEntityClassName.substring(0, index)
+ + relatedEntityClassName.substring(index + ct.name()
+ .length());
+ }
+ }
+
+ // to have final variables for Try
+ final String processedRelatedEntityClassName = relatedEntityClassName;
+ final ContextType contextTypeIfPresent = contextType;
+
+ // load class from model packages
+ Try<Class<Entity>> updateTry = Try
+ .of(() -> (Class<Entity>) Class
+ .forName("org.eclipse.mdm.api.base.model." + processedRelatedEntityClassName))
+ .orElse(Try.of(() -> (Class<Entity>) Class
+ .forName("org.eclipse.mdm.api.dflt.model." + processedRelatedEntityClassName)))
+ // update related entity by first finding the related entity by its id
+ // use find and store.set() with ContextType if needed
+ .andThenTry(entityClass -> {
+ if (contextTypeIfPresent == null) {
+ store.set(find(sourceNameSupplier, entityClass, V(relatedEntityId.toString()))
+ .onFailure(e -> LOGGER.error(e.getMessage()))
+ .get());
+ } else {
+ store.set(find(sourceNameSupplier, entityClass, V(relatedEntityId.toString()),
+ V(contextTypeIfPresent)).onFailure(e -> LOGGER.error(e.getMessage()))
+ .get(),
+ contextTypeIfPresent);
+ }
+ })
+ .onFailure(e -> LOGGER.error("Entity of type [" + processedRelatedEntityClassName
+ + "] and ID " + relatedEntityId + " not found", e));
+
+ return updateTry.isSuccess() ? true : false;
+ })
+ .keySet();
+
+ // return Try.Failure if there are keys that are not present in the entity and
+ // thus are not updated
+ String unmappedKeys = valueMap
+ .filterKeys(key -> !updatedPrimitiveValues.contains(key) && !updatedEnumerationValues.contains(key)
+ && !updatedRelations.contains(key))
+ .map(Tuple::toString)
+ .collect(Collectors.joining(", "));
+
+ if (unmappedKeys != null && !unmappedKeys.isEmpty()) {
+ return Try.failure(
+ new IllegalArgumentException("ValueMap to update entity contains the following keys that either "
+ + "have no match in the entity values or relations to update "
+ + "or an error occurred while finding the related entity: " + unmappedKeys));
+ } else {
+ return Try.of(() -> entity);
+ }
+ }
+
+ /**
+ * Get the mutableStore from {@link org.eclipse.mdm.api.base.adapter.Core} of
+ * given {@link org.eclipse.mdm.api.base.model.Entity}
+ *
+ * @param e
+ * Entity to get Core of
+ * @return Core of given Entity
+ */
+ private static EntityStore getMutableStore(Entity e) {
+ return Try.of(() -> {
+ Method getMetod;
+ try {
+ getMetod = BaseEntity.class.getDeclaredMethod("getCore");
+ getMetod.setAccessible(true);
+ } catch (NoSuchMethodException | SecurityException x) {
+ throw new IllegalStateException(
+ "Unable to load 'getCore()' in class '" + BaseEntity.class.getSimpleName() + "'.", x);
+ }
+ Core core = (Core) getMetod.invoke(e);
+ return core.getMutableStore();
+ })
+ .get();
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/EntityNotFoundException.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/EntityNotFoundException.java
new file mode 100755
index 00000000..dc0189b7
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/EntityNotFoundException.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.utils;
+
+import org.eclipse.mdm.api.base.model.Entity;
+
+/**
+ * Exception thrown if entity could not be retrieved from the datastore
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+public class EntityNotFoundException extends RuntimeException {
+
+ private static final long serialVersionUID = 6862157710262117670L;
+
+ /**
+ * Default constructor with causing exception
+ *
+ * @param entityClass
+ * Class of entity that could not be found
+ * @param id
+ * id of entity that could not be found
+ * @param x
+ * the cause of the exception
+ */
+ public EntityNotFoundException(Class<? extends Entity> entityClass, String id, Throwable x) {
+ super(entityClass.getSimpleName() + " with ID " + id + " not found.", x);
+ }
+
+ /**
+ * Default constructor without causing exception
+ *
+ * @param entityClass
+ * Class of entity that could not be found
+ * @param id
+ * id of entity that could not be found
+ */
+ public EntityNotFoundException(Class<? extends Entity> entityClass, String id) {
+ super(entityClass.getSimpleName() + " with ID " + id + " not found.");
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/ISODateDeseralizer.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/ISODateDeseralizer.java
new file mode 100755
index 00000000..181995fd
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/ISODateDeseralizer.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.utils;
+
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonTokenId;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer;
+
+/**
+ * JSON Deserializer for ISO 8601 compliant dates with format
+ *
+ * <pre>
+ * yyyy-MM-dd'T'HH:mm:ss'Z'
+ * </pre>
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+class ISODateDeseralizer extends UntypedObjectDeserializer {
+
+ private static final long serialVersionUID = 1L;
+
+ transient DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");
+
+ /**
+ * Overridden constructor as default one is deprecated
+ *
+ * @param listType
+ * @see #{@link com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer}
+ * @param mapType
+ * @see #{@link com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer}
+ */
+ public ISODateDeseralizer(JavaType listType, JavaType mapType) {
+ super(listType, mapType);
+ }
+
+ /**
+ * Deserialize JSON and try to parse every String as an ISO8601 date
+ */
+ @Override
+ public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
+ // try to parse every string as a date
+ // TODO anehmer on 2018-04-30: this approach could lead to a performance leak as
+ // every incoming string is tried to be converted into a date though the
+ // appraoch is very generic
+ if (jp.getCurrentTokenId() == JsonTokenId.ID_STRING) {
+ try {
+ return LocalDateTime.parse(jp.getText(), dateFormatter);
+ } catch (Exception e) {
+ return super.deserialize(jp, ctxt);
+ }
+ } else {
+ return super.deserialize(jp, ctxt);
+ }
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/RequestBody.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/RequestBody.java
new file mode 100644
index 00000000..307c1f25
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/RequestBody.java
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.utils;
+
+import java.util.NoSuchElementException;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
+import io.vavr.API;
+import io.vavr.CheckedFunction0;
+import io.vavr.Lazy;
+import io.vavr.collection.HashMap;
+import io.vavr.collection.Map;
+import io.vavr.control.Try;
+
+/**
+ * Class representing the JSON request body as a accessible map of values. The
+ * parsing occurs lazily on first get() on a value and as the {@link Lazy}
+ * result is memoized, the body is only parsed once. Any exceptions due to
+ * parsing or non-existing keys are thrown on get() call.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+public final class RequestBody {
+
+ private Lazy<HashMap<String, Object>> requestBodyMap;
+ private static ObjectMapper mapper;
+
+ static {
+ mapper = new ObjectMapper();
+ SimpleModule simpleModule = new SimpleModule();
+ simpleModule.addDeserializer(Object.class, new ISODateDeseralizer(null, null));
+ mapper.registerModule(simpleModule);
+ }
+
+ /**
+ * Just hide the default constructor
+ */
+ private RequestBody() {
+ }
+
+ /**
+ * Builds RequestBody by using the given function that returns the request body
+ * as a parsed {@link Map<String, Object>.
+ *
+ * @param requestBodyMapSupplier
+ * function that return a {@link Map<String, Object> with the parsed
+ * JSON body
+ */
+ private RequestBody(CheckedFunction0<HashMap<String, Object>> requestBodyMapSupplier) {
+ // make the function lazily evaluated, so that any parsing exception occur on
+ // first get() on a value
+ // unchecked() makes it possible to trick the compiler to not force us to deal
+ // with the checked exceptions here
+ this.requestBodyMap = Lazy.of(API.unchecked(requestBodyMapSupplier));
+ }
+
+ /**
+ * Creates a RequestBody
+ *
+ * @param body
+ * JSON request body to create RequestBody
+ * @return the RequestBody
+ */
+ public static RequestBody create(String requestBodyString) {
+ // create requestbody with a function that parses the json request and
+ // transforms it to a {@link Map<String, Object>
+ return new RequestBody(() -> HashMap
+ .ofAll(mapper.readValue(requestBodyString, new TypeReference<java.util.Map<String, Object>>() {
+ })));
+ }
+
+ /**
+ * Returns a {@link Try> that holds the string value for the given key. If the
+ * underlying request body map can be parsed, the appropriate JSON exceptions
+ * are thrown if get() is called on the {@link Try>. If the key was not found, a
+ * {@link NoSuchElementException} is thrown correspondingly.
+ *
+ * @param key
+ * key to get value for
+ * @return the string value for the given key
+ */
+ public Try<String> getStringValueSupplier(String key) {
+ return Try.of(() -> Lazy.of(() -> requestBodyMap.get()
+ .get(key)
+ .map(Object::toString)
+ .onEmpty(() -> {
+ throw new NoSuchElementException("Key [" + key + "] not found in request body.");
+ })
+ .get())
+ .get());
+ }
+
+ /**
+ * Returns a {@link Try<Object>> that holds the value for the given key. If the
+ * underlying request body map can be parsed, the appropriate JSON exceptions
+ * are thrown if get() is called on the {@link Try>. If the key was not found, a
+ * {@link NoSuchElementException} is thrown correspondingly.
+ *
+ * @param key
+ * key to get value for
+ * @return the value for the given key
+ */
+ public Try<Object> getValueSupplier(String key) {
+ return Try.of(() -> Lazy.of(() -> requestBodyMap.get()
+ .get(key)
+ .map(Object::toString)
+ .onEmpty(() -> {
+ throw new NoSuchElementException("Key [" + key + "] not found in request body.");
+ })
+ .get())
+ .get());
+ }
+
+ /**
+ * Returns a {@link Try} of the complete {@link Map<String, Object>} of the
+ * request body
+ *
+ * @return a {@link Try} of {@link Map<String, Object>} of the request body
+ */
+ public Try<Map<String, Object>> getValueMapSupplier() {
+ return Try.of(() -> requestBodyMap.get());
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/ServiceUtils.java b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/ServiceUtils.java
index d167470c..7411c7bb 100644
--- a/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/ServiceUtils.java
+++ b/org.eclipse.mdm.businessobjects/src/main/java/org/eclipse/mdm/businessobjects/utils/ServiceUtils.java
@@ -12,6 +12,7 @@
package org.eclipse.mdm.businessobjects.utils;
import java.util.List;
+import java.util.function.Function;
import java.util.stream.Collectors;
import javax.ws.rs.core.GenericEntity;
@@ -22,6 +23,7 @@ import javax.ws.rs.core.Response.Status;
import org.eclipse.mdm.api.base.ServiceNotProvidedException;
import org.eclipse.mdm.api.base.adapter.EntityType;
import org.eclipse.mdm.api.base.adapter.ModelManager;
+import org.eclipse.mdm.api.base.model.ContextType;
import org.eclipse.mdm.api.base.model.Entity;
import org.eclipse.mdm.api.base.model.ValueType;
import org.eclipse.mdm.api.base.query.ComparisonOperator;
@@ -30,26 +32,21 @@ import org.eclipse.mdm.api.base.query.Filter;
import org.eclipse.mdm.api.base.query.FilterItem;
import org.eclipse.mdm.api.dflt.ApplicationContext;
import org.eclipse.mdm.api.dflt.EntityManager;
+import org.eclipse.mdm.api.dflt.model.ValueList;
import org.eclipse.mdm.businessobjects.control.FilterParser;
+import org.eclipse.mdm.businessobjects.entity.I18NResponse;
+import org.eclipse.mdm.businessobjects.entity.MDMEntityResponse;
+import org.eclipse.mdm.businessobjects.entity.SearchAttributeResponse;
+import org.eclipse.mdm.businessobjects.service.EntityService;
+import org.slf4j.LoggerFactory;
+
+import io.vavr.Value;
+import io.vavr.collection.Stream;
+import io.vavr.control.Try;
public final class ServiceUtils {
-
- private ServiceUtils() {
- }
- /**
- * converts the given object to a {@link Response} with the given
- * {@link Status}
- *
- * @param responseEntry
- * object to convert
- * @param status
- * {@link Status} of the {@link Response}
- * @return the created {@link Response}
- */
- public static Response toResponse(Object response, Status status) {
- GenericEntity<Object> genEntity = new GenericEntity<Object>(response, response.getClass());
- return Response.status(status).entity(genEntity).type(MediaType.APPLICATION_JSON).build();
+ private ServiceUtils() {
}
/**
@@ -64,8 +61,10 @@ public final class ServiceUtils {
* class of the parent entity
* @return true if the give filter String is a parent filter
*/
- public static boolean isParentFilter(ApplicationContext context, String filter, Class<? extends Entity> parentType) {
- ModelManager mm = context.getModelManager().orElseThrow(() -> new ServiceNotProvidedException(ModelManager.class));
+ public static boolean isParentFilter(ApplicationContext context, String filter,
+ Class<? extends Entity> parentType) {
+ ModelManager mm = context.getModelManager()
+ .orElseThrow(() -> new ServiceNotProvidedException(ModelManager.class));
EntityType et = mm.getEntityType(parentType);
Filter f = FilterParser.parseFilterString(mm.listEntityTypes(), filter);
@@ -94,8 +93,10 @@ public final class ServiceUtils {
* this means the filter does not have exactly one condition on the parent's
* ID attribute with {@link ComparisonOperator#EQUAL}
*/
- public static String extactIdFromParentFilter(ApplicationContext context, String filter, Class<? extends Entity> parentType) {
- ModelManager mm = context.getModelManager().orElseThrow(() -> new ServiceNotProvidedException(ModelManager.class));
+ public static String extactIdFromParentFilter(ApplicationContext context, String filter,
+ Class<? extends Entity> parentType) {
+ ModelManager mm = context.getModelManager()
+ .orElseThrow(() -> new ServiceNotProvidedException(ModelManager.class));
EntityType et = mm.getEntityType(parentType);
Filter f = FilterParser.parseFilterString(mm.listEntityTypes(), filter);
@@ -135,4 +136,165 @@ public final class ServiceUtils {
return entityType.getName();
}
}
+
+ /**
+ * Builds {@Link Response} from given {@link Entity}
+ *
+ * @param entity
+ * {@link Entity} to build {@link Response} from
+ * @return the build {@link Response}
+ */
+ public static <T extends Entity> Response buildEntityResponse(T entity, Status status) {
+ if (entity != null) {
+ MDMEntityResponse response = new MDMEntityResponse(entity.getClass(), entity);
+ // TODO anehmer on 2018-02-08: relations should be included in the output
+ GenericEntity<Object> genEntity = new GenericEntity<Object>(response, response.getClass());
+ return Response.status(status)
+ .entity(genEntity)
+ .type(MediaType.APPLICATION_JSON)
+ .build();
+ } else {
+ return Response.status(Status.NO_CONTENT)
+ .type(MediaType.APPLICATION_JSON)
+ .build();
+ }
+ }
+
+ /**
+ * Builds {@Link Response} from given {@link Entity}
+ *
+ * @param entity
+ * {@link Entity} to build {@link Response} from
+ * @return the build {@link Response}
+ */
+ public static <T extends Entity> Response buildEntityResponse(io.vavr.collection.List<T> entities, Status status) {
+ if (entities.nonEmpty()) {
+ @SuppressWarnings("unchecked")
+ Class<T> entityClass = (Class<T>) entities.get()
+ .getClass();
+ MDMEntityResponse response = new MDMEntityResponse(entityClass, entities.asJava());
+ GenericEntity<Object> genEntity = new GenericEntity<Object>(response, response.getClass());
+ return Response.status(status)
+ .entity(genEntity)
+ .type(MediaType.APPLICATION_JSON)
+ .build();
+ } else {
+ return Response.status(Status.NO_CONTENT)
+ .type(MediaType.APPLICATION_JSON)
+ .build();
+ }
+ }
+
+ /**
+ * Builds {@Link Response} from given {@link Entity}
+ *
+ * @param entity
+ * {@link Entity} to build {@link Response} from
+ * @return the build {@link Response}
+ */
+ public static <T extends Entity> Response buildErrorResponse(Throwable t, Status status) {
+ return Response.status(status)
+ .entity(t)
+ .type(MediaType.APPLICATION_JSON)
+ .build();
+ }
+
+ /**
+ * Converts the given object to a {@link Response} with the given {@link Status}
+ *
+ * @param response
+ * object to convert
+ * @param status
+ * {@link Status} of the {@link Response}
+ * @return the created {@link Response}
+ */
+ public static Response toResponse(Object response, Status status) {
+ GenericEntity<Object> genEntity = new GenericEntity<Object>(response, response.getClass());
+ return Response.status(status)
+ .entity(genEntity)
+ .type(MediaType.APPLICATION_JSON)
+ .build();
+ }
+
+ /**
+ * Return the search attributes for the {@link ValueList} type.
+ *
+ * @param sourceNameSupplier
+ * {@link Value} with the name of the source (MDM {@link Environment}
+ * name)
+ * @param entityClass
+ * {@link Entity} class to get localization data for
+ * @param entityService
+ * {@link EntityService} used to get localization data
+ * @return the result of the delegated request as {@link Response}
+ */
+ public static <T extends Entity> Response buildSearchAttributesResponse(Value<String> sourceNameSupplier,
+ Class<T> entityClass, EntityService entityService) {
+ return entityService.getSearchAttributesSupplier(sourceNameSupplier, entityClass)
+ .map(searchAttributes -> ServiceUtils
+ .toResponse(new SearchAttributeResponse(searchAttributes.toJavaList()), Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * Return the localized type and attributes for the {@link Entity} type.
+ *
+ * @param sourceNameSupplier
+ * {@link Value} with the name of the source (MDM {@link Environment}
+ * name)
+ * @param entityClass
+ * {@link Entity} class to get localization data for
+ * @param entityService
+ * {@link EntityService} used to get localization data
+ * @return the {@link Response} with the localized data
+ */
+ public static <T extends Entity> Response buildLocalizationResponse(Value<String> sourceNameSupplier,
+ Class<T> entityClass, EntityService entityService) {
+ return Try
+ .of(() -> ServiceUtils.toResponse(new I18NResponse(
+ entityService.getLocalizeTypeSupplier(sourceNameSupplier, entityClass)
+ .get()
+ .toJavaMap(),
+ entityService.getLocalizeAttributesSupplier(sourceNameSupplier, entityClass)
+ .get()
+ .toJavaMap()),
+ Status.OK))
+ .recover(ServiceUtils.ERROR_RESPONSE_SUPPLIER)
+ .getOrElse(ServiceUtils.SERVER_ERROR_RESPONSE);
+ }
+
+ /**
+ * A Response representing a server error.
+ */
+ public final static Response SERVER_ERROR_RESPONSE = Response.serverError()
+ .build();
+
+ /**
+ * Builds an error response based on an exception to be sent to the client
+ */
+ public static final Function<? super Throwable, Response> ERROR_RESPONSE_SUPPLIER = (e) -> {
+ LoggerFactory.getLogger(ServiceUtils.class)
+ .error(e.getMessage(), e);
+ // TODO anehmer on 2017-11-22: customize status according to exception
+ return Response.status(Status.INTERNAL_SERVER_ERROR)
+ .entity(e.getStackTrace()[0].getClassName() + "." + e.getStackTrace()[0].getMethodName() + ": "
+ + e.getMessage())
+ .type(MediaType.APPLICATION_JSON)
+ .build();
+ };
+
+ /**
+ * Returns a {@link Try} to get the {@link ContextType} for the provided name
+ *
+ * @param contextTypeName
+ * name of the {@link ContextType}
+ * @return a {@link Try} of the {@link ContextType} for the given name
+ */
+ public static Try<ContextType> getContextTypeSupplier(String contextTypeName) {
+ return Stream.of(ContextType.values())
+ .filter(contextType -> contextType.name()
+ .equals(contextTypeName.toUpperCase()))
+ .toTry();
+ }
}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogAttributeTEQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogAttributeTEQResourceIntegrationTest.java
new file mode 100644
index 00000000..537a68e0
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogAttributeTEQResourceIntegrationTest.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for CatalogAttributeResource for TestEquipment
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class CatalogAttributeTEQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing CatalogAttributeTEQResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogComponent
+ CatalogComponentTEQResourceIntegrationTest.prepareTestData();
+ CatalogComponentTEQResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the ValueList to reference
+ ValueListResourceIntegrationTest.prepareTestData();
+ ValueListResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(CatalogAttributeTEQResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/catcomps/testequipment/"
+ + getTestDataValue(CatalogComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/catattrs");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testCatAttrTEQ");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "CatalogAttribute");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_DATATYPE, new JsonPrimitive("STRING"));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ json = new JsonObject();
+ json.add("ValueList",
+ new JsonPrimitive(getTestDataValue(ValueListResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(CatalogComponentTEQResourceIntegrationTest.class);
+ CatalogComponentTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(ValueListResourceIntegrationTest.class);
+ ValueListResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogAttributeTSQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogAttributeTSQResourceIntegrationTest.java
new file mode 100644
index 00000000..6286e137
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogAttributeTSQResourceIntegrationTest.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for CatalogAttributeResource for TestSequence {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class CatalogAttributeTSQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing CatalogAttributeTSQResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogComponent
+ CatalogComponentTSQResourceIntegrationTest.prepareTestData();
+ CatalogComponentTSQResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the ValueList to reference
+ ValueListResourceIntegrationTest.prepareTestData();
+ ValueListResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(CatalogAttributeTSQResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/catcomps/testsequence/" + getTestDataValue(CatalogComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/catattrs");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testCatAttrTSQ");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "CatalogAttribute");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_DATATYPE, new JsonPrimitive("STRING"));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ json = new JsonObject();
+ json.add("ValueList",
+ new JsonPrimitive(getTestDataValue(ValueListResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(CatalogComponentTSQResourceIntegrationTest.class);
+ CatalogComponentTSQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(ValueListResourceIntegrationTest.class);
+ ValueListResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogAttributeUUTResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogAttributeUUTResourceIntegrationTest.java
new file mode 100644
index 00000000..fb0940c4
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogAttributeUUTResourceIntegrationTest.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for CatalogAttributeResource for UnitUnderTest
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class CatalogAttributeUUTResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing CatalogAttributeUUTResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogComponent
+ CatalogComponentUUTResourceIntegrationTest.prepareTestData();
+ CatalogComponentUUTResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the ValueList to reference
+ ValueListResourceIntegrationTest.prepareTestData();
+ ValueListResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(CatalogAttributeUUTResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/catcomps/unitundertest/" + getTestDataValue(CatalogComponentUUTResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/catattrs");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testCatAttrUUT");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "CatalogAttribute");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_DATATYPE, new JsonPrimitive("STRING"));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ json = new JsonObject();
+ json.add("ValueList",
+ new JsonPrimitive(getTestDataValue(ValueListResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(CatalogComponentUUTResourceIntegrationTest.class);
+ CatalogComponentUUTResourceIntegrationTest.deleteEntity();
+
+ setContextClass(ValueListResourceIntegrationTest.class);
+ ValueListResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogComponentTEQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogComponentTEQResourceIntegrationTest.java
new file mode 100644
index 00000000..6f360ce1
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogComponentTEQResourceIntegrationTest.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for CatalogComponentResource for TestEquipment
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class CatalogComponentTEQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing CatalogComponentTEQResourceIntegrationTest");
+
+ // set up test data
+ setContextClass(CatalogComponentTEQResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/catcomps/testequipment");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testCatCompTEQ");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "CatalogComponent");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogComponentTSQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogComponentTSQResourceIntegrationTest.java
new file mode 100644
index 00000000..7dac9d2f
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogComponentTSQResourceIntegrationTest.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for CatalogComponentResource for TestSequence {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class CatalogComponentTSQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing CatalogComponentTSQResourceIntegrationTest");
+
+ // set up test data
+ setContextClass(CatalogComponentTSQResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/catcomps/testsequence");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testCatCompTSQ");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "CatalogComponent");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogComponentUUTResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogComponentUUTResourceIntegrationTest.java
new file mode 100644
index 00000000..ec065c79
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogComponentUUTResourceIntegrationTest.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for CatalogComponentResource for UnitUnderTest
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class CatalogComponentUUTResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing CatalogComponentUUTResourceIntegrationTest");
+
+ // set up test data
+ setContextClass(CatalogComponentUUTResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/catcomps/unitundertest");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testCatCompUUT");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "CatalogComponent");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogSensorAttributeResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogSensorAttributeResourceIntegrationTest.java
new file mode 100644
index 00000000..ff73834a
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogSensorAttributeResourceIntegrationTest.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2018 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Philipp Schweinbenz - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for CatalogSensorAttributeResource
+ *
+ * @author Philipp Schweinbenz, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class CatalogSensorAttributeResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing CatalogSensorAttributeResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogSensor
+ CatalogSensorResourceIntegrationTest.prepareTestData();
+ CatalogSensorResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(CatalogSensorAttributeResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/catcomps/testequipment/"
+ + getTestDataValue(CatalogComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)
+ + "/catsensors/" + getTestDataValue(CatalogSensorResourceIntegrationTest.class, TESTDATA_ENTITY_ID)
+ + "/catsensorattrs");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testCatSensorAttr");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "CatalogAttribute");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_DATATYPE, new JsonPrimitive("STRING"));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(CatalogSensorResourceIntegrationTest.class);
+ CatalogSensorResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentTEQResourceIntegrationTest.class);
+ CatalogComponentTEQResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogSensorResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogSensorResourceIntegrationTest.java
new file mode 100755
index 00000000..76740324
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/CatalogSensorResourceIntegrationTest.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for CatalogSensorResource
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class CatalogSensorResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing CatalogSensorResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogComponent
+ CatalogComponentTEQResourceIntegrationTest.prepareTestData();
+ CatalogComponentTEQResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(CatalogSensorResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/catcomps/testequipment/" + getTestDataValue(CatalogComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/catsensors");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testCatSensor");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "CatalogSensor");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(CatalogComponentTEQResourceIntegrationTest.class);
+ CatalogComponentTEQResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/EntityResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/EntityResourceIntegrationTest.java
new file mode 100644
index 00000000..e5472d35
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/EntityResourceIntegrationTest.java
@@ -0,0 +1,474 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
+import java.util.NoSuchElementException;
+
+import org.junit.Assume;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonPrimitive;
+
+import io.restassured.RestAssured;
+import io.restassured.authentication.PreemptiveBasicAuthScheme;
+import io.restassured.http.ContentType;
+import io.restassured.response.ExtractableResponse;
+import io.restassured.response.Response;
+import io.vavr.collection.HashMap;
+import io.vavr.collection.HashSet;
+import io.vavr.collection.Map;
+import io.vavr.collection.Set;
+
+/**
+ * Abstract test class for Entity resources. Tests are executed in
+ * {@code FixMethodOrder(MethodSorters.NAME_ASCENDING)} as {@link test1Create},
+ * {@link test2Find()}, {@link test3FindAll()}, {@link test4Update()} and
+ * {@link test5Delete()} depend on the entity created by test1Create().
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ *
+ */
+// TODO anehmer on 2017-11-23: test for specific return codes
+// TODO anehmer on 2017-11-24: expand tests to localization and search attribute
+// information
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public abstract class EntityResourceIntegrationTest {
+
+ private static Logger LOGGER = LoggerFactory.getLogger(EntityResourceIntegrationTest.class);
+
+ private static final String HOST = "localhost";
+ private static final String PORT = "8080";
+ private static final String BASE_PATH = "org.eclipse.mdm.nucleus";
+ private static final String API_PATH = "mdm";
+ private static final String ENV_PATH = "environments/PODS";
+
+ private static final String AUTH_USERNAME = "sa";
+ private static final String AUTH_PASSWORD = "sa";
+
+ protected final static String TESTDATA_ENTITY_ID = "entityId";
+ protected final static String TESTDATA_ENTITY_NAME = "entityName";
+ protected final static String TESTDATA_ENTITY_TYPE = "entityType";
+ protected final static String TESTDATA_CREATE_JSON_BODY = "createJSONBody";
+ protected final static String TESTDATA_UPDATE_JSON_BODY = "updateJSONBody";
+ protected final static String TESTDATA_RESOURCE_URI = "resourceURI";
+ protected final static String TESTDATA_RANDOM_DATA = "RANDOM_DATA";
+
+ private static final String RANDOM_ENTITY_NAME_SUFFIX = "_" + Long.toHexString(System.currentTimeMillis());
+
+ public enum TestType {
+ CREATE, FIND, FINDALL, UPDATE, DELETE;
+ }
+
+ private static Map<Class<?>, Set<TestType>> testsToSkip = HashMap.empty();
+
+ private static Map<Class<?>, Map<String, String>> testDataMap = HashMap.empty();
+
+ // if this is set, the resource URI for find() is constructed with the name as
+ // the PATH_PARAM
+ private static Map<Class<?>, Boolean> findByName = HashMap.empty();
+
+ /**
+ * The context class must be set by implementing tests as the context to get
+ * from and put test data values to
+ */
+ private static Class<?> contextClass;
+
+ /**
+ * Init RestAssured
+ */
+ static {
+ // configure URI
+ StringBuilder baseURI = new StringBuilder();
+ baseURI.append("http://")
+ .append(HOST)
+ .append(":")
+ .append(PORT)
+ .append("/")
+ .append(BASE_PATH)
+ .append("/")
+ .append(API_PATH);
+ RestAssured.baseURI = baseURI.toString();
+ RestAssured.basePath = ENV_PATH;
+
+ LOGGER.debug("RestAssured set up to " + RestAssured.baseURI + "/" + RestAssured.basePath);
+
+ // setup authentication
+ PreemptiveBasicAuthScheme authScheme = new PreemptiveBasicAuthScheme();
+ authScheme.setUserName(AUTH_USERNAME);
+ authScheme.setPassword(AUTH_PASSWORD);
+
+ RestAssured.authentication = authScheme;
+
+ LOGGER.debug("RestAssured authentication set to credentials [" + AUTH_USERNAME + "]/[" + AUTH_PASSWORD + "]");
+ }
+
+ @Test
+ public void test1Create() {
+ // only execute if not skipped by implementing test class
+ Assume.assumeFalse(testsToSkip.get(getContextClass())
+ .get()
+ .contains(TestType.CREATE));
+
+ createEntity();
+ }
+
+ /**
+ * Static method that can be utilised by tests to create a specific entity or is
+ * called indirectly by JUnit
+ */
+ public static void createEntity() {
+ // do not create entity if it was already created in a currently running
+ // prepareTestData() cascade
+ if (isTestDataValuePresent(TESTDATA_ENTITY_ID)) {
+ LOGGER.debug(getContextClass().getSimpleName() + ".create() aborted as entity "
+ + getTestDataValue(TESTDATA_ENTITY_NAME) + " of type " + getTestDataValue(TESTDATA_ENTITY_TYPE)
+ + " was already created");
+ return;
+ }
+
+ LOGGER.debug(getContextClass().getSimpleName() + ".create() sending POST to "
+ + getTestDataValue(TESTDATA_RESOURCE_URI) + " with: " + getTestDataValue(TESTDATA_CREATE_JSON_BODY));
+
+ ExtractableResponse<io.restassured.response.Response> response = given().contentType(ContentType.JSON)
+ .body(getTestDataValue(TESTDATA_CREATE_JSON_BODY))
+ .post(getTestDataValue(TESTDATA_RESOURCE_URI))
+ .then()
+ .log()
+ .ifError()
+ .contentType(ContentType.JSON)
+ // do not check for name equality as that might be created randomly
+ .and()
+ .body("data.first().type", equalTo(getTestDataValue(TESTDATA_ENTITY_TYPE)))
+ .extract();
+
+ LOGGER.debug(getContextClass().getSimpleName() + " created " + response.asString());
+
+ putTestDataValue(TESTDATA_ENTITY_ID, response.path("data.first().id"));
+ putTestDataValue(TESTDATA_ENTITY_NAME, response.path("data.first().name"));
+ }
+
+ @Test
+ public void test2Find() {
+ // only execute if not skipped by implementing test class
+ Assume.assumeFalse(testsToSkip.get(getContextClass())
+ .get()
+ .contains(TestType.FIND));
+
+ String uri = getTestDataValue(TESTDATA_RESOURCE_URI) + "/"
+ + (EntityResourceIntegrationTest.findByName.getOrElse(getContextClass(), false)
+ ? getTestDataValue(TESTDATA_ENTITY_NAME)
+ : getTestDataValue(TESTDATA_ENTITY_ID));
+
+ LOGGER.debug(getContextClass().getSimpleName() + ".find() sending GET to " + uri);
+
+ ExtractableResponse<Response> response = given().get(uri)
+ .then()
+ .log()
+ .ifError()
+ .contentType(ContentType.JSON)
+ .body("data.first().name", equalTo(getTestDataValue(TESTDATA_ENTITY_NAME)))
+ .body("data.first().type", equalTo(getTestDataValue(TESTDATA_ENTITY_TYPE)))
+ .extract();
+
+ LOGGER.debug(getContextClass().getSimpleName() + " found " + response.asString());
+ }
+
+ /**
+ * Finds the first entity of the {@code EntityType} set in the context and put
+ * the found ID in the context for further usage
+ */
+ public static void findFirst() {
+ LOGGER.debug(getContextClass().getSimpleName() + ".find() sending GET to "
+ + getTestDataValue(TESTDATA_RESOURCE_URI));
+
+ String id = given().get(getTestDataValue(TESTDATA_RESOURCE_URI))
+ .then()
+ .log()
+ .ifError()
+ .contentType(ContentType.JSON)
+ .body("data.first().name", equalTo(getTestDataValue(TESTDATA_ENTITY_NAME)))
+ .body("data.first().type", equalTo(getTestDataValue(TESTDATA_ENTITY_TYPE)))
+ .extract()
+ .path("data.first().id");
+
+ LOGGER.debug(getContextClass().getSimpleName() + " found " + getTestDataValue(TESTDATA_ENTITY_TYPE)
+ + " with ID " + id);
+
+ putTestDataValue(TESTDATA_ENTITY_ID, id);
+ }
+
+ @Test
+ public void test3FindAll() {
+ // only execute if not skipped by implementing test class
+ Assume.assumeFalse(testsToSkip.get(getContextClass())
+ .get()
+ .contains(TestType.FINDALL));
+
+ LOGGER.debug(getContextClass().getSimpleName() + ".findAll() sending GET to "
+ + getTestDataValue(TESTDATA_RESOURCE_URI));
+
+ ExtractableResponse<Response> response = given().get(getTestDataValue(TESTDATA_RESOURCE_URI))
+ .then()
+ .log()
+ .ifError()
+ .contentType(ContentType.JSON)
+ .body("data.first().type", equalTo(getTestDataValue(TESTDATA_ENTITY_TYPE)))
+ .extract();
+
+ LOGGER.debug(getContextClass().getSimpleName() + " found all " + response.asString());
+ }
+
+ // TODO anehmer on 2017-11-09: test findAll with filter
+
+ // TODO anehmer on 2018-02-06: update of relations are not checked as the
+ // returned Json does not include relations
+ @Test
+ public void test4Update() {
+ // only execute if not skipped by implementing test class
+ Assume.assumeFalse(testsToSkip.get(getContextClass())
+ .get()
+ .contains(TestType.UPDATE));
+
+ JsonObject json;
+ // if no UPDATE_JSON_BODY is defined in implementing test, just run the MimeType
+ // update
+ if (!isTestDataValuePresent(TESTDATA_UPDATE_JSON_BODY)) {
+ json = new JsonObject();
+ }
+ // or add it to the existing update
+ else {
+ json = new JsonParser().parse(getTestDataValue(TESTDATA_UPDATE_JSON_BODY))
+ .getAsJsonObject();
+ }
+ json.add("MimeType", new JsonPrimitive("updatedMimeType"));
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+
+ String uri = getTestDataValue(TESTDATA_RESOURCE_URI) + "/" + getTestDataValue(TESTDATA_ENTITY_ID);
+
+ LOGGER.debug(getContextClass().getSimpleName() + ".update() sending PUT to " + uri + " with: "
+ + getTestDataValue(TESTDATA_UPDATE_JSON_BODY));
+
+ ExtractableResponse<Response> response = given().contentType(ContentType.JSON)
+ // TODO anehmer on 2017-11-15: the update should use different data but as the
+ // returned JSON represents
+ // the entity prior update it does not make any difference as the update is
+ // performed just based on identical data. We should discuss the PUT-behaviour
+ // instead: return the old or updated object as returning the updated one would
+ // mean to perform another get as the ODSTransaction.update() does not return
+ // the updated entity
+ // TODO anehmer on 2017-11-15: use Description to test update
+ .body(getTestDataValue(TESTDATA_UPDATE_JSON_BODY))
+ .put(uri)
+ .then()
+ .log()
+ .ifError()
+ .contentType(ContentType.JSON)
+ .body("data.first().name", equalTo(getTestDataValue(TESTDATA_ENTITY_NAME)))
+ .body("data.first().type", equalTo(getTestDataValue(TESTDATA_ENTITY_TYPE)))
+ .body("data.first().attributes.find {it.name == 'MimeType'}.value", equalTo("updatedMimeType"))
+ .extract();
+
+ LOGGER.debug(getContextClass().getSimpleName() + " updated " + response.asString());
+ }
+
+ @Test
+ public void test5Delete() {
+ // only execute if not skipped by implementing test class
+ Assume.assumeFalse(testsToSkip.get(getContextClass())
+ .get()
+ .contains(TestType.DELETE));
+
+ deleteEntity();
+ }
+
+ /**
+ * Static method that can be utilised by tests to delete a specific entity or is
+ * called indirectly by JUnit
+ */
+ public static void deleteEntity() {
+ String uri = getTestDataValue(TESTDATA_RESOURCE_URI) + "/" + getTestDataValue(TESTDATA_ENTITY_ID);
+
+ LOGGER.debug(getContextClass().getSimpleName() + ".delete() sending DELETE to " + uri);
+
+ ExtractableResponse<Response> response = given().delete(uri)
+ .then()
+ .log()
+ .ifError()
+ .body("data.first().name", equalTo(getTestDataValue(TESTDATA_ENTITY_NAME)))
+ .body("data.first().type", equalTo(getTestDataValue(TESTDATA_ENTITY_TYPE)))
+ .extract();
+
+ LOGGER.debug(getContextClass().getSimpleName() + " deleted " + response.asString());
+
+ removeTestDataValue(TESTDATA_ENTITY_ID);
+ }
+
+ /**
+ * Gets value with key from the testDataMap. The value map is thereby
+ * automatically identified by the implementing class.
+ *
+ * @param key
+ * key to get value for
+ * @return value for given key
+ */
+ public static String getTestDataValue(String key) {
+ return getTestDataValue(getContextClass(), key);
+ }
+
+ /**
+ * Gets value with key from the testDataMap using the context specified by
+ * contextClass
+ *
+ * @param contextClass
+ * the class of the test implementation
+ * @param key
+ * key to get value for
+ * @return value for given key
+ */
+ public static String getTestDataValue(Class<?> contextClass, String key) {
+ return testDataMap.get(contextClass)
+ .map(valueMap -> valueMap.get(key)
+ .getOrElseThrow(() -> new NoSuchElementException(
+ "Key [" + key + "] not found in test data value map in context ["
+ + contextClass.getSimpleName() + "]")))
+ .get();
+ }
+
+ /**
+ * Checks if a test data value is present for the given key
+ *
+ * @param key
+ * key to check presence of test data value for
+ * @return true, if a test data value for the given key exists, false if not
+ */
+ public static boolean isTestDataValuePresent(String key) {
+ return testDataMap.get(getContextClass())
+ .map(valueMap -> valueMap.get(key)
+ .isDefined())
+ .get();
+ }
+
+ /**
+ * Removes the test data value for the given key. If the key is not present,
+ * nothing happens.
+ *
+ * @param key
+ * key to remove test data value for
+ */
+ public static void removeTestDataValue(String key) {
+ testDataMap.get(getContextClass())
+ .map(valueMap -> valueMap.remove(key))
+ .map(newValueMap -> testDataMap = testDataMap.put(getContextClass(), newValueMap));
+ }
+
+ /**
+ * Puts value with key in the testDataMap. The value map is thereby
+ * automatically identified by the implementing class.
+ *
+ * @param key
+ * key to store value under
+ * @param value
+ * value to store
+ */
+ public static void putTestDataValue(String key, String value) {
+ Map<String, String> entityTestData = testDataMap.getOrElse(getContextClass(), HashMap.empty());
+
+ // randomize name to allow failure runs not to require to reset the
+ // database in case the name of the entity must be unique
+ // do not append suffix if name is randomly generated
+ if (key.equals(TESTDATA_ENTITY_NAME) && !value.equals(TESTDATA_RANDOM_DATA)
+ && (entityTestData.get(TESTDATA_ENTITY_NAME)
+ .isEmpty()
+ || !entityTestData.get(TESTDATA_ENTITY_NAME)
+ .get()
+ .equals(TESTDATA_RANDOM_DATA))) {
+ // append suffix if it was not already appended or an already suffixed value was
+ // used for a new one (e.g: TplAttr.name and CatAttr.name)
+ if (!value.endsWith(RANDOM_ENTITY_NAME_SUFFIX)) {
+ value = value + RANDOM_ENTITY_NAME_SUFFIX;
+ }
+ }
+
+ entityTestData = entityTestData.put(key, value);
+
+ testDataMap = testDataMap.put(getContextClass(), entityTestData);
+ }
+
+ /**
+ * Gets the context class set by a test implementation used to store context
+ * aware test data
+ *
+ * @return the context class of the test implementation
+ */
+ private static Class<?> getContextClass() {
+ assertThat(contextClass, is(notNullValue()));
+ return contextClass;
+ }
+
+ /**
+ * Sets the context class used to store context aware test data. This method
+ * must be called by any test implementation before using
+ * {@link getTestDataValue} or {@link putTestDataValue}
+ *
+ * @param contextClass
+ * the context class set by a test implementation
+ */
+ public static void setContextClass(Class<?> contextClass) {
+ EntityResourceIntegrationTest.contextClass = contextClass;
+ testsToSkip = testsToSkip.put(contextClass, HashSet.empty());
+ LOGGER = LoggerFactory.getLogger(contextClass);
+ }
+
+ /**
+ * Set the test with the given {@link TestType} to be skipped
+ *
+ * @param testType
+ * the test to skip
+ */
+ public static void skipTest(TestType test) {
+ testsToSkip.get(getContextClass())
+ .map(tests -> tests.add(test))
+ .map(newTests -> testsToSkip = testsToSkip.put(getContextClass(), newTests));
+ }
+
+ /**
+ * Sets the option findByName to either true or false. If it's set to true, the
+ * URI for find() is constructed with the name rather than with the id of the
+ * entity as the PATH_PARAM
+ *
+ * @param findByName
+ * if find() should use the name instead of the id of the entity
+ */
+ public static void setFindByName(boolean findByNameValue) {
+ findByName = findByName.put(getContextClass(), findByNameValue);
+ }
+
+ /**
+ * Gets the logger
+ *
+ * @return logger configured to current context class
+ */
+ public static Logger getLogger() {
+ return LOGGER;
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateAttributeTEQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateAttributeTEQResourceIntegrationTest.java
new file mode 100644
index 00000000..6075b243
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateAttributeTEQResourceIntegrationTest.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for NestedTemplateAttributeResource for TestEquipment
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class NestedTemplateAttributeTEQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing NestedTemplateAttributeTEQResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogAttribute
+ CatalogAttributeTEQResourceIntegrationTest.prepareTestData();
+ CatalogAttributeTEQResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the NestedTemplateComponent
+ NestedTemplateComponentTEQResourceIntegrationTest.prepareTestData();
+ NestedTemplateComponentTEQResourceIntegrationTest.createEntity();
+
+ setContextClass(NestedTemplateAttributeTEQResourceIntegrationTest.class);
+
+ // set up test data
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testequipment/" + getTestDataValue(TemplateRootTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(TemplateComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(NestedTemplateComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplattrs");
+ putTestDataValue(TESTDATA_ENTITY_NAME, getTestDataValue(CatalogAttributeTEQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME));
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateAttribute");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(CatalogAttributeTEQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME)));
+ json.add("catalogattribute", new JsonPrimitive(getTestDataValue(CatalogAttributeTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ // delete the implicitly created NestedTemplateAttribute
+ NestedTemplateAttributeTEQResourceIntegrationTest.findFirst();
+ NestedTemplateAttributeTEQResourceIntegrationTest.deleteEntity();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(NestedTemplateComponentTEQResourceIntegrationTest.class);
+ NestedTemplateComponentTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateComponentTEQResourceIntegrationTest.class);
+ TemplateComponentTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootTEQResourceIntegrationTest.class);
+ TemplateRootTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogAttributeTEQResourceIntegrationTest.class);
+ CatalogAttributeTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentTEQResourceIntegrationTest.class);
+ CatalogComponentTEQResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateAttributeTSQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateAttributeTSQResourceIntegrationTest.java
new file mode 100644
index 00000000..36ab1a18
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateAttributeTSQResourceIntegrationTest.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for NestedTemplateAttributeResource for TestSequence
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class NestedTemplateAttributeTSQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing NestedTemplateAttributeTSQResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogAttribute
+ CatalogAttributeTSQResourceIntegrationTest.prepareTestData();
+ CatalogAttributeTSQResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the NestedTemplateComponent
+ NestedTemplateComponentTSQResourceIntegrationTest.prepareTestData();
+ NestedTemplateComponentTSQResourceIntegrationTest.createEntity();
+
+ setContextClass(NestedTemplateAttributeTSQResourceIntegrationTest.class);
+
+ // set up test data
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testsequence/" + getTestDataValue(TemplateRootTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(TemplateComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(NestedTemplateComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplattrs");
+ putTestDataValue(TESTDATA_ENTITY_NAME, getTestDataValue(CatalogAttributeTSQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME));
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateAttribute");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(CatalogAttributeTSQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ // delete the implicitly created NestedTemplateAttribute
+ NestedTemplateAttributeTSQResourceIntegrationTest.findFirst();
+ NestedTemplateAttributeTSQResourceIntegrationTest.deleteEntity();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(NestedTemplateComponentTSQResourceIntegrationTest.class);
+ NestedTemplateComponentTSQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateComponentTSQResourceIntegrationTest.class);
+ TemplateComponentTSQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootTSQResourceIntegrationTest.class);
+ TemplateRootTSQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogAttributeTSQResourceIntegrationTest.class);
+ CatalogAttributeTSQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentTSQResourceIntegrationTest.class);
+ CatalogComponentTSQResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateAttributeUUTResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateAttributeUUTResourceIntegrationTest.java
new file mode 100644
index 00000000..a32c8fc8
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateAttributeUUTResourceIntegrationTest.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for NestedTemplateAttributeResource for UnitUnderTest
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class NestedTemplateAttributeUUTResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing NestedTemplateAttributeUUTResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogAttribute
+ CatalogAttributeUUTResourceIntegrationTest.prepareTestData();
+ CatalogAttributeUUTResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the NestedTemplateComponent
+ NestedTemplateComponentUUTResourceIntegrationTest.prepareTestData();
+ NestedTemplateComponentUUTResourceIntegrationTest.createEntity();
+
+ setContextClass(NestedTemplateAttributeUUTResourceIntegrationTest.class);
+
+ // set up test data
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/unitundertest/" + getTestDataValue(TemplateRootUUTResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(TemplateComponentUUTResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(NestedTemplateComponentUUTResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplattrs");
+ putTestDataValue(TESTDATA_ENTITY_NAME, getTestDataValue(CatalogAttributeUUTResourceIntegrationTest.class, TESTDATA_ENTITY_NAME));
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateAttribute");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(CatalogAttributeUUTResourceIntegrationTest.class, TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ // delete the implicitly created NestedTemplateAttribute
+ NestedTemplateAttributeUUTResourceIntegrationTest.findFirst();
+ NestedTemplateAttributeUUTResourceIntegrationTest.deleteEntity();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(NestedTemplateComponentUUTResourceIntegrationTest.class);
+ NestedTemplateComponentUUTResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateComponentUUTResourceIntegrationTest.class);
+ TemplateComponentUUTResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootUUTResourceIntegrationTest.class);
+ TemplateRootUUTResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogAttributeUUTResourceIntegrationTest.class);
+ CatalogAttributeUUTResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentUUTResourceIntegrationTest.class);
+ CatalogComponentUUTResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateComponentTEQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateComponentTEQResourceIntegrationTest.java
new file mode 100644
index 00000000..f6a3c6c2
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateComponentTEQResourceIntegrationTest.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for NestedTemplateComponentResource for TestEquipment
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class NestedTemplateComponentTEQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing NestedTemplateComponentTEQResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogComponent
+ CatalogComponentTEQResourceIntegrationTest.prepareTestData();
+ CatalogComponentTEQResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the TemplateRoot
+ TemplateComponentTEQResourceIntegrationTest.prepareTestData();
+ TemplateComponentTEQResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(NestedTemplateComponentTEQResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testequipment/" + getTestDataValue(TemplateRootTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(TemplateComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testNestedTplCompTEQ");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateComponent");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_CATALOGCOMPONENT_ID, new JsonPrimitive(getTestDataValue(CatalogComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateComponentTEQResourceIntegrationTest.class);
+ TemplateComponentTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootTEQResourceIntegrationTest.class);
+ TemplateRootTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentTEQResourceIntegrationTest.class);
+ CatalogComponentTEQResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateComponentTSQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateComponentTSQResourceIntegrationTest.java
new file mode 100644
index 00000000..450f3be6
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateComponentTSQResourceIntegrationTest.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for NestedTemplateComponentResource for TestSequence
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class NestedTemplateComponentTSQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing NestedTemplateComponentTSQResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogComponent
+ CatalogComponentTSQResourceIntegrationTest.prepareTestData();
+ CatalogComponentTSQResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the TemplateRoot
+ TemplateComponentTSQResourceIntegrationTest.prepareTestData();
+ TemplateComponentTSQResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(NestedTemplateComponentTSQResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testsequence/" + getTestDataValue(TemplateRootTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(TemplateComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testNestedTplCompTSQ");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateComponent");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_CATALOGCOMPONENT_ID, new JsonPrimitive(getTestDataValue(CatalogComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateComponentTSQResourceIntegrationTest.class);
+ TemplateComponentTSQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootTSQResourceIntegrationTest.class);
+ TemplateRootTSQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentTSQResourceIntegrationTest.class);
+ CatalogComponentTSQResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateComponentUUTResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateComponentUUTResourceIntegrationTest.java
new file mode 100644
index 00000000..912fa76d
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/NestedTemplateComponentUUTResourceIntegrationTest.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for NestedTemplateComponentResource for UnitUnderTest
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class NestedTemplateComponentUUTResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing NestedTemplateComponentUUTResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogComponent
+ CatalogComponentUUTResourceIntegrationTest.prepareTestData();
+ CatalogComponentUUTResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the TemplateRoot
+ TemplateComponentUUTResourceIntegrationTest.prepareTestData();
+ TemplateComponentUUTResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(NestedTemplateComponentUUTResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/unitundertest/" + getTestDataValue(TemplateRootUUTResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(TemplateComponentUUTResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testNestedTplCompUUT");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateComponent");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_CATALOGCOMPONENT_ID, new JsonPrimitive(getTestDataValue(CatalogComponentUUTResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateComponentUUTResourceIntegrationTest.class);
+ TemplateComponentUUTResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootUUTResourceIntegrationTest.class);
+ TemplateRootUUTResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentUUTResourceIntegrationTest.class);
+ CatalogComponentUUTResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/PhysicalDimensionResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/PhysicalDimensionResourceIntegrationTest.java
new file mode 100644
index 00000000..68739531
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/PhysicalDimensionResourceIntegrationTest.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for PhysicalDimensionResource.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class PhysicalDimensionResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing PhysicalDimensionResourceIntegrationTest");
+
+ // set up test data
+ setContextClass(PhysicalDimensionResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/physicaldimensions");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testPhysicalDimension");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "PhysicalDimension");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ json = new JsonObject();
+ json.add("Mass", new JsonPrimitive(1));
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/QuantityResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/QuantityResourceIntegrationTest.java
new file mode 100755
index 00000000..c53648be
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/QuantityResourceIntegrationTest.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for QuantityResource.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class QuantityResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing QuantityResourceIntegrationTest");
+
+ // prepare test data for creating the Unit
+ UnitResourceIntegrationTest.prepareTestData();
+ UnitResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(QuantityResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/quantities");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testQuantity");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "Quantity");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ // TODO anehmer on 2017-11-17: create unit (and physDim) instead of taking fixed
+ // one
+ json.add(ResourceConstants.ENTITYATTRIBUTE_UNIT_ID, new JsonPrimitive(getTestDataValue(UnitResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(UnitResourceIntegrationTest.class);
+ UnitResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateAttributeTEQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateAttributeTEQResourceIntegrationTest.java
new file mode 100644
index 00000000..0ea025b2
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateAttributeTEQResourceIntegrationTest.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateAttributeResource for TestEquipment
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateAttributeTEQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateAttributeTEQResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogAttribute
+ CatalogAttributeTEQResourceIntegrationTest.prepareTestData();
+ CatalogAttributeTEQResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the TemplateComponent
+ TemplateComponentTEQResourceIntegrationTest.prepareTestData();
+ TemplateComponentTEQResourceIntegrationTest.createEntity();
+
+ setContextClass(TemplateAttributeTEQResourceIntegrationTest.class);
+
+ // set up test data
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testequipment/" + getTestDataValue(TemplateRootTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(TemplateComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplattrs");
+ putTestDataValue(TESTDATA_ENTITY_NAME, getTestDataValue(CatalogAttributeTEQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME));
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateAttribute");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(CatalogAttributeTEQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ // delete the implicitly created TemplateAttribute
+ TemplateAttributeTEQResourceIntegrationTest.findFirst();
+ TemplateAttributeTEQResourceIntegrationTest.deleteEntity();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateComponentTEQResourceIntegrationTest.class);
+ TemplateComponentTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootTEQResourceIntegrationTest.class);
+ TemplateRootTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogAttributeTEQResourceIntegrationTest.class);
+ CatalogAttributeTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentTEQResourceIntegrationTest.class);
+ CatalogComponentTEQResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateAttributeTSQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateAttributeTSQResourceIntegrationTest.java
new file mode 100644
index 00000000..4f731700
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateAttributeTSQResourceIntegrationTest.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateAttributeResource for TestSequence
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateAttributeTSQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateAttributeTSQResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogAttribute
+ CatalogAttributeTSQResourceIntegrationTest.prepareTestData();
+ CatalogAttributeTSQResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the TemplateComponent
+ TemplateComponentTSQResourceIntegrationTest.prepareTestData();
+ TemplateComponentTSQResourceIntegrationTest.createEntity();
+
+ setContextClass(TemplateAttributeTSQResourceIntegrationTest.class);
+
+ // set up test data
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testsequence/" + getTestDataValue(TemplateRootTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(TemplateComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplattrs");
+ putTestDataValue(TESTDATA_ENTITY_NAME, getTestDataValue(CatalogAttributeTSQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME));
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateAttribute");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(CatalogAttributeTSQResourceIntegrationTest.class, TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ // delete the implicitly created TemplateAttribute
+ TemplateAttributeTSQResourceIntegrationTest.findFirst();
+ TemplateAttributeTSQResourceIntegrationTest.deleteEntity();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateComponentTSQResourceIntegrationTest.class);
+ TemplateComponentTSQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootTSQResourceIntegrationTest.class);
+ TemplateRootTSQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogAttributeTSQResourceIntegrationTest.class);
+ CatalogAttributeTSQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentTSQResourceIntegrationTest.class);
+ CatalogComponentTSQResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateAttributeUUTResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateAttributeUUTResourceIntegrationTest.java
new file mode 100644
index 00000000..b7b8cd14
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateAttributeUUTResourceIntegrationTest.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateAttributeResource for UnitUnderTest
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateAttributeUUTResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateAttributeUUTResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogAttribute
+ CatalogAttributeUUTResourceIntegrationTest.prepareTestData();
+ CatalogAttributeUUTResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the TemplateComponent
+ TemplateComponentUUTResourceIntegrationTest.prepareTestData();
+ TemplateComponentUUTResourceIntegrationTest.createEntity();
+
+ setContextClass(TemplateAttributeUUTResourceIntegrationTest.class);
+
+ // set up test data
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/unitundertest/" + getTestDataValue(TemplateRootUUTResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(TemplateComponentUUTResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplattrs");
+ putTestDataValue(TESTDATA_ENTITY_NAME, getTestDataValue(CatalogAttributeUUTResourceIntegrationTest.class, TESTDATA_ENTITY_NAME));
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateAttribute");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(CatalogAttributeUUTResourceIntegrationTest.class, TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ // delete the implicitly created TemplateAttribute
+ TemplateAttributeUUTResourceIntegrationTest.findFirst();
+ TemplateAttributeUUTResourceIntegrationTest.deleteEntity();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateComponentUUTResourceIntegrationTest.class);
+ TemplateComponentUUTResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootUUTResourceIntegrationTest.class);
+ TemplateRootUUTResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogAttributeUUTResourceIntegrationTest.class);
+ CatalogAttributeUUTResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentUUTResourceIntegrationTest.class);
+ CatalogComponentUUTResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateComponentTEQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateComponentTEQResourceIntegrationTest.java
new file mode 100644
index 00000000..cdf1f189
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateComponentTEQResourceIntegrationTest.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateComponentResource for TestEquipment
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateComponentTEQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateComponentTEQResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogComponent
+ CatalogComponentTEQResourceIntegrationTest.prepareTestData();
+ CatalogComponentTEQResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the TemplateRoot
+ TemplateRootTEQResourceIntegrationTest.prepareTestData();
+ TemplateRootTEQResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(TemplateComponentTEQResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testequipment/" + getTestDataValue(TemplateRootTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testTplCompTEQ");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateComponent");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_CATALOGCOMPONENT_ID, new JsonPrimitive(getTestDataValue(CatalogComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateRootTEQResourceIntegrationTest.class);
+ TemplateRootTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentTEQResourceIntegrationTest.class);
+ CatalogComponentTEQResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateComponentTSQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateComponentTSQResourceIntegrationTest.java
new file mode 100644
index 00000000..419d5975
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateComponentTSQResourceIntegrationTest.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateComponentResource for TestSequence
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateComponentTSQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateComponentTSQResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogComponent
+ CatalogComponentTSQResourceIntegrationTest.prepareTestData();
+ CatalogComponentTSQResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the TemplateRoot
+ TemplateRootTSQResourceIntegrationTest.prepareTestData();
+ TemplateRootTSQResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(TemplateComponentTSQResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testsequence/" + getTestDataValue(TemplateRootTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testTplCompTSQ");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateComponent");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_CATALOGCOMPONENT_ID, new JsonPrimitive(getTestDataValue(CatalogComponentTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateRootTSQResourceIntegrationTest.class);
+ TemplateRootTSQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentTSQResourceIntegrationTest.class);
+ CatalogComponentTEQResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateComponentUUTResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateComponentUUTResourceIntegrationTest.java
new file mode 100644
index 00000000..5194575b
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateComponentUUTResourceIntegrationTest.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateComponentResource for UnitUnderTest
+ * {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateComponentUUTResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateComponentUUTResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogComponent
+ CatalogComponentUUTResourceIntegrationTest.prepareTestData();
+ CatalogComponentUUTResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the TemplateRoot
+ TemplateRootUUTResourceIntegrationTest.prepareTestData();
+ TemplateRootUUTResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(TemplateComponentUUTResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/unitundertest/" + getTestDataValue(TemplateRootUUTResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testTplCompUUT");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateComponent");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_CATALOGCOMPONENT_ID, new JsonPrimitive(getTestDataValue(CatalogComponentUUTResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateRootUUTResourceIntegrationTest.class);
+ TemplateRootUUTResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentUUTResourceIntegrationTest.class);
+ CatalogComponentUUTResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateRootTEQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateRootTEQResourceIntegrationTest.java
new file mode 100644
index 00000000..2931fb5f
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateRootTEQResourceIntegrationTest.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateRootResource for TestEquipment {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateRootTEQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateRootTEQResourceIntegrationTest");
+
+ // set up test data
+ setContextClass(TemplateRootTEQResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testequipment");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testTplRootTEQ");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateRoot");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ json = new JsonObject();
+ JsonObject enumerationJson = new JsonObject();
+ enumerationJson.add("Enumeration", new JsonPrimitive("VersionState"));
+ enumerationJson.add("EnumerationValue", new JsonPrimitive("VALID"));
+ json.add("ValidFlag", enumerationJson);
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateRootTSQResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateRootTSQResourceIntegrationTest.java
new file mode 100644
index 00000000..f25d51f7
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateRootTSQResourceIntegrationTest.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateRootResource for TestSequence {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateRootTSQResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateRootTSQResourceIntegrationTest");
+
+ // set up test data
+ setContextClass(TemplateRootTSQResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testsequence");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testTplRootTSQ");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateRoot");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ json = new JsonObject();
+ JsonObject enumerationJson = new JsonObject();
+ enumerationJson.add("Enumeration", new JsonPrimitive("VersionState"));
+ enumerationJson.add("EnumerationValue", new JsonPrimitive("VALID"));
+ json.add("ValidFlag", enumerationJson);
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateRootUUTResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateRootUUTResourceIntegrationTest.java
new file mode 100644
index 00000000..5efeff54
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateRootUUTResourceIntegrationTest.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateRootResource for UnitUnderTest {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateRootUUTResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateRootUUTResourceIntegrationTest");
+
+ // set up test data
+ setContextClass(TemplateRootUUTResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/unitundertest");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testTplRootpUUT");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateRoot");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ json = new JsonObject();
+ JsonObject enumerationJson = new JsonObject();
+ enumerationJson.add("Enumeration", new JsonPrimitive("VersionState"));
+ enumerationJson.add("EnumerationValue", new JsonPrimitive("VALID"));
+ json.add("ValidFlag", enumerationJson);
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateSensorAttributeResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateSensorAttributeResourceIntegrationTest.java
new file mode 100644
index 00000000..5324d132
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateSensorAttributeResourceIntegrationTest.java
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2018 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Philipp Schweinbenz - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateComponentResource for TestEquipment
+ * {@link ContextType}.
+ *
+ * @author Philipp Schweinbenz, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateSensorAttributeResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateSensorAttributeResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogSensorAttribute
+ CatalogSensorAttributeResourceIntegrationTest.prepareTestData();
+ CatalogSensorAttributeResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the TemplateSensor
+ TemplateSensorResourceIntegrationTest.prepareTestData();
+ TemplateSensorResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(TemplateSensorAttributeResourceIntegrationTest.class);
+
+ // skip the creation test as TemplateSensorAttributes are implicitly created
+ // with the TemplateSensor
+ skipTest(TestType.CREATE);
+ // skip the deletion test as TemplateSensorAttributes can't be deleted
+ skipTest(TestType.DELETE);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testequipment/"
+ + getTestDataValue(TemplateRootTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/"
+ + getTestDataValue(TemplateComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)
+ + "/tplsensors/" + getTestDataValue(TemplateSensorResourceIntegrationTest.class, TESTDATA_ENTITY_ID)
+ + "/tplsensorattrs");
+ putTestDataValue(TESTDATA_ENTITY_NAME,
+ getTestDataValue(CatalogSensorAttributeResourceIntegrationTest.class, TESTDATA_ENTITY_NAME));
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateAttribute");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(
+ getTestDataValue(CatalogSensorAttributeResourceIntegrationTest.class, TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ // get first TemplateSensorAttribute
+ TemplateSensorAttributeResourceIntegrationTest.findFirst();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateSensorResourceIntegrationTest.class);
+ TemplateSensorResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateComponentTEQResourceIntegrationTest.class);
+ TemplateComponentTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootTEQResourceIntegrationTest.class);
+ TemplateRootTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogSensorAttributeResourceIntegrationTest.class);
+ CatalogSensorAttributeResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogSensorResourceIntegrationTest.class);
+ CatalogSensorResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentTEQResourceIntegrationTest.class);
+ CatalogComponentTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(QuantityResourceIntegrationTest.class);
+ QuantityResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateSensorResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateSensorResourceIntegrationTest.java
new file mode 100755
index 00000000..51ffa3b1
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateSensorResourceIntegrationTest.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.api.base.model.ContextType;
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateSensorResource {@link ContextType}.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateSensorResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateAttributeTEQResourceIntegrationTest");
+
+ // prepare test data for creating the CatalogSensor
+ CatalogSensorResourceIntegrationTest.prepareTestData();
+ CatalogSensorResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the TemplateComponent
+ TemplateComponentTEQResourceIntegrationTest.prepareTestData();
+ TemplateComponentTEQResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the Quantity
+ QuantityResourceIntegrationTest.prepareTestData();
+ QuantityResourceIntegrationTest.createEntity();
+
+ setContextClass(TemplateSensorResourceIntegrationTest.class);
+
+ // set up test data
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplroots/testequipment/" + getTestDataValue(TemplateRootTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplcomps/" + getTestDataValue(TemplateComponentTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/tplsensors");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testTplSensor");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateSensor");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_CATALOGSENSOR_ID, new JsonPrimitive(getTestDataValue(CatalogSensorResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_QUANTITY_ID, new JsonPrimitive(getTestDataValue(QuantityResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_QUANTITY_ID,
+ new JsonPrimitive(getTestDataValue(QuantityResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateComponentTEQResourceIntegrationTest.class);
+ TemplateComponentTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootTEQResourceIntegrationTest.class);
+ TemplateRootTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogSensorResourceIntegrationTest.class);
+ CatalogSensorResourceIntegrationTest.deleteEntity();
+
+ setContextClass(CatalogComponentTEQResourceIntegrationTest.class);
+ CatalogSensorResourceIntegrationTest.deleteEntity();
+
+ setContextClass(QuantityResourceIntegrationTest.class);
+ QuantityResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateTestResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateTestResourceIntegrationTest.java
new file mode 100755
index 00000000..443595db
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateTestResourceIntegrationTest.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateTestResource.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateTestResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateTestResourceIntegrationTest");
+
+ // set up test data
+ setContextClass(TemplateTestResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tpltests");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testTplTest");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateTest");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ json = new JsonObject();
+ JsonObject enumerationJson = new JsonObject();
+ enumerationJson.add("Enumeration", new JsonPrimitive("VersionState"));
+ enumerationJson.add("EnumerationValue", new JsonPrimitive("VALID"));
+ json.add("ValidFlag", enumerationJson);
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateTestStepResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateTestStepResourceIntegrationTest.java
new file mode 100755
index 00000000..9facac64
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateTestStepResourceIntegrationTest.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateTestStepResource.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateTestStepResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateTestResourceIntegrationTest");
+
+ // prepare test data for creating the TemplateRoots
+ TemplateRootTEQResourceIntegrationTest.prepareTestData();
+ TemplateRootTEQResourceIntegrationTest.createEntity();
+ TemplateRootTSQResourceIntegrationTest.prepareTestData();
+ TemplateRootTSQResourceIntegrationTest.createEntity();
+ TemplateRootUUTResourceIntegrationTest.prepareTestData();
+ TemplateRootUUTResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(TemplateTestStepResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/tplteststeps");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testTplTestStep");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, ResourceConstants.ENTITYATTRIBUTE_TEMPLATETESTSTEP_ID);
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ json = new JsonObject();
+ JsonObject enumerationJson = new JsonObject();
+ enumerationJson.add("Enumeration", new JsonPrimitive("VersionState"));
+ enumerationJson.add("EnumerationValue", new JsonPrimitive("VALID"));
+ json.add("ValidFlag", enumerationJson);
+
+ json.add("TemplateTestEquipmentRoot",
+ new JsonPrimitive(getTestDataValue(TemplateRootTEQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ json.add("TemplateTestSequenceRoot",
+ new JsonPrimitive(getTestDataValue(TemplateRootTSQResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ json.add("TemplateUnitUnderTestRoot",
+ new JsonPrimitive(getTestDataValue(TemplateRootUUTResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateRootTEQResourceIntegrationTest.class);
+ TemplateRootTEQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootTSQResourceIntegrationTest.class);
+ TemplateRootTSQResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateRootUUTResourceIntegrationTest.class);
+ TemplateRootUUTResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateTestStepUsageResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateTestStepUsageResourceIntegrationTest.java
new file mode 100644
index 00000000..80d747dd
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/TemplateTestStepUsageResourceIntegrationTest.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for TemplateTestStepUsageResource.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class TemplateTestStepUsageResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing TemplateTestResourceIntegrationTest");
+
+ // prepare test data for creating the Test
+ TemplateTestResourceIntegrationTest.prepareTestData();
+ TemplateTestResourceIntegrationTest.createEntity();
+
+ // prepare test data for creating the TestStep
+ TemplateTestStepResourceIntegrationTest.prepareTestData();
+ TemplateTestStepResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(TemplateTestStepUsageResourceIntegrationTest.class);
+
+ // skip the update as TemplateTestStepUsages cannot be updated
+ // skipTest(TestType.UPDATE);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI,
+ "/tpltests/" + getTestDataValue(TemplateTestResourceIntegrationTest.class, TESTDATA_ENTITY_ID)
+ + "/tplteststepusages");
+ // indicates that the value is set with the response data from create()
+ putTestDataValue(TESTDATA_ENTITY_NAME, TESTDATA_RANDOM_DATA);
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "TemplateTestStepUsage");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_TEMPLATETESTSTEP_ID, new JsonPrimitive(getTestDataValue(TemplateTestStepResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ json = new JsonObject();
+ json.add("DefaultActive", new JsonPrimitive(true));
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(TemplateTestResourceIntegrationTest.class);
+ TemplateTestResourceIntegrationTest.deleteEntity();
+
+ setContextClass(TemplateTestStepResourceIntegrationTest.class);
+ TemplateTestStepResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/UnitResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/UnitResourceIntegrationTest.java
new file mode 100644
index 00000000..c75c228e
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/UnitResourceIntegrationTest.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for UnitResource.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class UnitResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing UnitResourceIntegrationTest");
+
+ // prepare test data for creating the PhysicalDimension
+ PhysicalDimensionResourceIntegrationTest.prepareTestData();
+ PhysicalDimensionResourceIntegrationTest.createEntity();
+
+ // set up test data
+ setContextClass(UnitResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/units");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testUnit");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "Unit");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ json.add(ResourceConstants.ENTITYATTRIBUTE_PHYSICALDIMENSION_ID, new JsonPrimitive(
+ getTestDataValue(PhysicalDimensionResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+
+ json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_PHYSICALDIMENSION_ID, new JsonPrimitive(
+ getTestDataValue(PhysicalDimensionResourceIntegrationTest.class, TESTDATA_ENTITY_ID)));
+ putTestDataValue(TESTDATA_UPDATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(PhysicalDimensionResourceIntegrationTest.class);
+ PhysicalDimensionResourceIntegrationTest.deleteEntity();
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/ValueListResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/ValueListResourceIntegrationTest.java
new file mode 100644
index 00000000..54fae219
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/ValueListResourceIntegrationTest.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for ValueListResource.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class ValueListResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing ValueListResourceIntegrationTest");
+
+ // set up test data
+ setContextClass(ValueListResourceIntegrationTest.class);
+
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/valuelists");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testValueList");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "ValueList");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+}
diff --git a/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/ValueListValueResourceIntegrationTest.java b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/ValueListValueResourceIntegrationTest.java
new file mode 100644
index 00000000..1a24c542
--- /dev/null
+++ b/org.eclipse.mdm.businessobjects/src/test/java/org/eclipse/mdm/businessobjects/boundary/integrationtest/ValueListValueResourceIntegrationTest.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2017 science + computing AG Tuebingen (ATOS SE)
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexander Nehmer - initial implementation
+ *******************************************************************************/
+package org.eclipse.mdm.businessobjects.boundary.integrationtest;
+
+import org.eclipse.mdm.businessobjects.boundary.ResourceConstants;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+
+/**
+ * Test class for ValueListValueResource.
+ *
+ * @author Alexander Nehmer, science+computing AG Tuebingen (Atos SE)
+ * @see EntityResourceIntegrationTest
+ *
+ */
+public class ValueListValueResourceIntegrationTest extends EntityResourceIntegrationTest {
+
+ @BeforeClass
+ public static void prepareTestData() {
+ getLogger().debug("Preparing ValueListValueResourceIntegrationTest");
+
+ // prepare test data for creating the ValueList
+ ValueListResourceIntegrationTest.prepareTestData();
+ ValueListResourceIntegrationTest.createEntity();
+
+ // reset the context
+ setContextClass(ValueListValueResourceIntegrationTest.class);
+
+ // set up test data
+ putTestDataValue(TESTDATA_RESOURCE_URI, "/valuelists/" + getTestDataValue(ValueListResourceIntegrationTest.class, TESTDATA_ENTITY_ID) + "/values");
+ putTestDataValue(TESTDATA_ENTITY_NAME, "testValueListValue");
+ putTestDataValue(TESTDATA_ENTITY_TYPE, "ValueListValue");
+
+ JsonObject json = new JsonObject();
+ json.add(ResourceConstants.ENTITYATTRIBUTE_NAME, new JsonPrimitive(getTestDataValue(TESTDATA_ENTITY_NAME)));
+ putTestDataValue(TESTDATA_CREATE_JSON_BODY, json.toString());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ setContextClass(ValueListResourceIntegrationTest.class);
+ ValueListResourceIntegrationTest.deleteEntity();
+ }
+}

Back to the top