Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to AAS4J milestone 04 release #144

Merged
merged 9 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetID;
import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.http.pagination.InlineResponse200;
import org.eclipse.digitaltwin.basyx.http.Base64UrlEncodedIdentifier;
import org.eclipse.digitaltwin.basyx.http.model.Result;
Expand Down Expand Up @@ -85,20 +85,20 @@ ResponseEntity<PagedResult> getAllAssetAdministrationShellIdsByAssetLink(@Parame

@Operation(summary = "Returns a list of specific Asset identifiers based on an Asset Administration Shell id to edit discoverable content", description = "", tags={ "Asset Administration Shell Basic Discovery API" })
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Requested specific Asset identifiers", content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = SpecificAssetID.class)))),
@ApiResponse(responseCode = "200", description = "Requested specific Asset identifiers", content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = SpecificAssetId.class)))),

@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Result.class))),

@ApiResponse(responseCode = "200", description = "Default error handling for unmentioned status codes", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Result.class))) })
@RequestMapping(value = "/lookup/shells/{aasIdentifier}",
produces = { "application/json" },
method = RequestMethod.GET)
ResponseEntity<List<SpecificAssetID>> getAllAssetLinksById(@Parameter(in = ParameterIn.PATH, description = "The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)", required=true, schema=@Schema()) @PathVariable("aasIdentifier") Base64UrlEncodedIdentifier aasIdentifier);
ResponseEntity<List<SpecificAssetId>> getAllAssetLinksById(@Parameter(in = ParameterIn.PATH, description = "The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)", required=true, schema=@Schema()) @PathVariable("aasIdentifier") Base64UrlEncodedIdentifier aasIdentifier);


@Operation(summary = "Creates specific Asset identifiers linked to an Asset Administration Shell to edit discoverable content", description = "", tags={ "Asset Administration Shell Basic Discovery API" })
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "Specific Asset identifiers created successfully", content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = SpecificAssetID.class)))),
@ApiResponse(responseCode = "201", description = "Specific Asset identifiers created successfully", content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = SpecificAssetId.class)))),

@ApiResponse(responseCode = "400", description = "Bad Request, e.g. the request parameters of the format of the request body is wrong.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Result.class))),

Expand All @@ -111,7 +111,7 @@ ResponseEntity<PagedResult> getAllAssetAdministrationShellIdsByAssetLink(@Parame
produces = { "application/json" },
consumes = { "application/json" },
method = RequestMethod.POST)
ResponseEntity<List<SpecificAssetID>> postAllAssetLinksById(@Parameter(in = ParameterIn.PATH, description = "The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)", required=true, schema=@Schema()) @PathVariable("aasIdentifier") Base64UrlEncodedIdentifier aasIdentifier, @Parameter(in = ParameterIn.DEFAULT, description = "A list of specific Asset identifiers", required=true, schema=@Schema()) @Valid @RequestBody List<SpecificAssetID> body);
ResponseEntity<List<SpecificAssetId>> postAllAssetLinksById(@Parameter(in = ParameterIn.PATH, description = "The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded)", required=true, schema=@Schema()) @PathVariable("aasIdentifier") Base64UrlEncodedIdentifier aasIdentifier, @Parameter(in = ParameterIn.DEFAULT, description = "A list of specific Asset identifiers", required=true, schema=@Schema()) @Valid @RequestBody List<SpecificAssetId> body);

}

Loading