Skip to content

Commit 132d373

Browse files
authored
Refactor Backend Architecture for the remaining Repositories, AASXFileServer and AasDiscoveryService (#612)
* refactor: change backend arch for the cdRepo * tests: fix remaining mongodb rel. tests from cdrepo * fix: issue with conflicting mappingMongoEntities * refactor: rename collection fields for MongoDb Configs * refactor: cdrepo: update MongoDB test configuration and clean up redudant tests * tests: aasrepo: refactor mongodb tests to follow same pattern as cdrepo * refactor: aasrepo: improve creation logic of CrudAasRepository * refactor: aasxfileserver: implement new arch * refactor: aasxfileserver: add file repository dependency * tests: aasxfileserver: fix for MongoDb tests * refactor: aasxfileserver: replace package ID generation with UUID * refactor: aasdiscoveryservice: impl new arch * refactor: aasdiscoveryservice: rename SimpleAasDiscoveryFactory to CrudAasDiscoveryFactory * tests: aasdiscoveryservice: fix failing component test * refactor: smrepo: impl new arch * refactor: smrepo: rename SimpleSubmodelRepositoryFactory to CrudSubmodelRepositoryFactory * refactor: smrepo: remove wrongly packaged classes * refactor: smrepo: add submodelOperations for submodelBackend * fix: inconsistency load order for BasyxMongoMappingContext * feat: smservice: implement MongoDbSubmodelOperations * refactor: smservice: add SubmodelFileOperations interface and integrate with repository backends * fix: smrepo: failing tests * fix: aasservice: getSubmodelReferences pagination handling * wip: refactor: smservice: create smservice-backend; move SubmodelBackend from smrepo * refactor: smservice: introduce SingleSubmodelBackend and update service factories to use it * feat: smservice: add general CrudSubmodelService and adapt -backend-mongodb to use it * wip: refactor: smrepo/service: change fragment injection strategy * wip: refactor: smrepo/service: simplify SubmodelBackend * refactor: smservice: update invokeOperation method to handle invokable operations * refactor: smrepository: update CrudSubmodelRepository to use SubmodelServiceFactory for operations * refactor: improve naming consistency across modules * refactor: aasrepo/service: to follow the same implementation strategy of smrepo/service * fix: aasrepo: incorrect pars calls * refactor: consistency fixes * chore: add missing license headers; bump year * docs: improve Javadoc comments for AAS and Submodel operations * tests: add MongoDB configuration and test setup for AAS service * tests: add missing assertTrue import
1 parent 0c97190 commit 132d373

File tree

156 files changed

+3350
-3715
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+3350
-3715
lines changed

basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/backend/inmemory/AasDiscoveryInMemoryBackendProvider.java renamed to basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-backend-inmemory/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/backend/inmemory/InMemoryAasDiscoveryDocumentBackend.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (C) 2024 the Eclipse BaSyx Authors
2+
* Copyright (C) 2025 the Eclipse BaSyx Authors
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining
55
* a copy of this software and associated documentation files (the
@@ -25,28 +25,23 @@
2525

2626
package org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.inmemory;
2727

28-
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.AasDiscoveryBackendProvider;
2928
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.AasDiscoveryDocument;
29+
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.AasDiscoveryDocumentBackend;
3030
import org.eclipse.digitaltwin.basyx.common.backend.inmemory.core.InMemoryCrudRepository;
3131
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
32-
import org.springframework.data.repository.CrudRepository;
3332
import org.springframework.stereotype.Component;
3433

3534
/**
35+
* InMemory backend for the AasDiscoveryDocument based on InMemoryCrudRepository
3636
*
37-
* InMemory backend provider for the AAS Discovery
38-
*
39-
* @author zielstor, fried
37+
* @author mateusmolina
4038
*/
4139
@ConditionalOnExpression("'${basyx.backend}'.equals('InMemory')")
4240
@Component
43-
public class AasDiscoveryInMemoryBackendProvider implements AasDiscoveryBackendProvider {
44-
45-
private CrudRepository<AasDiscoveryDocument, String> repository = new InMemoryCrudRepository<AasDiscoveryDocument>(AasDiscoveryDocument::getShellIdentifier);
41+
public class InMemoryAasDiscoveryDocumentBackend extends InMemoryCrudRepository<AasDiscoveryDocument> implements AasDiscoveryDocumentBackend {
4642

47-
@Override
48-
public CrudRepository<AasDiscoveryDocument, String> getCrudRepository() {
49-
return repository;
43+
public InMemoryAasDiscoveryDocumentBackend() {
44+
super(AasDiscoveryDocument::getShellIdentifier);
5045
}
5146

52-
}
47+
}

basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-backend-inmemory/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/backend/inmemory/TestInMemoryAasDiscoveryService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (C) 2023 the Eclipse BaSyx Authors
2+
* Copyright (C) 2025 the Eclipse BaSyx Authors
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining
55
* a copy of this software and associated documentation files (the
@@ -25,7 +25,7 @@
2525

2626
package org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.inmemory;
2727

28-
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.SimpleAasDiscoveryFactory;
28+
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.CrudAasDiscoveryFactory;
2929
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryService;
3030
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryServiceSuite;
3131

@@ -39,7 +39,7 @@ public class TestInMemoryAasDiscoveryService extends AasDiscoveryServiceSuite {
3939

4040
@Override
4141
protected AasDiscoveryService getAasDiscoveryService() {
42-
return new SimpleAasDiscoveryFactory(new AasDiscoveryInMemoryBackendProvider()).create();
42+
return new CrudAasDiscoveryFactory(new InMemoryAasDiscoveryDocumentBackend()).create();
4343
}
4444

4545
}

basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-backend-mongodb/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,10 @@
4444
<groupId>org.eclipse.digitaltwin.basyx</groupId>
4545
<artifactId>basyx.aasdiscoveryservice-backend</artifactId>
4646
</dependency>
47+
<dependency>
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-starter-test</artifactId>
50+
<scope>test</scope>
51+
</dependency>
4752
</dependencies>
4853
</project>

basyx.submodelrepository/basyx.submodelrepository-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/MongoDBSubmodelRepositoryConfiguration.java renamed to basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/backend/MongoDBAasDiscoveryDocumentBackendConfiguration.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*******************************************************************************
2-
* Copyright (C) 2023 the Eclipse BaSyx Authors
3-
*
2+
* Copyright (C) 2025 the Eclipse BaSyx Authors
3+
*
44
* Permission is hereby granted, free of charge, to any person obtaining
55
* a copy of this software and associated documentation files (the
66
* "Software"), to deal in the Software without restriction, including
@@ -19,33 +19,37 @@
1919
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2020
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2121
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22-
*
22+
*
2323
* SPDX-License-Identifier: MIT
2424
******************************************************************************/
25-
package org.eclipse.digitaltwin.basyx.submodelrepository;
2625

27-
import org.eclipse.digitaltwin.basyx.core.filerepository.FileRepository;
28-
import org.eclipse.digitaltwin.basyx.submodelservice.InMemorySubmodelServiceFactory;
29-
import org.eclipse.digitaltwin.basyx.submodelservice.SubmodelServiceFactory;
26+
package org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend;
27+
28+
import org.eclipse.digitaltwin.basyx.common.mongocore.MappingEntry;
29+
import org.springframework.beans.factory.annotation.Value;
3030
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
3131
import org.springframework.context.annotation.Bean;
3232
import org.springframework.context.annotation.Configuration;
33+
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
3334

3435
/**
35-
* Provides a InMemorySubmodelServiceFactory for usage in the MongoDB Submodel
36-
* Repository backend.<br>
37-
* <br>
38-
* This is needed to ensure that the SubmodelServiceFeatures are processed
39-
* correctly when utilizing MongoDb
4036
*
41-
* @author jungjan
37+
* Provides the MongoDB configuration for the {@link AasDiscoveryDocumentBackend}
38+
*
39+
* @author mateusmolina
4240
*
4341
*/
4442
@Configuration
4543
@ConditionalOnExpression("'${basyx.backend}'.equals('MongoDB')")
46-
public class MongoDBSubmodelRepositoryConfiguration {
44+
@EnableMongoRepositories(basePackages = "org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend")
45+
public class MongoDBAasDiscoveryDocumentBackendConfiguration {
46+
47+
static final String COLLECTION_NAME_FIELD = "basyx.aasdiscoveryservice.mongodb.collectionName";
48+
static final String DEFAULT_COLLECTION_NAME = "aasdiscovery-service";
49+
4750
@Bean
48-
public SubmodelServiceFactory getInMemorySubmodelServiceFactory(FileRepository fileRepository) {
49-
return new InMemorySubmodelServiceFactory(fileRepository);
51+
MappingEntry aasDiscoveryDocumentMappingEntry(@Value("${" + COLLECTION_NAME_FIELD + ":" + DEFAULT_COLLECTION_NAME + "}") String collectionName) {
52+
return MappingEntry.of(collectionName, AasDiscoveryDocument.class);
5053
}
54+
5155
}

basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-backend-mongodb/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/backend/mongodb/AasDiscoveryMongoDBBackendProvider.java

Lines changed: 0 additions & 76 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (C) 2024 the Eclipse BaSyx Authors
2+
* Copyright (C) 2025 the Eclipse BaSyx Authors
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining
55
* a copy of this software and associated documentation files (the
@@ -25,15 +25,10 @@
2525

2626
package org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.mongodb;
2727

28-
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.SimpleAasDiscoveryFactory;
2928
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryService;
30-
import org.eclipse.digitaltwin.basyx.common.mongocore.BasyxMongoMappingContext;
29+
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryServiceFactory;
3130
import org.springframework.context.annotation.Bean;
3231
import org.springframework.context.annotation.Configuration;
33-
import org.springframework.data.mongodb.core.MongoTemplate;
34-
35-
import com.mongodb.client.MongoClient;
36-
import com.mongodb.client.MongoClients;
3732

3833
/**
3934
* Configuration for tests
@@ -44,22 +39,11 @@
4439
@Configuration
4540
public class DummyDiscoveryServiceConfig {
4641

47-
public final static String COLLECTION = "discoveryServicePersistencyTestCollection";
48-
public final static String DB = "BaSyxTestDb";
49-
50-
@Bean
51-
public AasDiscoveryService createAasDiscoveryService(MongoTemplate template) {
52-
return new SimpleAasDiscoveryFactory(
53-
new AasDiscoveryMongoDBBackendProvider(new BasyxMongoMappingContext(), COLLECTION, template)).create();
54-
}
42+
static final String TEST_COLLECTION = "discoveryServiceTestCollection";
5543

5644
@Bean
57-
public MongoTemplate createMongoTemplate() {
58-
String connectionURL = "mongodb://mongoAdmin:mongoPassword@localhost:27017/";
59-
60-
MongoClient client = MongoClients.create(connectionURL);
61-
62-
return new MongoTemplate(client, DB);
45+
AasDiscoveryService aasDiscoveryService(AasDiscoveryServiceFactory factory) {
46+
return factory.create();
6347
}
6448

6549
}

basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-backend-mongodb/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/backend/mongodb/TestMongoDBAasDiscoveryPersistency.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (C) 2024 the Eclipse BaSyx Authors
2+
* Copyright (C) 2025 the Eclipse BaSyx Authors
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining
55
* a copy of this software and associated documentation files (the
@@ -51,7 +51,7 @@ public static void initComponent() {
5151
@Before
5252
public void clearTemplate() {
5353
MongoTemplate mongoTemplate = applicationContext.getBean(MongoTemplate.class);
54-
MongoDBUtilities.clearCollection(mongoTemplate, DummyDiscoveryServiceConfig.COLLECTION);
54+
MongoDBUtilities.clearCollection(mongoTemplate, DummyDiscoveryServiceConfig.TEST_COLLECTION);
5555
}
5656

5757
@Override

0 commit comments

Comments
 (0)