Skip to content

Commit

Permalink
Merge pull request #13 from catenax-ng/main
Browse files Browse the repository at this point in the history
Adjust depth of tree and prepare release 2.1.0
  • Loading branch information
ds-jhartmann authored Jan 11, 2023
2 parents 11054b5 + 6653d8d commit fff9f18
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 51 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.1.0] - 2023-01-11
### Changed
- Change 'jobParameter' to 'parameter' in GET calls in IRS API
- Change 'jobStates' to 'states' request parameter in GET call for jobs by states, 'jobStates' is now deprecated
Expand Down Expand Up @@ -132,7 +134,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Unresolved
- **Select Aspects you need** You are able to select the needed aspects for which you want to collect the correct endpoint information.

[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/2.0.0...HEAD
[Unreleased]: https://github.com/eclipse-tractusx/item-relationship-service/compare/2.1.0...HEAD
[2.1.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/2.0.0...2.1.0
[2.0.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/1.6.0...2.0.0
[1.6.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/1.5.0...1.6.0
[1.5.0]: https://github.com/eclipse-tractusx/item-relationship-service/compare/1.4.0...1.5.0
Expand Down
12 changes: 6 additions & 6 deletions api-tests/irs-api-tests.tavern.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ stages:

- name: get all COMPLETED jobs
request:
url: "{tavern.env_vars.IRS_HOST}/irs/jobs?jobStates=COMPLETED"
url: "{tavern.env_vars.IRS_HOST}/irs/jobs?states=COMPLETED"
method: GET
headers:
content-type: application/json
Expand Down Expand Up @@ -959,7 +959,7 @@ stages:

- name: get all ERROR jobs
request:
url: "{tavern.env_vars.IRS_HOST}/irs/jobs?jobStates=ERROR"
url: "{tavern.env_vars.IRS_HOST}/irs/jobs?states=ERROR"
method: GET
headers:
content-type: application/json
Expand Down Expand Up @@ -1004,7 +1004,7 @@ stages:

- name: get all INITIAL jobs
request:
url: "{tavern.env_vars.IRS_HOST}/irs/jobs?jobStates=INITIAL"
url: "{tavern.env_vars.IRS_HOST}/irs/jobs?states=INITIAL"
method: GET
headers:
content-type: application/json
Expand Down Expand Up @@ -1069,7 +1069,7 @@ stages:

- name: get all RUNNING jobs
request:
url: "{tavern.env_vars.IRS_HOST}/irs/jobs?jobStates=RUNNING"
url: "{tavern.env_vars.IRS_HOST}/irs/jobs?states=RUNNING"
method: GET
headers:
content-type: application/json
Expand Down Expand Up @@ -1291,7 +1291,7 @@ stages:

- name: get all jobs with status UNSAVED, INITIAL, RUNNING, TRANSFERS_FINISHED and CANCELED
request:
url: "{tavern.env_vars.IRS_HOST}/irs/jobs?jobStates=UNSAVED, INITIAL, RUNNING, TRANSFERS_FINISHED, CANCELED"
url: "{tavern.env_vars.IRS_HOST}/irs/jobs?states=UNSAVED, INITIAL, RUNNING, TRANSFERS_FINISHED, CANCELED"
method: GET
headers:
content-type: application/json
Expand Down Expand Up @@ -1379,7 +1379,7 @@ stages:

- name: get all jobs with status COMPLETED and ERROR
request:
url: "{tavern.env_vars.IRS_HOST}/irs/jobs?jobStates=COMPLETED, ERROR"
url: "{tavern.env_vars.IRS_HOST}/irs/jobs?states=COMPLETED, ERROR"
method: GET
headers:
content-type: application/json
Expand Down
2 changes: 2 additions & 0 deletions charts/irs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [4.1.0] - 2023-01-11
### Changed
- IRS configuration is now provided via ConfigMap instead of ENVs. This can be overwritten completely in the values.yaml. This is backward compatible with the previous configuration layout.

Expand Down
4 changes: 2 additions & 2 deletions charts/irs/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 4.0.0
version: 4.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "2.0.0"
appVersion: "2.1.0"

dependencies:
- name: common
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.stream.Stream;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.irs.component.JobParameter;
import org.eclipse.tractusx.irs.connector.job.MultiTransferJob;
import org.eclipse.tractusx.irs.connector.job.RecursiveJobHandler;

Expand Down Expand Up @@ -52,17 +51,9 @@ public Stream<ItemDataRequest> initiate(final MultiTransferJob job) {
public Stream<ItemDataRequest> recurse(final MultiTransferJob job, final AASTransferProcess transferProcess) {
log.info("Starting recursive request for job {}", job.getJobIdString());

final JobParameter jobParameter = job.getJobParameter();
final int expectedDepth = jobParameter.getDepth();
final Integer currentDepth = transferProcess.getDepth();

if (expectedDepthOfTreeIsNotReached(expectedDepth, currentDepth)) {
return transferProcess.getIdsToProcess()
.stream()
.map(itemId -> ItemDataRequest.nextDepthNode(itemId, currentDepth));
}

return Stream.empty();
return transferProcess.getIdsToProcess()
.stream()
.map(itemId -> ItemDataRequest.nextDepthNode(itemId, transferProcess.getDepth()));
}

@Override
Expand All @@ -73,8 +64,4 @@ public void complete(final MultiTransferJob job) {
logic.assemblePartialItemGraphBlobs(completedTransfers, targetBlobName.toString());
}

private boolean expectedDepthOfTreeIsNotReached(final Integer expectedDepth, final Integer currentDepth) {
log.info("Expected tree depth is {}, current depth is {}", expectedDepth, currentDepth);
return currentDepth < expectedDepth;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public class BpdmDelegate extends AbstractDelegate {

private final BpdmFacade bpdmFacade;

public BpdmDelegate(final BpdmFacade bpdmFacade) {
super(null); // no next step
public BpdmDelegate(final AbstractDelegate nextStep,
final BpdmFacade bpdmFacade) {
super(nextStep);
this.bpdmFacade = bpdmFacade;
}

Expand All @@ -72,7 +73,12 @@ public ItemContainer process(final ItemContainer.ItemContainerBuilder itemContai
itemContainerBuilder.tombstone(Tombstone.from(itemId, null, e, retryCount, ProcessStep.BPDM_REQUEST));
}

return next(itemContainerBuilder, jobData, aasTransferProcess, itemId);
if (expectedDepthOfTreeIsNotReached(jobData.getDepth(), aasTransferProcess.getDepth())) {
return next(itemContainerBuilder, jobData, aasTransferProcess, itemId);
}

// depth reached - stop processing
return itemContainerBuilder.build();
}

private void bpnFromManufacturerId(final ItemContainer.ItemContainerBuilder itemContainerBuilder,
Expand All @@ -94,4 +100,9 @@ private void bpnFromManufacturerId(final ItemContainer.ItemContainerBuilder item
});
}

private boolean expectedDepthOfTreeIsNotReached(final int expectedDepth, final int currentDepth) {
log.info("Expected tree depth is {}, current depth is {}", expectedDepth, currentDepth);
return currentDepth < expectedDepth;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ public class SubmodelDelegate extends AbstractDelegate {
private final JsonValidatorService jsonValidatorService;
private final JsonUtil jsonUtil;

public SubmodelDelegate(final AbstractDelegate nextStep, final EdcSubmodelFacade submodelFacade,
public SubmodelDelegate(final EdcSubmodelFacade submodelFacade,
final SemanticsHubFacade semanticsHubFacade, final JsonValidatorService jsonValidatorService,
final JsonUtil jsonUtil) {
super(nextStep);
super(null); // no next step
this.submodelFacade = submodelFacade;
this.semanticsHubFacade = semanticsHubFacade;
this.jsonValidatorService = jsonValidatorService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,15 @@ public TimedAspect timedAspect(final MeterRegistry registry) {
}

@Bean
public DigitalTwinDelegate digitalTwinDelegate(final RelationshipDelegate relationshipDelegate,
public DigitalTwinDelegate digitalTwinDelegate(final BpdmDelegate bpdmDelegate,
final DigitalTwinRegistryFacade digitalTwinRegistryFacade) {
return new DigitalTwinDelegate(relationshipDelegate, digitalTwinRegistryFacade);
return new DigitalTwinDelegate(bpdmDelegate, digitalTwinRegistryFacade);
}

@Bean
public BpdmDelegate bpdmDelegate(final RelationshipDelegate relationshipDelegate,
final BpdmFacade bpdmFacade) {
return new BpdmDelegate(relationshipDelegate, bpdmFacade);
}

@Bean
Expand All @@ -122,15 +128,9 @@ public RelationshipDelegate relationshipDelegate(final SubmodelDelegate submodel
}

@Bean
public SubmodelDelegate submodelDelegate(final BpdmDelegate bpdmDelegate, final EdcSubmodelFacade submodelFacade,
public SubmodelDelegate submodelDelegate(final EdcSubmodelFacade submodelFacade,
final SemanticsHubFacade semanticsHubFacade, final JsonValidatorService jsonValidatorService) {
return new SubmodelDelegate(bpdmDelegate, submodelFacade, semanticsHubFacade, jsonValidatorService, jsonUtil());
return new SubmodelDelegate(submodelFacade, semanticsHubFacade, jsonValidatorService, jsonUtil());
}

@Bean
public BpdmDelegate bpdmDelegate(final BpdmFacade bpdmFacade) {
return new BpdmDelegate(bpdmFacade);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.eclipse.tractusx.irs.aaswrapper.job.AASTransferProcess;
import org.eclipse.tractusx.irs.aaswrapper.job.ItemContainer;
import org.eclipse.tractusx.irs.bpdm.BpdmFacade;
import org.eclipse.tractusx.irs.component.JobParameter;
import org.eclipse.tractusx.irs.component.assetadministrationshell.AssetAdministrationShellDescriptor;
import org.eclipse.tractusx.irs.component.assetadministrationshell.IdentifierKeyValuePair;
import org.eclipse.tractusx.irs.component.enums.ProcessStep;
Expand All @@ -46,7 +45,7 @@
class BpdmDelegateTest {

final BpdmFacade bpdmFacade = mock(BpdmFacade.class);
final BpdmDelegate bpdmDelegate = new BpdmDelegate(bpdmFacade);
final BpdmDelegate bpdmDelegate = new BpdmDelegate(null, bpdmFacade);

@Test
void shouldFillItemContainerWithBpn() {
Expand All @@ -57,7 +56,7 @@ void shouldFillItemContainerWithBpn() {

// when
final ItemContainer result = bpdmDelegate.process(itemContainerWithShell, jobParameter(),
new AASTransferProcess(), "itemId");
new AASTransferProcess("id", 0), "itemId");

// then
assertThat(result).isNotNull();
Expand All @@ -73,7 +72,7 @@ void shouldCreateTombstoneForMissingManufacturerId() {

// when
final ItemContainer result = bpdmDelegate.process(itemContainerWithShell, jobParameter(),
new AASTransferProcess(), "itemId");
new AASTransferProcess("id", 0), "itemId");

// then
assertThat(result).isNotNull();
Expand All @@ -92,7 +91,7 @@ void shouldCreateTombstoneForNotValidBpn() {

// when
final ItemContainer result = bpdmDelegate.process(itemContainerWithShell, jobParameter(),
new AASTransferProcess(), "itemId");
new AASTransferProcess("id", 0), "itemId");

// then
assertThat(result).isNotNull();
Expand All @@ -111,7 +110,7 @@ void shouldCatchRestClientExceptionAndPutTombstone() {

// when
final ItemContainer result = bpdmDelegate.process(itemContainerWithShell, jobParameter(),
new AASTransferProcess(), "itemId");
new AASTransferProcess("id", 0), "itemId");

// then
assertThat(result).isNotNull();
Expand All @@ -129,7 +128,7 @@ void shouldCreateTombstoneForMissingBpnForGivenManufacturerId() {

// when
final ItemContainer result = bpdmDelegate.process(itemContainerWithShell, jobParameter(),
new AASTransferProcess(), "itemId");
new AASTransferProcess("id", 0), "itemId");

// then
assertThat(result).isNotNull();
Expand All @@ -147,7 +146,7 @@ void shouldNotCreateBpnsAndTombstonesIfShellIsMissing() {

// when
final ItemContainer result = bpdmDelegate.process(itemContainerWithoutShell, jobParameter(),
new AASTransferProcess(), "itemId");
new AASTransferProcess("id", 0), "itemId");

// then
assertThat(result).isNotNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SubmodelDelegateTest {
final EdcSubmodelFacade submodelFacade = mock(EdcSubmodelFacade.class);
final SemanticsHubFacade semanticsHubFacade = mock(SemanticsHubFacade.class);
final JsonValidatorService jsonValidatorService = mock(JsonValidatorService.class);
final SubmodelDelegate submodelDelegate = new SubmodelDelegate(null, submodelFacade,
final SubmodelDelegate submodelDelegate = new SubmodelDelegate(submodelFacade,
semanticsHubFacade, jsonValidatorService, new JsonUtil());

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void registerJobWithoutDepthShouldBuildFullTree() {
void registerJobWithCollectAspectsShouldIncludeSubmodels() throws InvalidSchemaException {
// given
when(jsonValidatorService.validate(any(), any())).thenReturn(ValidationResult.builder().valid(true).build());
final RegisterJob registerJob = registerJobWithGlobalAssetIdAndDepth("urn:uuid:4132cd2b-cbe7-4881-a6b4-39fdc31cca2b", 0,
final RegisterJob registerJob = registerJobWithGlobalAssetIdAndDepth("urn:uuid:4132cd2b-cbe7-4881-a6b4-39fdc31cca2b", 100,
List.of(AspectType.SERIAL_PART_TYPIZATION, AspectType.PRODUCT_DESCRIPTION, AspectType.ASSEMBLY_PART_RELATIONSHIP), true);
final int expectedSubmodelsSizeFullTree = 3; // stub

Expand Down Expand Up @@ -135,7 +135,7 @@ void registerJobShouldCreateTombstonesWhenNotPassingJsonSchemaValidation() throw
@Test
void registerJobWithDepthShouldBuildTreeUntilGivenDepth() {
// given
final RegisterJob registerJob = registerJobWithDepthAndAspect(0, null);
final RegisterJob registerJob = registerJobWithDepthAndAspect(1, null);
final int expectedRelationshipsSizeFirstDepth = 1; // stub

// when
Expand Down

0 comments on commit fff9f18

Please sign in to comment.