Skip to content

Commit

Permalink
Merge pull request #299 from catenax-ng/main
Browse files Browse the repository at this point in the history
Handling for duplicate shell Descriptor ids
  • Loading branch information
ds-mwesener authored Sep 29, 2023
2 parents 77f5d20 + 271a02b commit e9a8ea6
Show file tree
Hide file tree
Showing 41 changed files with 547 additions and 396 deletions.
6 changes: 4 additions & 2 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
# SPDX-License-Identifier: Apache-2.0
name: "TraceX CodeQL config"

# Exclude "Unused classes and interfaces"
# Exclude "Unused classes, interfaces and rules"
query-filters:
- exclude:
id: java/unused-reference-type
id:
- java/unused-reference-type
- java/spring-disabled-csrf-protection
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- LocalStorage to be used for saving view setting
- archunit tests as preparation for good quality architecture checks
- safety and security doc including roles matrix
- handling for duplicate shellDescriptor ids when refreshing registry
- Extendend testdata to reflect better overview of assets

### Changed
- added sorting for /api/investigations received and created endpoints
- added sorting for /api/alerts received and created endpoints
- integration tests uses flyway now rather than hibernate schema auto creation
- irs helm updated from 6.5.0 to 6.6.1
- BpnEntity now contains BpnEdcMappingEntity fields
- Directories of bpnEntity to match architecture
- Mapping logic of catena-x site id and manufacturerPartId for AssetsAsPlanned


### Removed
Expand Down
2 changes: 1 addition & 1 deletion DEPENDENCIES_BACKEND
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ maven/mavencentral/org.eclipse.edc/transfer-spi/0.1.3, Apache-2.0, approved, tec
maven/mavencentral/org.eclipse.edc/transform-spi/0.1.3, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/validator-spi/0.1.3, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/web-spi/0.1.3, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.tractusx.irs/irs-registry-client/1.2.1-20230922.131153-4, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-registry-client/1.2.1-20230928.131326-5, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.traceability/tx-backend/0.0.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.traceability/tx-models/0.0.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.flywaydb/flyway-core/9.16.3, Apache-2.0, approved, #7935
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

.other-parts-container {
@apply flex flex-col;
height: 68vh;
height: 72vh;
}

.app-bom-lifecycle-activator-container {
Expand All @@ -38,19 +38,19 @@
}

.supplier-parts-as-built-table-wrapper {
max-height: 58vh;
max-height: 51vh;
}

.supplier-parts-as-planned-table-wrapper {
max-height: 58vh;
max-height: 51vh;
}

.customer-parts-as-built-table-wrapper {
max-height: 58vh;
max-height: 51vh;
}

.customer-parts-as-planned-table-wrapper {
max-height: 58vh;
max-height: 51vh;
}

.other-parts-mat-tab-group {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
</div>
<div class="split-container-wrapper">
<as-split direction="horizontal" class="split-container">
<as-split-area [size]="bomLifecycleSize.asBuiltSize" >
<as-split-area [size]="bomLifecycleSize.asBuiltSize" class="split-area">
<div class="large-text table--header--text">{{"page.asBuiltParts" | i18n}}</div>
<div class="parts-as-built-table-wrapper">
<ng-container *viewContainer="partsAsBuilt$ | async; main: mainTmp; error: errorTmp; loading: loaderTmp"></ng-container>
<ng-template #mainTmp let-parts="view">
<div class="large-text">{{"page.asBuiltParts" | i18n}}</div>
<!-- asBuilt Parts Table-->
<app-table class="parts-asBuilt-table"
[PartsPaginationData]="parts.data | formatPaginationSemanticDataModelToCamelCase"
Expand All @@ -48,11 +48,11 @@
</ng-template>
</div>
</as-split-area>
<as-split-area [size]="bomLifecycleSize.asPlannedSize">
<as-split-area [size]="bomLifecycleSize.asPlannedSize" class="split-area">
<div class="large-text table--header--text">{{"page.asPlannedParts" | i18n}}</div>
<div class="parts-as-planned-table-wrapper">
<ng-container *viewContainer="partsAsPlanned$ | async; main: myTmp; error: errorTmp; loading: loaderTmp"></ng-container>
<ng-template #myTmp let-parts="view">
<div class="large-text">{{"page.asPlannedParts" | i18n}}</div>
<!-- asPlanned Parts Table-->
<app-table class="parts-asPlanned-table"
[PartsPaginationData]="parts.data | formatPaginationSemanticDataModelToCamelCase"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,24 @@
}

