From b8e2faf476202b6ffe61bc3a9a37df1304881d40 Mon Sep 17 00:00:00 2001 From: Avi Ziv Date: Tue, 18 Jul 2017 19:45:38 +0300 Subject: [SDC] Onboarding 1710 rebase. Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535 Signed-off-by: Avi Ziv --- .../rest/mapping/LimitCreationDto.java | 13 ++++ ...lementPoolEntityToEntitlementPoolEntityDto.java | 4 +- ...ementPoolRequestDtoToEntitlementPoolEntity.java | 3 +- ...tureGroupDescriptorDtoToFeatureGroupEntity.java | 3 +- ...tureGroupEntityToFeatureGroupDescriptorDto.java | 1 + .../mapping/MapLimitEntityToLimitCreationDto.java | 12 ++++ .../rest/mapping/MapLimitEntityToLimitDto.java | 23 +++++++ .../mapping/MapLimitRequestDtoToLimitEntity.java | 75 ++++++++++++++++++++++ 8 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java create mode 100644 openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping') diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java new file mode 100644 index 0000000000..da7852da2c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java @@ -0,0 +1,13 @@ +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +public class LimitCreationDto { + private String limitId; + + public String getLimitId() { + return limitId; + } + + public void setLimitId(String limitId) { + this.limitId = limitId; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java index c9f4ab894b..d35c06c30d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java @@ -47,7 +47,9 @@ public class MapEntitlementPoolEntityToEntitlementPoolEntityDto .applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class)); target.setTime(choiceOrOtherMapper.applyMapping(source.getTime(), ChoiceOrOtherDto.class)); target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - target.setReferencingFeatureGroups(source.getReferencingFeatureGroups()); + + target.setStartDate(source.getStartDate()); + target.setExpiryDate(source.getExpiryDate()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java index fe626e374c..5442e1af61 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java @@ -45,7 +45,8 @@ public class MapEntitlementPoolRequestDtoToEntitlementPoolEntity target.setOperationalScope(new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther() .applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class)); target.setTime(choiceOrOtherMapper.applyMapping(source.getTime(), ChoiceOrOther.class)); - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); + target.setStartDate(source.getStartDate()); + target.setExpiryDate(source.getExpiryDate()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java index 9875a332bd..dedc2a01f0 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java @@ -31,5 +31,6 @@ public class MapFeatureGroupDescriptorDtoToFeatureGroupEntity target.setName(source.getName()); target.setDescription(source.getDescription()); target.setPartNumber(source.getPartNumber()); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); } -} +} \ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java index 70f5666bcb..ce69384f41 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java @@ -31,5 +31,6 @@ public class MapFeatureGroupEntityToFeatureGroupDescriptorDto target.setName(source.getName()); target.setDescription(source.getDescription()); target.setPartNumber(source.getPartNumber()); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java new file mode 100644 index 0000000000..6883f3e48c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java @@ -0,0 +1,12 @@ +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapLimitEntityToLimitCreationDto extends + MappingBase { + @Override + public void doMapping(LimitEntity source, LimitCreationDto target) { + target.setLimitId(source.getId()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java new file mode 100644 index 0000000000..9678f927b0 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java @@ -0,0 +1,23 @@ +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; + +public class MapLimitEntityToLimitDto extends MappingBase { + + @Override + public void doMapping(LimitEntity source, LimitEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setMetric(source.getMetric() != null ? source.getMetric().name() : null); + target.setAggregationFunction(source.getAggregationFunction() != null ? source + .getAggregationFunction().name() : null); + target.setTime(source.getTime() != null ? source.getTime().name() : null); + target.setType(source.getType() != null ? source.getType().name() : null); + target.setUnit(source.getUnit()); + target.setValue(source.getValue()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java new file mode 100644 index 0000000000..7f48ece1cf --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java @@ -0,0 +1,75 @@ +package org.openecomp.sdcrests.vendorlicense.rest.mapping; + +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; +import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric; +import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime; +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; +import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder; +import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes; +import org.openecomp.sdc.vendorsoftwareproduct.errors.ImageErrorBuilder; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; +import org.openecomp.sdc.vendorlicense.dao.types.LimitType; + + +public class MapLimitRequestDtoToLimitEntity extends MappingBase { + @Override + public void doMapping(LimitRequestDto source, LimitEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + try { + LimitType type = LimitType.valueOf(source.getType()); + target.setType(type); + } + catch (IllegalArgumentException exception) { + throwInvalidValueError("type", VendorLicenseErrorCodes.LIMIT_INVALID_TYPE); + } + + try { + EntitlementMetric metric = EntitlementMetric.valueOf(source.getMetric()); + target.setMetric(metric); + } + catch (IllegalArgumentException exception) { + throwInvalidValueError("metric", VendorLicenseErrorCodes.LIMIT_INVALID_METRIC); + } + + try { + AggregationFunction function = source.getAggregationFunction() != null ? + AggregationFunction.valueOf(source.getAggregationFunction()) : null; + target.setAggregationFunction(function); + } + catch (IllegalArgumentException exception) { + throwInvalidValueError("aggregationFunction", + VendorLicenseErrorCodes.LIMIT_INVALID_AGGREGATIONFUNCTION); + } + + try { + EntitlementTime time = source.getTime() != null ? + EntitlementTime.valueOf(source.getTime()) : null; + target.setTime(time); + } + catch (IllegalArgumentException exception) { + throwInvalidValueError("time", VendorLicenseErrorCodes.LIMIT_INVALID_TIME); + } + + target.setValue(source.getValue()); + target.setUnit(source.getUnit()); + + } + + private void throwInvalidValueError(String attribute, String vendorLicenseErrorCode) { + ErrorCode errorCode = LimitErrorBuilder.getInvalidValueErrorBuilder(attribute, + vendorLicenseErrorCode); + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerServiceName.Create_LIMIT.toString(), ErrorLevel.ERROR.name(), + errorCode.id(), errorCode.message() ); + throw new CoreException(errorCode); + } +} -- cgit 1.2.3-korg