Skip to content

Commit

Permalink
Merge pull request eclipse-tractusx#554 from catenax-ng/feature/TRI-1…
Browse files Browse the repository at this point in the history
…663-unify-ess-into-irs

feat(impl):[TRI-1663] unify ess into irs
  • Loading branch information
ds-ext-kmassalski authored Sep 29, 2023
2 parents 46828e8 + a990255 commit eff3c84
Show file tree
Hide file tree
Showing 43 changed files with 110 additions and 635 deletions.
1 change: 0 additions & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ maven/mavencentral/org.eclipse.jetty/jetty-xml/11.0.15, EPL-2.0 OR Apache-2.0, a
maven/mavencentral/org.eclipse.tractusx.irs/irs-api/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-common/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-edc-client/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-ess/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-models/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-policy-store/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-registry-client/1.2.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ COPY .config .config
COPY .mvn .mvn
COPY pom.xml .

COPY irs-ess irs-ess
COPY irs-policy-store irs-policy-store
COPY irs-integration-tests irs-integration-tests
COPY irs-api irs-api
Expand Down
6 changes: 0 additions & 6 deletions irs-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@
</repositories>

<dependencies>
<!-- To find spring components and expose controller endpoints -->
<dependency>
<groupId>org.eclipse.tractusx.irs</groupId>
<artifactId>irs-ess</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.eclipse.tractusx.irs</groupId>
<artifactId>irs-edc-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
@ComponentScan(
basePackages = {
"org.eclipse.tractusx.irs",
"org.eclipse.tractusx.ess",
"org.eclipse.tractusx.irs.ess",
"org.eclipse.tractusx.irs.edc",
"org.eclipse.tractusx.irs.common.auth",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.examples.Example;
import org.eclipse.tractusx.ess.service.NotificationSummary;
import org.eclipse.tractusx.irs.ess.service.NotificationSummary;
import org.eclipse.tractusx.irs.component.AsyncFetchedItems;
import org.eclipse.tractusx.irs.component.BatchResponse;
import org.eclipse.tractusx.irs.component.BatchOrderResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.bpn.validation;
package org.eclipse.tractusx.irs.ess.bpn.validation;

import java.time.ZonedDateTime;
import java.util.List;
import java.util.NoSuchElementException;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.eclipse.tractusx.ess.service.SupplyChainImpacted;
import org.eclipse.tractusx.irs.ess.service.SupplyChainImpacted;
import org.eclipse.tractusx.irs.component.Jobs;
import org.eclipse.tractusx.irs.component.assetadministrationshell.AssetAdministrationShellDescriptor;
import org.eclipse.tractusx.irs.component.partasplanned.PartAsPlanned;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.controller;
package org.eclipse.tractusx.irs.ess.controller;

import static org.eclipse.tractusx.irs.common.ApiConstants.FORBIDDEN_DESC;
import static org.eclipse.tractusx.irs.common.ApiConstants.UNAUTHORIZED_DESC;
Expand All @@ -40,7 +40,7 @@
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.ess.service.EssService;
import org.eclipse.tractusx.irs.ess.service.EssService;
import org.eclipse.tractusx.irs.common.auth.AuthorizationService;
import org.eclipse.tractusx.irs.common.auth.IrsRoles;
import org.eclipse.tractusx.irs.component.JobHandle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.controller;
package org.eclipse.tractusx.irs.ess.controller;

import io.swagger.v3.oas.annotations.Hidden;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.ess.service.EssRecursiveService;
import org.eclipse.tractusx.irs.ess.service.EssRecursiveService;
import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification;
import org.eclipse.tractusx.irs.edc.client.model.notification.InvestigationNotificationContent;
import org.springframework.http.HttpStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.controller;
package org.eclipse.tractusx.irs.ess.controller;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

Expand All @@ -33,7 +33,7 @@
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.eclipse.tractusx.ess.service.EssService;
import org.eclipse.tractusx.irs.ess.service.EssService;
import org.eclipse.tractusx.irs.dtos.ErrorResponse;
import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification;
import org.eclipse.tractusx.irs.edc.client.model.notification.ResponseNotificationContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.controller.mock;
package org.eclipse.tractusx.irs.ess.controller.mock;

import java.util.List;
import java.util.Map;
Expand All @@ -32,8 +32,8 @@
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.ess.discovery.EdcDiscoveryMockConfig;
import org.eclipse.tractusx.ess.service.SupplyChainImpacted;
import org.eclipse.tractusx.irs.ess.discovery.EdcDiscoveryMockConfig;
import org.eclipse.tractusx.irs.ess.service.SupplyChainImpacted;
import org.eclipse.tractusx.irs.edc.client.EdcSubmodelFacade;
import org.eclipse.tractusx.irs.edc.client.exceptions.EdcClientException;
import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.discovery;
package org.eclipse.tractusx.irs.ess.discovery;

import java.util.Map;

import lombok.Data;
import org.eclipse.tractusx.ess.service.SupplyChainImpacted;
import org.eclipse.tractusx.irs.ess.service.SupplyChainImpacted;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.service;
package org.eclipse.tractusx.irs.ess.service;

/**
* Exception thrown if ESS Validation could not find the requested aspect model in the job.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.service;
package org.eclipse.tractusx.irs.ess.service;

import java.time.ZoneOffset;
import java.time.ZonedDateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.service;
package org.eclipse.tractusx.irs.ess.service;

import static java.util.Objects.requireNonNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.service;
package org.eclipse.tractusx.irs.ess.service;

import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.service;
package org.eclipse.tractusx.irs.ess.service;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.service;
package org.eclipse.tractusx.irs.ess.service;

import java.util.List;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.service;
package org.eclipse.tractusx.irs.ess.service;

import java.util.List;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,27 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.ess.service;
package org.eclipse.tractusx.irs.ess.service;

import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Predicate;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.ess.irs.IrsFacade;
import org.eclipse.tractusx.irs.common.auth.SecurityHelperService;
import org.eclipse.tractusx.irs.component.JobHandle;
import org.eclipse.tractusx.irs.component.Jobs;
import org.eclipse.tractusx.irs.component.PartChainIdentificationKey;
import org.eclipse.tractusx.irs.component.RegisterBpnInvestigationJob;
import org.eclipse.tractusx.irs.component.RegisterJob;
import org.eclipse.tractusx.irs.component.enums.AspectType;
import org.eclipse.tractusx.irs.component.enums.BomLifecycle;
import org.eclipse.tractusx.irs.component.enums.JobState;
import org.eclipse.tractusx.irs.edc.client.model.notification.EdcNotification;
import org.eclipse.tractusx.irs.edc.client.model.notification.ResponseNotificationContent;
import org.eclipse.tractusx.irs.services.IrsItemGraphQueryService;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ResponseStatusException;
Expand All @@ -49,7 +54,7 @@
@Slf4j
public class EssService {

private final IrsFacade irsFacade;
private final IrsItemGraphQueryService irsItemGraphQueryService;
private final SecurityHelperService securityHelperService;
private final BpnInvestigationJobCache bpnInvestigationJobCache;
private final EssRecursiveNotificationHandler recursiveNotificationHandler;
Expand Down Expand Up @@ -83,10 +88,10 @@ private static boolean hasUnansweredNotifications(final BpnInvestigationJob inve
}

public JobHandle startIrsJob(final RegisterBpnInvestigationJob request) {
final JobHandle jobHandle = irsFacade.startIrsJob(request.getKey(), request.getBomLifecycle());
final JobHandle jobHandle = irsItemGraphQueryService.registerItemJob(bpnInvestigations(request.getKey(), request.getBomLifecycle()));

final UUID createdJobId = jobHandle.getId();
final Jobs createdJob = irsFacade.getIrsJob(createdJobId.toString());
final Jobs createdJob = irsItemGraphQueryService.getJobForJobId(createdJobId, true);
final String owner = securityHelperService.getClientIdClaim();
bpnInvestigationJobCache.store(createdJobId,
BpnInvestigationJob.create(createdJob, owner, request.getIncidentBPNSs()));
Expand Down Expand Up @@ -149,4 +154,15 @@ private Predicate<BpnInvestigationJob> investigationJobNotificationPredicate(
return investigationJob -> investigationJob.getUnansweredNotifications()
.contains(notification.getHeader().getOriginalNotificationId());
}

private RegisterJob bpnInvestigations(final PartChainIdentificationKey key, final BomLifecycle bomLifecycle) {
return RegisterJob.builder()
.key(key)
.bomLifecycle(bomLifecycle != null ? bomLifecycle : BomLifecycle.AS_PLANNED)
.depth(1)
.aspects(List.of(AspectType.PART_SITE_INFORMATION_AS_PLANNED.toString(),
AspectType.PART_AS_PLANNED.toString()))
.collectAspects(true)
.build();
}
}
Loading

0 comments on commit eff3c84

Please sign in to comment.