Skip to content

Commit

Permalink
feature(chore):884 traction battery code update.
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-mwesener committed Jul 1, 2024
1 parent 2836655 commit 93f0c1c
Show file tree
Hide file tree
Showing 16 changed files with 5,115 additions and 70 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha
- #985 Added function to save Contracts based on notification contractAgreementIds into the database
- #985 Added function to filter notifications for contractAgreementIds
- #786 Added authorization as admin for submodel api & registry api
- #884 Upgraded tractionBatteryCode from 1.0.0 to 2.0.0

### Added
- #832 added policymanagement list view, creator and editor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class JsonFileValidator {
Map.entry("urn:samm:io.catenax.part_site_information_as_planned:1.0.0#PartSiteInformationAsPlanned", "/schema/semantichub/PartSiteInformationAsPlanned_1.0.0-schema.json"),
Map.entry("urn:samm:io.catenax.single_level_bom_as_built:3.0.0#SingleLevelBomAsBuilt", "/schema/semantichub/SingleLevelBomAsBuilt_3.0.0-schema.json"),
Map.entry("urn:samm:io.catenax.single_level_usage_as_built:3.0.0#SingleLevelUsageAsBuilt", "/schema/semantichub/SingleLevelUsageAsBuilt_3.0.0-schema.json"),
Map.entry("urn:samm:io.catenax.traction_battery_code:1.0.0#TractionBatteryCode", "/schema/semantichub/TractionBatteryCode_1.0.0-schema.json"),
Map.entry("urn:samm:io.catenax.traction_battery_code:2.0.0#TractionBatteryCode", "/schema/semantichub/TractionBatteryCode_2.0.0-schema.json"),
Map.entry("urn:samm:io.catenax.part_as_planned:2.0.0#PartAsPlanned", "/schema/semantichub/PartAsPlanned_2.0.0-schema.json"),
Map.entry("urn:samm:io.catenax.single_level_bom_as_planned:3.0.0#SingleLevelBomAsPlanned", "/schema/semantichub/SingleLevelBomAsPlanned_3.0.0-schema.json")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,11 @@
import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.AssetAsBuiltViewEntity;
import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.TractionBatteryCode;
import org.eclipse.tractusx.traceability.assets.infrastructure.asplanned.model.AssetAsPlannedEntity;
import org.eclipse.tractusx.traceability.assets.infrastructure.base.irs.model.response.semanticdatamodel.ManufacturingInformation;
import org.eclipse.tractusx.traceability.assets.infrastructure.base.irs.model.response.semanticdatamodel.PartTypeInformation;
import org.eclipse.tractusx.traceability.assets.infrastructure.base.irs.model.response.semanticdatamodel.Site;
import org.eclipse.tractusx.traceability.assets.infrastructure.base.irs.model.response.semanticdatamodel.ValidityPeriod;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

import static org.apache.commons.collections4.ListUtils.emptyIfNull;
import static org.eclipse.tractusx.traceability.common.date.DateUtil.toOffsetDateTime;

@Getter
Expand Down Expand Up @@ -132,44 +127,4 @@ public static List<DetailAspectModel> from(AssetAsPlannedEntity entity) {

return List.of(asPlannedInfo, partSiteInfo);
}

public static List<DetailAspectModel> extractDetailAspectModelsPartSiteInformationAsPlanned(List<Site> sites) {
List<DetailAspectModel> detailAspectModels = new ArrayList<>();
emptyIfNull(sites).forEach(site -> {
DetailAspectDataPartSiteInformationAsPlanned detailAspectDataPartSiteInformationAsPlanned = DetailAspectDataPartSiteInformationAsPlanned.builder()
.catenaXSiteId(site.catenaXSiteId())
.functionValidFrom(site.functionValidFrom())
.function(site.function())
.functionValidUntil(site.functionValidUntil())
.build();
detailAspectModels.add(DetailAspectModel.builder().data(detailAspectDataPartSiteInformationAsPlanned).type(DetailAspectType.PART_SITE_INFORMATION_AS_PLANNED).build());
});

return detailAspectModels;
}

public static DetailAspectModel extractDetailAspectModelsAsPlanned(ValidityPeriod validityPeriod) {
DetailAspectDataAsPlanned detailAspectDataAsPlanned = DetailAspectDataAsPlanned.builder()
.validityPeriodFrom(validityPeriod.validFrom())
.validityPeriodTo(validityPeriod.validTo())
.build();
return DetailAspectModel.builder().data(detailAspectDataAsPlanned).type(DetailAspectType.AS_PLANNED).build();
}

