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

Feature/tracefoss 617 upstream visiblity #169

Merged
merged 44 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
730924a
chore: TRACEFOSS-617 updated logic to accept upward visiblity.
ds-mwesener Apr 13, 2023
4c1e333
chore: TRACEFOSS-617 updated logic to accept upward visiblity.
ds-mwesener Apr 13, 2023
3b6cf91
chore: TRACEFOSS-617 updated logic to accept upward visiblity.
ds-mwesener Apr 14, 2023
b776177
chore: TRACEFOSS-617 updated logic to accept upward visiblity.
ds-mwesener Apr 14, 2023
d4bc98e
chore: TRACEFOSS-617 updated logic to accept upward visiblity.
ds-mwesener Apr 15, 2023
1c285f6
chore: TRACEFOSS-617 updated logic to accept upward visiblity.
ds-mwesener Apr 15, 2023
47b3ffc
chore: TRACEFOSS-617 updated logic to accept upward visiblity.
ds-mwesener Apr 15, 2023
228da9e
chore: TRACEFOSS-617 updated logic to accept upward visiblity.
ds-mwesener Apr 15, 2023
c1bf97f
chore: TRACEFOSS-617 updated logic to accept upward visiblity.
ds-mwesener Apr 16, 2023
7a54b92
chore: TRACEFOSS-617 removed deprecated apis
ds-mwesener Apr 18, 2023
1a5a47d
chore: TRACEFOSS-XXX refactored maven modules.
ds-mwesener Apr 18, 2023
e1bf843
chore: TRACEFOSS-XXX Updated models and add to tx-backend
ds-mwesener Apr 18, 2023
998618e
chore: TRACEFOSS-XXX Updated models and add to tx-backend
ds-mwesener Apr 18, 2023
3e0071f
chore: TRACEFOSS-XXX Updated models and add to tx-backend
ds-mwesener Apr 18, 2023
00df923
chore: TRACEFOSS-XXX Updated models and add to tx-backend
ds-mwesener Apr 18, 2023
f7ef9c5
chore: TRACEFOSS-XXX Updated models and add to tx-backend
ds-mwesener Apr 18, 2023
1ae1527
chore: TRACEFOSS-XXX Updated models and add to tx-backend
ds-mwesener Apr 18, 2023
2fc9b5e
chore: TRACEFOSS-XXX Updated models and add to tx-backend
ds-mwesener Apr 19, 2023
f0ca3fa
chore: TRACEFOSS-1281 Added root pom, spring-boot-parent-bom and refa…
ds-mwesener Apr 19, 2023
4e4c612
Merge branch 'feature/TRACEFOSS-maven-module-models' into feature/TRA…
ds-mwesener Apr 19, 2023
6b4fd44
init
ds-mwesener Apr 19, 2023
88a77c3
chore: TRACEFOSS-XXX updated technical documentation.
ds-mwesener Apr 19, 2023
81f5bab
chore: TRACEFOSS-617 removed license check from package phase.
ds-mwesener Apr 19, 2023
1313395
chore: TRACEFOSS-617 adapt failing integration tests.
ds-mwesener Apr 19, 2023
5478114
chore: TRACEFOSS-617 adapt license-check
ds-mwesener Apr 19, 2023
47f569c
chore: TRACEFOSS-617 adapt spotbugs. Added some logic to add the aspe…
ds-mwesener Apr 19, 2023
ad1da19
chore: TRACEFOSS-617 add some first tests.
ds-mwesener Apr 19, 2023
2358c23
chore: TRACEFOSS-617 add some first tests.
ds-mwesener Apr 20, 2023
86597d8
chore: TRACEFOSS-617 refactored some logic.
ds-mwesener Apr 20, 2023
c8c264e
chore: TRACEFOSS-XXX https://github.com/eclipse-tractusx/traceability…
ds-mwesener Apr 21, 2023
2160c0b
chore: TRACEFOSS-617 adapt behaviour of localId key to match correct …
ds-mwesener Apr 21, 2023
6620cb8
chore: TRACEFOSS-617 adapt behaviour of localId key to match correct …
ds-mwesener Apr 21, 2023
4dabb42
Merge branch 'main' into feature/TRACEFOSS-617-upstream-visiblity
ds-mwesener Apr 21, 2023
7885fd1
chore: TRACEFOSS-617 adapt tests
ds-mwesener Apr 21, 2023
ed3d663
chore: TRACEFOSS-617 adapt tests
ds-mwesener Apr 21, 2023
46bedfc
chore: TRACEFOSS-617 adapt tests
ds-mwesener Apr 21, 2023
8803fb5
chore: TRACEFOSS-617 adapt tests
ds-mwesener Apr 21, 2023
69960f9
chore: TRACEFOSS-617 adapt tests
ds-mwesener Apr 21, 2023
98d5cb5
chore: TRACEFOSS-617 adapt tests
ds-mwesener Apr 21, 2023
5b0c327
Merge branch 'main' into feature/TRACEFOSS-617-upstream-visiblity
ds-mwesener Apr 21, 2023
c84cde8
chore: TRACEFOSS-617 adapt tests
ds-mwesener Apr 21, 2023
64b399f
chore: TRACEFOSS-617 adapt tests
ds-mwesener Apr 21, 2023
cff1552
chore: TRACEFOSS-617 adapt tests
ds-mwesener Apr 21, 2023
e91fc08
chore: TRACEFOSS-617 refactored
ds-mwesener Apr 21, 2023
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@

