Skip to content

Commit

Permalink
Refactor Backend Architecture for the remaining Repositories, AASXFil…
Browse files Browse the repository at this point in the history
…eServer 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
  • Loading branch information
MateusMolina authored Feb 25, 2025
1 parent 0c97190 commit 132d373
Show file tree
Hide file tree
Showing 156 changed files with 3,350 additions and 3,715 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (C) 2024 the Eclipse BaSyx Authors
* Copyright (C) 2025 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
Expand All @@ -25,28 +25,23 @@

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

import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.AasDiscoveryBackendProvider;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.AasDiscoveryDocument;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.AasDiscoveryDocumentBackend;
import org.eclipse.digitaltwin.basyx.common.backend.inmemory.core.InMemoryCrudRepository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;

/**
* InMemory backend for the AasDiscoveryDocument based on InMemoryCrudRepository
*
* InMemory backend provider for the AAS Discovery
*
* @author zielstor, fried
* @author mateusmolina
*/
@ConditionalOnExpression("'${basyx.backend}'.equals('InMemory')")
@Component
public class AasDiscoveryInMemoryBackendProvider implements AasDiscoveryBackendProvider {

private CrudRepository<AasDiscoveryDocument, String> repository = new InMemoryCrudRepository<AasDiscoveryDocument>(AasDiscoveryDocument::getShellIdentifier);
public class InMemoryAasDiscoveryDocumentBackend extends InMemoryCrudRepository<AasDiscoveryDocument> implements AasDiscoveryDocumentBackend {

@Override
public CrudRepository<AasDiscoveryDocument, String> getCrudRepository() {
return repository;
public InMemoryAasDiscoveryDocumentBackend() {
super(AasDiscoveryDocument::getShellIdentifier);
}

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (C) 2023 the Eclipse BaSyx Authors
* Copyright (C) 2025 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
Expand All @@ -25,7 +25,7 @@

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

import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.SimpleAasDiscoveryFactory;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.CrudAasDiscoveryFactory;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryService;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryServiceSuite;

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

@Override
protected AasDiscoveryService getAasDiscoveryService() {
return new SimpleAasDiscoveryFactory(new AasDiscoveryInMemoryBackendProvider()).create();
return new CrudAasDiscoveryFactory(new InMemoryAasDiscoveryDocumentBackend()).create();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,10 @@
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-backend</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (C) 2023 the Eclipse BaSyx Authors
*
* Copyright (C) 2025 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
Expand All @@ -19,33 +19,37 @@
* 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;

import org.eclipse.digitaltwin.basyx.core.filerepository.FileRepository;
import org.eclipse.digitaltwin.basyx.submodelservice.InMemorySubmodelServiceFactory;
import org.eclipse.digitaltwin.basyx.submodelservice.SubmodelServiceFactory;
package org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend;

import org.eclipse.digitaltwin.basyx.common.mongocore.MappingEntry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;

/**
* Provides a InMemorySubmodelServiceFactory for usage in the MongoDB Submodel
* Repository backend.<br>
* <br>
* This is needed to ensure that the SubmodelServiceFeatures are processed
* correctly when utilizing MongoDb
*
* @author jungjan
* Provides the MongoDB configuration for the {@link AasDiscoveryDocumentBackend}
*
* @author mateusmolina
*
*/
@Configuration
@ConditionalOnExpression("'${basyx.backend}'.equals('MongoDB')")
public class MongoDBSubmodelRepositoryConfiguration {
@EnableMongoRepositories(basePackages = "org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend")
public class MongoDBAasDiscoveryDocumentBackendConfiguration {

static final String COLLECTION_NAME_FIELD = "basyx.aasdiscoveryservice.mongodb.collectionName";
static final String DEFAULT_COLLECTION_NAME = "aasdiscovery-service";

@Bean
public SubmodelServiceFactory getInMemorySubmodelServiceFactory(FileRepository fileRepository) {
return new InMemorySubmodelServiceFactory(fileRepository);
MappingEntry aasDiscoveryDocumentMappingEntry(@Value("${" + COLLECTION_NAME_FIELD + ":" + DEFAULT_COLLECTION_NAME + "}") String collectionName) {
return MappingEntry.of(collectionName, AasDiscoveryDocument.class);
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (C) 2024 the Eclipse BaSyx Authors
* Copyright (C) 2025 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
Expand All @@ -25,15 +25,10 @@

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

import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.SimpleAasDiscoveryFactory;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryService;
import org.eclipse.digitaltwin.basyx.common.mongocore.BasyxMongoMappingContext;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryServiceFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.core.MongoTemplate;

import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;

/**
* Configuration for tests
Expand All @@ -44,22 +39,11 @@
@Configuration
public class DummyDiscoveryServiceConfig {

public final static String COLLECTION = "discoveryServicePersistencyTestCollection";
public final static String DB = "BaSyxTestDb";

@Bean
public AasDiscoveryService createAasDiscoveryService(MongoTemplate template) {
return new SimpleAasDiscoveryFactory(
new AasDiscoveryMongoDBBackendProvider(new BasyxMongoMappingContext(), COLLECTION, template)).create();
}
static final String TEST_COLLECTION = "discoveryServiceTestCollection";

@Bean
public MongoTemplate createMongoTemplate() {
String connectionURL = "mongodb://mongoAdmin:mongoPassword@localhost:27017/";

MongoClient client = MongoClients.create(connectionURL);

return new MongoTemplate(client, DB);
AasDiscoveryService aasDiscoveryService(AasDiscoveryServiceFactory factory) {
return factory.create();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (C) 2024 the Eclipse BaSyx Authors
* Copyright (C) 2025 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
Expand Down Expand Up @@ -51,7 +51,7 @@ public static void initComponent() {
@Before
public void clearTemplate() {
MongoTemplate mongoTemplate = applicationContext.getBean(MongoTemplate.class);
MongoDBUtilities.clearCollection(mongoTemplate, DummyDiscoveryServiceConfig.COLLECTION);
MongoDBUtilities.clearCollection(mongoTemplate, DummyDiscoveryServiceConfig.TEST_COLLECTION);
}

@Override
Expand Down
Loading

0 comments on commit 132d373

Please sign in to comment.