public static DetailAspectModel extractDetailAspectModelsAsBuilt(ManufacturingInformation manufacturingInformation,
PartTypeInformation partTypeInformation) {

DetailAspectDataAsBuilt detailAspectDataAsBuilt = DetailAspectDataAsBuilt.builder()
.customerPartId(partTypeInformation.customerPartId())
.manufacturingCountry(manufacturingInformation.country())
.manufacturingDate(manufacturingInformation.date())
.nameAtCustomer(partTypeInformation.nameAtCustomer())
.partId(partTypeInformation.manufacturerPartId())
.build();
return DetailAspectModel.builder().data(detailAspectDataAsBuilt).type(DetailAspectType.AS_BUILT).build();
}

public static DetailAspectModel extractDetailAspectModelTractionBatteryCode(DetailAspectDataTractionBatteryCode detailAspectDataTractionBatteryCode) {
return DetailAspectModel.builder().data(detailAspectDataTractionBatteryCode).type(DetailAspectType.TRACTION_BATTERY_CODE).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.eclipse.tractusx.traceability.generated.SingleLevelBomAsBuilt300Schema;
import org.eclipse.tractusx.traceability.generated.SingleLevelBomAsPlanned300Schema;
import org.eclipse.tractusx.traceability.generated.SingleLevelUsageAsBuilt300Schema;
import org.eclipse.tractusx.traceability.generated.TractionBatteryCode100Schema;
import org.eclipse.tractusx.traceability.generated.TractionBatteryCode200Schema;

@Getter
public class IrsSubmodel {
Expand All @@ -41,8 +41,8 @@ public class IrsSubmodel {
@JsonSubTypes.Type(value = JustInSequencePart300Schema.class, names = {
"urn:samm:io.catenax.just_in_sequence_part:3.0.0#JustInSequencePart"
}),
@JsonSubTypes.Type(value = TractionBatteryCode100Schema.class, names = {
"urn:samm:io.catenax.traction_battery_code:1.0.0#TractionBatteryCode"
@JsonSubTypes.Type(value = TractionBatteryCode200Schema.class, names = {
"urn:samm:io.catenax.traction_battery_code:2.0.0#TractionBatteryCode"
}),
@JsonSubTypes.Type(value = SingleLevelBomAsBuilt300Schema.class, names = {
"urn:samm:io.catenax.single_level_bom_as_built:3.0.0#SingleLevelBomAsBuilt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.eclipse.tractusx.traceability.assets.domain.base.model.aspect.DetailAspectType;
import org.eclipse.tractusx.traceability.assets.infrastructure.base.irs.model.response.IrsSubmodel;
import org.eclipse.tractusx.traceability.assets.infrastructure.base.irs.model.response.mapping.asbuilt.AsBuiltDetailMapper;
import org.eclipse.tractusx.traceability.generated.TractionBatteryCode100Schema;
import org.eclipse.tractusx.traceability.generated.TractionBatteryCode200Schema;
import org.springframework.stereotype.Component;

import java.util.List;
Expand All @@ -33,7 +33,7 @@
public class TractionBatteryCodeMapper implements AsBuiltDetailMapper {
@Override
public List<DetailAspectModel> extractDetailAspectModel(IrsSubmodel irsSubmodel, String globalAssetId) {
TractionBatteryCode100Schema tractionBatteryCode = (TractionBatteryCode100Schema) irsSubmodel.getPayload();
TractionBatteryCode200Schema tractionBatteryCode = (TractionBatteryCode200Schema) irsSubmodel.getPayload();

List<DetailAspectDataTractionBatteryCode.DetailAspectDataTractionBatteryCodeSubcomponent> subComponents = tractionBatteryCode.getSubcomponents().stream().map(tractionBatteryComponent -> DetailAspectDataTractionBatteryCode.DetailAspectDataTractionBatteryCodeSubcomponent
.builder()
Expand All @@ -54,7 +54,7 @@ public List<DetailAspectModel> extractDetailAspectModel(IrsSubmodel irsSubmodel,

@Override
public boolean validMapper(IrsSubmodel submodel) {
return submodel.getPayload() instanceof TractionBatteryCode100Schema;
return submodel.getPayload() instanceof TractionBatteryCode200Schema;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public enum Aspect {
PART_SITE_INFORMATION_AS_PLANNED("urn:samm:io.catenax.part_site_information_as_planned:1.0.0#PartSiteInformationAsPlanned"),
PART_AS_PLANNED("urn:samm:io.catenax.part_as_planned:2.0.0#PartAsPlanned"),
JUST_IN_SEQUENCE_PART("urn:samm:io.catenax.just_in_sequence_part:3.0.0#JustInSequencePart"),
TRACTION_BATTERY_CODE("urn:samm:io.catenax.traction_battery_code:1.0.0#TractionBatteryCode");
TRACTION_BATTERY_CODE("urn:samm:io.catenax.traction_battery_code:2.0.0#TractionBatteryCode");

private final String aspectName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
},
{
"identification": "urn:uuid:781dabcb-93e7-442d-bc38-8ba1451c0217",
"aspectType": "urn:samm:io.catenax.traction_battery_code:1.0.0#TractionBatteryCode",
"aspectType": "urn:samm:io.catenax.traction_battery_code:2.0.0#TractionBatteryCode",
"payload": {
"tractionBatteryCode": "X12MCPM27KLPCLX2M2382320",
"subcomponents": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,55 @@
"type" : "object",
"components" : {
"schemas" : {
"urn_bamm_io.catenax.traction_battery_code_1.0.0_TractionBatteryCodeTrait" : {
"urn_samm_io.catenax.traction_battery_code_2.0.0_TractionBatteryCodeTrait" : {
"type" : "string",
"description" : "The traction battery code as required by the National Standard of the People's Republic of China according to GB/T 34014-2017 published by the Standardization Administration of China (SAC). It can have a length of either 24 or 18 characters.",
"pattern" : "(^[A-Z0-9]{3}[PMC]{1}[A-GZ]{1}[A-Z0-9]{2}[A-Z0-9]{7}[1-9A-GH-NPR-Y]{1}[1-9A-C]{1}[0-9A-GH-NPR-Y]{1}[0-9]{7}$)|(^[A-Z0-9]{3}[PMC]{1}[A-GZ]{1}[A-Z0-9]{2}[1-9A-GH-NPR-Y]{1}[1-9A-C]{1}[0-9A-GH-NPR-Y]{1}[0-9]{7}[R]{1}[PMC]{1}$)"
},
"urn_bamm_io.catenax.traction_battery_code_1.0.0_ComponentTypeCharacterstic" : {
"urn_samm_io.catenax.traction_battery_code_2.0.0_ComponentTypeCharacterstic" : {
"type" : "string",
"enum" : [ "pack", "module", "cell" ]
},
"urn_bamm_io.catenax.traction_battery_code_1.0.0_TractionBatteryComponent" : {
"urn_samm_io.catenax.traction_battery_code_2.0.0_TractionBatteryComponent" : {
"description" : "A battery component like a cell or a module.",
"type" : "object",
"properties" : {
"tractionBatteryCode" : {
"description" : "Traction Battery Code identifying a single traction battery component like a pack, module or cell. ",
"$ref" : "#/components/schemas/urn_bamm_io.catenax.traction_battery_code_1.0.0_TractionBatteryCodeTrait"
"$ref" : "#/components/schemas/urn_samm_io.catenax.traction_battery_code_2.0.0_TractionBatteryCodeTrait"
},
"subcomponents" : {
"description" : "Subcomponents of the component, if applicable. The relationship between traction battery codes are as follows:\n\nIf this traction battery code is given for a cell subcomponents are not required. \nIf this traction battery code is given for a battery module a list of cells are required to be registered as subcomponents.\nIf this traction battery code is given for a battery pack a list of modules are required to be registered as subcomponents (containing each a list of cell subcomponents respectively).",
"$ref" : "#/components/schemas/urn_bamm_io.catenax.traction_battery_code_1.0.0_ComponentList"
"$ref" : "#/components/schemas/urn_samm_io.catenax.traction_battery_code_2.0.0_ComponentList"
},
"productType" : {
"description" : "The type of the battery component, e.g. a pack, a module or a cell.",
"$ref" : "#/components/schemas/urn_bamm_io.catenax.traction_battery_code_1.0.0_ComponentTypeCharacterstic"
"$ref" : "#/components/schemas/urn_samm_io.catenax.traction_battery_code_2.0.0_ComponentTypeCharacterstic"
}
},
"required" : [ "tractionBatteryCode", "productType" ]
},
"urn_bamm_io.catenax.traction_battery_code_1.0.0_ComponentList" : {
"urn_samm_io.catenax.traction_battery_code_2.0.0_ComponentList" : {
"description" : "A list of battery components like modules or cells.",
"type" : "array",
"items" : {
"$ref" : "#/components/schemas/urn_bamm_io.catenax.traction_battery_code_1.0.0_TractionBatteryComponent"
"$ref" : "#/components/schemas/urn_samm_io.catenax.traction_battery_code_2.0.0_TractionBatteryComponent"
}
}
}
},
"properties" : {
"tractionBatteryCode" : {
"description" : "Traction Battery Code identifying a single traction battery component like a pack, module or cell. ",
"$ref" : "#/components/schemas/urn_bamm_io.catenax.traction_battery_code_1.0.0_TractionBatteryCodeTrait"
"$ref" : "#/components/schemas/urn_samm_io.catenax.traction_battery_code_2.0.0_TractionBatteryCodeTrait"
},
"subcomponents" : {
"description" : "Subcomponents of the component, if applicable. The relationship between traction battery codes are as follows:\n\nIf this traction battery code is given for a cell subcomponents are not required. \nIf this traction battery code is given for a battery module a list of cells are required to be registered as subcomponents.\nIf this traction battery code is given for a battery pack a list of modules are required to be registered as subcomponents (containing each a list of cell subcomponents respectively).",
"$ref" : "#/components/schemas/urn_bamm_io.catenax.traction_battery_code_1.0.0_ComponentList"
"$ref" : "#/components/schemas/urn_samm_io.catenax.traction_battery_code_2.0.0_ComponentList"
},
"productType" : {
"description" : "The type of the battery component, e.g. a pack, a module or a cell.",
"$ref" : "#/components/schemas/urn_bamm_io.catenax.traction_battery_code_1.0.0_ComponentTypeCharacterstic"
"$ref" : "#/components/schemas/urn_samm_io.catenax.traction_battery_code_2.0.0_ComponentTypeCharacterstic"
}
},
"required" : [ "tractionBatteryCode", "productType" ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class JsonSchemaTest {
Map.entry("urn:samm:io.catenax.part_site_information_as_planned:1.0.0#PartSiteInformationAsPlanned", "/schema/semantichub/PartSiteInformationAsPlanned_1.0.0-schema.json"),
Map.entry("urn:samm:io.catenax.single_level_bom_as_built:3.0.0#SingleLevelBomAsBuilt", "/schema/semantichub/SingleLevelBomAsBuilt_3.0.0-schema.json"),
Map.entry("urn:samm:io.catenax.single_level_usage_as_built:3.0.0#SingleLevelUsageAsBuilt", "/schema/semantichub/SingleLevelUsageAsBuilt_3.0.0-schema.json"),
Map.entry("urn:samm:io.catenax.traction_battery_code:1.0.0#TractionBatteryCode", "/schema/semantichub/TractionBatteryCode_1.0.0-schema.json"),
Map.entry("urn:samm:io.catenax.traction_battery_code:2.0.0#TractionBatteryCode", "/schema/semantichub/TractionBatteryCode_2.0.0-schema.json"),
Map.entry("urn:samm:io.catenax.part_as_planned:2.0.0#PartAsPlanned", "/schema/semantichub/PartAsPlanned_2.0.0-schema.json"),
Map.entry("urn:samm:io.catenax.single_level_bom_as_planned:3.0.0#SingleLevelBomAsPlanned", "/schema/semantichub/SingleLevelBomAsPlanned_3.0.0-schema.json")
);
Expand Down
2 changes: 1 addition & 1 deletion tx-backend/src/test/resources/testdata/import-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@
}
},
{
"aspectType" : "urn:samm:io.catenax.traction_battery_code:1.0.0#TractionBatteryCode",
"aspectType" : "urn:samm:io.catenax.traction_battery_code:2.0.0#TractionBatteryCode",
"payload" : {
"tractionBatteryCode" : "X12MCPM27KLPCLX2M2382320",
"subcomponents" : [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@
}
},
{
"aspectType" : "urn:samm:io.catenax.traction_battery_code:1.0.0#TractionBatteryCode",
"aspectType" : "urn:samm:io.catenax.traction_battery_code:2.0.0#TractionBatteryCode",
"payload" : {
"tractionBatteryCode" : "X12MCPM27KLPCLX2M2382320",
"subcomponents" : [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@
}
},
{
"aspectType" : "urn:samm:io.catenax.traction_battery_code:1.0.0#TractionBatteryCode",
"aspectType" : "urn:samm:io.catenax.traction_battery_code:2.0.0#TractionBatteryCode",
"payload" : {
"tractionBatteryCode" : "X12MCPM27KLPCLX2M2382320",
"subcomponents" : [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@
}
},
{
"aspectType" : "urn:samm:io.catenax.traction_battery_code:1.0.0#TractionBatteryCode",
"aspectType" : "urn:samm:io.catenax.traction_battery_code:2.0.0#TractionBatteryCode",
"payload" : {
"tractionBatteryCode" : "X12MCPM27KLPCLX2M2382320",
"subcomponents" : [
Expand Down
Loading

0 comments on commit 93f0c1c

Please sign in to comment.