Skip to content

Commit

Permalink
feat(imp):[#214] add some logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dsmf committed Jan 18, 2024
1 parent 8137cd2 commit f080d72
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,22 @@ private List<AssetAdministrationShellDescriptor> fetchShellDescriptorsForConnect
} catch (ExecutionException e) {
throw new RegistryServiceRuntimeException(
"Exception occurred while fetching shells for bpn '%s'".formatted(bpn), e);
} finally {
log.debug("End fetchShellDescriptorsForConnectorEndpoints");
}
}

private List<AssetAdministrationShellDescriptor> fetchShellDescriptorsForKey(
final List<DigitalTwinRegistryKey> keys, final EndpointDataReference endpointDataReference) {
log.info("Fetching shell descriptors for keys {}", keys);
return keys.stream().map(key -> fetchShellDescriptor(endpointDataReference, key)).toList();
}

private AssetAdministrationShellDescriptor fetchShellDescriptor(final EndpointDataReference endpointDataReference,
final DigitalTwinRegistryKey key) {
log.info("Retrieving AAS Identification for DigitalTwinRegistryKey: {}", key);
final String aaShellIdentification = mapToShellId(endpointDataReference, key.shellId());

log.debug("aaShellIdentification: {}", aaShellIdentification);
return decentralDigitalTwinRegistryClient.getAssetAdministrationShellDescriptor(endpointDataReference,
aaShellIdentification);
}
Expand Down Expand Up @@ -173,14 +176,15 @@ private String mapToShellId(final EndpointDataReference endpointDataReference, f
private Collection<String> lookupShellIds(final String bpn) {
log.info("Looking up shell ids for bpn {}", bpn);
final var connectorEndpoints = connectorEndpointsService.fetchConnectorEndpoints(bpn);
final var edrFutures = endpointDataForConnectorsService.createFindEndpointDataForConnectorsFutures(
connectorEndpoints);
log.debug("Looking up shell ids for bpn {} with connector endpoints {}", bpn, connectorEndpoints);

final var endpointDataReferenceFutures = endpointDataForConnectorsService.createFindEndpointDataForConnectorsFutures(
connectorEndpoints);
try {
final var futures = edrFutures.stream()
.map(edrFuture -> edrFuture.thenCompose(
edr -> supplyAsync(() -> lookupShellIds(bpn, edr))))
.toList();
final var futures = endpointDataReferenceFutures.stream()
.map(edrFuture -> edrFuture.thenCompose(
edr -> supplyAsync(() -> lookupShellIds(bpn, edr))))
.toList();
final var shellIds = resultFinder.getFastestResult(futures).get();

log.info("Found {} shell id(s) in total", shellIds.size());
Expand All @@ -197,6 +201,7 @@ private Collection<String> lookupShellIds(final String bpn) {
}

private List<String> lookupShellIds(final String bpn, final EndpointDataReference endpointDataReference) {
log.debug("lookupShellIds for bpn {} with endpointDataReference {}", bpn, endpointDataReference);
return decentralDigitalTwinRegistryClient.getAllAssetAdministrationShellIdsByAssetLink(endpointDataReference,
List.of(IdentifierKeyValuePair.builder().name("manufacturerId").value(bpn).build())).getResult();
}
Expand Down

0 comments on commit f080d72

Please sign in to comment.