.split-container-wrapper {
height: 68vh;
height: 65vh;
}

// TODO: fix bottom shadow of parts Table
.parts-as-built-table-wrapper {
max-height: 58vh;
max-height: 52vh;
margin: 16px;
overflow: auto;
box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12);
}

.split-area {
overflow-x: auto !important;
}

.parts-as-planned-table-wrapper {
max-height: 58vh;
max-height: 52vh;
overflow: auto;
margin: 16px;
box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.2), 0px 8px 10px 1px rgba(0, 0, 0, 0.14), 0px 3px 14px 2px rgba(0, 0, 0, 0.12);
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static List<DetailAspectModel> from(AssetAsPlannedEntity entity) {
DetailAspectModel partSiteInfo = DetailAspectModel.builder()
.type(DetailAspectType.PART_SITE_INFORMATION_AS_PLANNED)
.data(DetailAspectDataPartSiteInformationAsPlanned.builder()
.catenaXSiteId(entity.getId())
.catenaXSiteId(entity.getCatenaxSiteId())
.functionValidFrom(entity.getFunctionValidFrom())
.function(entity.getFunction())
.functionValidUntil(entity.getFunctionValidUntil())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class AsPlannedInfo {
private String function;
private String validityPeriodFrom;
private String validityPeriodTo;
private String catenaxSiteId;

public static AsPlannedInfo from(List<DetailAspectModel> detailAspectModels) {
Optional<DetailAspectModel> asPlannedInfo = detailAspectModels
Expand Down Expand Up @@ -50,12 +51,17 @@ public static AsPlannedInfo from(List<DetailAspectModel> detailAspectModels) {
.map(org.eclipse.tractusx.traceability.assets.domain.asplanned.model.aspect.DetailAspectDataPartSiteInformationAsPlanned::getFunctionValidFrom)
.orElse("");

String catenaxSiteId = partSiteInfo.map(detailAspectModel -> (DetailAspectDataPartSiteInformationAsPlanned) detailAspectModel.getData())
.map(org.eclipse.tractusx.traceability.assets.domain.asplanned.model.aspect.DetailAspectDataPartSiteInformationAsPlanned::getCatenaXSiteId)
.orElse("");

return AsPlannedInfo.builder()
.functionValidUntil(functionValidUntil)
.functionValidFrom(functionValidFrom)
.function(function)
.validityPeriodFrom(validityPeriodFrom)
.validityPeriodTo(validityPeriodTo)
.catenaxSiteId(catenaxSiteId)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class AssetAsPlannedEntity extends AssetBaseEntity {
private String functionValidUntil;
private String function;
private String functionValidFrom;
private String catenaxSiteId;


@ElementCollection
Expand All @@ -80,15 +81,14 @@ public static class ChildDescription {
}

public static AssetAsPlannedEntity from(AssetBase asset) {
ManufacturingInfo manufacturingInfo = ManufacturingInfo.from(asset.getDetailAspectModels());
List<DetailAspectModel> detailAspectModels = asset.getDetailAspectModels();
AsPlannedInfo asPlannedInfo = AsPlannedInfo.from(detailAspectModels);

return AssetAsPlannedEntity.builder()
.id(asset.getId())
.idShort(asset.getIdShort())
.nameAtManufacturer(asset.getNameAtManufacturer())
.manufacturerPartId(manufacturingInfo.getManufacturerPartId())
.manufacturerPartId(asset.getManufacturerPartId())
.manufacturerName(asset.getManufacturerName())
.semanticModelId(asset.getSemanticModelId())
.van(asset.getVan())
Expand All @@ -100,12 +100,13 @@ public static AssetAsPlannedEntity from(AssetBase asset) {
.owner(asset.getOwner())
.classification(asset.getClassification())
.childDescriptors(asset.getChildRelations().stream()
.map(child -> new AssetAsPlannedEntity.ChildDescription(child.id(), child.idShort()))
.map(child -> new ChildDescription(child.id(), child.idShort()))
.toList())
.qualityType(asset.getQualityType())
.activeAlert(asset.isActiveAlert())
.inInvestigation(asset.isUnderInvestigation())
.semanticDataModel(SemanticDataModelEntity.from(asset.getSemanticDataModel()))
.catenaxSiteId(asPlannedInfo.getCatenaxSiteId())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,21 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
package org.eclipse.tractusx.traceability.bpn.application.mapper;

package org.eclipse.tractusx.traceability.bpn.infrastructure.rest;
import bpn.response.BpnEdcMappingResponse;
import org.eclipse.tractusx.traceability.bpn.domain.model.BpnEdcMapping;

import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;
import org.apache.commons.lang3.StringUtils;
import java.util.List;

import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
public class BpnMapper {

public class ValidUrlParameterValidator implements ConstraintValidator<ValidUrlParameter, String> {

@Override
public void initialize(ValidUrlParameter constraintAnnotation) {
// nothing to do
public static BpnEdcMappingResponse from(BpnEdcMapping bpnEdcMapping) {
return new BpnEdcMappingResponse(bpnEdcMapping.bpn(), bpnEdcMapping.url());
}

@Override
public boolean isValid(String url, ConstraintValidatorContext context) {

// do not validate notNull
if (StringUtils.isBlank(url)) {
return true;
}

try {
new URL(url).toURI();
return true;
} catch (MalformedURLException | URISyntaxException e) {
return false;
}
public static List<BpnEdcMappingResponse> from(List<BpnEdcMapping> bpnEdcMappingList) {
return bpnEdcMappingList.stream().map(bpnEdcMapping -> new BpnEdcMappingResponse(bpnEdcMapping.bpn(), bpnEdcMapping.url())).toList();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

package org.eclipse.tractusx.traceability.bpn.infrastructure.rest;
package org.eclipse.tractusx.traceability.bpn.application.rest;

import bpn.request.BpnMappingRequest;
import bpn.response.BpnEdcMappingResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
Expand All @@ -29,22 +31,15 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Size;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.traceability.bpn.domain.model.BpnEdcMapping;
import org.eclipse.tractusx.traceability.bpn.domain.service.BpnService;
import org.eclipse.tractusx.traceability.bpn.application.mapper.BpnMapper;
import org.eclipse.tractusx.traceability.bpn.domain.service.BpnServiceImpl;
import org.eclipse.tractusx.traceability.common.response.ErrorResponse;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;

Expand All @@ -54,13 +49,10 @@
@Tag(name = "BpnEdcMapping")
@RequestMapping(path = "/bpn-config")
@Validated
@RequiredArgsConstructor
public class BpnMappingController {

private final BpnService service;

public BpnMappingController(BpnService service) {
this.service = service;
}
private final BpnServiceImpl service;

@Operation(operationId = "getBpnEdcs",
summary = "Get BPN EDC URL mappings",
Expand All @@ -69,7 +61,7 @@ public BpnMappingController(BpnService service) {
security = @SecurityRequirement(name = "oAuth2", scopes = "profile email"))
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Returns the paged result found", content = @Content(
mediaType = "application/json",
array = @ArraySchema(arraySchema = @Schema(description = "BPN Mappings", implementation = BpnEdcMapping.class, additionalProperties = Schema.AdditionalPropertiesValue.FALSE), minItems = 0, maxItems = Integer.MAX_VALUE)
array = @ArraySchema(arraySchema = @Schema(description = "BPN Mappings", implementation = BpnEdcMappingResponse.class, additionalProperties = Schema.AdditionalPropertiesValue.FALSE), minItems = 0, maxItems = Integer.MAX_VALUE)
)),
@ApiResponse(
responseCode = "400",
Expand Down Expand Up @@ -114,8 +106,8 @@ public BpnMappingController(BpnService service) {
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class)))})
@GetMapping("")
public List<BpnEdcMapping> getBpnMappings() {
return service.findAllBpnMappings();
public List<BpnEdcMappingResponse> getBpnMappings() {
return BpnMapper.from(service.findAllBpnMappings());
}

@Operation(operationId = "createBpnEdcUrlMappings",
Expand All @@ -125,7 +117,7 @@ public List<BpnEdcMapping> getBpnMappings() {
security = @SecurityRequirement(name = "oAuth2", scopes = "profile email"))
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Returns the paged result found for BpnEdcMapping", content = @Content(
mediaType = "application/json",
array = @ArraySchema(arraySchema = @Schema(description = "BpnEdcMapping", implementation = BpnEdcMapping.class, additionalProperties = Schema.AdditionalPropertiesValue.FALSE), minItems = 0, maxItems = Integer.MAX_VALUE)
array = @ArraySchema(arraySchema = @Schema(description = "BpnEdcMapping", implementation = BpnEdcMappingResponse.class, additionalProperties = Schema.AdditionalPropertiesValue.FALSE), minItems = 0, maxItems = Integer.MAX_VALUE)
)),
@ApiResponse(
responseCode = "400",
Expand Down Expand Up @@ -170,9 +162,9 @@ public List<BpnEdcMapping> getBpnMappings() {
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class)))})
@PostMapping("")
public List<BpnEdcMapping> createBpnUrlMapping(@RequestBody @Valid @Size(max = 1000) List<BpnMappingRequest> bpnEdcMappings) {
public List<BpnEdcMappingResponse> createBpnUrlMapping(@RequestBody @Valid @Size(max = 1000) List<BpnMappingRequest> bpnEdcMappings) {
log.info("BpnEdcController [createBpnEdcUrlMappings]");
return service.saveAllBpnEdcMappings(bpnEdcMappings);
return BpnMapper.from(service.saveAllBpnEdcMappings(bpnEdcMappings));
}

@Operation(operationId = "updateBpnEdcMappings",
Expand All @@ -183,7 +175,7 @@ public List<BpnEdcMapping> createBpnUrlMapping(@RequestBody @Valid @Size(max = 1
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Returns the paged result found for BpnEdcMapping", content = @Content(
mediaType = "application/json",
array = @ArraySchema(arraySchema = @Schema(description = "BpnEdcMapping", implementation = BpnEdcMapping.class, additionalProperties = Schema.AdditionalPropertiesValue.FALSE), minItems = 0, maxItems = Integer.MAX_VALUE)
array = @ArraySchema(arraySchema = @Schema(description = "BpnEdcMapping", implementation = BpnEdcMappingResponse.class, additionalProperties = Schema.AdditionalPropertiesValue.FALSE), minItems = 0, maxItems = Integer.MAX_VALUE)
)),
@ApiResponse(
responseCode = "400",
Expand Down Expand Up @@ -229,9 +221,9 @@ public List<BpnEdcMapping> createBpnUrlMapping(@RequestBody @Valid @Size(max = 1
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class)))})
@PutMapping("")
public List<BpnEdcMapping> updateBpnEdcUrlMapping(@RequestBody @Valid @Size(max = 1000) List<BpnMappingRequest> bpnMappings) {
public List<BpnEdcMappingResponse> updateBpnEdcUrlMapping(@RequestBody @Valid @Size(max = 1000) List<BpnMappingRequest> bpnMappings) {
log.info("BpnEdcController [createBpnEdcUrlMappings]");
return service.updateAllBpnMappings(bpnMappings);
return BpnMapper.from(service.updateAllBpnMappings(bpnMappings));
}

@Operation(operationId = "deleteBpnEdcUrlMappings",
Expand Down
Loading

0 comments on commit e9a8ea6

Please sign in to comment.