package org.openecomp.sdcrests.vendorlicense.rest.mapping;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
import org.openecomp.sdcrests.mapping.MappingBase;
import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto;
target.setStartDate(source.getStartDate());
target.setExpiryDate(source.getExpiryDate());
target.setVersionUUID(source.getVersionUuId());
+ if (ToggleableFeature.MRN.isActive()) {
+ target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber());
+ }
}
}
package org.openecomp.sdcrests.vendorlicense.rest.mapping;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
import org.openecomp.sdcrests.mapping.MappingBase;
@Override
public void doMapping(EntitlementPoolRequestDto source, EntitlementPoolEntity target) {
target.setName(source.getName());
+ if (ToggleableFeature.MRN.isActive()) {
+ target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber());
+ }
target.setDescription(source.getDescription());
target.setThresholdValue(source.getThresholdValue());
target.setThresholdUnit(source.getThresholdUnits());
package org.openecomp.sdcrests.vendorlicense.rest.mapping;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
import org.openecomp.sdcrests.mapping.MappingBase;
import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto;
target.setName(source.getName());
target.setDescription(source.getDescription());
target.setPartNumber(source.getPartNumber());
- target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber());
+ if (!ToggleableFeature.MRN.isActive()) {
+ target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber());
+ }
}
}
\ No newline at end of file
package org.openecomp.sdcrests.vendorlicense.rest.mapping;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
import org.openecomp.sdcrests.mapping.MappingBase;
import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto;
target.setName(source.getName());
target.setDescription(source.getDescription());
target.setPartNumber(source.getPartNumber());
- target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber());
+ if (!ToggleableFeature.MRN.isActive()) {
+ target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber());
+ }
}
}
package org.openecomp.sdcrests.vendorlicense.rest.mapping;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
import org.openecomp.sdcrests.mapping.MappingBase;
import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto;
target.setThresholdValue(source.getThresholdValue());
target.setIncrements(source.getIncrements());
target.setVersionUUID(source.getVersionUuId());
+ if (ToggleableFeature.MRN.isActive()) {
+ target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber());
+ }
}
}
package org.openecomp.sdcrests.vendorlicense.rest.mapping;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
import org.openecomp.sdcrests.mapping.MappingBase;
@Override
public void doMapping(LicenseKeyGroupRequestDto source, LicenseKeyGroupEntity target) {
target.setName(source.getName());
+ if (ToggleableFeature.MRN.isActive()) {
+ target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber());
+ }
target.setDescription(source.getDescription());
target.setType(source.getType());
target.setOperationalScope(new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther()
package org.openecomp.sdcrests.vendorlicense.rest.services;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
import javax.inject.Named;
import javax.ws.rs.core.Response;
import java.util.Collection;
+import java.util.Objects;
@Named
@Service("entitlementPools")
*/
public Response createEntitlementPool(EntitlementPoolRequestDto request, String vlmId,
String versionId, String user) {
+ if (ToggleableFeature.MRN.isActive()) {
+ if (Objects.isNull(request.getManufacturerReferenceNumber())) {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder().withMessage("Field does not conform to "
+ + "predefined criteria : manufacturerReferenceNumber : is mandatory and should not be empty").build()));
+ }
+ }
EntitlementPoolEntity entitlementPoolEntity =
new MapEntitlementPoolRequestDtoToEntitlementPoolEntity()
.applyMapping(request, EntitlementPoolEntity.class);
package org.openecomp.sdcrests.vendorlicense.rest.services;
import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
import javax.ws.rs.core.Response;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Objects;
@Named
@Service("featureGroups")
fgDto.setLicenseKeyGroupsIds(fg.getLicenseKeyGroupIds());
fgDto.setEntitlementPoolsIds(fg.getEntitlementPoolIds());
fgDto.setReferencingLicenseAgreements(fg.getReferencingLicenseAgreements());
- fgDto.setManufacturerReferenceNumber(fg.getManufacturerReferenceNumber());
outputMapper.doMapping(fg, fgDto);
results.add(fgDto);
}
@Override
public Response createFeatureGroup(FeatureGroupRequestDto request, String vlmId, String versionId,
String user) {
+ //Below if block is introduced to have feature toggleable. This if block needs to remove when
+ // we remove toggle.
+ if (!ToggleableFeature.MRN.isActive()) {
+ if (Objects.isNull(request.getManufacturerReferenceNumber())) {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder().withMessage("Field does not " +
+ "conform to predefined criteria : manufacturerReferenceNumber : is mandatory and should not be empty").build()));
+ }
+ }
+
FeatureGroupEntity featureGroupEntity = new MapFeatureGroupDescriptorDtoToFeatureGroupEntity()
.applyMapping(request, FeatureGroupEntity.class);
featureGroupEntity.setVendorLicenseModelId(vlmId);
mapper.doMapping(source, target);
assertEquals(target.getStartDate(), param);
}
+
+ @Test
+ public void testManufacturerReferenceNumber() {
+ EntitlementPoolEntity source = new EntitlementPoolEntity();
+ EntitlementPoolEntityDto target = new EntitlementPoolEntityDto();
+ MapEntitlementPoolEntityToEntitlementPoolEntityDto mapper = new
+ MapEntitlementPoolEntityToEntitlementPoolEntityDto();
+
+ String param = "02402e1e-7092-485a-9574-46e2d49cca97";
+ source.setManufacturerReferenceNumber(param);
+ mapper.doMapping(source, target);
+ assertEquals(target.getManufacturerReferenceNumber(), param);
+ }
}
assertEquals(target.getStartDate(), param);
}
+ @Test
+ public void testManufacturerReferenceNumber() {
+ EntitlementPoolRequestDto source = new EntitlementPoolRequestDto();
+ EntitlementPoolEntity target = new EntitlementPoolEntity();
+ MapEntitlementPoolRequestDtoToEntitlementPoolEntity mapper = new
+ MapEntitlementPoolRequestDtoToEntitlementPoolEntity();
+ String param = "02402e1e-7092-485a-9574-46e2d49cca97";
+ source.setManufacturerReferenceNumber(param);
+ mapper.doMapping(source, target);
+ assertEquals(target.getManufacturerReferenceNumber(), param);
+ }
+
enum TestEnum {
Yes
}
assertEquals(target.getDescription(), param);
}
- @Test
- public void testManufacturerReferenceNumber() {
- FeatureGroupDescriptorDto source = new FeatureGroupDescriptorDto();
- FeatureGroupEntity target = new FeatureGroupEntity();
- MapFeatureGroupDescriptorDtoToFeatureGroupEntity mapper =
- new MapFeatureGroupDescriptorDtoToFeatureGroupEntity();
- String param = "6751e741-ffc2-4034-863b-f0083f62c033";
- source.setManufacturerReferenceNumber(param);
- mapper.doMapping(source, target);
- assertEquals(target.getManufacturerReferenceNumber(), param);
- }
-
@Test
public void testPartNumber() {
FeatureGroupDescriptorDto source = new FeatureGroupDescriptorDto();
public class MapFeatureGroupEntityToFeatureGroupDescriptorDtoTest {
- @Test
- public void testManufacturerReferenceNumber() {
- FeatureGroupEntity source = new FeatureGroupEntity();
- FeatureGroupDescriptorDto target = new FeatureGroupDescriptorDto();
- MapFeatureGroupEntityToFeatureGroupDescriptorDto mapper =
- new MapFeatureGroupEntityToFeatureGroupDescriptorDto();
- String param = "02402e1e-7092-485a-9574-46e2d49cca97";
- source.setManufacturerReferenceNumber(param);
- mapper.doMapping(source, target);
- assertEquals(target.getManufacturerReferenceNumber(), param);
- }
-
@Test
public void testDescription() {
FeatureGroupEntity source = new FeatureGroupEntity();
assertEquals(target.getStartDate(), param);
}
+ @Test
+ public void testManufacturerReferenceNumber() {
+ LicenseKeyGroupEntity source = new LicenseKeyGroupEntity();
+ LicenseKeyGroupEntityDto target = new LicenseKeyGroupEntityDto();
+ MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto mapper = new
+ MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto();
+ String param = "02402e1e-7092-485a-9574-46e2d49cca97";
+ source.setManufacturerReferenceNumber(param);
+ mapper.doMapping(source, target);
+ assertEquals(target.getManufacturerReferenceNumber(), param);
+ }
+
enum TestEnum {
Yes
}
mapper.doMapping(source, target);
assertEquals(target.getStartDate(), param);
}
+
+ @Test
+ public void testManufacturerReferenceNumber() {
+ LicenseKeyGroupRequestDto source = new LicenseKeyGroupRequestDto();
+ LicenseKeyGroupEntity target = new LicenseKeyGroupEntity();
+ MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity mapper = new
+ MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity();
+ String param = "02402e1e-7092-485a-9574-46e2d49cca97";
+ source.setManufacturerReferenceNumber(param);
+ mapper.doMapping(source, target);
+ assertEquals(target.getManufacturerReferenceNumber(), param);
+ }
}
import javax.validation.constraints.Size;
@ApiModel(value = "EntitlementPoolRequest")
-@JsonIgnoreProperties({"manufacturerReferenceNumber", "time", "aggregationFunction", "entitlementMetric"})
+@JsonIgnoreProperties({"time", "aggregationFunction", "entitlementMetric"})
public class EntitlementPoolRequestDto {
@NotNull
@Size(max = 120)
private String name;
+ @Size(max = 100)
+ private String manufacturerReferenceNumber;
+
@Size(max = 1000)
private String description;
this.name = name;
}
+ public String getManufacturerReferenceNumber() {
+ return manufacturerReferenceNumber;
+ }
+
+ public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) {
+ this.manufacturerReferenceNumber = manufacturerReferenceNumber;
+ }
+
public String getDescription() {
return description;
}
package org.openecomp.sdcrests.vendorlicense.types;
-import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@NotNull
private String partNumber;
- @NotBlank(message = "is mandatory and should not be empty")
+
@Size(max = 100)
private String manufacturerReferenceNumber;
@NotNull
@Size(max = 120)
private String name;
+
+ @Size(max = 100)
+ private String manufacturerReferenceNumber;
+
@Size(max = 1000)
private String description;
+
@NotNull
private LicenseKeyType type;
this.name = name;
}
+ public String getManufacturerReferenceNumber() {
+ return manufacturerReferenceNumber;
+ }
+
+ public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) {
+ this.manufacturerReferenceNumber = manufacturerReferenceNumber;
+ }
+
public String getDescription() {
return description;
}
ARCHIVE_ITEM,
@Label("Filter")
- FILTER;
+ FILTER,
+
+ @Label(("MRN"))
+ MRN;
public boolean isActive() {
return FeatureContext.getFeatureManager().isActive(this);
"vlm": {
"structure": [
"org.openecomp.sdc.healing.healers.OwnerHealer"
+ ],
+ "data": [
+ "org.openecomp.sdc.healing.healers.ManufacturerReferenceNumberHealer"
]
}
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.healing.healers;
+
+import org.openecomp.sdc.healing.interfaces.Healer;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+import java.util.Objects;
+import java.util.Set;
+
+public class ManufacturerReferenceNumberHealer implements Healer {
+
+ private static final String manufacturerReferenceNumber = "MRN";
+ private VendorLicenseFacade vendorLicenseFacade = VendorLicenseFacadeFactory.getInstance()
+ .createInterface();
+ private static final FeatureGroupDao featureGroupDao =
+ FeatureGroupDaoFactory.getInstance().createInterface();
+
+ @Override
+ public boolean isHealingNeeded(String itemId, Version version) {
+ return Objects.isNull(vendorLicenseFacade.listEntitlementPools
+ (itemId, version).iterator().next().getManufacturerReferenceNumber()) ? true :
+ false;
+ }
+
+ @Override
+ public void heal(String itemId, Version version) throws Exception {
+
+ healEntitlementPools(itemId, version);
+ healLicenseKeyGroups(itemId, version);
+ healFeatureGroups(itemId, version);
+ }
+
+ private void healEntitlementPools(String itemId, Version version) {
+ Collection<EntitlementPoolEntity> entitlementPoolEntities = vendorLicenseFacade
+ .listEntitlementPools(itemId, version);
+
+ for (EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities) {
+ Set<String> referencingFeatureGroup = entitlementPoolEntity.getReferencingFeatureGroups();
+
+ if (referencingFeatureGroup.size() == 1) {
+ entitlementPoolEntity.setManufacturerReferenceNumber(getMRN(itemId, version,
+ referencingFeatureGroup));
+ } else {
+ entitlementPoolEntity.setManufacturerReferenceNumber(manufacturerReferenceNumber);
+ }
+ vendorLicenseFacade.updateEntitlementPool(entitlementPoolEntity);
+ }
+ }
+
+ private void healLicenseKeyGroups(String itemId, Version version) {
+ Collection<LicenseKeyGroupEntity> licenseKeyGroupEntities = vendorLicenseFacade
+ .listLicenseKeyGroups(itemId, version);
+
+ for (LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
+ Set<String> referencingFeatureGroup = licenseKeyGroupEntity.getReferencingFeatureGroups();
+ if (referencingFeatureGroup.size() == 1) {
+ licenseKeyGroupEntity.setManufacturerReferenceNumber(getMRN(itemId, version,
+ referencingFeatureGroup));
+ } else {
+ licenseKeyGroupEntity.setManufacturerReferenceNumber(manufacturerReferenceNumber);
+ }
+ vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroupEntity);
+ }
+ }
+
+ private String getMRN(String itemId, Version
+ version, Set<String> referencingFeatureGroup) {
+ FeatureGroupEntity featureGroupEntity = vendorLicenseFacade.getFeatureGroup(new
+ FeatureGroupEntity(itemId, version, referencingFeatureGroup.iterator().next()));
+ return featureGroupEntity.getManufacturerReferenceNumber();
+ }
+
+ private void healFeatureGroups(String itemId, Version version) {
+
+ Collection<FeatureGroupEntity> featureGroupEntities = vendorLicenseFacade.listFeatureGroups
+ (itemId, version);
+
+ for (FeatureGroupEntity featureGroupEntity : featureGroupEntities) {
+ featureGroupEntity.setManufacturerReferenceNumber("");
+ featureGroupDao.update(featureGroupEntity);
+ }
+ }
+}
info.addProperty("operational_scope", entitlementPool.getOperationalScope());
info.addProperty("startDate", entitlementPool.getStartDate());
info.addProperty("expiryDate", entitlementPool.getExpiryDate());
+ info.addProperty("manufacturerReferenceNumber", entitlementPool.getManufacturerReferenceNumber());
entitlementPoolElement.setInfo(info);
if (entitlementPool.getReferencingFeatureGroups() != null
info.addProperty("thresholdValue", licenseKeyGroup.getThresholdValue());
info.addProperty("thresholdUnits", licenseKeyGroup.getThresholdUnits());
info.addProperty("increments", licenseKeyGroup.getIncrements());
+ info.addProperty("manufacturerReferenceNumber", licenseKeyGroup.getManufacturerReferenceNumber());
lkgElement.setInfo(info);
if (licenseKeyGroup.getReferencingFeatureGroups() != null
getOperationalScopeMultiChoiceOrOther(info.getProperty("operational_scope")));
entitlementPool.setStartDate(info.getProperty("startDate"));
entitlementPool.setExpiryDate(info.getProperty("expiryDate"));
+ entitlementPool.setManufacturerReferenceNumber(info.getProperty("manufacturerReferenceNumber"));
}
private void mapRelationsToEntitlementPoolEntity(EntitlementPoolEntity entitlementPool,
licenseKeyGroup.setThresholdValue(toInteger(info.getProperty("thresholdValue")));
licenseKeyGroup.setIncrements(info.getProperty("increments"));
+ licenseKeyGroup.setManufacturerReferenceNumber(info.getProperty("manufacturerReferenceNumber"));
}
private void mapRelationsToLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
VersioningUtil
.validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
- if (retrieved.getManufacturerReferenceNumber() == null) {
- updateManufacturerNumberInFeatureGroup(retrieved);
+ if (!ToggleableFeature.MRN.isActive()) { //Remove updateManufacturerNumberInFeatureGroup() while removing remove toggle
+ if (retrieved.getManufacturerReferenceNumber() == null) {
+ updateManufacturerNumberInFeatureGroup(retrieved);
+ }
}
return retrieved;
}
import org.apache.commons.collections.CollectionUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.vendorlicense.HealingServiceFactory;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
for (String featureGroupId : featureGroups) {
FeatureGroupModel featureGroupModel = vendorLicenseFacade
.getFeatureGroupModel(new FeatureGroupEntity(vlmId, vlmVersion, featureGroupId));
- Set<EntitlementPoolEntity> entitlementPoolEntities =
- featureGroupModel.getEntitlementPools();
- for (EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities) {
- entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
- entitlementPoolEntity.getId()));
- entitlementPoolEntity.setManufacturerReferenceNumber(featureGroupModel.
- getEntityManufacturerReferenceNumber());
- }
- Set<LicenseKeyGroupEntity> licenseKeyGroupEntities =
- featureGroupModel.getLicenseKeyGroups();
- for (LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
- licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
- licenseKeyGroupEntity.getId()));
- licenseKeyGroupEntity.setManufacturerReferenceNumber(featureGroupModel.
- getEntityManufacturerReferenceNumber());
- }
+ updateEntitlementPools(vlmId, vlmVersion, featureGroupModel);
+ updateLicenseKeyGroupEntities(vlmId, vlmVersion, featureGroupModel);
- featureGroupModel.setEntitlementPools(entitlementPoolEntities.stream().map(
- entitlementPoolEntity -> (EntitlementPoolEntity) healingService
- .heal(entitlementPoolEntity)).collect(Collectors.toSet()));
- featureGroupModel.setLicenseKeyGroups(licenseKeyGroupEntities.stream().map(
- licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService
- .heal(licenseKeyGroupEntity)).collect(Collectors.toSet()));
artifact.getFeatureGroups().add(featureGroupModel);
}
}
return artifact.toXml().getBytes();
}
+ private static void updateEntitlementPools(String vlmId, Version vlmVersion, FeatureGroupModel featureGroupModel) {
+
+ Set<EntitlementPoolEntity> entitlementPoolEntities =
+ featureGroupModel.getEntitlementPools();
+
+ for (EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities) {
+ entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
+ entitlementPoolEntity.getId()));
+ String manuFacturerReferenceNumber = featureGroupModel.getEntityManufacturerReferenceNumber();
+ if (ToggleableFeature.MRN.isActive()) {
+ if (Objects.nonNull(manuFacturerReferenceNumber)
+ && !manuFacturerReferenceNumber.trim().isEmpty()) {
+ entitlementPoolEntity.setManufacturerReferenceNumber(manuFacturerReferenceNumber);
+ }
+ } else {
+ entitlementPoolEntity.setManufacturerReferenceNumber(manuFacturerReferenceNumber);
+ }
+ }
+ featureGroupModel.setEntitlementPools(entitlementPoolEntities.stream().map(
+ entitlementPoolEntity -> (EntitlementPoolEntity) healingService
+ .heal(entitlementPoolEntity)).collect(Collectors.toSet()));
+ }
+
+ private static void updateLicenseKeyGroupEntities(String vlmId, Version vlmVersion, FeatureGroupModel featureGroupModel) {
+
+ Set<LicenseKeyGroupEntity> licenseKeyGroupEntities =
+ featureGroupModel.getLicenseKeyGroups();
+ for (LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
+ licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
+ licenseKeyGroupEntity.getId()));
+ String manuFacturerReferenceNumber = featureGroupModel.getEntityManufacturerReferenceNumber();
+ if (ToggleableFeature.MRN.isActive()) {
+ if (Objects.nonNull(manuFacturerReferenceNumber)
+ && !manuFacturerReferenceNumber.trim().isEmpty()) {
+ licenseKeyGroupEntity.setManufacturerReferenceNumber(manuFacturerReferenceNumber);
+ }
+ } else {
+ licenseKeyGroupEntity.setManufacturerReferenceNumber(manuFacturerReferenceNumber);
+ }
+ }
+
+ featureGroupModel.setLicenseKeyGroups(licenseKeyGroupEntities.stream().map(
+ licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService
+ .heal(licenseKeyGroupEntity)).collect(Collectors.toSet()));
+
+ }
+
private static byte[] createVendorLicenseArtifact(String vlmId, String vendorName) {
VendorLicenseArtifact vendorLicenseArtifact = new VendorLicenseArtifact();
vendorLicenseArtifact.setVendorName(vendorName);
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types;
-
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-public class FeatureGroupForArtifact {
- Collection<EntitlementPoolEntity> entitlementPoolEntities = new ArrayList<>();
- Collection<LicenseKeyGroupEntity> licenseKeyGroupEntities = new ArrayList<>();
- private String name;
- private String description;
- private String partNumber;
- private String manufacturerReferenceNumber;
- private String id;
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getPartNumber() {
- return partNumber;
- }
-
- public String getManufacturerReferenceNumber(){
- return manufacturerReferenceNumber;
- }
-
- public String getId() {
- return id;
- }
-
- public Collection<EntitlementPoolEntity> getEntitlementPoolEntities() {
- return entitlementPoolEntities;
- }
-
- public Collection<LicenseKeyGroupEntity> getLicenseKeyGroupEntities() {
- return licenseKeyGroupEntities;
- }
-}