diff options
author | 2017-07-18 19:45:38 +0300 | |
---|---|---|
committer | 2017-07-18 19:45:38 +0300 | |
commit | b8e2faf476202b6ffe61bc3a9a37df1304881d40 (patch) | |
tree | f78b8c0517d8e16c5ae610bf8b49f68ea8a312a1 /openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java | |
parent | 75aacbbe1acf78fa53378f07f0a8c7769449a17e (diff) |
[SDC] Onboarding 1710 rebase.
Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535
Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java')
21 files changed, 526 insertions, 62 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/EntitlementPoolCassandraDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/EntitlementPoolCassandraDaoImpl.java index 496e653ef0..cc32d00906 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/EntitlementPoolCassandraDaoImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/EntitlementPoolCassandraDaoImpl.java @@ -83,6 +83,11 @@ public class EntitlementPoolCassandraDaoImpl extends CassandraBaseDao<Entitlemen } @Override + public String getManufacturerReferenceNumber(EntitlementPoolEntity entitlementPoolEntity){ + return null; + } + + @Override public Collection<EntitlementPoolEntity> list(EntitlementPoolEntity entity) { return accessor.listByVlmVersion(entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion())).all(); diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LimitDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LimitDaoFactoryImpl.java new file mode 100644 index 0000000000..6189a8bf6f --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LimitDaoFactoryImpl.java @@ -0,0 +1,17 @@ +package org.openecomp.sdc.vendorlicense.dao.impl; + +import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory; +import org.openecomp.sdc.vendorlicense.dao.LimitDao; +import org.openecomp.sdc.vendorlicense.dao.LimitDaoFactory; +import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.LimitZusammenDaoImpl; + +public class LimitDaoFactoryImpl extends LimitDaoFactory { + + private static LimitDao INSTANCE = new LimitZusammenDaoImpl(ZusammenAdaptorFactory.getInstance() + .createInterface()); + + @Override + public LimitDao createInterface() { + return INSTANCE; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/ElementType.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/ElementType.java index 4d9c0fa98c..1fc941bf1b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/ElementType.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/ElementType.java @@ -1,6 +1,6 @@ package org.openecomp.sdc.vendorlicense.dao.impl.zusammen; public enum ElementType { - + Limit } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java index a31210a81a..4cccb6712a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java @@ -83,7 +83,7 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao { if (entitlmentpoolElement.getRelations() == null) { entitlmentpoolElement.setRelations(new ArrayList<>()); } - if (epFromDb.get().getRelations() != null) { + if (epFromDb.get().getRelations() != null && epFromDb.get().getRelations().size() > 0) { entitlmentpoolElement.getRelations().addAll(epFromDb.get().getRelations()); } } @@ -205,6 +205,7 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao { private ZusammenElement buildEntitlementPoolElement(EntitlementPoolEntity entitlementPool, Action action) { + ZusammenElement entitlementPoolElement = new ZusammenElement(); entitlementPoolElement.setAction(action); if (entitlementPool.getId() != null) { @@ -222,10 +223,12 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao { info.addProperty("EntitlementTime", entitlementPool.getTime()); info.addProperty("manufacturerReferenceNumber", entitlementPool.getManufacturerReferenceNumber()); + info.addProperty("startDate", entitlementPool.getStartDate()); + info.addProperty("expiryDate", entitlementPool.getExpiryDate()); entitlementPoolElement.setInfo(info); - if (entitlementPool.getReferencingFeatureGroups() != null && - entitlementPool.getReferencingFeatureGroups().size() > 0) { + if (entitlementPool.getReferencingFeatureGroups() != null + && entitlementPool.getReferencingFeatureGroups().size() > 0) { entitlementPoolElement.setRelations(entitlementPool.getReferencingFeatureGroups().stream() .map(rel -> VlmZusammenUtil .createRelation(RelationType.EntitlmentPoolToReferencingFeatureGroup, rel)) @@ -241,9 +244,12 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao { entitlmentPool.setName(elementInfo.getInfo().getName()); entitlmentPool.setDescription(elementInfo.getInfo().getDescription()); entitlmentPool - .setThresholdValue(toInteger(elementInfo.getInfo().getProperty("thresholdValue"))); - entitlmentPool.setThresholdUnit( - ThresholdUnit.valueOf(elementInfo.getInfo().getProperty("threshold_unit"))); + .setThresholdValue(elementInfo.getInfo().getProperty("thresholdValue") != null + ? VlmZusammenUtil.toInteger(elementInfo.getInfo().getProperty("thresholdValue")) : null); + + Object threshold_unit = elementInfo.getInfo().getProperty("threshold_unit"); + entitlmentPool.setThresholdUnit( threshold_unit != null ? + ThresholdUnit.valueOf(elementInfo.getInfo().getProperty("threshold_unit")) : null); entitlmentPool.setEntitlementMetric( getEntitlementMetricCoiceOrOther(elementInfo.getInfo().getProperty("entitlement_metric"))); entitlmentPool.setIncrements(elementInfo.getInfo().getProperty("increments")); @@ -255,6 +261,8 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao { getEntitlementTimeCoiceOrOther(elementInfo.getInfo().getProperty("EntitlementTime"))); entitlmentPool.setManufacturerReferenceNumber( elementInfo.getInfo().getProperty("manufacturerReferenceNumber")); + entitlmentPool.setStartDate(elementInfo.getInfo().getProperty("startDate")); + entitlmentPool.setExpiryDate(elementInfo.getInfo().getProperty("expiryDate")); if (elementInfo.getRelations() != null && elementInfo.getRelations().size() > 0) { entitlmentPool @@ -284,22 +292,31 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao { private MultiChoiceOrOther<OperationalScope> getOperationalScopeMultiChoiceOrOther (Map<String, Object> operationalScope) { - Set<OperationalScope> choices = new HashSet<>(); - ((List<String>) operationalScope.get("choices")). - forEach(choice -> choices.add(OperationalScope.valueOf(choice))); + if(operationalScope != null && !operationalScope.isEmpty()) { + Set<OperationalScope> choices = new HashSet<>(); + ((List<String>) operationalScope.get("choices")). + forEach(choice -> choices.add(OperationalScope.valueOf(choice))); - return new MultiChoiceOrOther<>(choices, (String) operationalScope.get("other")); + return new MultiChoiceOrOther<>(choices, operationalScope.get("other")==null?null: + (String) operationalScope.get("other")); + } + return null; } - private Integer toInteger(Object val) { - if (val instanceof Double) { - return ((Double) val).intValue(); - } else if (val instanceof String) { - return new Integer((String) val); - } else if (val instanceof Integer) { - return (Integer) val; + @Override + public String getManufacturerReferenceNumber(EntitlementPoolEntity entitlementPoolEntity){ + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(entitlementPoolEntity.getVendorLicenseModelId()); + ElementContext elementContext = new ElementContext(itemId, + VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VlmZusammenUtil.getVersionTag(entitlementPoolEntity.getVersion())); + Optional<ElementInfo> elementInfo1 = zusammenAdaptor.getElementInfo(context, elementContext, new Id(entitlementPoolEntity.getId())); + Map<String, Object> properties = elementInfo1.get().getInfo().getProperties(); + String manufacturerReferenceNumber = null; + if(properties != null && properties.containsKey("manufacturerReferenceNumber") ) { + manufacturerReferenceNumber = (String)properties.get("manufacturerReferenceNumber"); } - throw new RuntimeException("invalid value for integer:" + val.getClass()); + return manufacturerReferenceNumber; } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/FeatureGroupDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/FeatureGroupDaoZusammenImpl.java index 6484e83319..aa9e6c7ae0 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/FeatureGroupDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/FeatureGroupDaoZusammenImpl.java @@ -176,12 +176,13 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao { mapElementInfoToFeatureGroup(featureGroup.getId(), featureGroup.getVersion(), elementInfo.get()); - if (!(removedEntitlementPools == null)) { + if (!(removedEntitlementPools == null )) { currentFeatureGroup.getEntitlementPoolIds().removeAll(removedEntitlementPools); } if (!(addedEntitlementPools == null)) { currentFeatureGroup.getEntitlementPoolIds().addAll(addedEntitlementPools); } + if (featureGroupElement.getRelations() == null) { featureGroupElement.setRelations(new ArrayList<>()); } @@ -191,13 +192,12 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao { .createRelation(RelationType.FeatureGroupToEntitlmentPool, relation)) .collect(Collectors.toList())); - if (!(removedLicenseKeyGroups == null)) { + if (! ( removedLicenseKeyGroups == null)) { currentFeatureGroup.getLicenseKeyGroupIds().removeAll(removedLicenseKeyGroups); } - if (!(addedLicenseKeyGroups == null)) { + if (! ( addedLicenseKeyGroups == null)) { currentFeatureGroup.getLicenseKeyGroupIds().addAll(addedLicenseKeyGroups); } - currentFeatureGroup.getLicenseKeyGroupIds().addAll(addedLicenseKeyGroups); featureGroupElement.getRelations() .addAll(currentFeatureGroup.getLicenseKeyGroupIds().stream() .map(relation -> VlmZusammenUtil @@ -268,6 +268,7 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao { } private ZusammenElement buildFeatureGroupElement(FeatureGroupEntity featureGroup, Action action) { + ZusammenElement featureGroupElement = new ZusammenElement(); featureGroupElement.setAction(action); if (featureGroup.getId() != null) { @@ -277,6 +278,7 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao { info.setName(featureGroup.getName()); info.setDescription(featureGroup.getDescription()); info.addProperty("partNumber", featureGroup.getPartNumber()); + info.addProperty("manufacturerReferenceNumber", featureGroup.getManufacturerReferenceNumber()); featureGroupElement.setInfo(info); featureGroupElement.setRelations(new ArrayList<>()); @@ -308,6 +310,7 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao { .collect(Collectors.toList())); } return featureGroupElement; + } private FeatureGroupEntity mapElementInfoToFeatureGroup(String vlmId, Version version, @@ -317,6 +320,8 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao { featureGroup.setName(elementInfo.getInfo().getName()); featureGroup.setDescription(elementInfo.getInfo().getDescription()); featureGroup.setPartNumber(elementInfo.getInfo().getProperty("partNumber")); + featureGroup.setManufacturerReferenceNumber(elementInfo.getInfo() + .getProperty("manufacturerReferenceNumber")); Set<String> entitlementPoolIds = new HashSet<>(); Set<String> licenseAgreements = new HashSet<>(); diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java index f5d905cf35..95dfd79cb6 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java @@ -74,13 +74,13 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao { Optional<ElementInfo> lkgFromDb = zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseKeyGroup.getId())); - if (lkgFromDb.isPresent()) { + if(lkgFromDb.isPresent()) { - if (licenseKeyGroupElement.getRelations() == null) { - licenseKeyGroupElement.setRelations(new ArrayList<>()); + if( licenseKeyGroupElement.getRelations() == null) { + licenseKeyGroupElement.setRelations(new ArrayList<>()); } - if (lkgFromDb.get().getRelations() != null) { + if (lkgFromDb.get().getRelations() != null && lkgFromDb.get().getRelations().size() > 0) { licenseKeyGroupElement.getRelations().addAll(lkgFromDb.get().getRelations()); } } @@ -203,6 +203,7 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao { private ZusammenElement buildLicenseKeyGroupElement(LicenseKeyGroupEntity licenseKeyGroup, Action action) { + ZusammenElement lkgElement = new ZusammenElement(); lkgElement.setAction(action); if (licenseKeyGroup.getId() != null) { @@ -215,13 +216,14 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao { info.addProperty("operational_scope", licenseKeyGroup.getOperationalScope()); lkgElement.setInfo(info); - if (licenseKeyGroup.getReferencingFeatureGroups() != null && - licenseKeyGroup.getReferencingFeatureGroups().size() > 0) { + if (licenseKeyGroup.getReferencingFeatureGroups() != null + && licenseKeyGroup.getReferencingFeatureGroups().size() > 0) { lkgElement.setRelations(licenseKeyGroup.getReferencingFeatureGroups().stream() .map(rel -> VlmZusammenUtil .createRelation(RelationType.LicenseKeyGroupToReferencingFeatureGroup, rel)) .collect(Collectors.toList())); } + return lkgElement; } @@ -248,13 +250,13 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao { private MultiChoiceOrOther<OperationalScope> getOperationalScopeMultiChoiceOrOther (Map<String, Object> operationalScope) { - + if(operationalScope != null && !operationalScope.isEmpty()) { Set<OperationalScope> choices = new HashSet<>(); - ((List<String>) operationalScope.get("choices")). - forEach(choice -> choices.add(OperationalScope.valueOf(choice))); + ((List<String>) operationalScope.get("choices")) + .forEach(choice -> choices.add(OperationalScope.valueOf(choice))); - return new MultiChoiceOrOther<>(choices, (String) operationalScope.get("other")); + return new MultiChoiceOrOther<>(choices, operationalScope.get("other")==null?null:(String) operationalScope.get("other")); + } + return null; } - - } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LimitZusammenDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LimitZusammenDaoImpl.java new file mode 100644 index 0000000000..c8612bfeaa --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LimitZusammenDaoImpl.java @@ -0,0 +1,215 @@ +package org.openecomp.sdc.vendorlicense.dao.impl.zusammen; + +import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo; +import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement; +import com.amdocs.zusammen.datatypes.Id; +import com.amdocs.zusammen.datatypes.SessionContext; +import com.amdocs.zusammen.datatypes.item.Action; +import com.amdocs.zusammen.datatypes.item.ElementContext; +import com.amdocs.zusammen.datatypes.item.Info; +import org.openecomp.core.zusammen.api.ZusammenAdaptor; +import org.openecomp.core.zusammen.api.ZusammenUtil; +import org.openecomp.sdc.vendorlicense.dao.LimitDao; +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.dao.types.LimitType; +import org.openecomp.sdc.versioning.dao.types.Version; + +import java.util.Collection; +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Collectors; + +public class LimitZusammenDaoImpl implements LimitDao { + + public static final String LIMT_TYPE = "type"; + public static final String METRIC = "metric"; + public static final String AGGREGATIONFUNCTION = "aggregationfunction"; + public static final String TIME = "time"; + public static final String UNIT = "unit"; + public static final String VALUE = "value"; + private ZusammenAdaptor zusammenAdaptor; + + public LimitZusammenDaoImpl(ZusammenAdaptor zusammenAdaptor) { + this.zusammenAdaptor = zusammenAdaptor; + } + + @Override + public void create(LimitEntity limitEntity) { + ZusammenElement limitElement = limitToZusammen(limitEntity, Action.CREATE); + + ZusammenElement limitsElement = + VlmZusammenUtil.buildStructuralElement(StructureElement.Limits, null); + limitsElement.setSubElements(Collections.singletonList(limitElement)); + + ZusammenElement epLkgElement = + buildZusammenElement(new Id(limitEntity.getEpLkgId()), Action.IGNORE); + epLkgElement.setSubElements(Collections.singletonList(limitsElement)); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(limitEntity.getVendorLicenseModelId()); + ElementContext elementContext = new ElementContext(itemId, + VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + Optional<Element> savedElement = + zusammenAdaptor.saveElement(context, elementContext, epLkgElement, "Create limit"); + savedElement.ifPresent(element -> + limitEntity.setId(element.getSubElements().iterator().next() + .getSubElements().iterator().next().getElementId().getValue())); + } + + @Override + public boolean isLimitPresent(LimitEntity limitEntity) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(limitEntity.getVendorLicenseModelId()); + ElementContext elementContext = new ElementContext(itemId, + VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VlmZusammenUtil.getVersionTag(limitEntity.getVersion())); + + Collection<ElementInfo> elementInfos = zusammenAdaptor.listElementsByName(context, + elementContext, new Id(limitEntity.getEpLkgId()),StructureElement.Limits.name()); + + for (ElementInfo elementInfo : elementInfos) { + if (elementInfo.getId().getValue().equals(limitEntity.getId())) { + return true; + } + } + + return false; + } + + @Override + public Collection<LimitEntity> list(LimitEntity limitEntity) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(limitEntity.getVendorLicenseModelId()); + ElementContext elementContext = new ElementContext(itemId, + VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VlmZusammenUtil.getVersionTag(limitEntity.getVersion())); + + return listLimits(context, elementContext, limitEntity); + } + + private Collection<LimitEntity> listLimits(SessionContext context, ElementContext elementContext, + LimitEntity limitEntity) { + return zusammenAdaptor + .listElementsByName(context, elementContext, new Id(limitEntity.getEpLkgId()), + StructureElement.Limits.name()) + .stream().map(elementInfo -> mapElementInfoToLimit( + limitEntity.getVendorLicenseModelId(), limitEntity.getVersion(), + limitEntity.getEpLkgId(), elementInfo)) + .collect(Collectors.toList()); + } + + private LimitEntity mapElementInfoToLimit(String vlmId, Version version, + String epLkgId, ElementInfo elementInfo) { + LimitEntity limitEntity = + new LimitEntity(vlmId, version, epLkgId, elementInfo.getId().getValue()); + + limitEntity.setName(elementInfo.getInfo().getName()); + limitEntity.setDescription(elementInfo.getInfo().getDescription()); + limitEntity.setType( elementInfo.getInfo().getProperties().get(LIMT_TYPE) != null ? + LimitType.valueOf((String) elementInfo.getInfo().getProperties().get(LIMT_TYPE)) : + null); + limitEntity.setTime( elementInfo.getInfo().getProperties().get(TIME) != null ? + EntitlementTime.valueOf((String) elementInfo.getInfo().getProperties().get(TIME)) : + null); + limitEntity.setMetric( elementInfo.getInfo().getProperties().get(METRIC) != null ? + EntitlementMetric.valueOf((String) elementInfo.getInfo().getProperties().get(METRIC)) : + null); + limitEntity.setAggregationFunction( elementInfo.getInfo().getProperties().get + (AGGREGATIONFUNCTION) != null ? + AggregationFunction.valueOf((String) elementInfo.getInfo().getProperties() + .get(AGGREGATIONFUNCTION)) : null); + Object unit = elementInfo.getInfo().getProperties().get(UNIT); + limitEntity.setUnit(unit != null ? VlmZusammenUtil.toInteger(unit) : null); + Object value = elementInfo.getInfo().getProperties().get(VALUE); + limitEntity.setValue(value != null ? VlmZusammenUtil.toInteger(value) : null); + + return limitEntity; + } + + @Override + public void update(LimitEntity entity) { + ZusammenElement limitElement = limitToZusammen(entity, Action.UPDATE); + + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(entity.getVendorLicenseModelId()); + ElementContext elementContext = new ElementContext(itemId, + VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + zusammenAdaptor.saveElement(context,elementContext, limitElement, + String.format("Update limit with id %s", entity.getId())); + } + + @Override + public LimitEntity get(LimitEntity limitEntity) { + SessionContext context = ZusammenUtil.createSessionContext(); + Id itemId = new Id(limitEntity.getVendorLicenseModelId()); + ElementContext elementContext = new ElementContext(itemId, + VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor), + VlmZusammenUtil.getVersionTag(limitEntity.getVersion())); + + return zusammenAdaptor.getElementInfo(context, elementContext, new Id(limitEntity.getId())) + .map(elementInfo -> mapElementInfoToLimit( + limitEntity.getVendorLicenseModelId(), limitEntity.getVersion(), limitEntity + .getEpLkgId(), elementInfo)) + .orElse(null); + } + + @Override + public void delete(LimitEntity entity) { + SessionContext context = ZusammenUtil.createSessionContext(); + ZusammenElement zusammenElement = new ZusammenElement(); + zusammenElement.setAction(Action.DELETE); + zusammenElement.setElementId(new Id(entity.getId())); + + Id itemId = new Id(entity.getVendorLicenseModelId()); + ElementContext elementContext = + new ElementContext(itemId, + VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + zusammenAdaptor.saveElement(context, elementContext, zusammenElement, + "delete limit Id:" + entity.getId() + "."); + } + + @Override + public void registerVersioning(String versionableEntityType) { + + } + + private ZusammenElement limitToZusammen(LimitEntity limit, + Action action) { + ZusammenElement limitElement = buildLimitElement(limit, action); + return limitElement; + } + + private ZusammenElement buildLimitElement(LimitEntity limit, + Action action) { + ZusammenElement limitElement = new ZusammenElement(); + limitElement.setAction(action); + if (limit.getId() != null) { + limitElement.setElementId(new Id(limit.getId())); + } + + Info info = new Info(); + info.setName(limit.getName()); + info.setDescription(limit.getDescription()); + info.addProperty(LIMT_TYPE, limit.getType()); + info.addProperty(METRIC, limit.getMetric()); + info.addProperty(AGGREGATIONFUNCTION, limit.getAggregationFunction()); + info.addProperty(TIME, limit.getTime()); + info.addProperty(VALUE, limit.getValue()); + info.addProperty(UNIT, limit.getUnit()); + limitElement.setInfo(info); + return limitElement; + } + + private ZusammenElement buildZusammenElement(Id elementId, Action action) { + ZusammenElement element = new ZusammenElement(); + element.setElementId(elementId); + element.setAction(action); + return element; + } +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/StructureElement.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/StructureElement.java index 767fa52d44..3cb389936d 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/StructureElement.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/StructureElement.java @@ -5,5 +5,6 @@ public enum StructureElement { LicenseAgreements, FeatureGroups, EntitlementPools, - LicenseKeyGroups + LicenseKeyGroups, + Limits } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VlmZusammenUtil.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VlmZusammenUtil.java index b2802bee66..f16d0fae67 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VlmZusammenUtil.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/VlmZusammenUtil.java @@ -65,4 +65,15 @@ public class VlmZusammenUtil { relation.setEdge2(edge2); return relation; } + + public static Integer toInteger(Object val) { + if (val instanceof Double) { + return ((Double) val).intValue(); + } else if (val instanceof String) { + return new Integer((String) val); + } else if (val instanceof Integer) { + return (Integer) val; + } + throw new RuntimeException("invalid value for integer:" + val.getClass()); + } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java index 6f3573981c..857ee7f9fa 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java @@ -20,6 +20,11 @@ package org.openecomp.sdc.vendorlicense.facade.impl; +import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE; +import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP; +import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG; +import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_MISSING_LA; + import org.openecomp.core.util.UniqueValueUtil; import org.openecomp.core.utilities.CommonMethods; import org.openecomp.sdc.common.errors.CoreException; @@ -40,6 +45,8 @@ import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao; import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory; import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao; import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory; +import org.openecomp.sdc.vendorlicense.dao.LimitDao; +import org.openecomp.sdc.vendorlicense.dao.LimitDaoFactory; import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao; import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; @@ -48,6 +55,7 @@ import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel; import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; import org.openecomp.sdc.vendorlicense.errors.SubmitUncompletedLicenseModelErrorBuilder; import org.openecomp.sdc.vendorlicense.errors.VendorLicenseModelNotFoundErrorBuilder; @@ -67,11 +75,6 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE; -import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP; -import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG; -import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_MISSING_LA; - public class VendorLicenseFacadeImpl implements VendorLicenseFacade { private static final VersioningManager versioningManager = @@ -87,6 +90,7 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade { entitlementPoolDao = EntitlementPoolDaoFactory.getInstance().createInterface(); private static final LicenseKeyGroupDao licenseKeyGroupDao = LicenseKeyGroupDaoFactory.getInstance().createInterface(); + private static final LimitDao limitDao = LimitDaoFactory.getInstance().createInterface(); private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); /** @@ -98,6 +102,7 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade { featureGroupDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE); entitlementPoolDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE); licenseKeyGroupDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE); + limitDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE); } @Override @@ -123,6 +128,8 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade { getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Read, user), user); featureGroup.setVersion(version); + + return getFeatureGroup(featureGroup); } @@ -130,6 +137,19 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade { FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup); VersioningUtil .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE); + if(retrieved.getManufacturerReferenceNumber() == null){ + Object[] entitlementPoolIdsList = retrieved.getEntitlementPoolIds().toArray(); + if(entitlementPoolIdsList != null && entitlementPoolIdsList.length > 0){ + String entitlementPoolId = entitlementPoolIdsList[0].toString(); + EntitlementPoolEntity entitlementPoolEntity = new EntitlementPoolEntity(retrieved.getVendorLicenseModelId(), + retrieved.getVersion(), entitlementPoolId); + entitlementPoolEntity = entitlementPoolDao.get(entitlementPoolEntity); + retrieved.setManufacturerReferenceNumber(entitlementPoolDao.getManufacturerReferenceNumber( + entitlementPoolEntity)); + featureGroupDao.update(retrieved); + } + } + return retrieved; } @@ -443,6 +463,38 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade { .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user)); } + @Override + public LimitEntity createLimit(LimitEntity limit, String user) { + limit.setVersion(VersioningUtil.resolveVersion(limit.getVersion(), + getVersionInfo(limit.getVendorLicenseModelId(), VersionableEntityAction.Write, + user), user)); + //limit.setVersionUuId(CommonMethods.nextUuId()); + limitDao.create(limit); + updateVlmLastModificationTime(limit.getVendorLicenseModelId(), + limit.getVersion()); + return limit; + } + + @Override + public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId, + String user) { + return limitDao.list(new LimitEntity(vlmId, VersioningUtil + .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user), + epLkgId, null)); + + } + + @Override + public void updateLimit(LimitEntity limit, String user) { + limit.setVersion(VersioningUtil.resolveVersion(limit.getVersion(), + getVersionInfo(limit.getVendorLicenseModelId(), VersionableEntityAction.Write, + user), user)); + //limit.setVersionUuId(CommonMethods.nextUuId()); + limitDao.update(limit); + updateVlmLastModificationTime(limit.getVendorLicenseModelId(), + limit.getVersion()); + } + private LicenseAgreementEntity getLicenseAgreement(String vlmId, String licenseAgreementId, Version version) { LicenseAgreementEntity input = new LicenseAgreementEntity(vlmId, version, licenseAgreementId); diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java index 580fc6c0e5..d91a5107af 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java @@ -28,6 +28,7 @@ import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade; import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory; import org.openecomp.sdc.vendorlicense.healing.HealingService; @@ -37,6 +38,7 @@ import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.VnfLicenseArt import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.util.VendorLicenseArtifactsServiceUtils; import org.openecomp.sdc.versioning.dao.types.Version; +import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -64,19 +66,29 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts artifact.setVspId(vspId); artifact.setVendorName(vendorName); - for (String featureGroupId : featureGroups) { - FeatureGroupModel featureGroupModel = vendorLicenseFacade - .getFeatureGroupModel(new FeatureGroupEntity(vlmId, vlmVersion, featureGroupId), user); - Set<EntitlementPoolEntity> entitlementPoolEntities = featureGroupModel.getEntitlementPools(); - Set<LicenseKeyGroupEntity> licenseKeyGroupEntities = featureGroupModel.getLicenseKeyGroups(); - - featureGroupModel.setEntitlementPools(entitlementPoolEntities.stream().map( - entitlementPoolEntity -> (EntitlementPoolEntity) healingService - .heal(entitlementPoolEntity, user)).collect(Collectors.toSet())); - featureGroupModel.setLicenseKeyGroups(licenseKeyGroupEntities.stream().map( - licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService - .heal(licenseKeyGroupEntity, user)).collect(Collectors.toSet())); - artifact.getFeatureGroups().add(featureGroupModel); + if(featureGroups != null) { + for (String featureGroupId : featureGroups) { + FeatureGroupModel featureGroupModel = vendorLicenseFacade + .getFeatureGroupModel(new FeatureGroupEntity(vlmId, vlmVersion, featureGroupId), user); + Set<EntitlementPoolEntity> entitlementPoolEntities = featureGroupModel.getEntitlementPools(); + for(EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities){ + entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion, + entitlementPoolEntity.getId(), user)); + } + Set<LicenseKeyGroupEntity> licenseKeyGroupEntities = featureGroupModel.getLicenseKeyGroups(); + for(LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities){ + licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion, + licenseKeyGroupEntity.getId(), user)); + } + + featureGroupModel.setEntitlementPools(entitlementPoolEntities.stream().map( + entitlementPoolEntity -> (EntitlementPoolEntity) healingService + .heal(entitlementPoolEntity, user)).collect(Collectors.toSet())); + featureGroupModel.setLicenseKeyGroups(licenseKeyGroupEntities.stream().map( + licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService + .heal(licenseKeyGroupEntity, user)).collect(Collectors.toSet())); + artifact.getFeatureGroups().add(featureGroupModel); + } } mdcDataDebugMessage.debugExitMessage("VLM name", vendorName); @@ -95,13 +107,23 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts List<Version> finalVersions = VendorLicenseArtifactsServiceUtils.getFinalVersionsForVlm(vlmId); for (Version finalVersion : finalVersions) { - entitlementPoolEntities - .addAll(vendorLicenseFacade.listEntitlementPools(vlmId, finalVersion, user)); - licenseKeyGroupEntities - .addAll(vendorLicenseFacade.listLicenseKeyGroups(vlmId, finalVersion, user)); + Collection<EntitlementPoolEntity> coll = vendorLicenseFacade.listEntitlementPools(vlmId, + finalVersion, user); + for(EntitlementPoolEntity entitlementPoolEntity : coll){ + entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, finalVersion, + entitlementPoolEntity.getId(), user)); + } + entitlementPoolEntities.addAll(coll); + + Collection<LicenseKeyGroupEntity> coll2 = vendorLicenseFacade.listLicenseKeyGroups(vlmId, + finalVersion, user); + for(LicenseKeyGroupEntity licenseKeyGroupEntity : coll2){ + licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, finalVersion, + licenseKeyGroupEntity.getId(), user)); + } + licenseKeyGroupEntities.addAll(coll2); } - entitlementPoolEntities = VendorLicenseArtifactsServiceUtils .healEPs(user, VendorLicenseArtifactsServiceUtils.filterChangedEntities(entitlementPoolEntities)); diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/FeatureGroupForArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/FeatureGroupForArtifact.java index 6dddb9ac69..61eb474736 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/FeatureGroupForArtifact.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/FeatureGroupForArtifact.java @@ -32,6 +32,7 @@ public class FeatureGroupForArtifact { private String name; private String description; private String partNumber; + private String manufacturerReferenceNumber; private String id; public String getName() { @@ -46,6 +47,10 @@ public class FeatureGroupForArtifact { return partNumber; } + public String getManufacturerReferenceNumber(){ + return manufacturerReferenceNumber; + } + public String getId() { return id; } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VendorLicenseArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VendorLicenseArtifact.java index 589b7fa668..afc1d3151b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VendorLicenseArtifact.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VendorLicenseArtifact.java @@ -26,8 +26,10 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitXml; import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinEntitlementPoolEntityForVendorLicenseArtifact; import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLicenseKeyGroupEntityForVendorLicenseArtifact; +import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLimitArtifact; import java.util.Collection; @@ -76,5 +78,6 @@ public class VendorLicenseArtifact extends XmlArtifact { MixinEntitlementPoolEntityForVendorLicenseArtifact.class); xmlMapper.addMixIn(LicenseKeyGroupEntity.class, MixinLicenseKeyGroupEntityForVendorLicenseArtifact.class); + xmlMapper.addMixIn(LimitXml.class, MixinLimitArtifact.class); } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VnfLicenseArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VnfLicenseArtifact.java index f1da629960..b2cb710eec 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VnfLicenseArtifact.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VnfLicenseArtifact.java @@ -32,15 +32,17 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; +import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitXml; import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinEntitlementPoolEntityForVnfArtifact; import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinFeatureGroupModel; import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLicenseKeyGroupEntityForVnfArtifact; +import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLimitArtifact; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; import java.io.Writer; import java.util.ArrayList; import java.util.List; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; @JacksonXmlRootElement(localName = "vf-license-model", namespace = "http://xmlns.openecomp.org/asdc/license-model/1.0") @@ -93,5 +95,6 @@ public class VnfLicenseArtifact extends XmlArtifact { xmlMapper.addMixIn(EntitlementPoolEntity.class, MixinEntitlementPoolEntityForVnfArtifact.class); xmlMapper.addMixIn(LicenseKeyGroupEntity.class, MixinLicenseKeyGroupEntityForVnfArtifact.class); xmlMapper.addMixIn(FeatureGroupModel.class, MixinFeatureGroupModel.class); + xmlMapper.addMixIn(LimitXml.class, MixinLimitArtifact.class); } } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVendorLicenseArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVendorLicenseArtifact.java index 020316f019..936f4da2a7 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVendorLicenseArtifact.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVendorLicenseArtifact.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; @@ -28,13 +29,16 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; 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.dao.types.OperationalScope; import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction; import org.openecomp.sdc.vendorlicense.dao.types.xml.AggregationFunctionForXml; import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementMetricForXml; import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementTimeForXml; import org.openecomp.sdc.vendorlicense.dao.types.xml.ThresholdForXml; +import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitForXml; +import java.util.Collection; import java.util.Set; @JsonPropertyOrder({ "entitlement-pool-invariant-uuid", "entitlement-pool-uuid" }) @@ -60,6 +64,12 @@ public abstract class MixinEntitlementPoolEntityForVendorLicenseArtifact { @JsonProperty(value = "version") abstract String getVersionForArtifact(); + @JsonInclude(JsonInclude.Include.NON_NULL) + abstract String getStartDate(); + + @JsonInclude(JsonInclude.Include.NON_NULL) + abstract String getExpiryDate(); + @JsonIgnore abstract String getVendorLicenseModelId(); @@ -90,7 +100,6 @@ public abstract class MixinEntitlementPoolEntityForVendorLicenseArtifact { @JsonIgnore abstract ChoiceOrOther<OperationalScope> getOperationalScope(); - @JsonProperty(value = "entitlement-metric") abstract EntitlementMetricForXml getEntitlementMetricForArtifact(); @@ -101,4 +110,12 @@ public abstract class MixinEntitlementPoolEntityForVendorLicenseArtifact { @JsonProperty(value = "aggregation-function") abstract AggregationFunctionForXml getAggregationFunctionForArtifact(); + @JsonProperty(value = "sp-limits") + abstract LimitForXml getSPLimits(); + + @JsonProperty(value = "vendor-limits") + abstract LimitForXml getVendorLimits(); + + @JsonIgnore + abstract Collection<LimitEntity> getLimits(); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java index 064d17b8fa..1a29d5b2c9 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; @@ -28,12 +29,15 @@ import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction; import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; 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.dao.types.OperationalScope; import org.openecomp.sdc.vendorlicense.dao.types.xml.AggregationFunctionForXml; import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementMetricForXml; import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementTimeForXml; import org.openecomp.sdc.vendorlicense.dao.types.xml.ThresholdForXml; +import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitForXml; +import java.util.Collection; import java.util.Set; public abstract class MixinEntitlementPoolEntityForVnfArtifact { @@ -70,6 +74,12 @@ public abstract class MixinEntitlementPoolEntityForVnfArtifact { @JsonIgnore abstract float getThresholdValue(); + @JsonInclude(JsonInclude.Include.NON_NULL) + abstract String getStartDate(); + + @JsonInclude(JsonInclude.Include.NON_NULL) + abstract String getExpiryDate(); + @JsonIgnore abstract ChoiceOrOther<EntitlementMetric> getEntitlementMetric(); @@ -100,4 +110,13 @@ public abstract class MixinEntitlementPoolEntityForVnfArtifact { @JsonProperty(value = "aggregation-function") abstract AggregationFunctionForXml getAggregationFunctionForArtifact(); + @JsonProperty(value = "sp-limits") + abstract LimitForXml getSPLimits(); + + @JsonProperty(value = "vendor-limits") + abstract LimitForXml getVendorLimits(); + + @JsonIgnore + abstract Collection<LimitEntity> getLimits(); + } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupEntity.java index be6bd61357..61751b111b 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupEntity.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupEntity.java @@ -50,6 +50,9 @@ public abstract class MixinFeatureGroupEntity { abstract String getPartNumber(); @JsonIgnore + abstract String getManufacturerReferenceNumber(); + + @JsonIgnore abstract Set<String> getLicenseKeyGroupIds(); @JsonIgnore diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupModel.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupModel.java index f5eb5f0bad..75beee4c6a 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupModel.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupModel.java @@ -41,6 +41,9 @@ public abstract class MixinFeatureGroupModel { @JacksonXmlProperty(isAttribute = false, localName = "part-number") abstract String getEntityPartNumber(); + @JacksonXmlProperty(isAttribute = false, localName = "manufacturer-reference-number") + abstract String getManufacturerReferenceNumber(); + @JacksonXmlProperty(isAttribute = false, localName = "feature-group-uuid") abstract String getEntityId(); diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVendorLicenseArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVendorLicenseArtifact.java index b5fb2f4549..6238988ece 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVendorLicenseArtifact.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVendorLicenseArtifact.java @@ -25,9 +25,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope; import org.openecomp.sdc.vendorlicense.dao.types.xml.LicenseKeyTypeForXml; +import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitForXml; +import java.util.Collection; import java.util.Set; public abstract class MixinLicenseKeyGroupEntityForVendorLicenseArtifact { @@ -68,5 +71,13 @@ public abstract class MixinLicenseKeyGroupEntityForVendorLicenseArtifact { @JsonIgnore abstract String getVersionableId(); + @JsonProperty(value = "sp-limits") + abstract LimitForXml getSPLimits(); + + @JsonProperty(value = "vendor-limits") + abstract LimitForXml getVendorLimits(); + + @JsonIgnore + abstract Collection<LimitEntity> getLimits(); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVnfArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVnfArtifact.java index ed171c6a4b..80ae054db0 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVnfArtifact.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLicenseKeyGroupEntityForVnfArtifact.java @@ -25,9 +25,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; +import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope; import org.openecomp.sdc.vendorlicense.dao.types.xml.LicenseKeyTypeForXml; +import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitForXml; +import java.util.Collection; import java.util.Set; public abstract class MixinLicenseKeyGroupEntityForVnfArtifact { @@ -71,5 +74,13 @@ public abstract class MixinLicenseKeyGroupEntityForVnfArtifact { @JsonIgnore abstract String getVersionableId(); + @JsonProperty(value = "sp-limits") + abstract LimitForXml getSPLimits(); + + @JsonProperty(value = "vendor-limits") + abstract LimitForXml getVendorLimits(); + + @JsonIgnore + abstract Collection<LimitEntity> getLimits(); } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLimitArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLimitArtifact.java new file mode 100644 index 0000000000..1a15a6e557 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinLimitArtifact.java @@ -0,0 +1,42 @@ +/*- + * ============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.mixins; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.openecomp.sdc.vendorlicense.dao.types.xml.AggregationFunctionForXml; +import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementTimeForXml; + +public abstract class MixinLimitArtifact { + + @JsonIgnore + abstract String getTime(); + + @JsonIgnore + abstract String getAggregationFunction(); + + @JsonProperty(value = "aggregation-function") + abstract AggregationFunctionForXml getAggregationFunctionForArtifact(); + + @JsonProperty(value = "time") + abstract EntitlementTimeForXml getTimeForArtifact(); + +} |