aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToEntitlementPoolConvertor.java135
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToFeatureGroupConvertor.java115
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseAgreementConvertor.java108
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseKeyGroupConvertor.java141
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLimitConvertor.java56
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToVLMGeneralConvertor.java64
6 files changed, 281 insertions, 338 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/zusammen/convertor/ElementToEntitlementPoolConvertor.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/convertor/ElementToEntitlementPoolConvertor.java
index 2f06b9b0d0..202e0eac68 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/convertor/ElementToEntitlementPoolConvertor.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/convertor/ElementToEntitlementPoolConvertor.java
@@ -19,99 +19,88 @@
*/
package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+import static org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil.toInteger;
+
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.datatypes.item.Info;
import com.amdocs.zusammen.datatypes.item.Relation;
-import org.openecomp.convertor.ElementConvertor;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolType;
-import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
-import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
-import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
-
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-
-import static org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil.toInteger;
-
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolType;
+import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
+import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
public class ElementToEntitlementPoolConvertor extends ElementConvertor {
- @Override
- public EntitlementPoolEntity convert(Element element) {
- if (element == null) {
- return null;
- }
- return mapElementToEntitlementPoolEntity(element);
- }
- @Override
- public EntitlementPoolEntity convert(ElementInfo elementInfo) {
- if (elementInfo == null) {
- return null;
+ @Override
+ public EntitlementPoolEntity convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapElementToEntitlementPoolEntity(element);
}
- return mapElementInfoToEntitlementPoolEntity(elementInfo);
- }
-
- private EntitlementPoolEntity mapElementToEntitlementPoolEntity(Element element) {
- EntitlementPoolEntity entitlementPool =
- new EntitlementPoolEntity();
- entitlementPool.setId(element.getElementId().getValue());
- mapInfoToEntitlementPoolEntity(entitlementPool, element.getInfo());
- mapRelationsToEntitlementPoolEntity(entitlementPool, element.getRelations());
- return entitlementPool;
- }
- private EntitlementPoolEntity mapElementInfoToEntitlementPoolEntity(ElementInfo elementInfo) {
- EntitlementPoolEntity entitlementPool =
- new EntitlementPoolEntity();
- entitlementPool.setId(elementInfo.getId().getValue());
- mapInfoToEntitlementPoolEntity(entitlementPool, elementInfo.getInfo());
- mapRelationsToEntitlementPoolEntity(entitlementPool, elementInfo.getRelations());
- return entitlementPool;
- }
+ @Override
+ public EntitlementPoolEntity convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ return mapElementInfoToEntitlementPoolEntity(elementInfo);
+ }
- private void mapInfoToEntitlementPoolEntity(EntitlementPoolEntity entitlementPool, Info info) {
- entitlementPool.setName(info.getName());
- entitlementPool.setDescription(info.getDescription());
- entitlementPool.setVersionUuId(info.getProperty("version_uuid"));
- entitlementPool.setType(EntitlementPoolType.permissiveValueOf(info.getProperty("EntitlementPoolType")));
- entitlementPool.setThresholdValue(toInteger(info.getProperty("thresholdValue")));
- String thresholdUnit = info.getProperty("threshold_unit");
- entitlementPool
- .setThresholdUnit(thresholdUnit == null ? null : ThresholdUnit.valueOf(thresholdUnit));
- entitlementPool.setIncrements(info.getProperty("increments"));
- entitlementPool.setOperationalScope(
- getOperationalScopeMultiChoiceOrOther(info.getProperty("operational_scope")));
- entitlementPool.setStartDate(info.getProperty("startDate"));
- entitlementPool.setExpiryDate(info.getProperty("expiryDate"));
- entitlementPool.setManufacturerReferenceNumber(info.getProperty("manufacturerReferenceNumber"));
- }
+ private EntitlementPoolEntity mapElementToEntitlementPoolEntity(Element element) {
+ EntitlementPoolEntity entitlementPool = new EntitlementPoolEntity();
+ entitlementPool.setId(element.getElementId().getValue());
+ mapInfoToEntitlementPoolEntity(entitlementPool, element.getInfo());
+ mapRelationsToEntitlementPoolEntity(entitlementPool, element.getRelations());
+ return entitlementPool;
+ }
- private void mapRelationsToEntitlementPoolEntity(EntitlementPoolEntity entitlementPool,
- Collection<Relation> relations) {
- if (relations != null && relations.size() > 0) {
- entitlementPool
- .setReferencingFeatureGroups(relations.stream().map(relation -> relation
- .getEdge2().getElementId().getValue()).collect(Collectors.toSet()));
+ private EntitlementPoolEntity mapElementInfoToEntitlementPoolEntity(ElementInfo elementInfo) {
+ EntitlementPoolEntity entitlementPool = new EntitlementPoolEntity();
+ entitlementPool.setId(elementInfo.getId().getValue());
+ mapInfoToEntitlementPoolEntity(entitlementPool, elementInfo.getInfo());
+ mapRelationsToEntitlementPoolEntity(entitlementPool, elementInfo.getRelations());
+ return entitlementPool;
}
- }
- private MultiChoiceOrOther<OperationalScope> getOperationalScopeMultiChoiceOrOther(
- Map<String, Object> operationalScope) {
- if (operationalScope == null || operationalScope.isEmpty()) {
- return null;
+ private void mapInfoToEntitlementPoolEntity(EntitlementPoolEntity entitlementPool, Info info) {
+ entitlementPool.setName(info.getName());
+ entitlementPool.setDescription(info.getDescription());
+ entitlementPool.setVersionUuId(info.getProperty("version_uuid"));
+ entitlementPool.setType(EntitlementPoolType.permissiveValueOf(info.getProperty("EntitlementPoolType")));
+ entitlementPool.setThresholdValue(toInteger(info.getProperty("thresholdValue")));
+ String thresholdUnit = info.getProperty("threshold_unit");
+ entitlementPool.setThresholdUnit(thresholdUnit == null ? null : ThresholdUnit.valueOf(thresholdUnit));
+ entitlementPool.setIncrements(info.getProperty("increments"));
+ entitlementPool.setOperationalScope(getOperationalScopeMultiChoiceOrOther(info.getProperty("operational_scope")));
+ entitlementPool.setStartDate(info.getProperty("startDate"));
+ entitlementPool.setExpiryDate(info.getProperty("expiryDate"));
+ entitlementPool.setManufacturerReferenceNumber(info.getProperty("manufacturerReferenceNumber"));
}
- Set<OperationalScope> choices = new HashSet<>();
- ((List<String>) operationalScope.get("choices")).
- forEach(choice -> choices.add(OperationalScope.valueOf(choice)));
+ private void mapRelationsToEntitlementPoolEntity(EntitlementPoolEntity entitlementPool, Collection<Relation> relations) {
+ if (relations != null && relations.size() > 0) {
+ entitlementPool.setReferencingFeatureGroups(
+ relations.stream().map(relation -> relation.getEdge2().getElementId().getValue()).collect(Collectors.toSet()));
+ }
+ }
- Object other = operationalScope.get("other");
- return new MultiChoiceOrOther<>(choices, other == null ? null : (String) other);
- }
+ private MultiChoiceOrOther<OperationalScope> getOperationalScopeMultiChoiceOrOther(Map<String, Object> operationalScope) {
+ if (operationalScope == null || operationalScope.isEmpty()) {
+ return null;
+ }
+ Set<OperationalScope> choices = new HashSet<>();
+ ((List<String>) operationalScope.get("choices")).forEach(choice -> choices.add(OperationalScope.valueOf(choice)));
+ Object other = operationalScope.get("other");
+ return new MultiChoiceOrOther<>(choices, other == null ? null : (String) other);
+ }
}
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/convertor/ElementToFeatureGroupConvertor.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/convertor/ElementToFeatureGroupConvertor.java
index 95eee9704c..d12cf3d8ea 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/convertor/ElementToFeatureGroupConvertor.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/convertor/ElementToFeatureGroupConvertor.java
@@ -23,80 +23,71 @@ import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.datatypes.item.Info;
import com.amdocs.zusammen.datatypes.item.Relation;
-import org.openecomp.convertor.ElementConvertor;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.RelationType;
-import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
-
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.RelationType;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
public class ElementToFeatureGroupConvertor extends ElementConvertor {
- @Override
- public FeatureGroupEntity convert(Element element) {
- if (element == null) {
- return null;
- }
- return mapElementToFeatureGroupEntity(element);
-
- }
- @Override
- public FeatureGroupEntity convert(ElementInfo elementInfo) {
- if (elementInfo == null) {
- return null;
+ @Override
+ public FeatureGroupEntity convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapElementToFeatureGroupEntity(element);
}
- return mapElementInfoToFeatureGroupEntity(elementInfo);
-
- }
-
-
- private FeatureGroupEntity mapElementToFeatureGroupEntity(Element element) {
- FeatureGroupEntity featureGroup =
- new FeatureGroupEntity();
- featureGroup.setId(element.getElementId().getValue());
- mapInfoToFeatureGroup(featureGroup, element.getInfo());
- mapRelationsToFeatureGroup(featureGroup, element.getRelations());
- return featureGroup;
- }
+ @Override
+ public FeatureGroupEntity convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ return mapElementInfoToFeatureGroupEntity(elementInfo);
+ }
- private FeatureGroupEntity mapElementInfoToFeatureGroupEntity(ElementInfo elementInfo) {
- FeatureGroupEntity featureGroup = new FeatureGroupEntity();
- featureGroup.setId(elementInfo.getId().getValue());
- mapInfoToFeatureGroup(featureGroup, elementInfo.getInfo());
- mapRelationsToFeatureGroup(featureGroup, elementInfo.getRelations());
- return featureGroup;
- }
+ private FeatureGroupEntity mapElementToFeatureGroupEntity(Element element) {
+ FeatureGroupEntity featureGroup = new FeatureGroupEntity();
+ featureGroup.setId(element.getElementId().getValue());
+ mapInfoToFeatureGroup(featureGroup, element.getInfo());
+ mapRelationsToFeatureGroup(featureGroup, element.getRelations());
+ return featureGroup;
+ }
- private void mapInfoToFeatureGroup(FeatureGroupEntity featureGroup, Info info) {
- featureGroup.setName(info.getName());
- featureGroup.setDescription(info.getDescription());
- featureGroup.setPartNumber(info.getProperty("partNumber"));
- featureGroup.setManufacturerReferenceNumber(info.getProperty("manufacturerReferenceNumber"));
- }
+ private FeatureGroupEntity mapElementInfoToFeatureGroupEntity(ElementInfo elementInfo) {
+ FeatureGroupEntity featureGroup = new FeatureGroupEntity();
+ featureGroup.setId(elementInfo.getId().getValue());
+ mapInfoToFeatureGroup(featureGroup, elementInfo.getInfo());
+ mapRelationsToFeatureGroup(featureGroup, elementInfo.getRelations());
+ return featureGroup;
+ }
- private void mapRelationsToFeatureGroup(FeatureGroupEntity featureGroup,
- Collection<Relation> relations) {
- Set<String> entitlementPoolIds = new HashSet<>();
- Set<String> licenseAgreements = new HashSet<>();
- Set<String> licenseKeyGroupIds = new HashSet<>();
+ private void mapInfoToFeatureGroup(FeatureGroupEntity featureGroup, Info info) {
+ featureGroup.setName(info.getName());
+ featureGroup.setDescription(info.getDescription());
+ featureGroup.setPartNumber(info.getProperty("partNumber"));
+ featureGroup.setManufacturerReferenceNumber(info.getProperty("manufacturerReferenceNumber"));
+ }
- if (relations != null) {
- for (Relation relation : relations) {
- if (RelationType.FeatureGroupToEntitlmentPool.name().equals(relation.getType())) {
- entitlementPoolIds.add(relation.getEdge2().getElementId().getValue());
- } else if (RelationType.FeatureGroupToLicenseKeyGroup.name().equals(relation.getType())) {
- licenseKeyGroupIds.add(relation.getEdge2().getElementId().getValue());
- } else if (RelationType.FeatureGroupToReferencingLicenseAgreement.name()
- .equals(relation.getType())) {
- licenseAgreements.add(relation.getEdge2().getElementId().getValue());
+ private void mapRelationsToFeatureGroup(FeatureGroupEntity featureGroup, Collection<Relation> relations) {
+ Set<String> entitlementPoolIds = new HashSet<>();
+ Set<String> licenseAgreements = new HashSet<>();
+ Set<String> licenseKeyGroupIds = new HashSet<>();
+ if (relations != null) {
+ for (Relation relation : relations) {
+ if (RelationType.FeatureGroupToEntitlmentPool.name().equals(relation.getType())) {
+ entitlementPoolIds.add(relation.getEdge2().getElementId().getValue());
+ } else if (RelationType.FeatureGroupToLicenseKeyGroup.name().equals(relation.getType())) {
+ licenseKeyGroupIds.add(relation.getEdge2().getElementId().getValue());
+ } else if (RelationType.FeatureGroupToReferencingLicenseAgreement.name().equals(relation.getType())) {
+ licenseAgreements.add(relation.getEdge2().getElementId().getValue());
+ }
+ }
}
- }
+ featureGroup.setEntitlementPoolIds(entitlementPoolIds);
+ featureGroup.setLicenseKeyGroupIds(licenseKeyGroupIds);
+ featureGroup.setReferencingLicenseAgreements(licenseAgreements);
}
- featureGroup.setEntitlementPoolIds(entitlementPoolIds);
- featureGroup.setLicenseKeyGroupIds(licenseKeyGroupIds);
- featureGroup.setReferencingLicenseAgreements(licenseAgreements);
- }
}
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/convertor/ElementToLicenseAgreementConvertor.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/convertor/ElementToLicenseAgreementConvertor.java
index 0623b10b04..f217c7c4c2 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/convertor/ElementToLicenseAgreementConvertor.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/convertor/ElementToLicenseAgreementConvertor.java
@@ -23,83 +23,63 @@ import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.datatypes.item.Info;
import com.amdocs.zusammen.datatypes.item.Relation;
+import java.util.Collection;
+import java.util.Map;
+import java.util.stream.Collectors;
import org.openecomp.convertor.ElementConvertor;
import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
-import java.util.Collection;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-
public class ElementToLicenseAgreementConvertor extends ElementConvertor {
- @Override
- public LicenseAgreementEntity convert(Element element) {
- if (element == null) {
- return null;
- }
- return mapElementToLicenseAgreementEntity(element);
-
- }
-
- @Override
- public LicenseAgreementEntity convert(ElementInfo elementInfo) {
- if (elementInfo == null) {
- return null;
+ @Override
+ public LicenseAgreementEntity convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapElementToLicenseAgreementEntity(element);
}
- return mapElementInfoToLicenseAgreementEntity(elementInfo);
-
- }
-
- private LicenseAgreementEntity mapElementToLicenseAgreementEntity(Element element) {
- LicenseAgreementEntity licenseAgreement =
- new LicenseAgreementEntity();
- licenseAgreement.setId(element.getElementId().getValue());
- mapInfoToLicenseAgreementEntity(licenseAgreement, element.getInfo());
- mapRelationsToLicenseAgreementEntity(licenseAgreement, element.getRelations());
- return licenseAgreement;
- }
-
-
- private LicenseAgreementEntity mapElementInfoToLicenseAgreementEntity(ElementInfo elementInfo) {
- LicenseAgreementEntity licenseAgreement =
- new LicenseAgreementEntity();
- licenseAgreement.setId( elementInfo.getId().getValue());
- mapInfoToLicenseAgreementEntity(licenseAgreement, elementInfo.getInfo());
- mapRelationsToLicenseAgreementEntity(licenseAgreement, elementInfo.getRelations());
- return licenseAgreement;
- }
-
- private void mapRelationsToLicenseAgreementEntity(LicenseAgreementEntity licenseAgreementEntity,
- Collection<Relation> relations) {
- if (relations != null && relations.size() > 0) {
- licenseAgreementEntity.setFeatureGroupIds(relations.stream()
- .map(relation -> relation.getEdge2().getElementId().getValue())
- .collect(Collectors.toSet()));
+ @Override
+ public LicenseAgreementEntity convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ return mapElementInfoToLicenseAgreementEntity(elementInfo);
}
- }
-
- private void mapInfoToLicenseAgreementEntity(LicenseAgreementEntity licenseAgreement, Info info) {
-
-
- licenseAgreement.setName(info.getName());
- licenseAgreement.setDescription(info.getDescription());
-
- licenseAgreement
- .setLicenseTerm(getCoiceOrOther(info.getProperty("licenseTerm")));
- licenseAgreement.setRequirementsAndConstrains(
- info.getProperty("requirementsAndConstrains"));
+ private LicenseAgreementEntity mapElementToLicenseAgreementEntity(Element element) {
+ LicenseAgreementEntity licenseAgreement = new LicenseAgreementEntity();
+ licenseAgreement.setId(element.getElementId().getValue());
+ mapInfoToLicenseAgreementEntity(licenseAgreement, element.getInfo());
+ mapRelationsToLicenseAgreementEntity(licenseAgreement, element.getRelations());
+ return licenseAgreement;
+ }
- }
+ private LicenseAgreementEntity mapElementInfoToLicenseAgreementEntity(ElementInfo elementInfo) {
+ LicenseAgreementEntity licenseAgreement = new LicenseAgreementEntity();
+ licenseAgreement.setId(elementInfo.getId().getValue());
+ mapInfoToLicenseAgreementEntity(licenseAgreement, elementInfo.getInfo());
+ mapRelationsToLicenseAgreementEntity(licenseAgreement, elementInfo.getRelations());
+ return licenseAgreement;
+ }
- private ChoiceOrOther<LicenseTerm> getCoiceOrOther(Map licenseTerm) {
- return new ChoiceOrOther<>(LicenseTerm.valueOf((String) licenseTerm.get("choice")),
- (String) licenseTerm.get("other"));
- }
+ private void mapRelationsToLicenseAgreementEntity(LicenseAgreementEntity licenseAgreementEntity, Collection<Relation> relations) {
+ if (relations != null && relations.size() > 0) {
+ licenseAgreementEntity
+ .setFeatureGroupIds(relations.stream().map(relation -> relation.getEdge2().getElementId().getValue()).collect(Collectors.toSet()));
+ }
+ }
+ private void mapInfoToLicenseAgreementEntity(LicenseAgreementEntity licenseAgreement, Info info) {
+ licenseAgreement.setName(info.getName());
+ licenseAgreement.setDescription(info.getDescription());
+ licenseAgreement.setLicenseTerm(getCoiceOrOther(info.getProperty("licenseTerm")));
+ licenseAgreement.setRequirementsAndConstrains(info.getProperty("requirementsAndConstrains"));
+ }
+ private ChoiceOrOther<LicenseTerm> getCoiceOrOther(Map licenseTerm) {
+ return new ChoiceOrOther<>(LicenseTerm.valueOf((String) licenseTerm.get("choice")), (String) licenseTerm.get("other"));
+ }
}
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/convertor/ElementToLicenseKeyGroupConvertor.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/convertor/ElementToLicenseKeyGroupConvertor.java
index c22fcf8935..601a5ec35a 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/convertor/ElementToLicenseKeyGroupConvertor.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/convertor/ElementToLicenseKeyGroupConvertor.java
@@ -19,103 +19,88 @@
*/
package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+import static org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil.toInteger;
+
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.datatypes.item.Info;
import com.amdocs.zusammen.datatypes.item.Relation;
-import org.openecomp.convertor.ElementConvertor;
-import org.openecomp.sdc.vendorlicense.dao.types.*;
-
-import java.util.stream.Collectors;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
-
-import static org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VlmZusammenUtil.toInteger;
-
+import java.util.stream.Collectors;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType;
+import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
+import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit;
public class ElementToLicenseKeyGroupConvertor extends ElementConvertor {
- @Override
- public LicenseKeyGroupEntity convert(Element element) {
- if (element == null) {
- return null;
- }
- return mapElementToLicenseKeyGroupEntity(element);
- }
-
- @Override
- public LicenseKeyGroupEntity convert(ElementInfo elementInfo) {
- if (elementInfo == null) {
- return null;
+ @Override
+ public LicenseKeyGroupEntity convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapElementToLicenseKeyGroupEntity(element);
}
- return mapElementInfoToLicenseKeyGroupEntity(elementInfo);
-
- }
-
- private LicenseKeyGroupEntity mapElementToLicenseKeyGroupEntity(
- Element element) {
- LicenseKeyGroupEntity licenseKeyGroup =
- new LicenseKeyGroupEntity();
- licenseKeyGroup.setId(element.getElementId().getValue());
- mapInfoToLicenseKeyGroup(licenseKeyGroup, element.getInfo());
- mapRelationsToLicenseKeyGroup(licenseKeyGroup, element.getRelations());
- return licenseKeyGroup;
- }
-
-
- private LicenseKeyGroupEntity mapElementInfoToLicenseKeyGroupEntity(ElementInfo elementInfo) {
- LicenseKeyGroupEntity licenseKeyGroup =
- new LicenseKeyGroupEntity();
- licenseKeyGroup.setId(elementInfo.getId().getValue());
-
- mapInfoToLicenseKeyGroup(licenseKeyGroup, elementInfo.getInfo());
- mapRelationsToLicenseKeyGroup(licenseKeyGroup, elementInfo.getRelations());
- return licenseKeyGroup;
- }
- private void mapInfoToLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, Info info) {
- licenseKeyGroup.setName(info.getName());
- licenseKeyGroup.setDescription(info.getDescription());
- licenseKeyGroup.setVersionUuId(info.getProperty("version_uuid"));
- licenseKeyGroup.setType(LicenseKeyType.valueOf(info.getProperty("LicenseKeyType")));
- licenseKeyGroup.setOperationalScope(
- getOperationalScopeMultiChoiceOrOther(info.getProperty("operational_scope")));
- licenseKeyGroup.setStartDate(info.getProperty("startDate"));
- licenseKeyGroup.setExpiryDate(info.getProperty("expiryDate"));
-
- String thresholdUnit = info.getProperty("thresholdUnits");
- licenseKeyGroup
- .setThresholdUnits(thresholdUnit == null ? null : ThresholdUnit.valueOf(thresholdUnit));
+ @Override
+ public LicenseKeyGroupEntity convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ return mapElementInfoToLicenseKeyGroupEntity(elementInfo);
+ }
- licenseKeyGroup.setThresholdValue(toInteger(info.getProperty("thresholdValue")));
- licenseKeyGroup.setIncrements(info.getProperty("increments"));
- licenseKeyGroup.setManufacturerReferenceNumber(info.getProperty("manufacturerReferenceNumber"));
- }
+ private LicenseKeyGroupEntity mapElementToLicenseKeyGroupEntity(Element element) {
+ LicenseKeyGroupEntity licenseKeyGroup = new LicenseKeyGroupEntity();
+ licenseKeyGroup.setId(element.getElementId().getValue());
+ mapInfoToLicenseKeyGroup(licenseKeyGroup, element.getInfo());
+ mapRelationsToLicenseKeyGroup(licenseKeyGroup, element.getRelations());
+ return licenseKeyGroup;
+ }
- private void mapRelationsToLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
- Collection<Relation> relations) {
- if (relations != null && relations.size() > 0) {
- licenseKeyGroup
- .setReferencingFeatureGroups((relations.stream().map(relation -> relation
- .getEdge2().getElementId().getValue()).collect(Collectors.toSet())));
+ private LicenseKeyGroupEntity mapElementInfoToLicenseKeyGroupEntity(ElementInfo elementInfo) {
+ LicenseKeyGroupEntity licenseKeyGroup = new LicenseKeyGroupEntity();
+ licenseKeyGroup.setId(elementInfo.getId().getValue());
+ mapInfoToLicenseKeyGroup(licenseKeyGroup, elementInfo.getInfo());
+ mapRelationsToLicenseKeyGroup(licenseKeyGroup, elementInfo.getRelations());
+ return licenseKeyGroup;
}
- }
- private MultiChoiceOrOther<OperationalScope> getOperationalScopeMultiChoiceOrOther(
- Map<String, Object> operationalScope) {
- if (operationalScope == null || operationalScope.isEmpty()) {
- return null;
+ private void mapInfoToLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, Info info) {
+ licenseKeyGroup.setName(info.getName());
+ licenseKeyGroup.setDescription(info.getDescription());
+ licenseKeyGroup.setVersionUuId(info.getProperty("version_uuid"));
+ licenseKeyGroup.setType(LicenseKeyType.valueOf(info.getProperty("LicenseKeyType")));
+ licenseKeyGroup.setOperationalScope(getOperationalScopeMultiChoiceOrOther(info.getProperty("operational_scope")));
+ licenseKeyGroup.setStartDate(info.getProperty("startDate"));
+ licenseKeyGroup.setExpiryDate(info.getProperty("expiryDate"));
+ String thresholdUnit = info.getProperty("thresholdUnits");
+ licenseKeyGroup.setThresholdUnits(thresholdUnit == null ? null : ThresholdUnit.valueOf(thresholdUnit));
+ licenseKeyGroup.setThresholdValue(toInteger(info.getProperty("thresholdValue")));
+ licenseKeyGroup.setIncrements(info.getProperty("increments"));
+ licenseKeyGroup.setManufacturerReferenceNumber(info.getProperty("manufacturerReferenceNumber"));
}
- Set<OperationalScope> choices = new HashSet<>();
- ((List<String>) operationalScope.get("choices")).
- forEach(choice -> choices.add(OperationalScope.valueOf(choice)));
+ private void mapRelationsToLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, Collection<Relation> relations) {
+ if (relations != null && relations.size() > 0) {
+ licenseKeyGroup.setReferencingFeatureGroups(
+ (relations.stream().map(relation -> relation.getEdge2().getElementId().getValue()).collect(Collectors.toSet())));
+ }
+ }
- Object other = operationalScope.get("other");
- return new MultiChoiceOrOther<>(choices, other == null ? null : (String) other);
- }
+ private MultiChoiceOrOther<OperationalScope> getOperationalScopeMultiChoiceOrOther(Map<String, Object> operationalScope) {
+ if (operationalScope == null || operationalScope.isEmpty()) {
+ return null;
+ }
+ Set<OperationalScope> choices = new HashSet<>();
+ ((List<String>) operationalScope.get("choices")).forEach(choice -> choices.add(OperationalScope.valueOf(choice)));
+ Object other = operationalScope.get("other");
+ return new MultiChoiceOrOther<>(choices, other == null ? null : (String) other);
+ }
}
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/convertor/ElementToLimitConvertor.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/convertor/ElementToLimitConvertor.java
index 20674c669a..ace15af3bf 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/convertor/ElementToLimitConvertor.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/convertor/ElementToLimitConvertor.java
@@ -24,36 +24,36 @@ import org.openecomp.sdc.vendorlicense.dao.types.LimitType;
* Created by ayalaben on 9/26/2017
*/
public class ElementToLimitConvertor extends ElementConvertor<LimitEntity> {
- @Override
- public LimitEntity convert(Element element) {
- if (element == null) {
- return null;
- }
- return mapElementToLimitEntity(element);
- }
- private LimitEntity mapElementToLimitEntity(Element element) {
- LimitEntity limit = new LimitEntity();
- limit.setId(element.getElementId().getValue());
- limit.setName(element.getInfo().getName());
- limit.setDescription(element.getInfo().getDescription());
- limit.setUnit(element.getInfo().getProperty("unit"));
- limit.setMetric(element.getInfo().getProperty("metric"));
- limit.setValue(element.getInfo().getProperty("value"));
- limit.setTime(element.getInfo().getProperty("time"));
- limit.setAggregationFunction(element.getInfo().getProperty("aggregationFunction"));
- setLimitType(limit,element.getInfo().getProperty("type"));
+ @Override
+ public LimitEntity convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapElementToLimitEntity(element);
+ }
- return limit;
- }
+ private LimitEntity mapElementToLimitEntity(Element element) {
+ LimitEntity limit = new LimitEntity();
+ limit.setId(element.getElementId().getValue());
+ limit.setName(element.getInfo().getName());
+ limit.setDescription(element.getInfo().getDescription());
+ limit.setUnit(element.getInfo().getProperty("unit"));
+ limit.setMetric(element.getInfo().getProperty("metric"));
+ limit.setValue(element.getInfo().getProperty("value"));
+ limit.setTime(element.getInfo().getProperty("time"));
+ limit.setAggregationFunction(element.getInfo().getProperty("aggregationFunction"));
+ setLimitType(limit, element.getInfo().getProperty("type"));
+ return limit;
+ }
- private void setLimitType(LimitEntity limit, String type) {
- switch (LimitType.valueOf(type)) {
- case ServiceProvider:
- limit.setType(LimitType.ServiceProvider);
- break;
- case Vendor:
- limit.setType(LimitType.Vendor);
+ private void setLimitType(LimitEntity limit, String type) {
+ switch (LimitType.valueOf(type)) {
+ case ServiceProvider:
+ limit.setType(LimitType.ServiceProvider);
+ break;
+ case Vendor:
+ limit.setType(LimitType.Vendor);
+ }
}
- }
}
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/convertor/ElementToVLMGeneralConvertor.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/convertor/ElementToVLMGeneralConvertor.java
index 5dc3b592c0..e274e264c0 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/convertor/ElementToVLMGeneralConvertor.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/convertor/ElementToVLMGeneralConvertor.java
@@ -27,39 +27,37 @@ import org.openecomp.convertor.ElementConvertor;
import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VendorLicenseModelDaoZusammenImpl;
import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-
public class ElementToVLMGeneralConvertor extends ElementConvertor {
- @Override
- public VendorLicenseModelEntity convert(Element element) {
- if(element == null) return null;
- return mapInfoToVendorLicenseModelEntity( element.getInfo());
-
- }
-
- @Override
- public VendorLicenseModelEntity convert(Item item) {
- if(item == null) return null;
- return mapInfoToVendorLicenseModelEntity( item.getInfo());
- }
-
- @Override
- public VendorLicenseModelEntity convert(ElementInfo elementInfo) {
- if(elementInfo == null) return null;
- return mapInfoToVendorLicenseModelEntity( elementInfo.getInfo());
-
- }
-
- private VendorLicenseModelEntity mapInfoToVendorLicenseModelEntity(Info info) {
-
- VendorLicenseModelEntity vendorLicenseModelEntity = new VendorLicenseModelEntity();
-
- vendorLicenseModelEntity.setVendorName(info.getProperty(
- VendorLicenseModelDaoZusammenImpl.InfoPropertyName.name.name()));
- vendorLicenseModelEntity.setDescription(info.getProperty(
- VendorLicenseModelDaoZusammenImpl.InfoPropertyName.description.name()));
- vendorLicenseModelEntity.setIconRef(info.getProperty(
- VendorLicenseModelDaoZusammenImpl.InfoPropertyName.iconRef.name()));
- return vendorLicenseModelEntity;
- }
+ @Override
+ public VendorLicenseModelEntity convert(Element element) {
+ if (element == null) {
+ return null;
+ }
+ return mapInfoToVendorLicenseModelEntity(element.getInfo());
+ }
+
+ @Override
+ public VendorLicenseModelEntity convert(Item item) {
+ if (item == null) {
+ return null;
+ }
+ return mapInfoToVendorLicenseModelEntity(item.getInfo());
+ }
+
+ @Override
+ public VendorLicenseModelEntity convert(ElementInfo elementInfo) {
+ if (elementInfo == null) {
+ return null;
+ }
+ return mapInfoToVendorLicenseModelEntity(elementInfo.getInfo());
+ }
+
+ private VendorLicenseModelEntity mapInfoToVendorLicenseModelEntity(Info info) {
+ VendorLicenseModelEntity vendorLicenseModelEntity = new VendorLicenseModelEntity();
+ vendorLicenseModelEntity.setVendorName(info.getProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.name.name()));
+ vendorLicenseModelEntity.setDescription(info.getProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.description.name()));
+ vendorLicenseModelEntity.setIconRef(info.getProperty(VendorLicenseModelDaoZusammenImpl.InfoPropertyName.iconRef.name()));
+ return vendorLicenseModelEntity;
+ }
}