Skip to content

Commit

Permalink
Merge branch 'main' into op-fork/jakarta-contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgordtop authored Nov 24, 2023
2 parents 88a2124 + 6078a5a commit 98cc9f9
Show file tree
Hide file tree
Showing 56 changed files with 373 additions and 230 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ The following off-the-shelf components are available:
* [Submodel Registry](basyx.submodelregistry)
* [AAS Discovery](basyx.aasdiscoveryservice)

## Documentation & Examples
## Documentation, Roadmap & Examples
In addition to the [general documentation](https://github.com/eclipse-basyx/basyx-java-server-sdk/tree/main/docs), each component has its own specific documentation that can be found in the respective folders.
Furthermore, we are providing easy to use [examples](examples) that can be leveraged for setting up your own AAS infrastructure.
The future roadmap of BaSyx is described [here](https://github.com/eclipse-basyx/basyx-java-server-sdk/blob/main/docs/Roadmap.md).

## Contributing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetID;
import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryService;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.model.AssetLink;
import org.eclipse.digitaltwin.basyx.core.exceptions.AssetLinkDoesNotExistException;
Expand Down Expand Up @@ -85,16 +85,16 @@ public CursorResult<List<String>> getAllAssetAdministrationShellIdsByAssetLink(P
}

@Override
public List<SpecificAssetID> getAllAssetLinksById(String shellIdentifier) {
public List<SpecificAssetId> getAllAssetLinksById(String shellIdentifier) {
throwIfAssetLinkDoesNotExist(shellIdentifier);

AssetLink assetLink = assetLinks.get(shellIdentifier);

return assetLink.getSpecificAssetIDs();
return assetLink.getSpecificAssetIds();
}

@Override
public List<SpecificAssetID> createAllAssetLinksById(String shellIdentifier, List<SpecificAssetID> assetIds) {
public List<SpecificAssetId> createAllAssetLinksById(String shellIdentifier, List<SpecificAssetId> assetIds) {
throwIfAssetLinkExists(shellIdentifier);

assetLinks.put(shellIdentifier, new AssetLink(shellIdentifier, assetIds));
Expand Down Expand Up @@ -126,7 +126,7 @@ private CursorResult<List<String>> paginateList(PaginationInfo pInfo, List<Strin
private String getShellIdWithAssetId(String id) {
return assetLinks.values()
.stream()
.filter(link -> link.getSpecificAssetIDStrings()
.filter(link -> link.getSpecificAssetIdStrings()
.contains(id))
.findFirst()
.map(link -> link.getShellIdentifier())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetID;
import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryService;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.model.AssetLink;
import org.eclipse.digitaltwin.basyx.core.exceptions.AssetLinkDoesNotExistException;
Expand Down Expand Up @@ -76,26 +76,26 @@ public CursorResult<List<String>> getAllAssetAdministrationShellIdsByAssetLink(P
List<AssetLink> assetLinks = mongoTemplate.findAll(AssetLink.class, collectionName);

Set<String> shellIdentifiers = assetLinks.stream()
.filter(link -> containsMatchingAssetId(link.getSpecificAssetIDs(), assetIds))
.filter(link -> containsMatchingAssetId(link.getSpecificAssetIds(), assetIds))
.map(AssetLink::getShellIdentifier)
.collect(Collectors.toSet());

return paginateList(pInfo, new ArrayList<>(shellIdentifiers));
}

@Override
public List<SpecificAssetID> getAllAssetLinksById(String shellIdentifier) {
public List<SpecificAssetId> getAllAssetLinksById(String shellIdentifier) {
AssetLink assetLink = mongoTemplate.findOne(new Query().addCriteria(Criteria.where(SHELL_IDENTIFIER)
.is(shellIdentifier)), AssetLink.class, collectionName);

if (assetLink == null)
throw new AssetLinkDoesNotExistException(shellIdentifier);

return assetLink.getSpecificAssetIDs();
return assetLink.getSpecificAssetIds();
}

@Override
public List<SpecificAssetID> createAllAssetLinksById(String shellIdentifier, List<SpecificAssetID> assetIds) {
public List<SpecificAssetId> createAllAssetLinksById(String shellIdentifier, List<SpecificAssetId> assetIds) {
Query query = new Query().addCriteria(Criteria.where(SHELL_IDENTIFIER)
.is(shellIdentifier));

Expand Down Expand Up @@ -134,7 +134,7 @@ private CursorResult<List<String>> paginateList(PaginationInfo pInfo, List<Strin
return paginationSupport.getPaged(pInfo);
}

private boolean containsMatchingAssetId(List<SpecificAssetID> containedSpecificAssetIds, List<String> queryAssetIds) {
private boolean containsMatchingAssetId(List<SpecificAssetId> containedSpecificAssetIds, List<String> queryAssetIds) {
return queryAssetIds.stream()
.anyMatch(queryAssetId -> containedSpecificAssetIds.stream()
.anyMatch(containedAssetId -> containedAssetId.getValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.Arrays;
import java.util.List;

import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetID;
import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryService;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryServiceSuite;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.model.AssetLink;
Expand Down Expand Up @@ -77,23 +77,23 @@ public void assetLinkIsPersisted() {

String dummyShellIdentifier = "DummyShellID";

List<SpecificAssetID> expectedAssetIDs = createDummyAssetLinkOnDiscoveryService(dummyShellIdentifier, aasDiscoveryService);
List<SpecificAssetId> expectedAssetIDs = createDummyAssetLinkOnDiscoveryService(dummyShellIdentifier, aasDiscoveryService);

List<SpecificAssetID> actualAssetIDs = aasDiscoveryService.getAllAssetLinksById(dummyShellIdentifier);
List<SpecificAssetId> actualAssetIDs = aasDiscoveryService.getAllAssetLinksById(dummyShellIdentifier);

assertEquals(expectedAssetIDs, actualAssetIDs);

removeCreatedAssetLink(dummyShellIdentifier, aasDiscoveryService);
}

private List<SpecificAssetID> createDummyAssetLinkOnDiscoveryService(String testShellIdentifier, AasDiscoveryService aasDiscoveryService) {
private List<SpecificAssetId> createDummyAssetLinkOnDiscoveryService(String testShellIdentifier, AasDiscoveryService aasDiscoveryService) {
AssetLink assetLink = getSingleDummyAasAssetLink(testShellIdentifier);
createAssetLink(assetLink, aasDiscoveryService);

SpecificAssetID specificAssetID_1 = createDummySpecificAssetID("TestAsset1", "TestAssetValue1");
SpecificAssetID specificAssetID_2 = createDummySpecificAssetID("TestAsset2", "TestAssetValue2");
SpecificAssetId specificAssetId_1 = createDummySpecificAssetId("TestAsset1", "TestAssetValue1");
SpecificAssetId specificAssetId_2 = createDummySpecificAssetId("TestAsset2", "TestAssetValue2");

return Arrays.asList(specificAssetID_1, specificAssetID_2);
return Arrays.asList(specificAssetId_1, specificAssetId_2);
}

private void removeCreatedAssetLink(String dummyShellIdentifier, AasDiscoveryService aasDiscoveryService) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import java.util.List;

import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetID;
import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId;
import org.eclipse.digitaltwin.basyx.core.pagination.CursorResult;
import org.eclipse.digitaltwin.basyx.core.pagination.PaginationInfo;

Expand Down Expand Up @@ -55,7 +55,7 @@ public interface AasDiscoveryService {
* @param aasIdentifier
* @return a list of asset identifiers
*/
public List<SpecificAssetID> getAllAssetLinksById(String shellIdentifier);
public List<SpecificAssetId> getAllAssetLinksById(String shellIdentifier);

/**
* Creates new asset identifier key-value-pairs linked to an Asset
Expand All @@ -66,7 +66,7 @@ public interface AasDiscoveryService {
* @param assetIds
* @return a list of asset identifiers
*/
public List<SpecificAssetID> createAllAssetLinksById(String shellIdentifier, List<SpecificAssetID> assetIds);
public List<SpecificAssetId> createAllAssetLinksById(String shellIdentifier, List<SpecificAssetId> assetIds);

/**
* Deletes all asset identifier key-value-pairs linked to an Asset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,37 @@
import java.util.stream.Collectors;

import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell;
import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetID;
import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId;

/**
* Represents the link between {@link AssetAdministrationShell} and
* {@link SpecificAssetID}
* {@link SpecificAssetId}
*
* @author danish
*
*/
public class AssetLink {

private String shellIdentifier;
private List<SpecificAssetID> specificAssetIDs;
private List<SpecificAssetId> specificAssetIds;

public AssetLink(String shellIdentifier, List<SpecificAssetID> specificAssetIDs) {
public AssetLink(String shellIdentifier, List<SpecificAssetId> specificAssetIds) {
super();
this.shellIdentifier = shellIdentifier;
this.specificAssetIDs = specificAssetIDs;
this.specificAssetIds = specificAssetIds;
}

public String getShellIdentifier() {
return shellIdentifier;
}

public List<SpecificAssetID> getSpecificAssetIDs() {
return specificAssetIDs;
public List<SpecificAssetId> getSpecificAssetIds() {
return specificAssetIds;
}

public List<String> getSpecificAssetIDStrings() {
return specificAssetIDs.stream()
.map(SpecificAssetID::getValue)
public List<String> getSpecificAssetIdStrings() {
return specificAssetIds.stream()
.map(SpecificAssetId::getValue)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import java.util.Arrays;
import java.util.List;

import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetID;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSpecificAssetID;
import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSpecificAssetId;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.model.AssetLink;
import org.eclipse.digitaltwin.basyx.core.exceptions.AssetLinkDoesNotExistException;
import org.eclipse.digitaltwin.basyx.core.exceptions.CollidingAssetLinkException;
Expand Down Expand Up @@ -82,11 +82,11 @@ public void getAllAssetLinksById() {
assetLinks.stream()
.forEach(assetLink -> createAssetLink(assetLink, discoveryService));

List<SpecificAssetID> expectedResult = Arrays.asList(createDummySpecificAssetID("DummyAssetName3", "DummyAsset_3_Value"), createDummySpecificAssetID("DummyAssetName4", "DummyAsset_4_Value"));
List<SpecificAssetId> expectedResult = Arrays.asList(createDummySpecificAssetId("DummyAssetName3", "DummyAsset_3_Value"), createDummySpecificAssetId("DummyAssetName4", "DummyAsset_4_Value"));

String shellIdentifier = "TestAasID2";

List<SpecificAssetID> actualResult = discoveryService.getAllAssetLinksById(shellIdentifier);
List<SpecificAssetId> actualResult = discoveryService.getAllAssetLinksById(shellIdentifier);

assertEquals(expectedResult.size(), actualResult.size());
assertEquals(expectedResult, actualResult);
Expand All @@ -98,12 +98,12 @@ public void createAllAssetLinksById() {

String shellIdentifier = "TestAasID3";

List<SpecificAssetID> expectedAssetIds = Arrays.asList(createDummySpecificAssetID("DummyAssetName4", "DummyAsset_4_Value"), createDummySpecificAssetID("DummyAssetName5", "DummyAsset_5_Value"));
List<SpecificAssetId> expectedAssetIds = Arrays.asList(createDummySpecificAssetId("DummyAssetName4", "DummyAsset_4_Value"), createDummySpecificAssetId("DummyAssetName5", "DummyAsset_5_Value"));

List<SpecificAssetID> createdAssetIds = discoveryService.createAllAssetLinksById(shellIdentifier, expectedAssetIds);
List<SpecificAssetId> createdAssetIds = discoveryService.createAllAssetLinksById(shellIdentifier, expectedAssetIds);
assertEquals(expectedAssetIds, createdAssetIds);

List<SpecificAssetID> actualAssetIds = discoveryService.getAllAssetLinksById(shellIdentifier);
List<SpecificAssetId> actualAssetIds = discoveryService.getAllAssetLinksById(shellIdentifier);

assertEquals(expectedAssetIds.size(), actualAssetIds.size());
assertEquals(expectedAssetIds, actualAssetIds);
Expand Down Expand Up @@ -153,29 +153,29 @@ public static List<AssetLink> getMultipleDummyAasAssetLink() {
String dummyShellIdentifier_1 = "TestAasID1";
String dummyShellIdentifier_2 = "TestAasID2";

SpecificAssetID specificAssetID_1 = createDummySpecificAssetID("DummyAssetName1", "DummyAsset_1_Value");
SpecificAssetID specificAssetID_2 = createDummySpecificAssetID("DummyAssetName2", "DummyAsset_2_Value");
SpecificAssetId specificAssetId_1 = createDummySpecificAssetId("DummyAssetName1", "DummyAsset_1_Value");
SpecificAssetId specificAssetId_2 = createDummySpecificAssetId("DummyAssetName2", "DummyAsset_2_Value");

SpecificAssetID specificAssetID_3 = createDummySpecificAssetID("DummyAssetName3", "DummyAsset_3_Value");
SpecificAssetID specificAssetID_4 = createDummySpecificAssetID("DummyAssetName4", "DummyAsset_4_Value");
SpecificAssetId specificAssetId_3 = createDummySpecificAssetId("DummyAssetName3", "DummyAsset_3_Value");
SpecificAssetId specificAssetId_4 = createDummySpecificAssetId("DummyAssetName4", "DummyAsset_4_Value");

return Arrays.asList(new AssetLink(dummyShellIdentifier_1, Arrays.asList(specificAssetID_1, specificAssetID_2)), new AssetLink(dummyShellIdentifier_2, Arrays.asList(specificAssetID_3, specificAssetID_4)));
return Arrays.asList(new AssetLink(dummyShellIdentifier_1, Arrays.asList(specificAssetId_1, specificAssetId_2)), new AssetLink(dummyShellIdentifier_2, Arrays.asList(specificAssetId_3, specificAssetId_4)));
}

public static void createAssetLink(AssetLink assetLink, AasDiscoveryService aasDiscoveryService) {
aasDiscoveryService.createAllAssetLinksById(assetLink.getShellIdentifier(), assetLink.getSpecificAssetIDs());
aasDiscoveryService.createAllAssetLinksById(assetLink.getShellIdentifier(), assetLink.getSpecificAssetIds());
}

public static AssetLink getSingleDummyAasAssetLink(String shellId) {

SpecificAssetID specificAssetID_1 = createDummySpecificAssetID("TestAsset1", "TestAssetValue1");
SpecificAssetID specificAssetID_2 = createDummySpecificAssetID("TestAsset2", "TestAssetValue2");
SpecificAssetId specificAssetId_1 = createDummySpecificAssetId("TestAsset1", "TestAssetValue1");
SpecificAssetId specificAssetId_2 = createDummySpecificAssetId("TestAsset2", "TestAssetValue2");

return new AssetLink(shellId, Arrays.asList(specificAssetID_1, specificAssetID_2));
return new AssetLink(shellId, Arrays.asList(specificAssetId_1, specificAssetId_2));
}

protected static SpecificAssetID createDummySpecificAssetID(String name, String value) {
return new DefaultSpecificAssetID.Builder().name(name)
protected static SpecificAssetId createDummySpecificAssetId(String name, String value) {
return new DefaultSpecificAssetId.Builder().name(name)
.value(value)
.build();
}
Expand Down
Loading

0 comments on commit 98cc9f9

Please sign in to comment.