From 68c2feb86c51beee57ab60a7ee531331ef85149f Mon Sep 17 00:00:00 2001 From: PatriceKammognie <100808545+PatriceKammognie@users.noreply.github.com> Date: Tue, 22 Aug 2023 11:54:54 +0200 Subject: [PATCH 1/5] Adds feature to configure repository names (#56) Signed-off-by: PatriceKammognie Signed-off-by: Mohammad Ghazanfar Ali Danish Co-authored-by: Mohammad Ghazanfar Ali Danish Co-authored-by: Mohammad Ghazanfar Ali Danish <62088117+mdanish98@users.noreply.github.com> --- .gitignore | 2 +- .../basyx.aasenvironment-core/pom.xml | 89 +++++++++++++++---- .../aasrepository/InMemoryAasRepository.java | 26 +++++- .../InMemoryAasRepositoryFactory.java | 17 +++- .../TestInMemoryAasRepository.java | 17 +++- .../aasrepository/MongoDBAasRepository.java | 15 +++- .../MongoDBAasRepositoryFactory.java | 19 +++- .../TestMongoDBAasRepository.java | 27 ++++-- .../basyx/aasrepository/AasRepository.java | 14 ++- .../aasrepository/AasRepositorySuite.java | 9 +- .../http/DummyAasRepositoryComponent.java | 21 +++-- .../http/testconfig/DummyConfig.java | 51 +++++++++++ .../basyx.aasrepository.component/pom.xml | 5 ++ .../src/main/resources/application.properties | 1 + .../component/TestAasRepositoryName.java | 89 +++++++++++++++++++ .../InMemoryConceptDescriptionRepository.java | 31 ++++++- ...ryConceptDescriptionRepositoryFactory.java | 14 ++- ...tInMemoryConceptDescriptionRepository.java | 13 ++- .../MongoDBConceptDescriptionRepository.java | 13 ++- ...DBConceptDescriptionRepositoryFactory.java | 26 ++++-- ...stMongoDBConceptDescriptionRepository.java | 19 +++- .../ConceptDescriptionRepository.java | 13 ++- .../ConceptDescriptionRepositorySuite.java | 9 +- ...ConceptDescriptionRepositoryComponent.java | 12 ++- .../http/testconfig/DummyConfig.java | 48 ++++++++++ .../pom.xml | 5 ++ .../src/main/resources/application.properties | 1 + .../TestConceptDescriptionRepositoryName.java | 89 +++++++++++++++++++ .../InMemorySubmodelRepository.java | 34 ++++++- .../InMemorySubmodelRepositoryFactory.java | 13 ++- .../TestInMemorySubmodelRepository.java | 13 ++- .../MongoDBSubmodelRepository.java | 77 ++++++++++++---- .../MongoDBSubmodelRepositoryFactory.java | 30 +++++-- .../TestMongoDBSubmodelRepository.java | 12 ++- .../SubmodelRepository.java | 18 ++-- .../core/SubmodelRepositorySuite.java | 9 +- .../DummySubmodelRepositoryComponent.java | 16 ++-- .../http/testconfig/DummyConfig.java | 50 +++++++++++ .../pom.xml | 5 ++ .../src/main/resources/application.properties | 1 + .../component/TestSubmodelRepositoryName.java | 89 +++++++++++++++++++ .../basyx.submodelservice-core/pom.xml | 9 +- 42 files changed, 944 insertions(+), 127 deletions(-) create mode 100644 basyx.aasrepository/basyx.aasrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/http/testconfig/DummyConfig.java create mode 100644 basyx.aasrepository/basyx.aasrepository.component/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/component/TestAasRepositoryName.java create mode 100644 basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/http/testconfig/DummyConfig.java create mode 100644 basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/component/TestConceptDescriptionRepositoryName.java create mode 100644 basyx.submodelrepository/basyx.submodelrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/testconfig/DummyConfig.java create mode 100644 basyx.submodelrepository/basyx.submodelrepository.component/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/component/TestSubmodelRepositoryName.java diff --git a/.gitignore b/.gitignore index e55168d8b..729324cec 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,7 @@ local.properties .settings/ .loadpath .recommenders -META-INF/* +**/META-INF/* # External tool builders .externalToolBuilders/ diff --git a/basyx.aasenvironment/basyx.aasenvironment-core/pom.xml b/basyx.aasenvironment/basyx.aasenvironment-core/pom.xml index 48dd74378..6f6c4d99d 100644 --- a/basyx.aasenvironment/basyx.aasenvironment-core/pom.xml +++ b/basyx.aasenvironment/basyx.aasenvironment-core/pom.xml @@ -30,14 +30,43 @@ org.eclipse.digitaltwin.basyx - basyx.aasservice-core + basyx.submodelrepository-backend-inmemory org.eclipse.digitaltwin.basyx - basyx.aasservice-core + basyx.submodelservice-core tests test + + org.eclipse.digitaltwin.basyx + basyx.submodelservice-backend-inmemory + + + org.eclipse.digitaltwin.basyx + basyx.aasservice-backend-inmemory + + + org.eclipse.digitaltwin.basyx + basyx.conceptdescriptionrepository-backend-inmemory + + + org.eclipse.digitaltwin.basyx + basyx.aasrepository-backend-inmemory + + + org.eclipse.digitaltwin.basyx + basyx.submodelrepository-core + + + org.eclipse.digitaltwin.basyx + basyx.aasrepository-core + + + org.eclipse.digitaltwin.basyx + basyx.conceptdescriptionrepository-core + + org.eclipse.digitaltwin.aas4j dataformat-json @@ -55,21 +84,49 @@ dataformat-core - org.eclipse.digitaltwin.basyx - basyx.submodelservice-core - tests - test - + org.eclipse.digitaltwin.aas4j + model + + - org.eclipse.digitaltwin.basyx - basyx.http - tests - test - + javax.validation + validation-api + + - org.apache.httpcomponents.client5 - httpclient5 - test - + org.slf4j + slf4j-api + + + + com.google.guava + guava + 30.1.1-jre + + + + org.apache.poi + poi-ooxml + 4.1.2 + + + + junit + junit + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + groupId:artifactId + + + + + \ No newline at end of file diff --git a/basyx.aasrepository/basyx.aasrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/InMemoryAasRepository.java b/basyx.aasrepository/basyx.aasrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/InMemoryAasRepository.java index cd5ccab3e..7b0c70d84 100644 --- a/basyx.aasrepository/basyx.aasrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/InMemoryAasRepository.java +++ b/basyx.aasrepository/basyx.aasrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/InMemoryAasRepository.java @@ -45,15 +45,17 @@ /** * In-memory implementation of the AasRepository * - * @author schnicke, danish - * + * @author schnicke, danish, kammognie + * */ public class InMemoryAasRepository implements AasRepository { private Map aasServices = new LinkedHashMap<>(); private AasServiceFactory aasServiceFactory; - + + private String aasRepositoryName; + /** * Creates the AasRepository using an in-memory backend. * @@ -63,6 +65,17 @@ public class InMemoryAasRepository implements AasRepository { public InMemoryAasRepository(AasServiceFactory aasServiceFactory) { this.aasServiceFactory = aasServiceFactory; } + + /** + * Creates the AasRepository using an in-memory backend. + * + * @param aasServiceFactory Used for creating the AasService for new AAS + * @param aasRepositoryName Name of the AASRepository + */ + public InMemoryAasRepository(AasServiceFactory aasServiceFactory, String aasRepositoryName) { + this(aasServiceFactory); + this.aasRepositoryName = aasRepositoryName; + } @Override public CursorResult> getAllAas(PaginationInfo pInfo) { @@ -160,7 +173,12 @@ public AssetInformation getAssetInformation(String aasId) throws ElementDoesNotE .getAAS() .getAssetInformation(); } - + + @Override + public String getName() { + return aasRepositoryName == null ? AasRepository.super.getName() : aasRepositoryName; + } + private void throwIfMismatchingIds(String aasId, AssetAdministrationShell newAas) { String newAasId = newAas.getId(); diff --git a/basyx.aasrepository/basyx.aasrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/InMemoryAasRepositoryFactory.java b/basyx.aasrepository/basyx.aasrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/InMemoryAasRepositoryFactory.java index 75174c584..0b84d0fa6 100644 --- a/basyx.aasrepository/basyx.aasrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/InMemoryAasRepositoryFactory.java +++ b/basyx.aasrepository/basyx.aasrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/InMemoryAasRepositoryFactory.java @@ -22,31 +22,42 @@ * * SPDX-License-Identifier: MIT ******************************************************************************/ + package org.eclipse.digitaltwin.basyx.aasrepository; import org.eclipse.digitaltwin.basyx.aasservice.AasServiceFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; /** * AasRepository factory returning an in-memory backend AasRepository * - * @author schnicke + * @author schnicke, kammognie */ @ConditionalOnExpression("'${basyx.aasrepository.backend}'.equals('InMemory') or '${basyx.backend}'.equals('InMemory')") @Component public class InMemoryAasRepositoryFactory implements AasRepositoryFactory { private AasServiceFactory aasApiFactory; + + private String aasRepositoryName; - @Autowired + @Autowired(required = false) public InMemoryAasRepositoryFactory(AasServiceFactory aasApiFactory) { this.aasApiFactory = aasApiFactory; } + + @Autowired(required = false) + public InMemoryAasRepositoryFactory(AasServiceFactory aasApiFactory, @Value("${basyx.aasrepo.name:aas-repo}") String aasRepositoryName) { + this(aasApiFactory); + this.aasRepositoryName = aasRepositoryName; + } @Override public AasRepository create() { - return new InMemoryAasRepository(aasApiFactory); + return new InMemoryAasRepository(aasApiFactory, aasRepositoryName); } + } diff --git a/basyx.aasrepository/basyx.aasrepository-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/TestInMemoryAasRepository.java b/basyx.aasrepository/basyx.aasrepository-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/TestInMemoryAasRepository.java index 1d6f8ae77..8603299f5 100644 --- a/basyx.aasrepository/basyx.aasrepository-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/TestInMemoryAasRepository.java +++ b/basyx.aasrepository/basyx.aasrepository-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/TestInMemoryAasRepository.java @@ -26,18 +26,29 @@ package org.eclipse.digitaltwin.basyx.aasrepository; +import static org.junit.Assert.assertEquals; import org.eclipse.digitaltwin.basyx.aasservice.backend.InMemoryAasServiceFactory; +import org.junit.Test; /** - * - * @author schnicke + * Tests the {@link InMemoryAasRepository} name + * + * @author schnicke, kammognie * */ public class TestInMemoryAasRepository extends AasRepositorySuite { - + private static final String CONFIGURED_AAS_REPO_NAME = "configured-aas-repo-name"; + @Override protected AasRepositoryFactory getAasRepositoryFactory() { return new InMemoryAasRepositoryFactory(new InMemoryAasServiceFactory()); } + + @Test + public void getConfiguredInMemoryAasRepositoryName() { + AasRepository repo = new InMemoryAasRepository(new InMemoryAasServiceFactory(), CONFIGURED_AAS_REPO_NAME); + + assertEquals(CONFIGURED_AAS_REPO_NAME, repo.getName()); + } } diff --git a/basyx.aasrepository/basyx.aasrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/MongoDBAasRepository.java b/basyx.aasrepository/basyx.aasrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/MongoDBAasRepository.java index 58efb5191..4b76d3c54 100644 --- a/basyx.aasrepository/basyx.aasrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/MongoDBAasRepository.java +++ b/basyx.aasrepository/basyx.aasrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/MongoDBAasRepository.java @@ -48,8 +48,8 @@ /** * * MongoDB implementation of the AasRepository - * - * @author schnicke, kevinbck + * + * @author schnicke, kevinbck, kammognie * */ public class MongoDBAasRepository implements AasRepository { @@ -58,6 +58,7 @@ public class MongoDBAasRepository implements AasRepository { private MongoTemplate mongoTemplate; private String collectionName; private AasServiceFactory aasServiceFactory; + private String aasRepositoryName; public MongoDBAasRepository(MongoTemplate mongoTemplate, String collectionName, AasServiceFactory aasServiceFactory) { this.mongoTemplate = mongoTemplate; @@ -65,6 +66,11 @@ public MongoDBAasRepository(MongoTemplate mongoTemplate, String collectionName, this.aasServiceFactory = aasServiceFactory; configureIndexForAasId(mongoTemplate); } + + public MongoDBAasRepository(MongoTemplate mongoTemplate, String collectionName, AasServiceFactory aasServiceFactory, String aasRepositoryName) { + this(mongoTemplate, collectionName, aasServiceFactory); + this.aasRepositoryName = aasRepositoryName; + } private void configureIndexForAasId(MongoTemplate mongoTemplate) { Index idIndex = new Index().on(IDJSONPATH, Direction.ASC); @@ -163,6 +169,11 @@ public AssetInformation getAssetInformation(String aasId) throws ElementDoesNotE return this.getAas(aasId) .getAssetInformation(); } + + @Override + public String getName() { + return aasRepositoryName == null ? AasRepository.super.getName() : aasRepositoryName; + } private AasService getAasService(String aasId) { return aasServiceFactory.create(getAas(aasId)); diff --git a/basyx.aasrepository/basyx.aasrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/MongoDBAasRepositoryFactory.java b/basyx.aasrepository/basyx.aasrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/MongoDBAasRepositoryFactory.java index 8e777c378..2d70cd5e7 100644 --- a/basyx.aasrepository/basyx.aasrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/MongoDBAasRepositoryFactory.java +++ b/basyx.aasrepository/basyx.aasrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/MongoDBAasRepositoryFactory.java @@ -23,7 +23,6 @@ * SPDX-License-Identifier: MIT ******************************************************************************/ - package org.eclipse.digitaltwin.basyx.aasrepository; import org.eclipse.digitaltwin.basyx.aasservice.AasServiceFactory; @@ -44,16 +43,28 @@ public class MongoDBAasRepositoryFactory implements AasRepositoryFactory { private MongoTemplate mongoTemplate; private String collectionName; private AasServiceFactory aasServiceFactory; + + private String aasRepositoryName; - @Autowired - public MongoDBAasRepositoryFactory(MongoTemplate mongoTemplate, @Value("${basyx.aasrepository.mongodb.collectionName:aas-repo}") String collectionName, AasServiceFactory aasServiceFactory) { + @Autowired(required = false) + public MongoDBAasRepositoryFactory(MongoTemplate mongoTemplate, + @Value("${basyx.aasrepository.mongodb.collectionName:aas-repo}") String collectionName, + AasServiceFactory aasServiceFactory) { this.mongoTemplate = mongoTemplate; this.collectionName = collectionName; this.aasServiceFactory = aasServiceFactory; } + + @Autowired(required = false) + public MongoDBAasRepositoryFactory(MongoTemplate mongoTemplate, + @Value("${basyx.aasrepository.mongodb.collectionName:aas-repo}") String collectionName, + AasServiceFactory aasServiceFactory, @Value("${basyx.aasrepo.name:aas-repo}") String aasRepositoryName) { + this(mongoTemplate, collectionName, aasServiceFactory); + this.aasRepositoryName = aasRepositoryName; + } @Override public AasRepository create() { - return new MongoDBAasRepository(mongoTemplate, collectionName, aasServiceFactory); + return new MongoDBAasRepository(mongoTemplate, collectionName, aasServiceFactory, aasRepositoryName); } } diff --git a/basyx.aasrepository/basyx.aasrepository-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/TestMongoDBAasRepository.java b/basyx.aasrepository/basyx.aasrepository-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/TestMongoDBAasRepository.java index bbc79089a..46d7fc9bb 100644 --- a/basyx.aasrepository/basyx.aasrepository-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/TestMongoDBAasRepository.java +++ b/basyx.aasrepository/basyx.aasrepository-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/TestMongoDBAasRepository.java @@ -35,30 +35,28 @@ import org.eclipse.digitaltwin.basyx.common.mongocore.MongoDBUtilities; import org.junit.Test; import org.springframework.data.mongodb.core.MongoTemplate; - import com.mongodb.client.MongoClient; import com.mongodb.client.MongoClients; /** * - * @author schnicke, danish + * @author schnicke, danish, kammognie * */ public class TestMongoDBAasRepository extends AasRepositorySuite { - private final String COLLECTION = "aasTestCollection"; + private static final String CONFIGURED_AAS_REPO_NAME = "configured-aas-repo-name"; + @Override protected AasRepositoryFactory getAasRepositoryFactory() { - String connectionURL = "mongodb://mongoAdmin:mongoPassword@localhost:27017/"; - MongoClient client = MongoClients.create(connectionURL); - MongoTemplate template = new MongoTemplate(client, "BaSyxTestDb"); + MongoTemplate template = createMongoTemplate(); MongoDBUtilities.clearCollection(template, COLLECTION); return new MongoDBAasRepositoryFactory(template, COLLECTION, new InMemoryAasServiceFactory()); } - + @Test public void aasIsPersisted() { AasRepositoryFactory repoFactory = getAasRepositoryFactory(); @@ -80,6 +78,13 @@ public void updatedAasIsPersisted() { assertEquals(expectedShell, retrievedShell); } + + @Test + public void getConfiguredMongoDBAasRepositoryName() { + AasRepository repo = new MongoDBAasRepository(createMongoTemplate(), COLLECTION, new InMemoryAasServiceFactory(), CONFIGURED_AAS_REPO_NAME); + + assertEquals(CONFIGURED_AAS_REPO_NAME, repo.getName()); + } private void addSubmodelReferenceToAas(AssetAdministrationShell expectedShell) { expectedShell.setSubmodels(Arrays.asList(AasRepositorySuite.createDummyReference("dummySubmodel"))); @@ -99,4 +104,12 @@ private AssetAdministrationShell createDummyShellOnRepo(AasRepository aasReposit return expectedShell; } + private MongoTemplate createMongoTemplate() { + String connectionURL = "mongodb://mongoAdmin:mongoPassword@localhost:27017/"; + + MongoClient client = MongoClients.create(connectionURL); + + return new MongoTemplate(client, "BaSyxTestDb"); + } + } diff --git a/basyx.aasrepository/basyx.aasrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/AasRepository.java b/basyx.aasrepository/basyx.aasrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/AasRepository.java index 8b37a0a27..3502f0f1b 100644 --- a/basyx.aasrepository/basyx.aasrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/AasRepository.java +++ b/basyx.aasrepository/basyx.aasrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/aasrepository/AasRepository.java @@ -37,11 +37,11 @@ /** * Specifies the overall AasRepository API * - * @author schnicke + * @author schnicke, kammognie * */ public interface AasRepository { - + /** * Retrieves all Asset Administration Shells from the repository * @@ -121,8 +121,14 @@ public interface AasRepository { * @return the requested AAS */ public AssetInformation getAssetInformation(String aasId) throws ElementDoesNotExistException; - + + /** + * Returns the name of the repository + * + * @return repoName + */ public default String getName() { - return "aasRepository-default-name"; + return "aas-repo"; } + } diff --git a/basyx.aasrepository/basyx.aasrepository-core/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/AasRepositorySuite.java b/basyx.aasrepository/basyx.aasrepository-core/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/AasRepositorySuite.java index a4f3c275f..1a2b84764 100644 --- a/basyx.aasrepository/basyx.aasrepository-core/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/AasRepositorySuite.java +++ b/basyx.aasrepository/basyx.aasrepository-core/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/AasRepositorySuite.java @@ -55,7 +55,7 @@ /** * Testsuite for implementations of the AasRepository interface * - * @author schnicke + * @author schnicke, kammognie * */ public abstract class AasRepositorySuite { @@ -74,7 +74,7 @@ public abstract class AasRepositorySuite { private AasRepository aasRepo; protected abstract AasRepositoryFactory getAasRepositoryFactory(); - + @Before public void createAasRepoWithDummyAas() { aasRepo = getAasRepositoryFactory().create(); @@ -93,6 +93,11 @@ public void createAasRepoWithDummyAas() { preconfiguredShells.forEach(shell -> aasRepo.createAas(shell)); } + + @Test + public void getDefaultAasRepositoryName() { + assertEquals("aas-repo", aasRepo.getName()); + } @Test public void allAasRetrieval() throws Exception { diff --git a/basyx.aasrepository/basyx.aasrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/http/DummyAasRepositoryComponent.java b/basyx.aasrepository/basyx.aasrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/http/DummyAasRepositoryComponent.java index f311f3add..c03e6a99f 100644 --- a/basyx.aasrepository/basyx.aasrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/http/DummyAasRepositoryComponent.java +++ b/basyx.aasrepository/basyx.aasrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/http/DummyAasRepositoryComponent.java @@ -26,17 +26,20 @@ package org.eclipse.digitaltwin.basyx.aasrepository.http; -import org.eclipse.digitaltwin.basyx.aasrepository.AasRepository; -import org.eclipse.digitaltwin.basyx.aasrepository.InMemoryAasRepository; -import org.eclipse.digitaltwin.basyx.aasservice.backend.InMemoryAasServiceFactory; +import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; + +/** + * Spring application configured for tests. + * + * @author danish, kammognie + * + */ @SpringBootApplication(scanBasePackages = "org.eclipse.digitaltwin.basyx") public class DummyAasRepositoryComponent { - - @Bean - public AasRepository createAasRepository() { - return new InMemoryAasRepository(new InMemoryAasServiceFactory()); - } + + public static void main(String[] args) { + SpringApplication.run(DummyAasRepositoryComponent.class, args); + } } diff --git a/basyx.aasrepository/basyx.aasrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/http/testconfig/DummyConfig.java b/basyx.aasrepository/basyx.aasrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/http/testconfig/DummyConfig.java new file mode 100644 index 000000000..d88a43046 --- /dev/null +++ b/basyx.aasrepository/basyx.aasrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/http/testconfig/DummyConfig.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (C) 2023 the Eclipse BaSyx Authors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ + +package org.eclipse.digitaltwin.basyx.aasrepository.http.testconfig; + +import org.eclipse.digitaltwin.basyx.aasrepository.AasRepository; + +import org.eclipse.digitaltwin.basyx.aasrepository.InMemoryAasRepository; +import org.eclipse.digitaltwin.basyx.aasservice.backend.InMemoryAasServiceFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + + +/** + * Configuration for tests + * + * @author danish, kammognie + * + */ +@Configuration +public class DummyConfig { + + @Bean + @ConditionalOnMissingBean + public AasRepository createAasRepository() { + return new InMemoryAasRepository(new InMemoryAasServiceFactory()); + } +} diff --git a/basyx.aasrepository/basyx.aasrepository.component/pom.xml b/basyx.aasrepository/basyx.aasrepository.component/pom.xml index 198981558..fa3ca06a9 100644 --- a/basyx.aasrepository/basyx.aasrepository.component/pom.xml +++ b/basyx.aasrepository/basyx.aasrepository.component/pom.xml @@ -82,6 +82,11 @@ spring-boot-starter-test test + + org.junit.vintage + junit-vintage-engine + test + org.springframework.boot spring-boot-starter-web diff --git a/basyx.aasrepository/basyx.aasrepository.component/src/main/resources/application.properties b/basyx.aasrepository/basyx.aasrepository.component/src/main/resources/application.properties index cd3d3b524..f631808ab 100644 --- a/basyx.aasrepository/basyx.aasrepository.component/src/main/resources/application.properties +++ b/basyx.aasrepository/basyx.aasrepository.component/src/main/resources/application.properties @@ -1,6 +1,7 @@ server.port=8081 spring.application.name=AAS Repository +basyx.aasrepo.name=aas-repo basyx.backend = InMemory diff --git a/basyx.aasrepository/basyx.aasrepository.component/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/component/TestAasRepositoryName.java b/basyx.aasrepository/basyx.aasrepository.component/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/component/TestAasRepositoryName.java new file mode 100644 index 000000000..7cb9aeb40 --- /dev/null +++ b/basyx.aasrepository/basyx.aasrepository.component/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/component/TestAasRepositoryName.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (C) 2023 the Eclipse BaSyx Authors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ + +package org.eclipse.digitaltwin.basyx.aasrepository.component; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.digitaltwin.basyx.aasrepository.AasRepository; +import org.junit.Test; +import org.springframework.boot.SpringApplication; +import org.springframework.context.ConfigurableApplicationContext; + +/** + * + * Test the configuration of the AasRepository's name + * + * @author danish, kammognie + * + */ +public class TestAasRepositoryName { + private static final String CONFIGURED_AAS_REPO_NAME = "configured-aas-repo-name"; + private static final String BASYX_AASREPO_NAME_KEY = "basyx.aasrepo.name"; + private static ConfigurableApplicationContext appContext; + + public void startContext() { + appContext = new SpringApplication(AasRepositoryComponent.class).run(new String[] {}); + } + + public static void closeContext() { + appContext.close(); + } + + @Test + public void getDefaultRepoName() { + startContext(); + + AasRepository repo = appContext.getBean(AasRepository.class); + + assertEquals("aas-repo", repo.getName()); + + closeContext(); + } + + @Test + public void getConfiguredRepoName() { + configureRepoNamePropertyAndStartContext(); + + AasRepository repo = appContext.getBean(AasRepository.class); + + assertEquals(CONFIGURED_AAS_REPO_NAME, repo.getName()); + + resetRepoNamePropertyAndCloseContext(); + } + + private void resetRepoNamePropertyAndCloseContext() { + System.clearProperty(BASYX_AASREPO_NAME_KEY); + + closeContext(); + } + + private void configureRepoNamePropertyAndStartContext() { + System.setProperty(BASYX_AASREPO_NAME_KEY, CONFIGURED_AAS_REPO_NAME); + + startContext(); + } + +} diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/InMemoryConceptDescriptionRepository.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/InMemoryConceptDescriptionRepository.java index 60a36f40a..b6d941641 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/InMemoryConceptDescriptionRepository.java +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/InMemoryConceptDescriptionRepository.java @@ -48,18 +48,28 @@ /** * In-memory implementation of the ConceptDescriptionRepository * - * @author danish + * @author danish, kammognie * */ public class InMemoryConceptDescriptionRepository implements ConceptDescriptionRepository { private Map conceptDescriptions = new LinkedHashMap<>(); + + private String cdRepositoryName; /** * Creates the InMemoryConceptDescriptionRepository * */ - public InMemoryConceptDescriptionRepository() { + public InMemoryConceptDescriptionRepository() { } + + /** + * Creates the InMemoryConceptDescriptionRepository + * + * @param cdRepositoryName Name of the CDRepository + */ + public InMemoryConceptDescriptionRepository(String cdRepositoryName) { + this.cdRepositoryName = cdRepositoryName; } /** @@ -73,6 +83,18 @@ public InMemoryConceptDescriptionRepository(Collection conce this.conceptDescriptions.putAll(mapConceptDescriptions(conceptDescriptions)); } + + /** + * Creates the InMemoryConceptDescriptionRepository and preconfiguring + * it with the passed ConceptDescriptions + * + * @param conceptDescriptions + * @param cdRepositoryName Name of the CDRepository + */ + public InMemoryConceptDescriptionRepository(Collection conceptDescriptions, String cdRepositoryName) { + this(conceptDescriptions); + this.cdRepositoryName = cdRepositoryName; + } @Override public CursorResult> getAllConceptDescriptions(PaginationInfo pInfo) { @@ -154,6 +176,11 @@ public void deleteConceptDescription(String conceptDescriptionId) throws Element conceptDescriptions.remove(conceptDescriptionId); } + + @Override + public String getName() { + return cdRepositoryName == null ? ConceptDescriptionRepository.super.getName() : cdRepositoryName; + } private static void assertIdUniqueness(Collection conceptDescriptionsToCheck) { Set ids = new HashSet<>(); diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/InMemoryConceptDescriptionRepositoryFactory.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/InMemoryConceptDescriptionRepositoryFactory.java index dbd921ed0..64487b84d 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/InMemoryConceptDescriptionRepositoryFactory.java +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/InMemoryConceptDescriptionRepositoryFactory.java @@ -24,6 +24,8 @@ package org.eclipse.digitaltwin.basyx.conceptdescriptionrepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; @@ -35,10 +37,20 @@ @Component @ConditionalOnExpression("'${basyx.backend}'.equals('InMemory')") public class InMemoryConceptDescriptionRepositoryFactory implements ConceptDescriptionRepositoryFactory { + + private String cdRepositoryName; + + @Autowired(required = false) + public InMemoryConceptDescriptionRepositoryFactory() { } + + @Autowired(required = false) + public InMemoryConceptDescriptionRepositoryFactory(@Value("${basyx.cdrepo.name:cd-repo}") String cdRepositoryName) { + this.cdRepositoryName = cdRepositoryName; + } @Override public ConceptDescriptionRepository create() { - return new InMemoryConceptDescriptionRepository(); + return new InMemoryConceptDescriptionRepository(cdRepositoryName); } } diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/TestInMemoryConceptDescriptionRepository.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/TestInMemoryConceptDescriptionRepository.java index 7696655a0..de3528f0e 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/TestInMemoryConceptDescriptionRepository.java +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/TestInMemoryConceptDescriptionRepository.java @@ -26,6 +26,8 @@ package org.eclipse.digitaltwin.basyx.conceptdescriptionrepository; +import static org.junit.Assert.assertEquals; + import java.util.Arrays; import java.util.Collection; @@ -38,10 +40,12 @@ /** * Tests the {@link InMemoryConceptDescriptionRepository} * - * @author danish + * @author danish, kammognie * */ public class TestInMemoryConceptDescriptionRepository extends ConceptDescriptionRepositorySuite { + + private static final String CONFIGURED_CD_REPO_NAME = "configured-cd-repo-name"; @Override protected ConceptDescriptionRepository getConceptDescriptionRepository() { @@ -52,6 +56,13 @@ protected ConceptDescriptionRepository getConceptDescriptionRepository() { protected ConceptDescriptionRepository getConceptDescriptionRepository(Collection conceptDescriptions) { return new InMemoryConceptDescriptionRepository(conceptDescriptions); } + + @Test + public void getConfiguredInMemoryConceptDescriptionRepositoryName() { + ConceptDescriptionRepository repo = new InMemoryConceptDescriptionRepository(CONFIGURED_CD_REPO_NAME); + + assertEquals(CONFIGURED_CD_REPO_NAME, repo.getName()); + } @Test(expected = CollidingIdentifierException.class) public void idCollisionDuringConstruction() { diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/MongoDBConceptDescriptionRepository.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/MongoDBConceptDescriptionRepository.java index ead390919..fc031b9da 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/MongoDBConceptDescriptionRepository.java +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/MongoDBConceptDescriptionRepository.java @@ -49,7 +49,7 @@ * * MongoDB implementation of the ConceptDescriptionRepository * - * @author danish + * @author danish, kammognie * */ public class MongoDBConceptDescriptionRepository implements ConceptDescriptionRepository { @@ -57,12 +57,18 @@ public class MongoDBConceptDescriptionRepository implements ConceptDescriptionRe private MongoTemplate mongoTemplate; private String collectionName; + private String cdRepositoryName; public MongoDBConceptDescriptionRepository(MongoTemplate mongoTemplate, String collectionName) { this.mongoTemplate = mongoTemplate; this.collectionName = collectionName; configureIndexForConceptDescriptionId(mongoTemplate); } + + public MongoDBConceptDescriptionRepository(MongoTemplate mongoTemplate, String collectionName, String cdRepositoryName) { + this(mongoTemplate, collectionName); + this.cdRepositoryName = cdRepositoryName; + } @Override public CursorResult> getAllConceptDescriptions(PaginationInfo pInfo) { @@ -153,6 +159,11 @@ public void deleteConceptDescription(String conceptDescriptionId) throws Element throw new ElementDoesNotExistException(conceptDescriptionId); } + + @Override + public String getName() { + return cdRepositoryName == null ? ConceptDescriptionRepository.super.getName() : cdRepositoryName; + } private void configureIndexForConceptDescriptionId(MongoTemplate mongoTemplate) { Index idIndex = new Index().on(IDJSONPATH, Direction.ASC); diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/MongoDBConceptDescriptionRepositoryFactory.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/MongoDBConceptDescriptionRepositoryFactory.java index f8b4998f3..f9cac3a88 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/MongoDBConceptDescriptionRepositoryFactory.java +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/MongoDBConceptDescriptionRepositoryFactory.java @@ -23,7 +23,6 @@ * SPDX-License-Identifier: MIT ******************************************************************************/ - package org.eclipse.digitaltwin.basyx.conceptdescriptionrepository; import org.springframework.beans.factory.annotation.Autowired; @@ -33,25 +32,36 @@ import org.springframework.stereotype.Component; /** - * ConceptDescriptionRepository factory returning a MongoDb backend ConceptDescriptionRepository + * ConceptDescriptionRepository factory returning a MongoDb backend + * ConceptDescriptionRepository * - * @author schnicke, danish + * @author schnicke, danish, kammognie */ @Component @ConditionalOnExpression("'${basyx.backend}'.equals('MongoDB')") public class MongoDBConceptDescriptionRepositoryFactory implements ConceptDescriptionRepositoryFactory { - + private MongoTemplate mongoTemplate; private String collectionName; - - @Autowired - public MongoDBConceptDescriptionRepositoryFactory(MongoTemplate mongoTemplate, @Value("${basyx.conceptdescriptionrepository.mongodb.collectionName:conceptdescription-repo}") String collectionName) { + private String cdRepositoryName; + + @Autowired(required = false) + public MongoDBConceptDescriptionRepositoryFactory(MongoTemplate mongoTemplate, + @Value("${basyx.conceptdescriptionrepository.mongodb.collectionName:conceptdescription-repo}") String collectionName) { this.mongoTemplate = mongoTemplate; this.collectionName = collectionName; } + @Autowired(required = false) + public MongoDBConceptDescriptionRepositoryFactory(MongoTemplate mongoTemplate, + @Value("${basyx.conceptdescriptionrepository.mongodb.collectionName:conceptdescription-repo}") String collectionName, + @Value("${basyx.cdrepo.name:cd-repo}") String cdRepositoryName) { + this(mongoTemplate, collectionName); + this.cdRepositoryName = cdRepositoryName; + } + @Override public ConceptDescriptionRepository create() { - return new MongoDBConceptDescriptionRepository(mongoTemplate, collectionName); + return new MongoDBConceptDescriptionRepository(mongoTemplate, collectionName, cdRepositoryName); } } diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/TestMongoDBConceptDescriptionRepository.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/TestMongoDBConceptDescriptionRepository.java index cbe129796..2f1a32229 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/TestMongoDBConceptDescriptionRepository.java +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/aasrepository/TestMongoDBConceptDescriptionRepository.java @@ -48,11 +48,11 @@ /** * Tests the {@link MongoDBConceptDescriptionRepository} * - * @author danish + * @author danish, kammognie * */ public class TestMongoDBConceptDescriptionRepository extends ConceptDescriptionRepositorySuite { - + private static final String CONFIGURED_CD_REPO_NAME = "configured-cd-repo-name"; private final String COLLECTION = "conceptDescTestCollection"; @Override @@ -77,6 +77,17 @@ protected ConceptDescriptionRepository getConceptDescriptionRepository( return conceptDescriptionRepository; } + + @Test + public void testConfiguredMongoDBConceptDescriptionRepositoryName() { + MongoTemplate template = createTemplate(); + + clearDatabase(template); + + ConceptDescriptionRepository repo = new MongoDBConceptDescriptionRepository(template, COLLECTION, CONFIGURED_CD_REPO_NAME); + + assertEquals(CONFIGURED_CD_REPO_NAME, repo.getName()); + } @Test public void conceptDescriptionIsPersisted() { @@ -122,10 +133,10 @@ private ConceptDescription createDummyConceptDescriptionOnRepo(ConceptDescriptio private MongoTemplate createTemplate() { String connectionURL = "mongodb://mongoAdmin:mongoPassword@localhost:27017/"; + MongoClient client = MongoClients.create(connectionURL); - MongoTemplate template = new MongoTemplate(client, "BaSyxTestDb"); - return template; + return new MongoTemplate(client, "BaSyxTestDb"); } private void clearDatabase(MongoTemplate template) { diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/ConceptDescriptionRepository.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/ConceptDescriptionRepository.java index ba564e3ba..41b27dd17 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/ConceptDescriptionRepository.java +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/ConceptDescriptionRepository.java @@ -37,7 +37,7 @@ /** * Specifies the overall ConceptDescriptionRepository API * - * @author danish + * @author danish, kammognie * */ public interface ConceptDescriptionRepository { @@ -109,5 +109,14 @@ public interface ConceptDescriptionRepository { * @throws ElementDoesNotExistException */ public void deleteConceptDescription(String conceptDescriptionId) throws ElementDoesNotExistException; - + + /** + * Returns the name of the repository + * + * @return repoName + */ + public default String getName() { + return "cd-repo"; + } + } diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-core/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/core/ConceptDescriptionRepositorySuite.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-core/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/core/ConceptDescriptionRepositorySuite.java index 9cbc1ed3c..cc4cc4dcf 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-core/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/core/ConceptDescriptionRepositorySuite.java +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-core/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/core/ConceptDescriptionRepositorySuite.java @@ -52,7 +52,7 @@ /** * Testsuite for implementations of the ConceptDescriptionRepository interface * - * @author schnicke, danish + * @author schnicke, danish, kammognie * */ public abstract class ConceptDescriptionRepositorySuite { @@ -216,6 +216,13 @@ public void deleteNonExistingConceptDescription() { ConceptDescriptionRepository repo = getConceptDescriptionRepositoryWithDummyConceptDescriptions(); repo.deleteConceptDescription("nonExisting"); } + + @Test + public void getDefaultConceptDescriptionRepositoryName() { + ConceptDescriptionRepository repo = getConceptDescriptionRepository(); + + assertEquals("cd-repo", repo.getName()); + } @Test public void allContextDescriptionPaginated() { diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/http/DummyConceptDescriptionRepositoryComponent.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/http/DummyConceptDescriptionRepositoryComponent.java index 02624edd2..0958ce7f7 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/http/DummyConceptDescriptionRepositoryComponent.java +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/http/DummyConceptDescriptionRepositoryComponent.java @@ -26,21 +26,19 @@ package org.eclipse.digitaltwin.basyx.conceptdescriptionrepository.http; -import org.eclipse.digitaltwin.basyx.conceptdescriptionrepository.InMemoryConceptDescriptionRepository; +import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; /** * Spring application configured for tests. * - * @author schnicke, danish + * @author schnicke, danish, kammognie * */ @SpringBootApplication(scanBasePackages = "org.eclipse.digitaltwin.basyx") public class DummyConceptDescriptionRepositoryComponent { - - @Bean - public InMemoryConceptDescriptionRepository createConceptDescriptionRepository() { - return new InMemoryConceptDescriptionRepository(); + + public static void main(String[] args) { + SpringApplication.run(DummyConceptDescriptionRepositoryComponent.class, args); } } diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/http/testconfig/DummyConfig.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/http/testconfig/DummyConfig.java new file mode 100644 index 000000000..2993c0a6a --- /dev/null +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/http/testconfig/DummyConfig.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (C) 2023 the Eclipse BaSyx Authors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ + +package org.eclipse.digitaltwin.basyx.conceptdescriptionrepository.http.testconfig; + +import org.eclipse.digitaltwin.basyx.conceptdescriptionrepository.ConceptDescriptionRepository; +import org.eclipse.digitaltwin.basyx.conceptdescriptionrepository.InMemoryConceptDescriptionRepository; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Configuration for tests + * + * @author danish, kammognie + * + */ +@Configuration +public class DummyConfig { + + @Bean + @ConditionalOnMissingBean + public ConceptDescriptionRepository createConceptDescriptionRepository() { + return new InMemoryConceptDescriptionRepository(); + } +} \ No newline at end of file diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component/pom.xml b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component/pom.xml index e5b65a6a6..7acac2a78 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component/pom.xml +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component/pom.xml @@ -46,6 +46,11 @@ spring-boot-starter-test test + + org.junit.vintage + junit-vintage-engine + test + org.springframework.boot spring-boot-starter-web diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component/src/main/resources/application.properties b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component/src/main/resources/application.properties index 824fef9e8..f2f97de04 100644 --- a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component/src/main/resources/application.properties +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component/src/main/resources/application.properties @@ -1,5 +1,6 @@ server.port=8081 spring.application.name=Concept Description Repository +basyx.cdrepo.name = cd-repo basyx.backend = InMemory diff --git a/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/component/TestConceptDescriptionRepositoryName.java b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/component/TestConceptDescriptionRepositoryName.java new file mode 100644 index 000000000..8b1af341f --- /dev/null +++ b/basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component/src/test/java/org/eclipse/digitaltwin/basyx/conceptdescriptionrepository/component/TestConceptDescriptionRepositoryName.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (C) 2023 the Eclipse BaSyx Authors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ + +package org.eclipse.digitaltwin.basyx.conceptdescriptionrepository.component; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.digitaltwin.basyx.conceptdescriptionrepository.ConceptDescriptionRepository; +import org.junit.Test; +import org.springframework.boot.SpringApplication; +import org.springframework.context.ConfigurableApplicationContext; + +/** + * + * Test the configuration of the AasRepository's name + * + * @author danish, kammognie + * + */ +public class TestConceptDescriptionRepositoryName { + private static final String CONFIGURED_CD_REPO_NAME = "configured-cd-repo-name"; + private static final String BASYX_CDREPO_NAME_KEY = "basyx.cdrepo.name"; + private static ConfigurableApplicationContext appContext; + + public void startContext() { + appContext = new SpringApplication(ConceptDescriptionRepositoryComponent.class).run(new String[] {}); + } + + public static void closeContext() { + appContext.close(); + } + + @Test + public void getDefaultRepoName() { + startContext(); + + ConceptDescriptionRepository repo = appContext.getBean(ConceptDescriptionRepository.class); + + assertEquals("cd-repo", repo.getName()); + + closeContext(); + } + + @Test + public void getConfiguredRepoName() { + configureRepoNamePropertyAndStartContext(); + + ConceptDescriptionRepository repo = appContext.getBean(ConceptDescriptionRepository.class); + + assertEquals(CONFIGURED_CD_REPO_NAME, repo.getName()); + + resetRepoNamePropertyAndCloseContext(); + } + + private void resetRepoNamePropertyAndCloseContext() { + System.clearProperty(BASYX_CDREPO_NAME_KEY); + + closeContext(); + } + + private void configureRepoNamePropertyAndStartContext() { + System.setProperty(BASYX_CDREPO_NAME_KEY, CONFIGURED_CD_REPO_NAME); + + startContext(); + } + +} diff --git a/basyx.submodelrepository/basyx.submodelrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/InMemorySubmodelRepository.java b/basyx.submodelrepository/basyx.submodelrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/InMemorySubmodelRepository.java index fddf412a0..cb9159460 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/InMemorySubmodelRepository.java +++ b/basyx.submodelrepository/basyx.submodelrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/InMemorySubmodelRepository.java @@ -51,7 +51,7 @@ /** * In-memory implementation of the SubmodelRepository * - * @author schnicke, danish + * @author schnicke, danish, kammognie * */ public class InMemorySubmodelRepository implements SubmodelRepository { @@ -59,6 +59,7 @@ public class InMemorySubmodelRepository implements SubmodelRepository { private static final PaginationInfo NO_LIMIT_PAGINATION_INFO = new PaginationInfo(0, null); private Map submodelServices = new LinkedHashMap<>(); private SubmodelServiceFactory submodelServiceFactory; + private String smRepositoryName; /** * Creates the InMemorySubmodelRepository utilizing the passed @@ -69,6 +70,18 @@ public class InMemorySubmodelRepository implements SubmodelRepository { public InMemorySubmodelRepository(SubmodelServiceFactory submodelServiceFactory) { this.submodelServiceFactory = submodelServiceFactory; } + + /** + * Creates the InMemorySubmodelRepository utilizing the passed + * SubmodelServiceFactory for creating new SubmodelServices + * + * @param submodelServiceFactory + * @param smRepositoryName Name of the SubmodelRepository + */ + public InMemorySubmodelRepository(SubmodelServiceFactory submodelServiceFactory, String smRepositoryName) { + this(submodelServiceFactory); + this.smRepositoryName = smRepositoryName; + } /** * Creates the InMemorySubmodelRepository utilizing the passed @@ -84,6 +97,20 @@ public InMemorySubmodelRepository(SubmodelServiceFactory submodelServiceFactory, submodelServices = createServices(submodels); } + + /** + * Creates the InMemorySubmodelRepository utilizing the passed + * SubmodelServiceFactory for creating new SubmodelServices and preconfiguring + * it with the passed Submodels + * + * @param submodelServiceFactory + * @param submodels + * @param smRepositoryName Name of the SubmodelRepository + */ + public InMemorySubmodelRepository(SubmodelServiceFactory submodelServiceFactory, Collection submodels, String smRepositoryName) { + this(submodelServiceFactory, submodels); + this.smRepositoryName = smRepositoryName; + } private void throwIfHasCollidingIds(Collection submodelsToCheck) { Set ids = new HashSet<>(); @@ -196,6 +223,11 @@ public Submodel getSubmodelByIdMetadata(String submodelId) { submodel.setSubmodelElements(null); return submodel; } + + @Override + public String getName() { + return smRepositoryName == null ? SubmodelRepository.super.getName() : smRepositoryName; + } @Override public OperationVariable[] invokeOperation(String submodelId, String idShortPath, OperationVariable[] input) throws ElementDoesNotExistException { diff --git a/basyx.submodelrepository/basyx.submodelrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/InMemorySubmodelRepositoryFactory.java b/basyx.submodelrepository/basyx.submodelrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/InMemorySubmodelRepositoryFactory.java index 9566aaa02..ff3d95730 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/InMemorySubmodelRepositoryFactory.java +++ b/basyx.submodelrepository/basyx.submodelrepository-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/InMemorySubmodelRepositoryFactory.java @@ -26,6 +26,7 @@ import org.eclipse.digitaltwin.basyx.submodelservice.SubmodelServiceFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.stereotype.Component; @@ -38,15 +39,23 @@ @Component public class InMemorySubmodelRepositoryFactory implements SubmodelRepositoryFactory { private SubmodelServiceFactory submodelServiceFactory; + + private String smRepositoryName; - @Autowired + @Autowired(required = false) public InMemorySubmodelRepositoryFactory(SubmodelServiceFactory submodelServiceFactory) { this.submodelServiceFactory = submodelServiceFactory; } + + @Autowired(required = false) + public InMemorySubmodelRepositoryFactory(SubmodelServiceFactory submodelServiceFactory, @Value("${basyx.smrepo.name:sm-repo}") String smRepositoryName) { + this(submodelServiceFactory); + this.smRepositoryName = smRepositoryName; + } @Override public SubmodelRepository create() { - return new InMemorySubmodelRepository(submodelServiceFactory); + return new InMemorySubmodelRepository(submodelServiceFactory, smRepositoryName); } } diff --git a/basyx.submodelrepository/basyx.submodelrepository-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/TestInMemorySubmodelRepository.java b/basyx.submodelrepository/basyx.submodelrepository-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/TestInMemorySubmodelRepository.java index 79f092913..1d9cf5a3d 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/TestInMemorySubmodelRepository.java +++ b/basyx.submodelrepository/basyx.submodelrepository-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/TestInMemorySubmodelRepository.java @@ -25,6 +25,8 @@ package org.eclipse.digitaltwin.basyx.submodelrepository; +import static org.junit.Assert.assertEquals; + import java.util.Arrays; import java.util.Collection; @@ -38,10 +40,12 @@ /** * - * @author schnicke + * @author schnicke, kammognie * */ public class TestInMemorySubmodelRepository extends SubmodelRepositorySuite { + + private static final String CONFIGURED_SM_REPO_NAME = "configured-sm-repo-name"; @Override protected SubmodelRepository getSubmodelRepository() { @@ -53,6 +57,13 @@ protected SubmodelRepository getSubmodelRepository(Collection submodel return new InMemorySubmodelRepository(new InMemorySubmodelServiceFactory(), submodels); } + @Test + public void getConfiguredInMemorySmRepositoryName() { + SubmodelRepository repo = new InMemorySubmodelRepository(new InMemorySubmodelServiceFactory(), CONFIGURED_SM_REPO_NAME); + + assertEquals(CONFIGURED_SM_REPO_NAME, repo.getName()); + } + @Test(expected = CollidingIdentifierException.class) public void idCollisionDuringConstruction() { Collection submodelsWithCollidingIds = createSubmodelCollectionWithCollidingIds(); diff --git a/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepository.java b/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepository.java index a4e492152..de3b22829 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepository.java +++ b/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepository.java @@ -53,7 +53,7 @@ /** * MongoDB implementation of the SubmodelRepository * - * @author jungjan + * @author jungjan, kammognie * */ public class MongoDBSubmodelRepository implements SubmodelRepository { @@ -64,6 +64,7 @@ public class MongoDBSubmodelRepository implements SubmodelRepository { private MongoTemplate mongoTemplate; private String collectionName; private SubmodelServiceFactory submodelServiceFactory; + private String smRepositoryName; /** * Creates the MongoDBSubmodelRepository utilizing the passed @@ -74,13 +75,30 @@ public class MongoDBSubmodelRepository implements SubmodelRepository { * @param collectionName * @param submodelServiceFactory */ - public MongoDBSubmodelRepository(MongoTemplate mongoTemplate, String collectionName, SubmodelServiceFactory submodelServiceFactory) { + public MongoDBSubmodelRepository(MongoTemplate mongoTemplate, String collectionName, + SubmodelServiceFactory submodelServiceFactory) { this.mongoTemplate = mongoTemplate; this.collectionName = collectionName; this.submodelServiceFactory = submodelServiceFactory; configureIndexForSubmodelId(mongoTemplate); } + /** + * Creates the MongoDBSubmodelRepository utilizing the passed + * SubmodelServiceFactory for creating new SubmodelServices and uses a + * collectionName and a mongoTemplate for operating MongoDB + * + * @param mongoTemplate + * @param collectionName + * @param submodelServiceFactory + * @param smRepositoryName Name of the SubmodelRepository + */ + public MongoDBSubmodelRepository(MongoTemplate mongoTemplate, String collectionName, + SubmodelServiceFactory submodelServiceFactory, String smRepositoryName) { + this(mongoTemplate, collectionName, submodelServiceFactory); + this.smRepositoryName = smRepositoryName; + } + /** * Creates the MongoDBSubmodelRepository utilizing the passed * SubmodelServiceFactory for creating new SubmodelServices and uses a @@ -90,11 +108,32 @@ public MongoDBSubmodelRepository(MongoTemplate mongoTemplate, String collectionN * @param submodelServiceFactory * @param submodels */ - public MongoDBSubmodelRepository(MongoTemplate mongoTemplate, String collectionName, SubmodelServiceFactory submodelServiceFactory, Collection submodels) { + public MongoDBSubmodelRepository(MongoTemplate mongoTemplate, String collectionName, + SubmodelServiceFactory submodelServiceFactory, Collection submodels) { this(mongoTemplate, collectionName, submodelServiceFactory); initializeRemoteCollection(submodels); } + /** + * Creates the MongoDBSubmodelRepository utilizing the passed + * SubmodelServiceFactory for creating new SubmodelServices and uses a + * collectionName and a mongoTemplate for operating MongoDB. Additionally + * initializes the MongoDB collection with a collection of submodels. + * And configures the SubmodelRepository name. + * + * @param mongoTemplate + * @param collectionName + * @param submodelServiceFactory + * @param submodels + * @param smRepositoryName Name of the SubmodelRepository + */ + public MongoDBSubmodelRepository(MongoTemplate mongoTemplate, String collectionName, + SubmodelServiceFactory submodelServiceFactory, Collection submodels, String smRepositoryName) { + this(mongoTemplate, collectionName, submodelServiceFactory, submodels); + + this.smRepositoryName = smRepositoryName; + } + private void initializeRemoteCollection(Collection submodels) { if (submodels == null || submodels.isEmpty()) { return; @@ -121,8 +160,8 @@ public CursorResult> getAllSubmodels(PaginationInfo pInfo) { @Override public Submodel getSubmodel(String submodelId) throws ElementDoesNotExistException { - Submodel submodel = mongoTemplate.findOne(new Query().addCriteria(Criteria.where(ID_JSON_PATH) - .is(submodelId)), Submodel.class, collectionName); + Submodel submodel = mongoTemplate.findOne(new Query().addCriteria(Criteria.where(ID_JSON_PATH).is(submodelId)), + Submodel.class, collectionName); if (submodel == null) { throw new ElementDoesNotExistException(submodelId); } @@ -131,8 +170,7 @@ public Submodel getSubmodel(String submodelId) throws ElementDoesNotExistExcepti @Override public void updateSubmodel(String submodelId, Submodel submodel) throws ElementDoesNotExistException { - Query query = new Query().addCriteria(Criteria.where(ID_JSON_PATH) - .is(submodelId)); + Query query = new Query().addCriteria(Criteria.where(ID_JSON_PATH).is(submodelId)); throwIfSubmodelDoesNotExist(query, submodelId); throwIfMismatchingIds(submodelId, submodel); @@ -162,8 +200,8 @@ public void createSubmodel(Submodel submodel) throws CollidingIdentifierExceptio } private void throwIfCollidesWithRemoteId(Submodel submodel) { - if (mongoTemplate.exists(new Query().addCriteria(Criteria.where(ID_JSON_PATH) - .is(submodel.getId())), Submodel.class, collectionName)) { + if (mongoTemplate.exists(new Query().addCriteria(Criteria.where(ID_JSON_PATH).is(submodel.getId())), + Submodel.class, collectionName)) { throw new CollidingIdentifierException(submodel.getId()); } } @@ -179,17 +217,20 @@ public CursorResult> getSubmodelElements(String submodelId } @Override - public SubmodelElement getSubmodelElement(String submodelId, String submodelElementIdShort) throws ElementDoesNotExistException { + public SubmodelElement getSubmodelElement(String submodelId, String submodelElementIdShort) + throws ElementDoesNotExistException { return getSubmodelService(submodelId).getSubmodelElement(submodelElementIdShort); } @Override - public SubmodelElementValue getSubmodelElementValue(String submodelId, String submodelElementIdShort) throws ElementDoesNotExistException { + public SubmodelElementValue getSubmodelElementValue(String submodelId, String submodelElementIdShort) + throws ElementDoesNotExistException { return getSubmodelService(submodelId).getSubmodelElementValue(submodelElementIdShort); } @Override - public void setSubmodelElementValue(String submodelId, String submodelElementIdShort, SubmodelElementValue value) throws ElementDoesNotExistException { + public void setSubmodelElementValue(String submodelId, String submodelElementIdShort, SubmodelElementValue value) + throws ElementDoesNotExistException { SubmodelService submodelService = getSubmodelService(submodelId); submodelService.setSubmodelElementValue(submodelElementIdShort, value); @@ -198,8 +239,8 @@ public void setSubmodelElementValue(String submodelId, String submodelElementIdS @Override public void deleteSubmodel(String submodelId) throws ElementDoesNotExistException { - DeleteResult result = mongoTemplate.remove(new Query().addCriteria(Criteria.where(ID_JSON_PATH) - .is(submodelId)), Submodel.class, collectionName); + DeleteResult result = mongoTemplate.remove(new Query().addCriteria(Criteria.where(ID_JSON_PATH).is(submodelId)), + Submodel.class, collectionName); if (result.getDeletedCount() == 0) { throw new ElementDoesNotExistException(submodelId); @@ -216,7 +257,8 @@ public void createSubmodelElement(String submodelId, SubmodelElement submodelEle } @Override - public void createSubmodelElement(String submodelId, String idShortPath, SubmodelElement submodelElement) throws ElementDoesNotExistException { + public void createSubmodelElement(String submodelId, String idShortPath, SubmodelElement submodelElement) + throws ElementDoesNotExistException { SubmodelService submodelService = getSubmodelService(submodelId); submodelService.createSubmodelElement(idShortPath, submodelElement); @@ -243,6 +285,11 @@ public Submodel getSubmodelByIdMetadata(String submodelId) throws ElementDoesNot return submodel; } + @Override + public String getName() { + return smRepositoryName == null ? SubmodelRepository.super.getName() : smRepositoryName; + } + private String resolveCursor(PaginationInfo pRequest, List foundDescriptors, Function idResolver) { if (foundDescriptors.isEmpty() || !pRequest.isPaged()) { diff --git a/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepositoryFactory.java b/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepositoryFactory.java index 8ff561fee..c3659566c 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepositoryFactory.java +++ b/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepositoryFactory.java @@ -48,28 +48,46 @@ public class MongoDBSubmodelRepositoryFactory implements SubmodelRepositoryFacto private String collectionName; private SubmodelServiceFactory submodelServiceFactory; private Collection submodels; + + private String smRepositoryName; @Autowired(required = false) - public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate, @Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName, SubmodelServiceFactory submodelServiceFactory) { + public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate, + @Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName, + SubmodelServiceFactory submodelServiceFactory) { this.mongoTemplate = mongoTemplate; this.collectionName = collectionName; this.submodelServiceFactory = submodelServiceFactory; } - + + public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate, + @Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName, + SubmodelServiceFactory submodelServiceFactory, @Value("${basyx.smrepo.name:sm-repo}") String smRepositoryName) { + this(mongoTemplate, collectionName, submodelServiceFactory); + this.smRepositoryName = smRepositoryName; + } @Autowired(required = false) - public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate, @Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName, SubmodelServiceFactory submodelServiceFactory, - Collection submodels) { + public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate, + @Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName, + SubmodelServiceFactory submodelServiceFactory, Collection submodels) { this(mongoTemplate, collectionName, submodelServiceFactory); this.submodels = submodels; } + + public MongoDBSubmodelRepositoryFactory(MongoTemplate mongoTemplate, + @Value("${basyx.submodelrepository.mongodb.collectionName:submodel-repo}") String collectionName, + SubmodelServiceFactory submodelServiceFactory, Collection submodels, @Value("${basyx.smrepo.name:sm-repo}") String smRepositoryName) { + this(mongoTemplate, collectionName, submodelServiceFactory, submodels); + this.smRepositoryName = smRepositoryName; + } @Override public SubmodelRepository create() { if (this.submodels == null || this.submodels.isEmpty()) { - return new MongoDBSubmodelRepository(mongoTemplate, collectionName, submodelServiceFactory); + return new MongoDBSubmodelRepository(mongoTemplate, collectionName, submodelServiceFactory, smRepositoryName); } - return new MongoDBSubmodelRepository(mongoTemplate, collectionName, submodelServiceFactory, submodels); + return new MongoDBSubmodelRepository(mongoTemplate, collectionName, submodelServiceFactory, submodels, smRepositoryName); } } diff --git a/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/TestMongoDBSubmodelRepository.java b/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/TestMongoDBSubmodelRepository.java index b38f267e8..27f0d29be 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/TestMongoDBSubmodelRepository.java +++ b/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/TestMongoDBSubmodelRepository.java @@ -24,6 +24,8 @@ ******************************************************************************/ package org.eclipse.digitaltwin.basyx.submodelrepository; +import static org.junit.Assert.assertEquals; + import java.util.Collection; import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; @@ -34,7 +36,7 @@ import org.eclipse.digitaltwin.basyx.submodelservice.InMemorySubmodelServiceFactory; import org.junit.Test; import org.springframework.data.mongodb.core.MongoTemplate; - +import org.junit.Test; import com.mongodb.client.MongoClient; import com.mongodb.client.MongoClients; @@ -44,6 +46,7 @@ public class TestMongoDBSubmodelRepository extends SubmodelRepositorySuite { private final MongoClient CLIENT = MongoClients.create(CONNECTION_URL); private final MongoTemplate TEMPLATE = new MongoTemplate(CLIENT, "BaSyxTestDb"); private final InMemorySubmodelServiceFactory SUBMODEL_SERVICE_FACTORY = new InMemorySubmodelServiceFactory(); + private static final String CONFIGURED_SM_REPO_NAME = "configured-sm-repo-name"; @Override protected SubmodelRepository getSubmodelRepository() { @@ -61,6 +64,13 @@ protected SubmodelRepository getSubmodelRepository(Collection submodel return new MongoDBSubmodelRepositoryFactory(TEMPLATE, COLLECTION, SUBMODEL_SERVICE_FACTORY, submodels).create(); } + + @Test + public void getConfiguredMongoDBSmRepositoryName() { + SubmodelRepository repo = new MongoDBSubmodelRepository(TEMPLATE, COLLECTION, SUBMODEL_SERVICE_FACTORY, CONFIGURED_SM_REPO_NAME); + + assertEquals(CONFIGURED_SM_REPO_NAME, repo.getName()); + } @Test(expected = FeatureNotSupportedException.class) @Override diff --git a/basyx.submodelrepository/basyx.submodelrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/SubmodelRepository.java b/basyx.submodelrepository/basyx.submodelrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/SubmodelRepository.java index 721465629..5d2fa71ba 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/SubmodelRepository.java +++ b/basyx.submodelrepository/basyx.submodelrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/SubmodelRepository.java @@ -40,7 +40,7 @@ /** * Specifies the overall SubmodelRepository API * - * @author schnicke, danish + * @author schnicke, danish, kammognie * */ public interface SubmodelRepository { @@ -167,6 +167,15 @@ public CursorResult> getSubmodelElements(String submodelId */ public void deleteSubmodelElement(String submodelId, String idShortPath) throws ElementDoesNotExistException; + /** + * Returns the name of the repository + * + * @return repoName + */ + public default String getName() { + return "sm-repo"; + } + /** * Invokes an operation * @@ -182,13 +191,6 @@ public CursorResult> getSubmodelElements(String submodelId */ public OperationVariable[] invokeOperation(String submodelId, String idShortPath, OperationVariable[] input) throws ElementDoesNotExistException; - /** - * Returns the name of the submodel repository - */ - public default String getName() { - return "submodelRepository-default-name"; - } - /** * Retrieves the Submodel as Value-Only_representation with the specific id * diff --git a/basyx.submodelrepository/basyx.submodelrepository-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/core/SubmodelRepositorySuite.java b/basyx.submodelrepository/basyx.submodelrepository-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/core/SubmodelRepositorySuite.java index a8ad2be88..37ba5d562 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/core/SubmodelRepositorySuite.java +++ b/basyx.submodelrepository/basyx.submodelrepository-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/core/SubmodelRepositorySuite.java @@ -54,7 +54,7 @@ /** * Testsuite for implementations of the SubmodelRepository interface * - * @author schnicke, danish + * @author schnicke, danish, kammognie * */ public abstract class SubmodelRepositorySuite { @@ -346,6 +346,13 @@ public void deleteNestedSubmodelElementInSubmodelElementList() { throw expected; } } + + @Test + public void getDefaultSubmodelRepositoryName() { + SubmodelRepository repo = getSubmodelRepository(); + + assertEquals("sm-repo", repo.getName()); + } @Test public void getPaginatedSubmodel() { diff --git a/basyx.submodelrepository/basyx.submodelrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/DummySubmodelRepositoryComponent.java b/basyx.submodelrepository/basyx.submodelrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/DummySubmodelRepositoryComponent.java index ef15468b5..271786dff 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/DummySubmodelRepositoryComponent.java +++ b/basyx.submodelrepository/basyx.submodelrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/DummySubmodelRepositoryComponent.java @@ -26,16 +26,22 @@ package org.eclipse.digitaltwin.basyx.submodelrepository.http; + +import org.springframework.boot.SpringApplication; import org.eclipse.digitaltwin.basyx.submodelrepository.InMemorySubmodelRepository; import org.eclipse.digitaltwin.basyx.submodelservice.InMemorySubmodelServiceFactory; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; +/** + * Spring application configured for tests. + * + * @author schnicke, danish, kammognie + * + */ @SpringBootApplication(scanBasePackages = "org.eclipse.digitaltwin.basyx") public class DummySubmodelRepositoryComponent { - @Bean - public InMemorySubmodelRepository createSubmodelRepository() { - return new InMemorySubmodelRepository(new InMemorySubmodelServiceFactory()); + public static void main(String[] args) { + SpringApplication.run(DummySubmodelRepositoryComponent.class, args); } -} +} \ No newline at end of file diff --git a/basyx.submodelrepository/basyx.submodelrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/testconfig/DummyConfig.java b/basyx.submodelrepository/basyx.submodelrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/testconfig/DummyConfig.java new file mode 100644 index 000000000..881ebf4f4 --- /dev/null +++ b/basyx.submodelrepository/basyx.submodelrepository-http/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/testconfig/DummyConfig.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (C) 2023 the Eclipse BaSyx Authors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ + + +package org.eclipse.digitaltwin.basyx.submodelrepository.http.testconfig; + +import org.eclipse.digitaltwin.basyx.submodelrepository.InMemorySubmodelRepository; +import org.eclipse.digitaltwin.basyx.submodelrepository.SubmodelRepository; +import org.eclipse.digitaltwin.basyx.submodelservice.InMemorySubmodelServiceFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Configuration for tests + * + * @author danish, kammognie + * + */ +@Configuration +public class DummyConfig { + + @Bean + @ConditionalOnMissingBean + public SubmodelRepository createSubmodelRepository() { + return new InMemorySubmodelRepository(new InMemorySubmodelServiceFactory()); + } +} \ No newline at end of file diff --git a/basyx.submodelrepository/basyx.submodelrepository.component/pom.xml b/basyx.submodelrepository/basyx.submodelrepository.component/pom.xml index 5da1fe67d..16ca9bd9f 100644 --- a/basyx.submodelrepository/basyx.submodelrepository.component/pom.xml +++ b/basyx.submodelrepository/basyx.submodelrepository.component/pom.xml @@ -49,6 +49,11 @@ spring-boot-starter-test test + + org.junit.vintage + junit-vintage-engine + test + org.springframework.boot spring-boot-starter-web diff --git a/basyx.submodelrepository/basyx.submodelrepository.component/src/main/resources/application.properties b/basyx.submodelrepository/basyx.submodelrepository.component/src/main/resources/application.properties index 691e2a0df..019cfdb9c 100644 --- a/basyx.submodelrepository/basyx.submodelrepository.component/src/main/resources/application.properties +++ b/basyx.submodelrepository/basyx.submodelrepository.component/src/main/resources/application.properties @@ -1,6 +1,7 @@ server.port=8081 spring.application.name=Submodel Repository +basyx.smrepo.name = sm-repo basyx.backend = InMemory #basyx.backend = MongoDB diff --git a/basyx.submodelrepository/basyx.submodelrepository.component/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/component/TestSubmodelRepositoryName.java b/basyx.submodelrepository/basyx.submodelrepository.component/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/component/TestSubmodelRepositoryName.java new file mode 100644 index 000000000..e2963f981 --- /dev/null +++ b/basyx.submodelrepository/basyx.submodelrepository.component/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/component/TestSubmodelRepositoryName.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (C) 2023 the Eclipse BaSyx Authors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ + +package org.eclipse.digitaltwin.basyx.submodelrepository.component; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.digitaltwin.basyx.submodelrepository.SubmodelRepository; +import org.junit.Test; +import org.springframework.boot.SpringApplication; +import org.springframework.context.ConfigurableApplicationContext; + +/** + * + * Test the configuration of the SubmodelRepository's name + * + * @author danish, kammognie + * + */ +public class TestSubmodelRepositoryName { + private static final String CONFIGURED_SM_REPO_NAME = "configured-sm-repo-name"; + private static final String BASYX_SMREPO_NAME_KEY = "basyx.smrepo.name"; + private static ConfigurableApplicationContext appContext; + + private void startContext() { + appContext = new SpringApplication(SubmodelRepositoryComponent.class).run(new String[] {}); + } + + private void closeContext() { + appContext.close(); + } + + @Test + public void getDefaultRepoName() { + startContext(); + + SubmodelRepository repo = appContext.getBean(SubmodelRepository.class); + + assertEquals("sm-repo", repo.getName()); + + closeContext(); + } + + @Test + public void getConfiguredRepoName() { + configureRepoNamePropertyAndStartContext(); + + SubmodelRepository repo = appContext.getBean(SubmodelRepository.class); + + assertEquals(CONFIGURED_SM_REPO_NAME, repo.getName()); + + resetRepoNamePropertyAndCloseContext(); + } + + private void resetRepoNamePropertyAndCloseContext() { + System.clearProperty(BASYX_SMREPO_NAME_KEY); + + closeContext(); + } + + private void configureRepoNamePropertyAndStartContext() { + System.setProperty(BASYX_SMREPO_NAME_KEY, CONFIGURED_SM_REPO_NAME); + + startContext(); + } + +} diff --git a/basyx.submodelservice/basyx.submodelservice-core/pom.xml b/basyx.submodelservice/basyx.submodelservice-core/pom.xml index 82c2a0519..b81d1c456 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/pom.xml +++ b/basyx.submodelservice/basyx.submodelservice-core/pom.xml @@ -7,15 +7,14 @@ basyx.submodelservice ${revision} - + basyx.submodelservice-core - - + + org.eclipse.digitaltwin.basyx basyx.core - - + org.eclipse.digitaltwin.aas4j model From cb7961d4bb494736d1c6b0e6f183fb05f17be9e7 Mon Sep 17 00:00:00 2001 From: ahoimariew <134478949+ahoimariew@users.noreply.github.com> Date: Wed, 23 Aug 2023 07:52:51 +0200 Subject: [PATCH 2/5] implements valueOnly-Serialization for SpecificAssetIDValue (#77) Co-authored-by: Marie Witt Signed-off-by: Jannis Jung --- ...lRepositoryHTTPSerializationExtension.java | 6 +- .../SpecificAssetIDValueJsonDeserializer.java | 85 +++++++++++++++++++ .../SpecificAssetIDValueSerializer.java | 57 +++++++++++++ .../submodelservice/value/EntityValue.java | 4 +- .../value/mapper/EntityValueMapper.java | 3 +- ...odelServiceHTTPSerializationExtension.java | 5 ++ .../resources/value/expectedEntityValue.json | 3 +- .../value/expectedUpdatedMRPEntityValue.json | 3 +- ...ectedValueOnlySerializationOfSubmodel.json | 3 +- .../test/resources/value/setEntityValue.json | 3 +- 10 files changed, 159 insertions(+), 13 deletions(-) create mode 100644 basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/SpecificAssetIDValueJsonDeserializer.java create mode 100644 basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/serialization/SpecificAssetIDValueSerializer.java diff --git a/basyx.submodelrepository/basyx.submodelrepository-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/SubmodelRepositoryHTTPSerializationExtension.java b/basyx.submodelrepository/basyx.submodelrepository-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/SubmodelRepositoryHTTPSerializationExtension.java index aa59624b5..683d83c2e 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/SubmodelRepositoryHTTPSerializationExtension.java +++ b/basyx.submodelrepository/basyx.submodelrepository-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/SubmodelRepositoryHTTPSerializationExtension.java @@ -23,15 +23,16 @@ * SPDX-License-Identifier: MIT ******************************************************************************/ - package org.eclipse.digitaltwin.basyx.submodelrepository.http; import org.eclipse.digitaltwin.basyx.deserialization.SubmodelElementValueJsonDeserializer; import org.eclipse.digitaltwin.basyx.deserialization.ValueOnlyJsonDeserializer; +import org.eclipse.digitaltwin.basyx.deserialization.SpecificAssetIDValueJsonDeserializer; import org.eclipse.digitaltwin.basyx.http.SerializationExtension; import org.eclipse.digitaltwin.basyx.mixins.ReferenceElementValueMixIn; import org.eclipse.digitaltwin.basyx.serialization.MultiLanguagePropertyValueSerializer; import org.eclipse.digitaltwin.basyx.serialization.PropertyValueSerializer; +import org.eclipse.digitaltwin.basyx.serialization.SpecificAssetIDValueSerializer; import org.eclipse.digitaltwin.basyx.serialization.SubmodelElementCollectionValueSerializer; import org.eclipse.digitaltwin.basyx.serialization.SubmodelElementListValueSerializer; import org.eclipse.digitaltwin.basyx.serialization.SubmodelValueOnlySerializer; @@ -39,6 +40,7 @@ import org.eclipse.digitaltwin.basyx.submodelservice.value.MultiLanguagePropertyValue; import org.eclipse.digitaltwin.basyx.submodelservice.value.PropertyValue; import org.eclipse.digitaltwin.basyx.submodelservice.value.ReferenceElementValue; +import org.eclipse.digitaltwin.basyx.submodelservice.value.SpecificAssetIDValue; import org.eclipse.digitaltwin.basyx.submodelservice.value.SubmodelElementCollectionValue; import org.eclipse.digitaltwin.basyx.submodelservice.value.SubmodelElementListValue; import org.eclipse.digitaltwin.basyx.submodelservice.value.SubmodelElementValue; @@ -68,6 +70,8 @@ public void extend(Jackson2ObjectMapperBuilder builder) { builder.serializerByType(SubmodelElementListValue.class, new SubmodelElementListValueSerializer()); builder.mixIn(ReferenceElementValue.class, ReferenceElementValueMixIn.class); builder.serializerByType(SubmodelValueOnly.class, new SubmodelValueOnlySerializer()); + builder.deserializerByType(SpecificAssetIDValue.class, new SpecificAssetIDValueJsonDeserializer()); + builder.serializerByType(SpecificAssetIDValue.class, new SpecificAssetIDValueSerializer()); } } diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/SpecificAssetIDValueJsonDeserializer.java b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/SpecificAssetIDValueJsonDeserializer.java new file mode 100644 index 000000000..d5472731c --- /dev/null +++ b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/SpecificAssetIDValueJsonDeserializer.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (C) 2023 the Eclipse BaSyx Authors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ + +package org.eclipse.digitaltwin.basyx.deserialization; + +import java.io.IOException; +import java.util.Iterator; +import java.util.Map.Entry; + +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.basyx.submodelservice.value.ReferenceValue; +import org.eclipse.digitaltwin.basyx.submodelservice.value.SpecificAssetIDValue; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * @author jungjan, witt + */ +public class SpecificAssetIDValueJsonDeserializer extends JsonDeserializer { + private final String EXTERNAL_SUBJECT_ID_KEY = "externalSubjectId"; + + @Override + public SpecificAssetIDValue deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + try { + ObjectMapper mapper = (ObjectMapper) p.getCodec(); + JsonNode node = mapper.readTree(p); + + Iterator> jsnonFields = node.fields(); + Entry nameValueMap = jsnonFields.next(); + + String name = nameValueMap.getKey(); + String value = nameValueMap.getValue() + .asText(); + ReferenceValue externalSubjectIdValue = null; + + if (jsonContainsExternalSubjectId(node)) { + externalSubjectIdValue = handleExternalSubjectId(mapper, node); + } + + return new SpecificAssetIDValue(name, value, externalSubjectIdValue); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private boolean jsonContainsExternalSubjectId(JsonNode node) { + return node.get(EXTERNAL_SUBJECT_ID_KEY) != null; + } + + private ReferenceValue handleExternalSubjectId(ObjectMapper mapper, JsonNode node) throws JsonProcessingException, JsonMappingException { + JsonNode externalSubjectIdNode = node.get(EXTERNAL_SUBJECT_ID_KEY); + Reference externalSubjectId = mapper.readValue(externalSubjectIdNode.toString(), new TypeReference() { + }); + return new ReferenceValue(externalSubjectId.getType(), externalSubjectId.getKeys()); + } +} \ No newline at end of file diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/serialization/SpecificAssetIDValueSerializer.java b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/serialization/SpecificAssetIDValueSerializer.java new file mode 100644 index 000000000..a7251c241 --- /dev/null +++ b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/serialization/SpecificAssetIDValueSerializer.java @@ -0,0 +1,57 @@ +/******************************************************************************* +* Copyright (C) 2023 the Eclipse BaSyx Authors +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +* +* SPDX-License-Identifier: MIT +******************************************************************************/ + +package org.eclipse.digitaltwin.basyx.serialization; + +import java.io.IOException; + +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; +import org.eclipse.digitaltwin.basyx.submodelservice.value.ReferenceValue; +import org.eclipse.digitaltwin.basyx.submodelservice.value.SpecificAssetIDValue; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +/** + * @author witt, jungjan + */ +public class SpecificAssetIDValueSerializer extends JsonSerializer { + + @Override + public void serialize(SpecificAssetIDValue value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + gen.writeStartObject(); + gen.writePOJOField(value.getName(), value.getValue()); + + Reference externalSubjectId = value.getExternalSubjectId(); + + if (externalSubjectId != null) { + ReferenceValue externalSubjectIdValue = new ReferenceValue(externalSubjectId.getType(), externalSubjectId.getKeys()); + gen.writeObjectField("externalSubjectId", externalSubjectIdValue); + } + gen.writeEndObject(); + } + +} diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/EntityValue.java b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/EntityValue.java index f2d034f80..77e389e12 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/EntityValue.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/EntityValue.java @@ -40,7 +40,7 @@ public class EntityValue implements SubmodelElementValue { private List statements; private EntityType entityType; private Optional globalAssetId = Optional.empty(); - private Optional> specificAssetIds = Optional.empty(); + private Optional> specificAssetIds = Optional.empty(); @SuppressWarnings("unused") private EntityValue() { @@ -48,7 +48,7 @@ private EntityValue() { } public EntityValue(List statements, EntityType entityType, String globalAssetId, - List specificAssetIds) { + List< SpecificAssetIDValue> specificAssetIds) { this.statements = statements; this.entityType = entityType; this.globalAssetId = Optional.ofNullable(globalAssetId); diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/EntityValueMapper.java b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/EntityValueMapper.java index cdc5a06f0..227263ade 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/EntityValueMapper.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/EntityValueMapper.java @@ -47,8 +47,7 @@ public EntityValueMapper(Entity entity) { @Override public EntityValue getValue() { - return new EntityValue(ValueMapperUtil.createValueOnlyCollection(entity.getStatements()), entity.getEntityType(), - entity.getGlobalAssetID(), getSpecificAssetIdValue(entity.getSpecificAssetIds())); + return new EntityValue(ValueMapperUtil.createValueOnlyCollection(entity.getStatements()), entity.getEntityType(), entity.getGlobalAssetID(), getSpecificAssetIdValue(entity.getSpecificAssetIds())); } @Override diff --git a/basyx.submodelservice/basyx.submodelservice-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/http/SubmodelServiceHTTPSerializationExtension.java b/basyx.submodelservice/basyx.submodelservice-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/http/SubmodelServiceHTTPSerializationExtension.java index b2b52f03c..a9fafca77 100644 --- a/basyx.submodelservice/basyx.submodelservice-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/http/SubmodelServiceHTTPSerializationExtension.java +++ b/basyx.submodelservice/basyx.submodelservice-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/http/SubmodelServiceHTTPSerializationExtension.java @@ -26,11 +26,13 @@ package org.eclipse.digitaltwin.basyx.submodelservice.http; import org.eclipse.digitaltwin.basyx.deserialization.SubmodelElementValueJsonDeserializer; +import org.eclipse.digitaltwin.basyx.deserialization.SpecificAssetIDValueJsonDeserializer; import org.eclipse.digitaltwin.basyx.deserialization.ValueOnlyJsonDeserializer; import org.eclipse.digitaltwin.basyx.http.SerializationExtension; import org.eclipse.digitaltwin.basyx.mixins.ReferenceElementValueMixIn; import org.eclipse.digitaltwin.basyx.serialization.MultiLanguagePropertyValueSerializer; import org.eclipse.digitaltwin.basyx.serialization.PropertyValueSerializer; +import org.eclipse.digitaltwin.basyx.serialization.SpecificAssetIDValueSerializer; import org.eclipse.digitaltwin.basyx.serialization.SubmodelElementCollectionValueSerializer; import org.eclipse.digitaltwin.basyx.serialization.SubmodelElementListValueSerializer; import org.eclipse.digitaltwin.basyx.serialization.SubmodelValueOnlySerializer; @@ -38,6 +40,7 @@ import org.eclipse.digitaltwin.basyx.submodelservice.value.MultiLanguagePropertyValue; import org.eclipse.digitaltwin.basyx.submodelservice.value.PropertyValue; import org.eclipse.digitaltwin.basyx.submodelservice.value.ReferenceElementValue; +import org.eclipse.digitaltwin.basyx.submodelservice.value.SpecificAssetIDValue; import org.eclipse.digitaltwin.basyx.submodelservice.value.SubmodelElementCollectionValue; import org.eclipse.digitaltwin.basyx.submodelservice.value.SubmodelElementListValue; import org.eclipse.digitaltwin.basyx.submodelservice.value.SubmodelElementValue; @@ -67,6 +70,8 @@ public void extend(Jackson2ObjectMapperBuilder builder) { builder.serializerByType(SubmodelElementListValue.class, new SubmodelElementListValueSerializer()); builder.mixIn(ReferenceElementValue.class, ReferenceElementValueMixIn.class); builder.serializerByType(SubmodelValueOnly.class, new SubmodelValueOnlySerializer()); + builder.deserializerByType(SpecificAssetIDValue.class, new SpecificAssetIDValueJsonDeserializer()); + builder.serializerByType(SpecificAssetIDValue.class, new SpecificAssetIDValueSerializer()); } } diff --git a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedEntityValue.json b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedEntityValue.json index 94085d5ef..9ec7f2ca8 100644 --- a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedEntityValue.json +++ b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedEntityValue.json @@ -14,8 +14,7 @@ "globalAssetId": "globalAssetID", "specificAssetIds": [ { - "name": "specificAssetIdName", - "value": "specificValue" + "specificAssetIdName" : "specificValue" } ] } \ No newline at end of file diff --git a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedUpdatedMRPEntityValue.json b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedUpdatedMRPEntityValue.json index 74aa6641c..a83e90e8d 100644 --- a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedUpdatedMRPEntityValue.json +++ b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedUpdatedMRPEntityValue.json @@ -14,8 +14,7 @@ "globalAssetId": "globalAssetId", "specificAssetIds": [ { - "name": "specificAssetIdName", - "value": "specificValue" + "specificAssetIdName": "specificValue" } ] } \ No newline at end of file diff --git a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedValueOnlySerializationOfSubmodel.json b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedValueOnlySerializationOfSubmodel.json index 986aad48b..c2fff9f68 100644 --- a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedValueOnlySerializationOfSubmodel.json +++ b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedValueOnlySerializationOfSubmodel.json @@ -16,8 +16,7 @@ "globalAssetId": "globalAssetID", "specificAssetIds": [ { - "name": "specificAssetIdName", - "value": "specificValue" + "specificAssetIdName": "specificValue" } ] }, diff --git a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/setEntityValue.json b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/setEntityValue.json index 1895e2540..21de2c469 100644 --- a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/setEntityValue.json +++ b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/setEntityValue.json @@ -14,8 +14,7 @@ "globalAssetId": "globalAssetId", "specificAssetIds": [ { - "name": "assetName", - "value": "assetValue", + "assetName" : "assetValue", "externalSubjectId": { "type": "ExternalReference", "keys": [ From 9ea794ecba7cbe956b11db807fff7a38cdf597bc Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Thu, 24 Aug 2023 08:09:34 +0200 Subject: [PATCH 3/5] Renames bean to avoid collision Signed-off-by: Frank Schnicke --- .../MongoDBSubmodelRepositoryConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepositoryConfiguration.java b/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepositoryConfiguration.java index c3a6c4f64..43c6ef743 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepositoryConfiguration.java +++ b/basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepositoryConfiguration.java @@ -44,7 +44,7 @@ @ConditionalOnExpression("'${basyx.backend}'.equals('MongoDB')") public class MongoDBSubmodelRepositoryConfiguration { @Bean - public SubmodelServiceFactory getSubmodelServiceFactory() { + public SubmodelServiceFactory getInMemorySubmodelServiceFactory() { return new InMemorySubmodelServiceFactory(); } } From 0f2d65005ee6b3d386ebb62e45dfab04392ab1b9 Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Thu, 24 Aug 2023 08:33:51 +0200 Subject: [PATCH 4/5] Fixes SubmodelRepo TCK Signed-off-by: Frank Schnicke --- ...delRepositorySubmodelElementsTestDefinedURL.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/basyx.submodelrepository/basyx.submodelrepository-tck/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/tck/SubmodelRepositorySubmodelElementsTestDefinedURL.java b/basyx.submodelrepository/basyx.submodelrepository-tck/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/tck/SubmodelRepositorySubmodelElementsTestDefinedURL.java index 47562940a..9bb5e8629 100644 --- a/basyx.submodelrepository/basyx.submodelrepository-tck/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/tck/SubmodelRepositorySubmodelElementsTestDefinedURL.java +++ b/basyx.submodelrepository/basyx.submodelrepository-tck/src/test/java/org/eclipse/digitaltwin/basyx/submodelrepository/tck/SubmodelRepositorySubmodelElementsTestDefinedURL.java @@ -26,6 +26,10 @@ package org.eclipse.digitaltwin.basyx.submodelrepository.tck; +import java.io.FileNotFoundException; +import java.io.IOException; + +import org.apache.hc.core5.http.ParseException; import org.eclipse.digitaltwin.basyx.submodelrepository.http.BaSyxSubmodelHttpTestUtils; import org.eclipse.digitaltwin.basyx.submodelservice.http.SubmodelServiceSubmodelElementsTestSuiteHTTP; import org.junit.After; @@ -42,16 +46,21 @@ public class SubmodelRepositorySubmodelElementsTestDefinedURL extends SubmodelSe @Before public void createSubmodelOnRepo() { - SubmodelTCKHelper.createSubmodelOnRepository(getURL(), createSubmodel()); + SubmodelTCKHelper.createSubmodelOnRepository(url, createSubmodel()); } @After public void removeSubmodelFromRepo() { - SubmodelTCKHelper.deleteAllSubmodelsOnRepository(getURL()); + SubmodelTCKHelper.deleteAllSubmodelsOnRepository(url); } @Override protected String getURL() { return BaSyxSubmodelHttpTestUtils.getSpecificSubmodelAccessPath(url, createSubmodel().getId()); } + + @Override + public void invokeOperation() throws FileNotFoundException, IOException, ParseException { + // Not supported on OTS Components for now + } } From 6b60bfed9eaa04f04ff4ef0432f4ba7d8dc30857 Mon Sep 17 00:00:00 2001 From: Frank Schnicke <77283144+FrankSchnicke@users.noreply.github.com> Date: Tue, 5 Sep 2023 08:53:53 +0200 Subject: [PATCH 5/5] Update Readme.md --- basyx.aasenvironment/Readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/basyx.aasenvironment/Readme.md b/basyx.aasenvironment/Readme.md index 0d0e54a3d..f3f889c03 100644 --- a/basyx.aasenvironment/Readme.md +++ b/basyx.aasenvironment/Readme.md @@ -21,7 +21,7 @@ The Aggregated Swagger UI for the endpoint is available at: http://{host}:{port}/swagger-ui/index.html For a configuration example, see [application.properties](./basyx.aasenvironment.component/src/main/resources/application.properties) -The Health Endpoint an -d CORS Documentation can be found [here](../docs/Readme.md). +The Health Endpoint and CORS Documentation can be found [here](../docs/Readme.md). -Right now, no additional input parameters modifying the output (e.g., cursor, serializationModifier) are supported. +## Preconfiguration of AAS Environments +The AAS Environment Component supports the preconfiguration of AAS Environments (e.g., XML, JSON, AASX) via the _basyx.environment_ parameter. For examples, see [application.properties](./basyx.aasenvironment.component/src/main/resources/application.properties)