package org.eclipse.tractusx.traceability.common.support

import net.bytebuddy.build.BuildLogger
import org.eclipse.tractusx.traceability.assets.infrastructure.adapters.feign.irs.model.AssetsConverter
import org.eclipse.tractusx.traceability.assets.infrastructure.adapters.jpa.asset.AssetEntity
import org.eclipse.tractusx.traceability.infrastructure.jpa.investigation.InvestigationEntity
import org.eclipse.tractusx.traceability.investigations.domain.model.InvestigationSide
import org.eclipse.tractusx.traceability.investigations.domain.model.InvestigationStatus
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import java.time.Instant

trait AssetsSupport implements AssetRepositoryProvider, InvestigationsRepositoryProvider {
private static final Logger logger = LoggerFactory.getLogger(AssetsSupport.class);

void defaultAssetsStored() {
assetRepository().saveAll(assetsConverter().readAndConvertAssets())
Expand All @@ -49,10 +53,13 @@ trait AssetsSupport implements AssetRepositoryProvider, InvestigationsRepository
asset.getCustomerPartId(),
asset.getManufacturingDate(),
asset.getManufacturingCountry(),
asset.isSupplierPart(),
asset.getOwner(),
asset.getChildDescriptions().stream()
.map(child -> new AssetEntity.ChildDescription(child.id(), child.idShort()))
.toList(),
asset.getParentDescriptions().stream()
.map(parent -> new AssetEntity.ParentDescription(parent.id(), parent.idShort()))
.toList(),
asset.getQualityType(),
asset.getVan()
)
Expand All @@ -72,6 +79,7 @@ trait AssetsSupport implements AssetRepositoryProvider, InvestigationsRepository
}

void assertAssetsSize(int size) {
logger.info("Assetsize: " + assetRepository().countAssets());
assert assetRepository().countAssets() == size
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

package org.eclipse.tractusx.traceability.common.support

import com.xebialabs.restito.builder.verify.VerifySequenced
import org.glassfish.grizzly.http.util.HttpStatus
import org.springframework.http.HttpHeaders

Expand Down Expand Up @@ -115,8 +116,8 @@ trait IrsApiSupport implements RestitoProvider {
ok(),
header("Content-Type", "application/json")
).withSequence(
jsonResponseFromFile("./stubs/irs/get/jobs/id/running_job_response_200.json"),
jsonResponseFromFile("./stubs/irs/get/jobs/id/response_200.json")
jsonResponseFromFile("./stubs/irs/get/jobs/id/response_200.json"),
jsonResponseFromFile("./stubs/irs/get/jobs/id/response_200.json")
)
}

Expand Down Expand Up @@ -147,6 +148,12 @@ trait IrsApiSupport implements RestitoProvider {
)
}

void verifyIrsApiTriggerJobCalledTimes(int times) {
verifyHttp(stubServer()).times(times,
post("/irs/jobs")
)
}

