Skip to content

Commit

Permalink
Merge branch 'eclipse-basyx:main' into kafka-event
Browse files Browse the repository at this point in the history
  • Loading branch information
geso02 authored Nov 11, 2024
2 parents aa7e39b + b3f7507 commit 73eed34
Show file tree
Hide file tree
Showing 137 changed files with 4,234 additions and 862 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-backend</artifactId>
</dependency>

</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.backend.inmemory.core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.AasDiscoveryBackendProvider;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.AasDiscoveryDocument;
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;
Expand All @@ -41,7 +42,7 @@
@Component
public class AasDiscoveryInMemoryBackendProvider implements AasDiscoveryBackendProvider {

private AasDiscoveryInMemoryCrudRepository repository = new AasDiscoveryInMemoryCrudRepository();
private CrudRepository<AasDiscoveryDocument, String> repository = new InMemoryCrudRepository<AasDiscoveryDocument>(AasDiscoveryDocument::getShellIdentifier);

@Override
public CrudRepository<AasDiscoveryDocument, String> getCrudRepository() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public abstract class AasDiscoveryServiceSuite {

protected abstract AasDiscoveryService getAasDiscoveryService();

private final PaginationInfo noLimitPaginationInfo = new PaginationInfo(0, "");

@Test
public void getAllAssetAdministrationShellIdsByAssetLink() {
AasDiscoveryService discoveryService = getAasDiscoveryService();
Expand All @@ -74,7 +72,7 @@ public void getAllAssetAdministrationShellIdsByAssetLink() {
new AssetLink("DummyAssetName2", "DummyAsset_2_Value")
));

List<String> actualResult = discoveryService.getAllAssetAdministrationShellIdsByAssetLink(noLimitPaginationInfo, assetIds)
List<String> actualResult = discoveryService.getAllAssetAdministrationShellIdsByAssetLink(PaginationInfo.NO_LIMIT, assetIds)
.getResult();

assertEquals(expectedResult.size(), actualResult.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,20 @@

import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetAdministrationShellDescriptor;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.Endpoint;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.ProtocolInformation;
import org.eclipse.digitaltwin.basyx.aasservice.client.ConnectedAasService;
import org.eclipse.digitaltwin.basyx.client.internal.resolver.DescriptorResolver;

/**
* Resolves an AasDescriptor into a {@link ConnectedAasService}
*
*
* @author mateusmolina, danish
*
*/
public class AasDescriptorResolver implements DescriptorResolver<AssetAdministrationShellDescriptor, ConnectedAasService> {

static final String SPEC_INTERFACE = "AAS-3.0";

private final EndpointResolver endpointResolver;

/**
Expand All @@ -66,16 +69,7 @@ public ConnectedAasService resolveDescriptor(AssetAdministrationShellDescriptor

public static Optional<URI> parseEndpoint(Endpoint endpoint) {
try {
if (endpoint == null || endpoint.getProtocolInformation() == null || endpoint.getProtocolInformation()
.getHref() == null)
return Optional.empty();

String baseHref = endpoint.getProtocolInformation()
.getHref();
// TODO not working: String queryString = "?" + endpoint.toUrlQueryString();
String queryString = "";
URI uri = new URI(baseHref + queryString);
return Optional.of(uri);
return Optional.ofNullable(endpoint).filter(ep -> ep.getInterface().equals(SPEC_INTERFACE)).map(Endpoint::getProtocolInformation).map(ProtocolInformation::getHref).map(URI::create);
} catch (Exception e) {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package org.eclipse.digitaltwin.basyx.aasenvironment.client.resolvers;

import org.eclipse.digitaltwin.basyx.submodelregistry.client.model.ProtocolInformation;
import org.eclipse.digitaltwin.basyx.client.internal.resolver.DescriptorResolver;
import java.net.URI;
import java.util.Optional;
Expand All @@ -41,6 +42,8 @@
*/
public class SubmodelDescriptorResolver implements DescriptorResolver<SubmodelDescriptor, ConnectedSubmodelService> {

static final String SPEC_INTERFACE = "SUBMODEL-3.0";

private final EndpointResolver endpointResolver;

/**
Expand All @@ -67,16 +70,7 @@ public ConnectedSubmodelService resolveDescriptor(SubmodelDescriptor smDescripto

public static Optional<URI> parseEndpoint(Endpoint endpoint) {
try {
if (endpoint == null || endpoint.getProtocolInformation() == null || endpoint.getProtocolInformation()
.getHref() == null)
return Optional.empty();

String baseHref = endpoint.getProtocolInformation()
.getHref();
// TODO not working: String queryString = "?" + endpoint.toUrlQueryString();
String queryString = "";
URI uri = new URI(baseHref + queryString);
return Optional.of(uri);
return Optional.ofNullable(endpoint).filter(ep -> ep.getInterface().equals(SPEC_INTERFACE)).map(Endpoint::getProtocolInformation).map(ProtocolInformation::getHref).map(URI::create);
} catch (Exception e) {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

package org.eclipse.digitaltwin.basyx.aasenvironment.client;

import java.util.LinkedList;

import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell;
import org.eclipse.digitaltwin.aas4j.v3.model.AssetInformation;
import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind;
Expand All @@ -38,6 +40,7 @@
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodel;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetAdministrationShellDescriptor;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.Endpoint;
import org.eclipse.digitaltwin.basyx.aasregistry.main.client.mapper.DummyAasDescriptorFactory;
import org.eclipse.digitaltwin.basyx.http.Base64UrlEncoder;
import org.eclipse.digitaltwin.basyx.submodelregistry.client.mapper.AttributeMapper;
Expand Down Expand Up @@ -91,6 +94,15 @@ public AssetAdministrationShellDescriptor buildAasPre1Descriptor() {
return DummyAasDescriptorFactory.createDummyDescriptor(AAS_PRE1_ID, AAS_PRE1_IDSHORT, AAS_PRE1_GLOBALASSETID, aasRepositoryBasePath);
}

public AssetAdministrationShellDescriptor buildAasPre1Descriptor_withMultipleInterfaces() {
LinkedList<Endpoint> endpoints = new LinkedList<>();

endpoints.add(DummyAasDescriptorFactory.createEndpoint(aasRepositoryBasePath, "AAS-REPOSITORY-3.0"));
endpoints.add(DummyAasDescriptorFactory.createEndpoint(AAS_PRE1_ID, aasRepositoryBasePath, "AAS-3.0"));

return DummyAasDescriptorFactory.createDummyDescriptor(AAS_PRE1_ID, AAS_PRE1_IDSHORT, AAS_PRE1_GLOBALASSETID, endpoints);
}

public Reference buildSmPre1Ref() {
return new DefaultReference.Builder().type(ReferenceTypes.MODEL_REFERENCE).keys(new DefaultKey.Builder().type(KeyTypes.SUBMODEL).value(SM_PRE1_ID).build()).build();
}
Expand All @@ -100,7 +112,16 @@ public Submodel buildSmPre1() {
}

public SubmodelDescriptor buildSmPre1Descriptor() {
return DummySubmodelDescriptorFactory.createDummyDescriptor(SM_PRE1_ID, SM_PRE1_IDSHORT, smRepositoryBasePath, null);
return DummySubmodelDescriptorFactory.createDummyDescriptor(SM_PRE1_ID, SM_PRE1_IDSHORT, null, smRepositoryBasePath);
}

public SubmodelDescriptor buildSmPre1Descriptor_withMultipleInterfaces() {
LinkedList<org.eclipse.digitaltwin.basyx.submodelregistry.client.model.Endpoint> endpoints = new LinkedList<>();

endpoints.add(DummySubmodelDescriptorFactory.createEndpoint(smRepositoryBasePath, "SUBMODEL-REPOSITORY-3.0"));
endpoints.add(DummySubmodelDescriptorFactory.createEndpoint(SM_PRE1_ID, smRepositoryBasePath, "SUBMODEL-3.0"));

return DummySubmodelDescriptorFactory.createDummyDescriptor(SM_PRE1_ID, SM_PRE1_IDSHORT, null, endpoints);
}

public AssetAdministrationShell buildAasPos1() {
Expand All @@ -116,7 +137,7 @@ public AssetAdministrationShellDescriptor buildAasPos1Descriptor() {
}

public SubmodelDescriptor buildSmPos1Descriptor() {
return DummySubmodelDescriptorFactory.createDummyDescriptor(SM_POS1_ID, SM_POS1_IDSHORT, smRepositoryBasePath, new AttributeMapper(ConnectedAasManagerHelper.buildObjectMapper()).mapSemanticId(buildSmPos1SemanticId()));
return DummySubmodelDescriptorFactory.createDummyDescriptor(SM_POS1_ID, SM_POS1_IDSHORT, new AttributeMapper(ConnectedAasManagerHelper.buildObjectMapper()).mapSemanticId(buildSmPos1SemanticId()), smRepositoryBasePath);
}

public Reference buildSmPos1SemanticId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.eclipse.digitaltwin.aas4j.v3.model.Submodel;
import org.eclipse.digitaltwin.basyx.aasenvironment.client.DummyAasEnvironmentComponent;
import org.eclipse.digitaltwin.basyx.aasenvironment.client.TestFixture;
import org.eclipse.digitaltwin.basyx.aasregistry.client.ApiException;
import org.eclipse.digitaltwin.basyx.aasrepository.AasRepository;
import org.eclipse.digitaltwin.basyx.submodelrepository.SubmodelRepository;
import org.junit.AfterClass;
Expand All @@ -52,10 +51,10 @@ public class RegistryDescriptorResolverTest {
private static AasRepository aasRepository;
private static SubmodelRepository smRepository;

private final static String AAS_REPOSITORY_BASE_PATH = "http://localhost:8081";
private final static String SM_REPOSITORY_BASE_PATH = "http://localhost:8081";
private static final String AAS_REPOSITORY_BASE_PATH = "http://localhost:8081";
private static final String SM_REPOSITORY_BASE_PATH = "http://localhost:8081";

private final static TestFixture FIXTURE = new TestFixture(AAS_REPOSITORY_BASE_PATH, SM_REPOSITORY_BASE_PATH);
private static final TestFixture FIXTURE = new TestFixture(AAS_REPOSITORY_BASE_PATH, SM_REPOSITORY_BASE_PATH);

@BeforeClass
public static void initApplication() {
Expand All @@ -73,7 +72,7 @@ public static void cleanUp() {
}

@Test
public void resolveAasDescriptor() throws ApiException {
public void resolveAasDescriptor() {
AasDescriptorResolver resolver = new AasDescriptorResolver(new EndpointResolver());

AssetAdministrationShell expectedAas = FIXTURE.buildAasPre1();
Expand All @@ -84,7 +83,18 @@ public void resolveAasDescriptor() throws ApiException {
}

@Test
public void resolveSmDescriptor() throws ApiException {
public void resolveAasDescriptor_withMultipleInterfaces() {
AasDescriptorResolver resolver = new AasDescriptorResolver(new EndpointResolver());

AssetAdministrationShell expectedAas = FIXTURE.buildAasPre1();

AssetAdministrationShell actualAas = resolver.resolveDescriptor(FIXTURE.buildAasPre1Descriptor_withMultipleInterfaces()).getAAS();

assertEquals(expectedAas, actualAas);
}

@Test
public void resolveSmDescriptor() {
SubmodelDescriptorResolver resolver = new SubmodelDescriptorResolver(new EndpointResolver());

Submodel expectedSm = FIXTURE.buildSmPre1();
Expand All @@ -94,4 +104,14 @@ public void resolveSmDescriptor() throws ApiException {
assertEquals(expectedSm, actualSm);
}

@Test
public void resolveSmDescriptor_withMultipleInterfaces() {
SubmodelDescriptorResolver resolver = new SubmodelDescriptorResolver(new EndpointResolver());

Submodel expectedSm = FIXTURE.buildSmPre1();

Submodel actualSm = resolver.resolveDescriptor(FIXTURE.buildSmPre1Descriptor_withMultipleInterfaces()).getSubmodel();

assertEquals(expectedSm, actualSm);
}
}
Loading

0 comments on commit 73eed34

Please sign in to comment.