void verifyIrsApiTriggerJobNotCalled() {
verifyHttp(stubServer()).never(
post("/irs/jobs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import org.eclipse.tractusx.traceability.assets.infrastructure.adapters.feign.irs.model.Owner;

import java.time.Instant;
import java.util.List;
Expand Down Expand Up @@ -53,10 +54,11 @@ public final class Asset {
private final Instant manufacturingDate;
@ApiModelProperty(example = "DEU")
private final String manufacturingCountry;
@ApiModelProperty(example = "true")
private final boolean supplierPart;
@ApiModelProperty(example = "CUSTOMER")
private final Owner owner;

private List<ChildDescriptions> childDescriptions;
private List<Descriptions> childDescriptions;
private List<Descriptions> parentDescriptions;
@ApiModelProperty(example = "false")
private boolean underInvestigation;
@ApiModelProperty(example = "Ok")
Expand All @@ -77,8 +79,9 @@ public Asset(
String customerPartId,
Instant manufacturingDate,
String manufacturingCountry,
boolean supplierPart,
List<ChildDescriptions> childDescriptions,
Owner owner,
List<Descriptions> childDescriptions,
List<Descriptions> parentDescriptions,
boolean underInvestigation,
QualityType qualityType,
String van
Expand All @@ -95,8 +98,9 @@ public Asset(
this.customerPartId = customerPartId;
this.manufacturingDate = manufacturingDate;
this.manufacturingCountry = manufacturingCountry;
this.supplierPart = supplierPart;
this.owner = owner;
this.childDescriptions = childDescriptions;
this.parentDescriptions = parentDescriptions;
this.underInvestigation = underInvestigation;
this.qualityType = qualityType;
this.van = van;
Expand Down Expand Up @@ -150,18 +154,22 @@ public String getManufacturingCountry() {
return manufacturingCountry;
}

public boolean isSupplierPart() {
return supplierPart;
}
public Owner getOwner() {
return owner;
}

public String getPartInstanceId() {
public String getPartInstanceId() {
return partInstanceId;
}

public List<ChildDescriptions> getChildDescriptions() {
public List<Descriptions> getChildDescriptions() {
return childDescriptions;
}

public List<Descriptions> getParentDescriptions() {
return parentDescriptions;
}

public QualityType getQualityType() {
return qualityType;
}
Expand All @@ -170,7 +178,7 @@ public boolean isUnderInvestigation() {
return underInvestigation;
}

public record ChildDescriptions(
public record Descriptions(
@ApiModelProperty(example = "urn:uuid:a4a26b9c-9460-4cc5-8645-85916b86adb0") String id,
@ApiModelProperty(example = "null") String idShort) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,17 @@
package org.eclipse.tractusx.traceability.assets.domain.ports;

import org.eclipse.tractusx.traceability.assets.domain.model.Asset;
import org.eclipse.tractusx.traceability.assets.infrastructure.adapters.feign.irs.model.Direction;

import java.util.List;

public interface IrsRepository {
List<Asset> findAssets(String globalAssetId);
/**
* Finds a list of assets with the given global asset ID and direction.
*
* @param globalAssetId the global asset ID to search for
* @param direction the direction of the search
* @return a list of assets that match the given global asset ID and direction, or an empty list if no assets are found
*/
List<Asset> findAssets(String globalAssetId, Direction direction);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
import org.eclipse.tractusx.traceability.assets.domain.model.QualityType;
import org.eclipse.tractusx.traceability.assets.domain.ports.AssetRepository;
import org.eclipse.tractusx.traceability.assets.domain.ports.IrsRepository;
import org.eclipse.tractusx.traceability.assets.infrastructure.adapters.feign.irs.model.Direction;
import org.eclipse.tractusx.traceability.assets.infrastructure.config.async.AssetsAsyncConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -62,11 +64,13 @@ public void synchronizeAssets(String globalAssetId) {
logger.info("Synchronizing assets for globalAssetId: {}", globalAssetId);

try {
List<Asset> assets = irsRepository.findAssets(globalAssetId);

logger.info("Assets synchronization for globalAssetId: {} is done. Found {} assets. Saving them in the repository.", globalAssetId, assets.size());

assetRepository.saveAll(assets);
List<Asset> downwardAssets = irsRepository.findAssets(globalAssetId, Direction.DOWNWARD);
List<Asset> upwardAssets = irsRepository.findAssets(globalAssetId, Direction.UPWARD);
List<Asset> combinedAssetList = new ArrayList<>(upwardAssets);
combinedAssetList.addAll(downwardAssets);
logger.info("Assets synchronization for globalAssetId: {} is done. Found {} downwardAssets. Saving them in the repository.", globalAssetId, downwardAssets.size());
logger.info("Assets synchronization for globalAssetId: {} is done. Found {} upwardAssets. Saving them in the repository.", globalAssetId, upwardAssets.size());
assetRepository.saveAll(combinedAssetList);

logger.info("Assets for globalAssetId {} successfully saved.", globalAssetId);
} catch (Exception e) {
Expand All @@ -76,9 +80,7 @@ public void synchronizeAssets(String globalAssetId) {

public Asset updateQualityType(String assetId, QualityType qualityType) {
Asset foundAsset = assetRepository.getAssetById(assetId);

foundAsset.updateQualityType(qualityType);

return assetRepository.save(foundAsset);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.tractusx.traceability.assets.domain.ports.BpnRepository;
import org.eclipse.tractusx.traceability.assets.domain.ports.IrsRepository;
import org.eclipse.tractusx.traceability.assets.infrastructure.adapters.feign.irs.model.AssetsConverter;
import org.eclipse.tractusx.traceability.assets.infrastructure.adapters.feign.irs.model.Direction;
import org.eclipse.tractusx.traceability.assets.infrastructure.adapters.feign.irs.model.JobResponse;
import org.eclipse.tractusx.traceability.assets.infrastructure.adapters.feign.irs.model.JobStatus;
import org.eclipse.tractusx.traceability.assets.infrastructure.adapters.feign.irs.model.StartJobRequest;
Expand Down Expand Up @@ -52,8 +53,8 @@ public IrsService(IRSApiClient irsClient, AssetsConverter assetsConverter, BpnRe
}

@Override
public List<Asset> findAssets(String globalAssetId) {
StartJobResponse startJobResponse = irsClient.registerJob(StartJobRequest.forGlobalAssetId(globalAssetId));
public List<Asset> findAssets(String globalAssetId, Direction direction) {
StartJobResponse startJobResponse = irsClient.registerJob(StartJobRequest.buildJobRequest(globalAssetId, direction));
JobResponse jobResponse = irsClient.getJobDetails(startJobResponse.id());

JobStatus jobStatus = jobResponse.jobStatus();
Expand Down
Loading