aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-license-lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-license-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseUtil.java28
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java61
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java63
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java50
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/VendorLicenseModelEntity.java10
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java60
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/VendorLicenseArtifactsService.java2
-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/FeatureGroupCassandraDaoImpl.java4
-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/EntitlementPoolZusammenDaoImpl.java191
-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/FeatureGroupDaoZusammenImpl.java197
-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/LicenseAgreementDaoZusammenImpl.java159
-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/LicenseKeyGroupZusammenDaoImpl.java200
-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/LimitZusammenDaoImpl.java134
-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/VendorLicenseModelDaoZusammenImpl.java111
-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/VlmZusammenUtil.java39
-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.java95
-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.java83
-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.java86
-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.java104
-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.java44
-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.java52
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java316
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java20
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java94
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/VnfLicenseArtifact.java4
-rw-r--r--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.java10
-rw-r--r--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.java14
-rw-r--r--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.java10
-rw-r--r--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.java14
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java70
31 files changed, 1268 insertions, 1059 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseUtil.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseUtil.java
new file mode 100644
index 0000000000..3ee326af4c
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseUtil.java
@@ -0,0 +1,28 @@
+package org.openecomp.sdc.vendorlicense;
+
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+
+public class VendorLicenseUtil {
+
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ public static String getIsoFormatDate(String inputDate) {
+ mdcDataDebugMessage.debugEntryMessage("inputDate date", inputDate);
+ String isoFormatDate = null;
+ SimpleDateFormat isoDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+ SimpleDateFormat inputDateFormat = new SimpleDateFormat("MM/dd/yyyy'T'HH:mm:ss'Z'");
+
+ try {
+ isoFormatDate = isoDateFormat.format(inputDateFormat.parse(inputDate));
+ } catch (ParseException e) {
+ mdcDataDebugMessage.debugExitMessage("parsing error", isoFormatDate);
+ isoFormatDate = null;
+ }
+
+ mdcDataDebugMessage.debugExitMessage("formatted date", isoFormatDate);
+ return isoFormatDate;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java
index 2b7b3a6ded..6c4ba90d96 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java
@@ -26,6 +26,9 @@ import com.datastax.driver.mapping.annotations.Enumerated;
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.vendorlicense.VendorLicenseUtil;
import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitForXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.OperationalScopeForXml;
@@ -40,6 +43,8 @@ import java.util.Set;
@Table(keyspace = "dox", name = "entitlement_pool")
public class EntitlementPoolEntity implements VersionableEntity {
+
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static final String ENTITY_TYPE = "Entitlement Pool";
@PartitionKey
@@ -201,7 +206,7 @@ public class EntitlementPoolEntity implements VersionableEntity {
}
public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) {
- if(operationalScope != null) {
+ if (operationalScope != null) {
operationalScope.resolveEnum(OperationalScope.class);
}
this.operationalScope = operationalScope;
@@ -220,7 +225,8 @@ public class EntitlementPoolEntity implements VersionableEntity {
}
/**
- * Gets version for artifact.
+ * Gets version for artifact.
+ *
* @return version in format suitable for artifact
*/
public String getVersionForArtifact() {
@@ -251,17 +257,18 @@ public class EntitlementPoolEntity implements VersionableEntity {
this.limits = limits;
}
- public LimitForXml getSPLimits(){
- if(limits != null){
+ public LimitForXml getSPLimits() {
+ if (limits != null) {
Set<LimitXml> hs = new HashSet<>();
- for(LimitEntity obj : limits){
- if(obj.getType().equals(LimitType.ServiceProvider)){
+ for (LimitEntity obj : limits) {
+ if (obj.getType().equals(LimitType.ServiceProvider)) {
LimitXml xmlObj = new LimitXml();
xmlObj.setDescription(obj.getDescription());
xmlObj.setMetric(obj.getMetric());
xmlObj.setValues(obj.getValue());
xmlObj.setUnit(obj.getUnit());
- xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+ xmlObj.setAggregationFunction(
+ obj.getAggregationFunction() != null ? obj.getAggregationFunction().name() : null);
xmlObj.setTime(obj.getTime());
hs.add(xmlObj);
}
@@ -274,17 +281,18 @@ public class EntitlementPoolEntity implements VersionableEntity {
return null;
}
- public LimitForXml getVendorLimits(){
- if(limits != null){
+ public LimitForXml getVendorLimits() {
+ if (limits != null) {
Set<LimitXml> hs = new HashSet<>();
- for(LimitEntity obj : limits){
- if(obj.getType().equals(LimitType.Vendor)){
+ for (LimitEntity obj : limits) {
+ if (obj.getType().equals(LimitType.Vendor)) {
LimitXml xmlObj = new LimitXml();
xmlObj.setDescription(obj.getDescription());
xmlObj.setMetric(obj.getMetric());
xmlObj.setValues(obj.getValue());
xmlObj.setUnit(obj.getUnit());
- xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+ xmlObj.setAggregationFunction(
+ obj.getAggregationFunction() != null ? obj.getAggregationFunction().name() : null);
xmlObj.setTime(obj.getTime());
hs.add(xmlObj);
}
@@ -324,7 +332,9 @@ public class EntitlementPoolEntity implements VersionableEntity {
&& Objects.equals(operationalScope, that.operationalScope)
&& Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups)
&& Objects.equals(startDate, that.startDate)
- && Objects.equals(expiryDate, that.expiryDate);
+ && Objects.equals(expiryDate, that.expiryDate)
+ && Objects.equals(manufacturerReferenceNumber, that.manufacturerReferenceNumber)
+ && Objects.equals(version, that.version);
}
@Override
@@ -354,7 +364,7 @@ public class EntitlementPoolEntity implements VersionableEntity {
public OperationalScopeForXml getOperationalScopeForArtifact() {
OperationalScopeForXml obj = new OperationalScopeForXml();
if (operationalScope != null) {
- if(operationalScope.getResults().size() > 0) {
+ if (operationalScope.getResults().size() > 0) {
obj.setValue(operationalScope.getResults());
}
}
@@ -369,4 +379,27 @@ public class EntitlementPoolEntity implements VersionableEntity {
public String getManufacturerReferenceNumber() {
return manufacturerReferenceNumber;
}
+
+ public String getIsoFormatStartDate() {
+ mdcDataDebugMessage.debugEntryMessage("start date", startDate);
+ String isoFormatStartDate = null;
+ if (!StringUtils.isEmpty(startDate)) {
+ isoFormatStartDate = VendorLicenseUtil.getIsoFormatDate(startDate);
+ mdcDataDebugMessage.debugExitMessage("start date", "iso format start date", startDate,
+ isoFormatStartDate);
+ }
+ return isoFormatStartDate;
+ }
+
+
+ public String getIsoFormatExpiryDate() {
+ mdcDataDebugMessage.debugEntryMessage("expiry date", expiryDate);
+ String isoFormatExpDate = null;
+ if (!StringUtils.isEmpty(expiryDate)) {
+ isoFormatExpDate = VendorLicenseUtil.getIsoFormatDate(expiryDate);
+ mdcDataDebugMessage.debugExitMessage("expiry date", "iso format expiry date", expiryDate,
+ isoFormatExpDate);
+ }
+ return isoFormatExpDate;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java
index 364a240498..7794aaf275 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java
@@ -26,9 +26,12 @@ import com.datastax.driver.mapping.annotations.Enumerated;
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
+import org.apache.commons.lang3.StringUtils;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.vendorlicense.VendorLicenseUtil;
import org.openecomp.sdc.vendorlicense.dao.types.xml.LicenseKeyTypeForXml;
-import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitForXml;
+import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.OperationalScopeForXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.ThresholdForXml;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -41,6 +44,8 @@ import java.util.Set;
@Table(keyspace = "dox", name = "license_key_group")
public class LicenseKeyGroupEntity implements VersionableEntity {
+
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private static final String ENTITY_TYPE = "License Key Group";
@PartitionKey
@@ -164,7 +169,7 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
}
public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) {
- if(operationalScope != null) {
+ if (operationalScope != null) {
operationalScope.resolveEnum(OperationalScope.class);
}
this.operationalScope = operationalScope;
@@ -217,17 +222,18 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
this.limits = limits;
}
- public LimitForXml getSPLimits(){
- if(limits != null){
+ public LimitForXml getSPLimits() {
+ if (limits != null) {
Set<LimitXml> hs = new HashSet<>();
- for(LimitEntity obj : limits){
- if(obj.getType().equals(LimitType.ServiceProvider)){
+ for (LimitEntity obj : limits) {
+ if (obj.getType().equals(LimitType.ServiceProvider)) {
LimitXml xmlObj = new LimitXml();
xmlObj.setDescription(obj.getDescription());
xmlObj.setMetric(obj.getMetric());
xmlObj.setValues(obj.getValue());
xmlObj.setUnit(obj.getUnit());
- xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+ xmlObj.setAggregationFunction(
+ obj.getAggregationFunction() != null ? obj.getAggregationFunction().name() : null);
xmlObj.setTime(obj.getTime());
hs.add(xmlObj);
}
@@ -240,17 +246,18 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
return null;
}
- public LimitForXml getVendorLimits(){
- if(limits != null){
+ public LimitForXml getVendorLimits() {
+ if (limits != null) {
Set<LimitXml> hs = new HashSet<>();
- for(LimitEntity obj : limits){
- if(obj.getType().equals(LimitType.Vendor)){
+ for (LimitEntity obj : limits) {
+ if (obj.getType().equals(LimitType.Vendor)) {
LimitXml xmlObj = new LimitXml();
xmlObj.setDescription(obj.getDescription());
xmlObj.setMetric(obj.getMetric());
xmlObj.setValues(obj.getValue());
xmlObj.setUnit(obj.getUnit());
- xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+ xmlObj.setAggregationFunction(
+ obj.getAggregationFunction() != null ? obj.getAggregationFunction().name() : null);
xmlObj.setTime(obj.getTime());
hs.add(xmlObj);
}
@@ -297,6 +304,7 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
}
LicenseKeyGroupEntity that = (LicenseKeyGroupEntity) obj;
return Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
+ && Objects.equals(version, that.version)
&& Objects.equals(id, that.id)
&& Objects.equals(name, that.name)
&& Objects.equals(description, that.description)
@@ -307,7 +315,8 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
&& Objects.equals(expiryDate, that.expiryDate)
&& Objects.equals(thresholdValue, that.thresholdValue)
&& Objects.equals(thresholdUnits, that.thresholdUnits)
- && Objects.equals(increments, that.increments);
+ && Objects.equals(increments, that.increments)
+ && Objects.equals(manufacturerReferenceNumber, that.manufacturerReferenceNumber);
}
@Override
@@ -337,7 +346,7 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
public OperationalScopeForXml getOperationalScopeForArtifact() {
OperationalScopeForXml obj = new OperationalScopeForXml();
if (operationalScope != null) {
- if(operationalScope.getResults().size() > 0) {
+ if (operationalScope.getResults().size() > 0) {
obj.setValue(operationalScope.getResults());
}
}
@@ -346,6 +355,7 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
/**
* Gets version for artifact.
+ *
* @return version in format suitable for artifact
*/
public String getVersionForArtifact() {
@@ -375,4 +385,29 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) {
this.manufacturerReferenceNumber = manufacturerReferenceNumber;
}
+
+ public String getIsoFormatStartDate() {
+ mdcDataDebugMessage.debugEntryMessage("start date", startDate);
+ String isoFormatStartDate = null;
+ if (!StringUtils.isEmpty(startDate)) {
+ isoFormatStartDate = VendorLicenseUtil.getIsoFormatDate(startDate);
+ mdcDataDebugMessage.debugExitMessage("start date", "iso format start date", startDate,
+ isoFormatStartDate);
+ }
+ return isoFormatStartDate;
+ }
+
+
+ public String getIsoFormatExpiryDate() {
+ mdcDataDebugMessage.debugEntryMessage("expiry date", expiryDate);
+ String isoFormatExpDate = null;
+ if (!StringUtils.isEmpty(expiryDate)) {
+ isoFormatExpDate = VendorLicenseUtil.getIsoFormatDate(expiryDate);
+ mdcDataDebugMessage.debugExitMessage("expiry date", "iso format expiry date", expiryDate,
+ isoFormatExpDate);
+ }
+ return isoFormatExpDate;
+ }
+
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java
index 58ccd5e608..0860c243b0 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitEntity.java
@@ -47,7 +47,7 @@ public class LimitEntity implements VersionableEntity {
}
public void setAggregationFunction(
- AggregationFunction aggregationFunction) {
+ AggregationFunction aggregationFunction) {
this.aggregationFunction = aggregationFunction;
}
@@ -159,7 +159,7 @@ public class LimitEntity implements VersionableEntity {
@Override
public int hashCode() {
return Objects.hash(vendorLicenseModelId, version, epLkgId, id, name, description, type,
- metric, unit, time, aggregationFunction, value);
+ metric, unit, time, aggregationFunction, value);
}
@Override
@@ -172,35 +172,35 @@ public class LimitEntity implements VersionableEntity {
}
LimitEntity that = (LimitEntity) obj;
return Objects.equals(that.unit, unit)
- && Objects.equals(that.value, value)
- && Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
- && Objects.equals(epLkgId, that.epLkgId)
- && Objects.equals(id, that.id)
- && Objects.equals(name, that.name)
- && Objects.equals(description, that.description)
- && Objects.equals(type, that.type)
- && Objects.equals(metric, that.metric)
- && Objects.equals(aggregationFunction, that.aggregationFunction);
+ && Objects.equals(that.value, value)
+ && Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
+ && Objects.equals(epLkgId, that.epLkgId)
+ && Objects.equals(id, that.id)
+ && Objects.equals(name, that.name)
+ && Objects.equals(description, that.description)
+ && Objects.equals(type, that.type)
+ && Objects.equals(metric, that.metric)
+ && Objects.equals(aggregationFunction, that.aggregationFunction);
}
@Override
public String toString() {
return "LimitEntity{"
- + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
- + ", version=" + version
- + ", epLkgId=" + epLkgId
- + ", id='" + id + '\''
- + ", name='" + name + '\''
- + ", description='" + description + '\''
- + ", type=" + type
- + ", metric=" + metric
- + ", value='" + value + '\''
- + ", unit='" + unit + '\''
- + ", aggregationFunction=" + aggregationFunction
- + ", time=" + time
-
- + '}';
+ + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
+ + ", version=" + version
+ + ", epLkgId=" + epLkgId
+ + ", id='" + id + '\''
+ + ", name='" + name + '\''
+ + ", description='" + description + '\''
+ + ", type=" + type
+ + ", metric=" + metric
+ + ", value='" + value + '\''
+ + ", unit='" + unit + '\''
+ + ", aggregationFunction=" + aggregationFunction
+ + ", time=" + time
+
+ + '}';
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/VendorLicenseModelEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/VendorLicenseModelEntity.java
index b57b850f60..05cc78f855 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/VendorLicenseModelEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/VendorLicenseModelEntity.java
@@ -45,6 +45,7 @@ public class VendorLicenseModelEntity implements VersionableEntity {
@Column(name = "vendor_name")
private String vendorName;
private String description;
+ private String oldVersion;
@Column(name = "icon")
private String iconRef;
@@ -111,6 +112,15 @@ public class VendorLicenseModelEntity implements VersionableEntity {
this.iconRef = iconRef;
}
+ public void setOldVersion(String oldVersion) {
+ this.oldVersion = oldVersion;
+ }
+
+ public String getOldVersion() {
+ return oldVersion;
+ }
+
+
@Override
public int hashCode() {
return Objects.hash(id, version, vendorName, description, iconRef);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java
index 3d27de3a88..dda42eeff3 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/facade/VendorLicenseFacade.java
@@ -29,72 +29,52 @@ 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.types.VersionedVendorLicenseModel;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import java.util.Collection;
public interface VendorLicenseFacade {
- Version checkin(String vendorLicenseModelId, String user);
-
- Version submit(String vendorLicenseModelId, String user);
-
- FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup, String user);
-
- FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user);
-
LicenseAgreementEntity getLicenseAgreement(String vlmId, Version version,
- String licenseAgreementId, String user);
+ String licenseAgreementId);
LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
- String licenseAgreementId, String user);
+ String licenseAgreementId);
+
+ LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement);
- EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
+ Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version);
- void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
+ FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup);
- Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
- String user);
+ FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup);
- Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version,
- String user);
+ FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup);
- void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version);
- LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool);
+ void updateEntitlementPool(EntitlementPoolEntity entitlementPool);
- VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version, String user);
+ Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version);
- VendorLicenseModelEntity createVendorLicenseModel(
- VendorLicenseModelEntity vendorLicenseModelEntity, String user);
+ LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
+ void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup);
- LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
- String user);
+ Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId);
- Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version,
- String user);
+ LimitEntity createLimit(LimitEntity limit);
- FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user);
+ void updateLimit(LimitEntity limit);
+
+ VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version);
Collection<ErrorCode> validateLicensingData(String vlmId, Version vlmVersion,
String licenseAgreementId,
Collection<String> featureGroupIds);
- VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action,
- String user);
-
- void updateVlmLastModificationTime(String vendorLicenseModelId, Version version);
-
- LimitEntity createLimit(LimitEntity limit, String user);
-
- Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId
- ,String user);
-
- void updateLimit(LimitEntity limit, String user);
+ void validate(String vendorLicenseModelId, Version version);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java
index 6ae2de1a63..a3a5b7263f 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/healing/HealingService.java
@@ -24,7 +24,7 @@ import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
public interface HealingService {
- VersionableEntity heal(VersionableEntity toHeal, String user);
+ VersionableEntity heal(VersionableEntity toHeal);
void persistNoHealing(VersionableEntity alreadyHealed);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/VendorLicenseArtifactsService.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/VendorLicenseArtifactsService.java
index c0610a99cd..66ac7ab33f 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/VendorLicenseArtifactsService.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/VendorLicenseArtifactsService.java
@@ -28,5 +28,5 @@ import java.util.List;
public interface VendorLicenseArtifactsService {
FileContentHandler createLicenseArtifacts(String vspId, String vlmId, Version vlmVersion,
- List<String> featureGroups, String user);
+ List<String> featureGroups);
}
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/FeatureGroupCassandraDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/FeatureGroupCassandraDaoImpl.java
index 2568d719e2..dd22397760 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/FeatureGroupCassandraDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/FeatureGroupCassandraDaoImpl.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.vendorlicense.dao.impl;
-import static org.openecomp.core.utilities.CommonMethods.toSingleElementSet;
-
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.UDTValue;
import com.datastax.driver.mapping.Mapper;
@@ -47,6 +45,8 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import static org.openecomp.core.utilities.CommonMethods.toSingleElementSet;
+
public class FeatureGroupCassandraDaoImpl extends CassandraBaseDao<FeatureGroupEntity>
implements FeatureGroupDao {
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 b880c67cbc..35182a3502 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
@@ -10,25 +10,20 @@ 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.datatypes.model.ElementType;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToEntitlementPoolConvertor;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-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 org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Set;
import java.util.stream.Collectors;
-/**
- * Created by ayalaben on 3/28/2017.
- */
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+
public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -48,18 +43,22 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
buildEntitlementPoolElement(entitlementPool, Action.CREATE);
ZusammenElement entitlementPoolsElement =
- VlmZusammenUtil.buildStructuralElement(StructureElement.EntitlementPools, null);
+ ZusammenUtil.buildStructuralElement(ElementType.EntitlementPools, Action.IGNORE);
+
+ ZusammenElement limitsElement =
+ ZusammenUtil.buildStructuralElement(ElementType.Limits, Action.CREATE);
+ entitlementPoolElement.addSubElement(limitsElement);
entitlementPoolsElement.addSubElement(entitlementPoolElement);
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ Element epsSavedElement = zusammenAdaptor.saveElement(context,
+ new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId()),
entitlementPoolsElement, "Create entitlement pool");
- savedElement.ifPresent(element -> entitlementPool
- .setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ entitlementPool
+ .setId(epsSavedElement.getSubElements().iterator().next().getElementId().getValue());
}
@Override
@@ -68,9 +67,8 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
buildEntitlementPoolElement(entitlementPool, Action.UPDATE);
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
Optional<ElementInfo> epFromDb = zusammenAdaptor.getElementInfo(context, elementContext,
new Id(entitlementPool.getId()));
@@ -84,35 +82,33 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
}
}
- zusammenAdaptor.saveElement(context,elementContext, entitlmentpoolElement,
+ zusammenAdaptor.saveElement(context, elementContext, entitlmentpoolElement,
String.format("Update entitlement pool with id %s", entitlementPool.getId()));
}
@Override
public EntitlementPoolEntity get(EntitlementPoolEntity entitlementPool) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(entitlementPool.getVersion()));
-
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
+ ElementToEntitlementPoolConvertor convertor = new ElementToEntitlementPoolConvertor();
return zusammenAdaptor.getElementInfo(context, elementContext, new Id(entitlementPool.getId()))
- .map(elementInfo -> mapElementInfoToEntitlementPool(
- entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(), elementInfo))
+ .map(elementInfo -> {
+ EntitlementPoolEntity entity = convertor.convert(elementInfo);
+ entity.setVendorLicenseModelId(entitlementPool.getVendorLicenseModelId());
+ entity.setVersion(entitlementPool.getVersion());
+ return entity;
+ })
.orElse(null);
}
@Override
public void delete(EntitlementPoolEntity entitlementPool) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ZusammenElement zusammenElement = new ZusammenElement();
- zusammenElement.setAction(Action.DELETE);
- zusammenElement.setElementId(new Id(entitlementPool.getId()));
+ ZusammenElement zusammenElement = buildElement(new Id(entitlementPool.getId()), Action.DELETE);
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext =
- new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = ZusammenUtil.createSessionContext();
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
"delete entitlement pool. id:" + entitlementPool.getId() + ".");
}
@@ -120,28 +116,27 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
@Override
public Collection<EntitlementPoolEntity> list(EntitlementPoolEntity entitlementPool) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(entitlementPool.getVersion()));
-
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
+ ElementToEntitlementPoolConvertor convertor = new ElementToEntitlementPoolConvertor();
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.EntitlementPools.name())
- .stream().map(elementInfo -> mapElementInfoToEntitlementPool(
- entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(), elementInfo))
- .collect(Collectors.toList());
+ .listElementsByName(context, elementContext, null, ElementType.EntitlementPools.name())
+ .stream().map(elementInfo -> {
+ EntitlementPoolEntity entity = convertor.convert(elementInfo);
+ entity.setVendorLicenseModelId(entitlementPool.getVendorLicenseModelId());
+ entity.setVersion(entitlementPool.getVersion());
+ return entity;
+ }).collect(Collectors.toList());
}
@Override
public long count(EntitlementPoolEntity entitlementPool) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(entitlementPool.getVersion()));
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.EntitlementPools.name())
+ .listElementsByName(context, elementContext, null, ElementType.EntitlementPools.name())
.size();
}
@@ -149,9 +144,8 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
public void removeReferencingFeatureGroup(EntitlementPoolEntity entitlementPool,
String referencingFeatureGroupId) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(entitlementPool.getId()));
@@ -173,9 +167,8 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
public void addReferencingFeatureGroup(EntitlementPoolEntity entitlementPool,
String referencingFeatureGroupId) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ElementContext elementContext = new ElementContext(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().getId());
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(entitlementPool.getId()));
@@ -199,17 +192,32 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
//not supported
}
- private ZusammenElement buildEntitlementPoolElement(EntitlementPoolEntity entitlementPool,
- Action action) {
+ @Override
+ public String getManufacturerReferenceNumber(EntitlementPoolEntity entitlementPoolEntity) {
+ SessionContext context = ZusammenUtil.createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(entitlementPoolEntity.getVendorLicenseModelId(),
+ entitlementPoolEntity.getVersion().getId());
- ZusammenElement entitlementPoolElement = new ZusammenElement();
- entitlementPoolElement.setAction(action);
- if (entitlementPool.getId() != null) {
- entitlementPoolElement.setElementId(new Id(entitlementPool.getId()));
+ 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");
}
+ return manufacturerReferenceNumber;
+ }
+
+ private ZusammenElement buildEntitlementPoolElement(EntitlementPoolEntity entitlementPool,
+ Action action) {
+ ZusammenElement entitlementPoolElement =
+ buildElement(entitlementPool.getId() == null ? null : new Id(entitlementPool.getId()),
+ action);
Info info = new Info();
info.setName(entitlementPool.getName());
info.setDescription(entitlementPool.getDescription());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.EntitlementPool);
info.addProperty("version_uuid", entitlementPool.getVersionUuId());
info.addProperty("thresholdValue", entitlementPool.getThresholdValue());
info.addProperty("threshold_unit", entitlementPool.getThresholdUnit());
@@ -219,8 +227,8 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
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))
@@ -229,62 +237,5 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
return entitlementPoolElement;
}
- private EntitlementPoolEntity mapElementInfoToEntitlementPool(String vlmId, Version version,
- ElementInfo elementInfo) {
- EntitlementPoolEntity entitlmentPool =
- new EntitlementPoolEntity(vlmId, version, elementInfo.getId().getValue());
- entitlmentPool.setName(elementInfo.getInfo().getName());
- entitlmentPool.setDescription(elementInfo.getInfo().getDescription());
- entitlmentPool.setVersionUuId(elementInfo.getInfo().getProperty("version_uuid"));
- entitlmentPool
- .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.setIncrements(elementInfo.getInfo().getProperty("increments"));
- entitlmentPool.setOperationalScope(getOperationalScopeMultiChoiceOrOther(
- elementInfo.getInfo().getProperty("operational_scope")));
- entitlmentPool.setStartDate(elementInfo.getInfo().getProperty("startDate"));
- entitlmentPool.setExpiryDate(elementInfo.getInfo().getProperty("expiryDate"));
-
- if (elementInfo.getRelations() != null && elementInfo.getRelations().size() > 0) {
- entitlmentPool
- .setReferencingFeatureGroups(elementInfo.getRelations().stream().map(relation -> relation
- .getEdge2().getElementId().getValue()).collect(Collectors.toSet()));
- }
- return entitlmentPool;
- }
-
- 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)));
-
- return new MultiChoiceOrOther<>(choices, operationalScope.get("other")==null?null:
- (String) operationalScope.get("other"));
- }
- return null;
- }
-
- @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");
- }
- 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 aa9e6c7ae0..8dcc964e7d 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
@@ -10,21 +10,22 @@ import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
import com.amdocs.zusammen.datatypes.item.Relation;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToFeatureGroupConvertor;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
-/**
- * Created by ayalaben on 3/27/2017.
- */
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -40,88 +41,86 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao {
@Override
public void create(FeatureGroupEntity featureGroup) {
- ZusammenElement featureGroupElement =
- buildFeatureGroupElement(featureGroup, Action.CREATE);
+ ZusammenElement featureGroupElement = buildFeatureGroupElement(featureGroup, Action.CREATE);
ZusammenElement featureGroupsElement =
- VlmZusammenUtil.buildStructuralElement(StructureElement.FeatureGroups, null);
+ buildStructuralElement(ElementType.FeatureGroups, Action.IGNORE);
featureGroupsElement.addSubElement(featureGroupElement);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- featureGroupsElement, "Create feature group");
+ SessionContext context = createSessionContext();
+ Element featureGroupsSavedElement = zusammenAdaptor.saveElement(context,
+ new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId()), featureGroupsElement, "Create feature group");
- savedElement.ifPresent(element -> featureGroup
- .setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ featureGroup.setId(
+ featureGroupsSavedElement.getSubElements().iterator().next().getElementId().getValue());
}
@Override
public void update(FeatureGroupEntity featureGroup) {
ZusammenElement featureGroupElement = buildFeatureGroupElement(featureGroup, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)), featureGroupElement,
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context, new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId()), featureGroupElement,
String.format("Update feature group with id %s", featureGroup.getId()));
}
@Override
public FeatureGroupEntity get(FeatureGroupEntity featureGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(featureGroup.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
return zusammenAdaptor.getElementInfo(context, elementContext, new Id(featureGroup.getId()))
- .map(elementInfo -> mapElementInfoToFeatureGroup(
- featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), elementInfo))
+ .map(elementInfo -> {
+ FeatureGroupEntity entity = new ElementToFeatureGroupConvertor().convert(elementInfo);
+ entity.setVendorLicenseModelId(featureGroup.getVendorLicenseModelId());
+ entity.setVersion(featureGroup.getVersion());
+ return entity;
+ })
.orElse(null);
}
@Override
public void delete(FeatureGroupEntity featureGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ZusammenElement zusammenElement = new ZusammenElement();
- zusammenElement.setAction(Action.DELETE);
- zusammenElement.setElementId(new Id(featureGroup.getId()));
-
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ZusammenElement zusammenElement = buildElement(new Id(featureGroup.getId()), Action.DELETE);
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
"delete feature group. id:" + featureGroup.getId() + ".");
}
@Override
public Collection<FeatureGroupEntity> list(FeatureGroupEntity featureGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(featureGroup.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
+ ElementToFeatureGroupConvertor convertor = new ElementToFeatureGroupConvertor();
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.FeatureGroups.name())
- .stream().map(elementInfo -> mapElementInfoToFeatureGroup(
- featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), elementInfo))
+ .listElementsByName(context, elementContext, null, ElementType.FeatureGroups.name())
+ .stream().map(elementInfo -> {
+ FeatureGroupEntity entity = convertor.convert(
+ elementInfo);
+ entity.setVendorLicenseModelId(featureGroup.getVendorLicenseModelId());
+ entity.setVersion(featureGroup.getVersion());
+ return entity;
+ })
.collect(Collectors.toList());
}
@Override
public long count(FeatureGroupEntity featureGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(featureGroup.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.FeatureGroups.name())
+ .listElementsByName(context, elementContext, null, ElementType.FeatureGroups.name())
.size();
}
@@ -138,10 +137,9 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao {
private void removeRelationToContainedEntity(FeatureGroupEntity featureGroup,
String containedEntityId,
String containedEntityType) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
Optional<ElementInfo> elementInfo = zusammenAdaptor.getElementInfo(context,
elementContext, new Id(featureGroup.getId()));
@@ -158,25 +156,23 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao {
}
@Override
- public void updateFeatureGroup(FeatureGroupEntity
- featureGroup, Set<String> addedEntitlementPools,
+ public void updateFeatureGroup(FeatureGroupEntity featureGroup,
+ Set<String> addedEntitlementPools,
Set<String> removedEntitlementPools,
Set<String> addedLicenseKeyGroups,
Set<String> removedLicenseKeyGroups) {
ZusammenElement featureGroupElement = buildFeatureGroupElement(featureGroup, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
-
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
+ ElementToFeatureGroupConvertor convertor = new ElementToFeatureGroupConvertor();
Optional<ElementInfo> elementInfo = zusammenAdaptor.getElementInfo(context,
elementContext, new Id(featureGroup.getId()));
if (elementInfo.isPresent()) {
- FeatureGroupEntity currentFeatureGroup =
- mapElementInfoToFeatureGroup(featureGroup.getId(), featureGroup.getVersion(),
- elementInfo.get());
-
- if (!(removedEntitlementPools == null )) {
+ FeatureGroupEntity currentFeatureGroup = convertor.convert(elementInfo.get());
+ currentFeatureGroup.setVendorLicenseModelId(featureGroup.getVendorLicenseModelId());
+ currentFeatureGroup.setVersion(featureGroup.getVersion());
+ if (!(removedEntitlementPools == null)) {
currentFeatureGroup.getEntitlementPoolIds().removeAll(removedEntitlementPools);
}
if (!(addedEntitlementPools == null)) {
@@ -192,22 +188,24 @@ 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);
}
+
featureGroupElement.getRelations()
.addAll(currentFeatureGroup.getLicenseKeyGroupIds().stream()
.map(relation -> VlmZusammenUtil
.createRelation(RelationType.FeatureGroupToLicenseKeyGroup, relation))
.collect(Collectors.toList()));
- Collection<Relation> LaRelations = elementInfo.get().getRelations().stream().filter
- (rel->rel.getType().equals(RelationType.FeatureGroupToReferencingLicenseAgreement.name()))
- .map(rel ->VlmZusammenUtil.createRelation(RelationType
- .FeatureGroupToReferencingLicenseAgreement,rel.getEdge2().getElementId().toString()))
+ Collection<Relation> LaRelations = elementInfo.get().getRelations().stream().filter
+ (rel -> rel.getType()
+ .equals(RelationType.FeatureGroupToReferencingLicenseAgreement.name()))
+ .map(rel -> VlmZusammenUtil.createRelation(RelationType
+ .FeatureGroupToReferencingLicenseAgreement, rel.getEdge2().getElementId().toString()))
.collect(Collectors.toList());
featureGroupElement.getRelations().addAll(LaRelations);
@@ -226,10 +224,9 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao {
@Override
public void addReferencingLicenseAgreement(FeatureGroupEntity featureGroup,
String licenseAgreementId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(featureGroup.getId()));
@@ -247,10 +244,9 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao {
@Override
public void removeReferencingLicenseAgreement(FeatureGroupEntity featureGroup,
String licenseAgreementId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(featureGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion().getId());
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(featureGroup.getId()));
@@ -268,15 +264,12 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao {
}
private ZusammenElement buildFeatureGroupElement(FeatureGroupEntity featureGroup, Action action) {
-
- ZusammenElement featureGroupElement = new ZusammenElement();
- featureGroupElement.setAction(action);
- if (featureGroup.getId() != null) {
- featureGroupElement.setElementId(new Id(featureGroup.getId()));
- }
+ ZusammenElement featureGroupElement =
+ buildElement(featureGroup.getId() == null ? null : new Id(featureGroup.getId()), action);
Info info = new Info();
info.setName(featureGroup.getName());
info.setDescription(featureGroup.getDescription());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.FeatureGroup);
info.addProperty("partNumber", featureGroup.getPartNumber());
info.addProperty("manufacturerReferenceNumber", featureGroup.getManufacturerReferenceNumber());
featureGroupElement.setInfo(info);
@@ -310,39 +303,5 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao {
.collect(Collectors.toList()));
}
return featureGroupElement;
-
- }
-
- private FeatureGroupEntity mapElementInfoToFeatureGroup(String vlmId, Version version,
- ElementInfo elementInfo) {
- FeatureGroupEntity featureGroup =
- new FeatureGroupEntity(vlmId, version, elementInfo.getId().getValue());
- 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<>();
- Set<String> licenseKeyGroupIds = new HashSet<>();
-
- if (elementInfo.getRelations() != null) {
- for (Relation relation : elementInfo.getRelations()) {
- 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);
-
- return featureGroup;
}
}
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/LicenseAgreementDaoZusammenImpl.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/LicenseAgreementDaoZusammenImpl.java
index 45c831fbd7..0fbac66b58 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/LicenseAgreementDaoZusammenImpl.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/LicenseAgreementDaoZusammenImpl.java
@@ -29,19 +29,21 @@ 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.datatypes.model.ElementType;
import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
-import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToLicenseAgreementConvertor;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.util.Collection;
-import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
public class LicenseAgreementDaoZusammenImpl implements LicenseAgreementDao {
@@ -61,16 +63,17 @@ public class LicenseAgreementDaoZusammenImpl implements LicenseAgreementDao {
ZusammenElement licenseAgreementElement =
buildLicenseAgreementElement(licenseAgreement, Action.CREATE);
ZusammenElement licenseAgreementsElement =
- VlmZusammenUtil.buildStructuralElement(StructureElement.LicenseAgreements, null);
+ buildStructuralElement(ElementType.LicenseAgreements, Action.IGNORE);
licenseAgreementsElement.addSubElement(licenseAgreementElement);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- licenseAgreementsElement, "Create license agreement");
- savedElement.ifPresent(element -> licenseAgreement
- .setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ SessionContext context = createSessionContext();
+ Element licenseAgreementsSavedElement = zusammenAdaptor.saveElement(context,
+ new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId()), licenseAgreementsElement,
+ "Create license agreement");
+ licenseAgreement
+ .setId(licenseAgreementsSavedElement.getSubElements().iterator().next().getElementId()
+ .getValue());
}
@Override
@@ -78,38 +81,36 @@ public class LicenseAgreementDaoZusammenImpl implements LicenseAgreementDao {
ZusammenElement licenseAgreementElement =
buildLicenseAgreementElement(licenseAgreement, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- licenseAgreementElement,
+ SessionContext context = createSessionContext();
+ zusammenAdaptor.saveElement(context,
+ new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId()), licenseAgreementElement,
String.format("Update license agreement with id %s", licenseAgreement.getId()));
}
@Override
public LicenseAgreementEntity get(LicenseAgreementEntity licenseAgreement) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(licenseAgreement.getVersion()));
-
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
+ ElementToLicenseAgreementConvertor convertor = new ElementToLicenseAgreementConvertor();
return zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseAgreement.getId()))
- .map(elementInfo -> mapElementInfoToLicenseAgreement(
- licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion(), elementInfo))
+ .map(elementInfo -> {
+ LicenseAgreementEntity entity = convertor.convert(elementInfo);
+ entity.setVendorLicenseModelId(licenseAgreement.getVendorLicenseModelId());
+ entity.setVersion(licenseAgreement.getVersion());
+ return entity;
+ })
.orElse(null);
}
@Override
public void delete(LicenseAgreementEntity licenseAgreement) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ZusammenElement zusammenElement = new ZusammenElement();
- zusammenElement.setAction(Action.DELETE);
- zusammenElement.setElementId(new Id(licenseAgreement.getId()));
-
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ ZusammenElement zusammenElement = buildElement(new Id(licenseAgreement.getId()), Action.DELETE);
+
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
"delete license agreement. id:" + licenseAgreement.getId() + ".");
}
@@ -117,30 +118,30 @@ public class LicenseAgreementDaoZusammenImpl implements LicenseAgreementDao {
@Override
public Collection<LicenseAgreementEntity> list(LicenseAgreementEntity licenseAgreement) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(licenseAgreement.getVersion()));
-
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
+ ElementToLicenseAgreementConvertor convertor = new ElementToLicenseAgreementConvertor();
return zusammenAdaptor
.listElementsByName(context, elementContext, null,
- StructureElement.LicenseAgreements.name())
- .stream().map(elementInfo -> mapElementInfoToLicenseAgreement(
- licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion(), elementInfo))
+ ElementType.LicenseAgreements.name())
+ .stream().map(elementInfo -> {
+ LicenseAgreementEntity entity = convertor.convert(elementInfo);
+ entity.setVendorLicenseModelId(licenseAgreement.getVendorLicenseModelId());
+ entity.setVersion(licenseAgreement.getVersion());
+ return entity;
+ })
.collect(Collectors.toList());
}
@Override
public long count(LicenseAgreementEntity licenseAgreement) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(licenseAgreement.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
return zusammenAdaptor.listElementsByName(context, elementContext, null,
- StructureElement.LicenseAgreements.name())
+ ElementType.LicenseAgreements.name())
.size();
}
@@ -151,10 +152,9 @@ public class LicenseAgreementDaoZusammenImpl implements LicenseAgreementDao {
@Override
public void removeFeatureGroup(LicenseAgreementEntity licenseAgreement, String featureGroupId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
Optional<ElementInfo> elementInfo = zusammenAdaptor.getElementInfo(context,
elementContext, new Id(licenseAgreement.getId()));
@@ -175,23 +175,22 @@ public class LicenseAgreementDaoZusammenImpl implements LicenseAgreementDao {
ZusammenElement licenseAgreementElement =
buildLicenseAgreementElement(licenseAgreement, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseAgreement.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
-
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion().getId());
+ ElementToLicenseAgreementConvertor convertor = new ElementToLicenseAgreementConvertor();
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseAgreement.getId()));
if (elementInfo.isPresent()) {
LicenseAgreementEntity currentLicenseAgreement =
- mapElementInfoToLicenseAgreement(licenseAgreement.getId(), licenseAgreement.getVersion(),
- elementInfo.get());
-
- if (! (removedFeatureGroupIds == null) ) {
+ convertor.convert(elementInfo.get());
+ currentLicenseAgreement.setVendorLicenseModelId(licenseAgreement.getVendorLicenseModelId());
+ currentLicenseAgreement.setVersion(licenseAgreement.getVersion());
+ if (!(removedFeatureGroupIds == null)) {
currentLicenseAgreement.getFeatureGroupIds().removeAll(removedFeatureGroupIds);
}
- if (! (addedFeatureGroupIds == null)) {
+ if (!(addedFeatureGroupIds == null)) {
currentLicenseAgreement.getFeatureGroupIds().addAll(addedFeatureGroupIds);
}
licenseAgreementElement.setRelations(currentLicenseAgreement.getFeatureGroupIds().stream()
@@ -203,41 +202,15 @@ public class LicenseAgreementDaoZusammenImpl implements LicenseAgreementDao {
}
}
- private LicenseAgreementEntity mapElementInfoToLicenseAgreement(String vlmId, Version version,
- ElementInfo elementInfo) {
- LicenseAgreementEntity licenseAgreement =
- new LicenseAgreementEntity(vlmId, version, elementInfo.getId().getValue());
- licenseAgreement.setName(elementInfo.getInfo().getName());
- licenseAgreement.setDescription(elementInfo.getInfo().getDescription());
-
- licenseAgreement
- .setLicenseTerm(getCoiceOrOther(elementInfo.getInfo().getProperty("licenseTerm")));
- licenseAgreement.setRequirementsAndConstrains(
- elementInfo.getInfo().getProperty("requirementsAndConstrains"));
- if (elementInfo.getRelations() != null && elementInfo.getRelations().size() > 0) {
- licenseAgreement.setFeatureGroupIds(elementInfo.getRelations().stream()
- .map(relation -> relation.getEdge2().getElementId().getValue())
- .collect(Collectors.toSet()));
- }
- return licenseAgreement;
- }
-
- private ChoiceOrOther<LicenseTerm> getCoiceOrOther(Map licenseTerm) {
- return new ChoiceOrOther(LicenseTerm.valueOf((String) licenseTerm.get("choice")),
- (String) licenseTerm.get("other"));
- }
-
-
private ZusammenElement buildLicenseAgreementElement(LicenseAgreementEntity licenseAgreement,
Action action) {
- ZusammenElement licenseAgreementElement = new ZusammenElement();
- licenseAgreementElement.setAction(action);
- if (licenseAgreement.getId() != null) {
- licenseAgreementElement.setElementId(new Id(licenseAgreement.getId()));
- }
+ ZusammenElement licenseAgreementElement =
+ buildElement(licenseAgreement.getId() == null ? null : new Id(licenseAgreement.getId()),
+ action);
Info info = new Info();
info.setName(licenseAgreement.getName());
info.setDescription(licenseAgreement.getDescription());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.LicenseAgreement);
info.addProperty("licenseTerm", licenseAgreement.getLicenseTerm());
info.addProperty("requirementsAndConstrains", licenseAgreement.getRequirementsAndConstrains());
licenseAgreementElement.setInfo(info);
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 976db94f39..4e7aee377a 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
@@ -9,27 +9,22 @@ 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.datatypes.model.ElementType;
import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToLicenseKeyGroupConvertor;
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;
-import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.types.ElementPropertyName;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
import java.util.Optional;
-import java.util.Set;
import java.util.stream.Collectors;
-/**
- * Created by ayalaben on 3/30/2017.
- */
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
+
public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao {
private ZusammenAdaptor zusammenAdaptor;
@@ -47,18 +42,20 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao {
ZusammenElement licenseKeyGroupElement =
buildLicenseKeyGroupElement(licenseKeyGroup, Action.CREATE);
+ ZusammenElement limitsElement = buildStructuralElement(ElementType.Limits, Action.CREATE);
+ licenseKeyGroupElement.addSubElement(limitsElement);
+
ZusammenElement lkgsElement =
- VlmZusammenUtil.buildStructuralElement(StructureElement.LicenseKeyGroups, null);
+ buildStructuralElement(ElementType.LicenseKeyGroups, Action.IGNORE);
lkgsElement.addSubElement(licenseKeyGroupElement);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- Optional<Element> savedElement = zusammenAdaptor.saveElement(context, new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
- lkgsElement, "Create license Key Group");
+ SessionContext context = createSessionContext();
+ Element lkgsSavedElement = zusammenAdaptor.saveElement(context,
+ new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId()), lkgsElement, "Create license Key Group");
- savedElement.ifPresent(element -> licenseKeyGroup
- .setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ licenseKeyGroup
+ .setId(lkgsSavedElement.getSubElements().iterator().next().getElementId().getValue());
}
@Override
@@ -66,55 +63,50 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao {
ZusammenElement licenseKeyGroupElement =
buildLicenseKeyGroupElement(licenseKeyGroup, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
-
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
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 && lkgFromDb.get().getRelations().size() > 0) {
licenseKeyGroupElement.getRelations().addAll(lkgFromDb.get().getRelations());
}
}
-
- zusammenAdaptor.saveElement(context, elementContext,
- licenseKeyGroupElement,
+ zusammenAdaptor.saveElement(context, elementContext, licenseKeyGroupElement,
String.format("Update license key group with id %s", licenseKeyGroup.getId()));
}
@Override
public LicenseKeyGroupEntity get(LicenseKeyGroupEntity licenseKeyGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(licenseKeyGroup.getVersion()));
-
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
+ ElementToLicenseKeyGroupConvertor convertor = new ElementToLicenseKeyGroupConvertor();
return zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseKeyGroup.getId()))
- .map(elementInfo -> mapElementInfoToLicenseKeyGroup(
- licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(), elementInfo))
+ .map(elementInfo -> {
+ LicenseKeyGroupEntity entity = convertor.convert(elementInfo);
+ entity.setVendorLicenseModelId(licenseKeyGroup.getVendorLicenseModelId());
+ entity.setVersion(licenseKeyGroup.getVersion());
+ return entity;
+ })
.orElse(null);
}
@Override
public void delete(LicenseKeyGroupEntity licenseKeyGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ZusammenElement zusammenElement = new ZusammenElement();
- zusammenElement.setAction(Action.DELETE);
- zusammenElement.setElementId(new Id(licenseKeyGroup.getId()));
+ ZusammenElement zusammenElement = buildElement(new Id(licenseKeyGroup.getId()), Action.DELETE);
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
"delete license key group. id:" + licenseKeyGroup.getId() + ".");
@@ -122,29 +114,29 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao {
@Override
public Collection<LicenseKeyGroupEntity> list(LicenseKeyGroupEntity licenseKeyGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(licenseKeyGroup.getVersion()));
-
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
+ ElementToLicenseKeyGroupConvertor convertor = new ElementToLicenseKeyGroupConvertor();
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.LicenseKeyGroups.name())
- .stream().map(elementInfo -> mapElementInfoToLicenseKeyGroup(
- licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(), elementInfo))
+ .listElementsByName(context, elementContext, null, ElementType.LicenseKeyGroups.name())
+ .stream().map(elementInfo -> {
+ LicenseKeyGroupEntity entity = convertor.convert(elementInfo);
+ entity.setVendorLicenseModelId(licenseKeyGroup.getVendorLicenseModelId());
+ entity.setVersion(licenseKeyGroup.getVersion());
+ return entity;
+ })
.collect(Collectors.toList());
}
@Override
public long count(LicenseKeyGroupEntity licenseKeyGroup) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor),
- VlmZusammenUtil.getVersionTag(licenseKeyGroup.getVersion()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
return zusammenAdaptor
- .listElementsByName(context, elementContext, null, StructureElement.LicenseKeyGroups.name())
+ .listElementsByName(context, elementContext, null, ElementType.LicenseKeyGroups.name())
.size();
}
@@ -156,10 +148,9 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao {
@Override
public void removeReferencingFeatureGroup(LicenseKeyGroupEntity licenseKeyGroup,
String featureGroupId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseKeyGroup.getId()));
@@ -180,10 +171,9 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao {
@Override
public void addReferencingFeatureGroup(LicenseKeyGroupEntity licenseKeyGroup,
String featureGroupId) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext = new ElementContext(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().getId());
Optional<ElementInfo> elementInfo =
zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseKeyGroup.getId()));
@@ -204,18 +194,15 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao {
private ZusammenElement buildLicenseKeyGroupElement(LicenseKeyGroupEntity licenseKeyGroup,
Action action) {
-
- ZusammenElement lkgElement = new ZusammenElement();
- lkgElement.setAction(action);
- if (licenseKeyGroup.getId() != null) {
- lkgElement.setElementId(new Id(licenseKeyGroup.getId()));
- }
+ ZusammenElement lkgElement =
+ buildElement(licenseKeyGroup.getId() == null ? null : new Id(licenseKeyGroup.getId()),
+ action);
Info info = new Info();
info.setName(licenseKeyGroup.getName());
info.setDescription(licenseKeyGroup.getDescription());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.LicenseKeyGroup);
info.addProperty("version_uuid", licenseKeyGroup.getVersionUuId());
info.addProperty("LicenseKeyType", licenseKeyGroup.getType());
- info.addProperty("version_uuid", licenseKeyGroup.getVersionUuId());
info.addProperty("operational_scope", licenseKeyGroup.getOperationalScope());
info.addProperty("startDate", licenseKeyGroup.getStartDate());
info.addProperty("expiryDate", licenseKeyGroup.getExpiryDate());
@@ -224,70 +211,15 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao {
info.addProperty("increments", licenseKeyGroup.getIncrements());
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;
}
- private LicenseKeyGroupEntity mapElementInfoToLicenseKeyGroup(String vlmId, Version version,
- ElementInfo elementInfo) {
- LicenseKeyGroupEntity licenseKeyGroup =
- new LicenseKeyGroupEntity(vlmId, version, elementInfo.getId().getValue());
- licenseKeyGroup.setName(elementInfo.getInfo().getName());
- licenseKeyGroup.setDescription(elementInfo.getInfo().getDescription());
- licenseKeyGroup.setVersionUuId(elementInfo.getInfo().getProperty("version_uuid"));
- licenseKeyGroup
- .setType(LicenseKeyType.valueOf(elementInfo.getInfo().getProperty("LicenseKeyType")));
- licenseKeyGroup.setVersionUuId(elementInfo.getInfo().getProperty("version_uuid"));
- licenseKeyGroup.setOperationalScope(getOperationalScopeMultiChoiceOrOther(
- elementInfo.getInfo().getProperty("operational_scope")));
- licenseKeyGroup.setStartDate(elementInfo.getInfo().getProperty("startDate"));
- licenseKeyGroup.setExpiryDate(elementInfo.getInfo().getProperty("expiryDate"));
- if (elementInfo.getInfo().getProperty("thresholdUnits") != null ){
- licenseKeyGroup.setThresholdUnits(ThresholdUnit.valueOf(elementInfo
- .getInfo().getProperty("thresholdUnits")));
- }
- if (elementInfo.getInfo().getProperty("thresholdValue") != null ){
- licenseKeyGroup.setThresholdValue(toInteger(elementInfo.getInfo().getProperty
- ("thresholdValue")));
- }
- licenseKeyGroup.setIncrements(elementInfo.getInfo().getProperty("increments"));
-
- if (elementInfo.getRelations() != null && elementInfo.getRelations().size() > 0) {
- licenseKeyGroup
- .setReferencingFeatureGroups(elementInfo.getRelations().stream().map(relation -> relation
- .getEdge2().getElementId().getValue()).collect(Collectors.toSet()));
- }
- return licenseKeyGroup;
- }
- 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)));
-
- 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;
- }
- 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/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
index 78c26c83d3..7b19236409 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/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
@@ -9,26 +9,30 @@ 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.datatypes.model.ElementType;
import org.openecomp.sdc.vendorlicense.dao.LimitDao;
import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
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 org.openecomp.types.ElementPropertyName;
import java.util.Collection;
import java.util.Collections;
-import java.util.Optional;
import java.util.stream.Collectors;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.createSessionContext;
+
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 static final String LIMT_TYPE = "type";
+ private static final String METRIC = "metric";
+ private static final String AGGREGATIONFUNCTION = "aggregationfunction";
+ private static final String TIME = "time";
+ private static final String UNIT = "unit";
+ private static final String VALUE = "value";
private ZusammenAdaptor zusammenAdaptor;
public LimitZusammenDaoImpl(ZusammenAdaptor zusammenAdaptor) {
@@ -39,36 +43,30 @@ public class LimitZusammenDaoImpl implements LimitDao {
public void create(LimitEntity limitEntity) {
ZusammenElement limitElement = limitToZusammen(limitEntity, Action.CREATE);
- ZusammenElement limitsElement =
- VlmZusammenUtil.buildStructuralElement(StructureElement.Limits, null);
+ ZusammenElement limitsElement = buildStructuralElement(ElementType.Limits, null);
limitsElement.setSubElements(Collections.singletonList(limitElement));
- ZusammenElement epLkgElement =
- buildZusammenElement(new Id(limitEntity.getEpLkgId()), Action.IGNORE);
+ ZusammenElement epLkgElement = buildElement(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));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(limitEntity.getVendorLicenseModelId(), limitEntity.getVersion().getId());
- Optional<Element> savedElement =
+ Element savedElement =
zusammenAdaptor.saveElement(context, elementContext, epLkgElement, "Create limit");
- savedElement.ifPresent(element ->
- limitEntity.setId(element.getSubElements().iterator().next()
- .getSubElements().iterator().next().getElementId().getValue()));
+ limitEntity.setId(savedElement.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()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(limitEntity.getVendorLicenseModelId(), limitEntity.getVersion().getId());
Collection<ElementInfo> elementInfos = zusammenAdaptor.listElementsByName(context,
- elementContext, new Id(limitEntity.getEpLkgId()),StructureElement.Limits.name());
+ elementContext, new Id(limitEntity.getEpLkgId()), ElementType.Limits.name());
for (ElementInfo elementInfo : elementInfos) {
if (elementInfo.getId().getValue().equals(limitEntity.getId())) {
@@ -81,20 +79,18 @@ public class LimitZusammenDaoImpl implements LimitDao {
@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()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(limitEntity.getVendorLicenseModelId(), limitEntity.getVersion().getId());
return listLimits(context, elementContext, limitEntity);
}
private Collection<LimitEntity> listLimits(SessionContext context, ElementContext elementContext,
- LimitEntity limitEntity) {
+ LimitEntity limitEntity) {
return zusammenAdaptor
.listElementsByName(context, elementContext, new Id(limitEntity.getEpLkgId()),
- StructureElement.Limits.name())
+ ElementType.Limits.name())
.stream().map(elementInfo -> mapElementInfoToLimit(
limitEntity.getVendorLicenseModelId(), limitEntity.getVersion(),
limitEntity.getEpLkgId(), elementInfo))
@@ -102,18 +98,18 @@ public class LimitZusammenDaoImpl implements LimitDao {
}
private LimitEntity mapElementInfoToLimit(String vlmId, Version version,
- String epLkgId, ElementInfo elementInfo) {
+ 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 ?
+ limitEntity.setType(elementInfo.getInfo().getProperties().get(LIMT_TYPE) != null ?
LimitType.valueOf((String) elementInfo.getInfo().getProperties().get(LIMT_TYPE)) :
null);
- limitEntity.setTime((String) elementInfo.getInfo().getProperties().get(TIME) );
- limitEntity.setMetric( (String) elementInfo.getInfo().getProperties().get(METRIC));
- limitEntity.setAggregationFunction( elementInfo.getInfo().getProperties().get
+ limitEntity.setTime((String) elementInfo.getInfo().getProperties().get(TIME));
+ limitEntity.setMetric((String) elementInfo.getInfo().getProperties().get(METRIC));
+ limitEntity.setAggregationFunction(elementInfo.getInfo().getProperties().get
(AGGREGATIONFUNCTION) != null ?
AggregationFunction.valueOf((String) elementInfo.getInfo().getProperties()
.get(AGGREGATIONFUNCTION)) : null);
@@ -126,25 +122,22 @@ public class LimitZusammenDaoImpl implements LimitDao {
}
@Override
- public void update(LimitEntity entity) {
- ZusammenElement limitElement = limitToZusammen(entity, Action.UPDATE);
+ public void update(LimitEntity limitEntity) {
+ ZusammenElement limitElement = limitToZusammen(limitEntity, Action.UPDATE);
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(entity.getVendorLicenseModelId());
- ElementContext elementContext = new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(limitEntity.getVendorLicenseModelId(), limitEntity.getVersion().getId());
- zusammenAdaptor.saveElement(context,elementContext, limitElement,
- String.format("Update limit with id %s", entity.getId()));
+ zusammenAdaptor.saveElement(context, elementContext, limitElement,
+ String.format("Update limit with id %s", limitEntity.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()));
+ SessionContext context = createSessionContext();
+ ElementContext elementContext =
+ new ElementContext(limitEntity.getVendorLicenseModelId(), limitEntity.getVersion().getId());
return zusammenAdaptor.getElementInfo(context, elementContext, new Id(limitEntity.getId()))
.map(elementInfo -> mapElementInfoToLimit(
@@ -154,18 +147,14 @@ public class LimitZusammenDaoImpl implements LimitDao {
}
@Override
- public void delete(LimitEntity entity) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ZusammenElement zusammenElement = new ZusammenElement();
- zusammenElement.setAction(Action.DELETE);
- zusammenElement.setElementId(new Id(entity.getId()));
+ public void delete(LimitEntity limitEntity) {
+ ZusammenElement zusammenElement = buildElement(new Id(limitEntity.getId()), Action.DELETE);
- Id itemId = new Id(entity.getVendorLicenseModelId());
+ SessionContext context = createSessionContext();
ElementContext elementContext =
- new ElementContext(itemId,
- VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ new ElementContext(limitEntity.getVendorLicenseModelId(), limitEntity.getVersion().getId());
zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
- "delete limit Id:" + entity.getId() + ".");
+ "delete limit Id:" + limitEntity.getId() + ".");
}
@Override
@@ -173,23 +162,13 @@ public class LimitZusammenDaoImpl implements LimitDao {
}
- 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()));
- }
-
+ private ZusammenElement limitToZusammen(LimitEntity limit, Action action) {
+ ZusammenElement limitElement =
+ buildElement(limit.getId() == null ? null : new Id(limit.getId()), action);
Info info = new Info();
info.setName(limit.getName());
info.setDescription(limit.getDescription());
+ info.addProperty(ElementPropertyName.elementType.name(), ElementType.Limit);
info.addProperty(LIMT_TYPE, limit.getType());
info.addProperty(METRIC, limit.getMetric());
info.addProperty(AGGREGATIONFUNCTION, limit.getAggregationFunction());
@@ -199,11 +178,4 @@ public class LimitZusammenDaoImpl implements LimitDao {
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/VendorLicenseModelDaoZusammenImpl.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/VendorLicenseModelDaoZusammenImpl.java
index cd1ef0fbcf..13065515d8 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/VendorLicenseModelDaoZusammenImpl.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/VendorLicenseModelDaoZusammenImpl.java
@@ -1,23 +1,21 @@
package org.openecomp.sdc.vendorlicense.dao.impl.zusammen;
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 com.amdocs.zusammen.datatypes.item.ItemVersion;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToVLMGeneralConvertor;
import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.versioning.VersioningManagerFactory;
-import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
import org.openecomp.sdc.versioning.types.VersionableEntityStoreType;
import java.util.Collection;
-import java.util.Date;
import java.util.stream.Collectors;
public class VendorLicenseModelDaoZusammenImpl implements VendorLicenseModelDao {
@@ -31,63 +29,91 @@ public class VendorLicenseModelDaoZusammenImpl implements VendorLicenseModelDao
@Override
public void registerVersioning(String versionableEntityType) {
VersionableEntityMetadata metadata =
- new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "vlm", null, null);
+ new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "VendorLicenseModel",
+ null, null);
VersioningManagerFactory.getInstance().createInterface()
.register(versionableEntityType, metadata);
}
@Override
- public Collection<VendorLicenseModelEntity> list(VendorLicenseModelEntity entity) {
+ public Collection<VendorLicenseModelEntity> list(
+ VendorLicenseModelEntity vendorLicenseModelEntity) {
+
+ ElementToVLMGeneralConvertor convertor = new ElementToVLMGeneralConvertor();
return zusammenAdaptor.listItems(ZusammenUtil.createSessionContext()).stream()
- .map(item -> mapInfoToVlm(
- item.getId().getValue(), null, item.getInfo(),
- item.getModificationTime(), item.getCreationTime()))
+ .filter(item -> "VendorLicenseModel".equals(item.getInfo().getProperty("item_type")))
+ .map(item -> {
+ VendorLicenseModelEntity entity = convertor.convert(item);
+ entity.setId(item.getId().getValue());
+ entity.setVersion(null);
+ return entity;
+ })
.collect(Collectors.toList());
}
@Override
public void create(VendorLicenseModelEntity vendorLicenseModel) {
+
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = zusammenAdaptor.createItem(context, mapVlmToZusammenItemInfo(vendorLicenseModel));
- Id versionId =
- zusammenAdaptor.createVersion(context, itemId, null, ZusammenUtil.createFirstVersionData());
+ ElementContext elementContext = new ElementContext(vendorLicenseModel.getId(),
+ vendorLicenseModel.getVersion().getId());
ZusammenElement generalElement = mapVlmToZusammenElement(vendorLicenseModel, Action.CREATE);
- zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId),
- generalElement, "Create VSP General Info Element");
- vendorLicenseModel.setId(itemId.getValue());//set id for caller
+ zusammenAdaptor.saveElement(context, elementContext, generalElement,
+ "Create VLM General Info Element");
+
+ ZusammenElement licenseAgreementsElement =
+ ZusammenUtil.buildStructuralElement(ElementType.LicenseAgreements, Action.CREATE);
+
+ zusammenAdaptor.saveElement(context, elementContext, licenseAgreementsElement,
+ "Create VLM licenseAgreementsElement");
+
+ ZusammenElement featureGroupsElement =
+ ZusammenUtil.buildStructuralElement(ElementType.FeatureGroups, Action.CREATE);
+
+ zusammenAdaptor.saveElement(context, elementContext, featureGroupsElement,
+ "Create VLM featureGroupsElement");
+
+ ZusammenElement lkgsElement =
+ ZusammenUtil.buildStructuralElement(ElementType.LicenseKeyGroups, Action.CREATE);
+
+ zusammenAdaptor.saveElement(context, elementContext, lkgsElement,
+ "Create VLM lkgsElement");
+
+ ZusammenElement entitlementPoolsElement =
+ ZusammenUtil.buildStructuralElement(ElementType.EntitlementPools, Action.CREATE);
+
+ zusammenAdaptor.saveElement(context, elementContext, entitlementPoolsElement,
+ "Create VLM entitlementPoolsElement");
}
@Override
public void update(VendorLicenseModelEntity vendorLicenseModel) {
- SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vendorLicenseModel.getId());
- Id versionId = VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor);
-
- zusammenAdaptor.updateItem(context, itemId, mapVlmToZusammenItemInfo(vendorLicenseModel));
-
ZusammenElement generalElement = mapVlmToZusammenElement(vendorLicenseModel, Action.UPDATE);
- zusammenAdaptor.saveElement(context, new ElementContext(itemId, versionId),
+
+ SessionContext context = ZusammenUtil.createSessionContext();
+ zusammenAdaptor.saveElement(context,
+ new ElementContext(vendorLicenseModel.getId(), vendorLicenseModel.getVersion().getId()),
generalElement, "Update VSP General Info Element");
}
@Override
public VendorLicenseModelEntity get(VendorLicenseModelEntity vendorLicenseModel) {
SessionContext context = ZusammenUtil.createSessionContext();
- Id itemId = new Id(vendorLicenseModel.getId());
- ItemVersion itemVersion = VlmZusammenUtil.getFirstVersion(context, itemId, zusammenAdaptor);
- ElementContext elementContext = new ElementContext(itemId, itemVersion.getId(),
- VlmZusammenUtil.getVersionTag(vendorLicenseModel.getVersion()));
-
+ ElementContext elementContext =
+ new ElementContext(vendorLicenseModel.getId(), vendorLicenseModel.getVersion().getId());
+ ElementToVLMGeneralConvertor convertor = new ElementToVLMGeneralConvertor();
return zusammenAdaptor
- .getElementInfoByName(context, elementContext, null, StructureElement.General.name())
- .map(generalElementInfo -> mapInfoToVlm(
- vendorLicenseModel.getId(), vendorLicenseModel.getVersion(),
- generalElementInfo.getInfo(),
- itemVersion.getModificationTime(), itemVersion.getCreationTime()))
+ .getElementInfoByName(context, elementContext, null, ElementType.VendorLicenseModel.name())
+ .map(generalElementInfo -> {
+ VendorLicenseModelEntity entity = convertor.convert(generalElementInfo);
+ entity.setId(vendorLicenseModel.getId());
+ entity.setVersion(vendorLicenseModel.getVersion());
+ return entity;
+ })
.orElse(null);
}
@@ -96,19 +122,19 @@ public class VendorLicenseModelDaoZusammenImpl implements VendorLicenseModelDao
}
- private Info mapVlmToZusammenItemInfo(VendorLicenseModelEntity vendorLicenseModel) {
+ /* private Info mapVlmToZusammenItemInfo(VendorLicenseModelEntity vendorLicenseModel) {
Info info = new Info();
info.setName(vendorLicenseModel.getVendorName());
info.setDescription(vendorLicenseModel.getDescription());
- info.addProperty("type", "vlm");
+ info.addProperty("type", "VendorLicenseModel");
addVlmToInfo(info, vendorLicenseModel);
return info;
- }
+ }*/
private ZusammenElement mapVlmToZusammenElement(VendorLicenseModelEntity vendorLicenseModel,
Action action) {
ZusammenElement generalElement =
- VlmZusammenUtil.buildStructuralElement(StructureElement.General, action);
+ ZusammenUtil.buildStructuralElement(ElementType.VendorLicenseModel, action);
addVlmToInfo(generalElement.getInfo(), vendorLicenseModel);
return generalElement;
}
@@ -117,22 +143,21 @@ public class VendorLicenseModelDaoZusammenImpl implements VendorLicenseModelDao
info.addProperty(InfoPropertyName.name.name(), vendorLicenseModel.getVendorName());
info.addProperty(InfoPropertyName.description.name(), vendorLicenseModel.getDescription());
info.addProperty(InfoPropertyName.iconRef.name(), vendorLicenseModel.getIconRef());
+ info.addProperty(InfoPropertyName.oldVersion.name(), vendorLicenseModel.getOldVersion());
}
- private VendorLicenseModelEntity mapInfoToVlm(String vlmId, Version version, Info info,
- Date modificationTime, Date creationTime) {
+ /*private VendorLicenseModelEntity mapInfoToVlm(String vlmId, Version version, Info info) {
VendorLicenseModelEntity vendorLicenseModel = new VendorLicenseModelEntity(vlmId, version);
vendorLicenseModel.setVendorName(info.getProperty(InfoPropertyName.name.name()));
vendorLicenseModel.setDescription(info.getProperty(InfoPropertyName.description.name()));
vendorLicenseModel.setIconRef(info.getProperty(InfoPropertyName.iconRef.name()));
- vendorLicenseModel.setWritetimeMicroSeconds(
- modificationTime == null ? creationTime.getTime() : modificationTime.getTime());
return vendorLicenseModel;
- }
+ }*/
- private enum InfoPropertyName {
+ public enum InfoPropertyName {
name,
description,
- iconRef
+ iconRef,
+ oldVersion
}
}
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 f16d0fae67..07a4f87e67 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
@@ -3,49 +3,13 @@ package org.openecomp.sdc.vendorlicense.dao.impl.zusammen;
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.ItemVersion;
import com.amdocs.zusammen.datatypes.item.Relation;
import com.amdocs.zusammen.datatypes.item.RelationEdge;
-import org.openecomp.core.zusammen.api.ZusammenAdaptor;
-import org.openecomp.core.zusammen.api.ZusammenUtil;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorlicense.errors.VendorLicenseModelNotFoundErrorBuilder;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import java.util.Optional;
import java.util.stream.Collectors;
public class VlmZusammenUtil {
- static ItemVersion getFirstVersion(SessionContext context, Id itemId,
- ZusammenAdaptor zusammenAdaptor) {
- Optional<ItemVersion> itemVersion = zusammenAdaptor.getFirstVersion(context, itemId);
-
- if (!itemVersion.isPresent()) {
- throw new CoreException(
- new VendorLicenseModelNotFoundErrorBuilder(itemId.getValue()).build());
- }
- return itemVersion.get();
- }
-
- static Id getFirstVersionId(SessionContext context, Id itemId, ZusammenAdaptor zusammenAdaptor) {
- return getFirstVersion(context, itemId, zusammenAdaptor).getId();
- }
-
- // TODO: 4/25/2017 remove upon working with more than one single version
- static String getVersionTag(Version version) {
- return version.getStatus() == VersionStatus.Locked
- ? null
- : version.toString();
- }
-
- static ZusammenElement buildStructuralElement(StructureElement structureElement, Action action) {
- return ZusammenUtil.buildStructuralElement(structureElement.name(), action);
- }
-
static ZusammenElement getZusammenElement(ElementInfo elementInfo) {
ZusammenElement zusammenElement = new ZusammenElement();
zusammenElement.setElementId(elementInfo.getId());
@@ -67,6 +31,9 @@ public class VlmZusammenUtil {
}
public static Integer toInteger(Object val) {
+ if (val == null) {
+ return null;
+ }
if (val instanceof Double) {
return ((Double) val).intValue();
} else if (val instanceof String) {
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
new file mode 100644
index 0000000000..75fc6f2605
--- /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/convertor/ElementToEntitlementPoolConvertor.java
@@ -0,0 +1,95 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+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.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;
+
+
+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;
+ }
+ 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;
+ }
+
+ private void mapInfoToEntitlementPoolEntity(EntitlementPoolEntity entitlementPool, Info info) {
+ entitlementPool.setName(info.getName());
+ entitlementPool.setDescription(info.getDescription());
+ entitlementPool.setVersionUuId(info.getProperty("version_uuid"));
+ 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"));
+ }
+
+ 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 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
new file mode 100644
index 0000000000..e39c22e569
--- /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/convertor/ElementToFeatureGroupConvertor.java
@@ -0,0 +1,83 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+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;
+
+
+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;
+ }
+ 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;
+ }
+
+
+ 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 mapInfoToFeatureGroup(FeatureGroupEntity featureGroup, Info info) {
+ featureGroup.setName(info.getName());
+ featureGroup.setDescription(info.getDescription());
+ featureGroup.setPartNumber(info.getProperty("partNumber"));
+ featureGroup.setManufacturerReferenceNumber(info.getProperty("manufacturerReferenceNumber"));
+ }
+
+ 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);
+ }
+}
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
new file mode 100644
index 0000000000..a0caa0cf5b
--- /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/convertor/ElementToLicenseAgreementConvertor.java
@@ -0,0 +1,86 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+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.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;
+ }
+ 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()));
+ }
+
+ }
+
+ 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
new file mode 100644
index 0000000000..5956c3e6f1
--- /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/convertor/ElementToLicenseKeyGroupConvertor.java
@@ -0,0 +1,104 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+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.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;
+
+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;
+
+
+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;
+ }
+ 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));
+
+ licenseKeyGroup.setThresholdValue(toInteger(info.getProperty("thresholdValue")));
+ licenseKeyGroup.setIncrements(info.getProperty("increments"));
+ }
+
+ 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 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
new file mode 100644
index 0000000000..4b2370aea1
--- /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/convertor/ElementToLimitConvertor.java
@@ -0,0 +1,44 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import org.openecomp.convertor.ElementConvertor;
+import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LimitType;
+
+/**
+ * Created by ayalaben on 9/26/2017
+ */
+public class ElementToLimitConvertor extends ElementConvertor {
+ @Override
+ public Object 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"));
+
+ 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);
+ }
+ }
+}
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
new file mode 100644
index 0000000000..c2ef5a6c41
--- /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/convertor/ElementToVLMGeneralConvertor.java
@@ -0,0 +1,52 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor;
+
+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.Item;
+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()));
+ vendorLicenseModelEntity.setOldVersion(info.getProperty(
+ VendorLicenseModelDaoZusammenImpl.InfoPropertyName.oldVersion.name()));
+
+
+ return vendorLicenseModelEntity;
+ }
+
+
+}
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 b2f2d488e9..0898e48b54 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,18 +20,12 @@
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 org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -62,23 +56,21 @@ import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.vendorlicense.errors.SubmitUncompletedLicenseModelErrorBuilder;
import org.openecomp.sdc.vendorlicense.errors.VendorLicenseModelNotFoundErrorBuilder;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
-import org.openecomp.sdc.versioning.VersioningManager;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.errors.RequestedVersionInvalidErrorBuilder;
import org.openecomp.sdc.versioning.errors.VersionableSubEntityNotFoundErrorBuilder;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
-public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
-
- private static final VersioningManager versioningManager =
- VersioningManagerFactory.getInstance().createInterface();
+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;
+public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
private static final VendorLicenseModelDao
vendorLicenseModelDao = VendorLicenseModelDaoFactory.getInstance().createInterface();
private static final LicenseAgreementDao
@@ -91,7 +83,6 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
licenseKeyGroupDao = LicenseKeyGroupDaoFactory.getInstance().createInterface();
private static final LimitDao limitDao = LimitDaoFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
/**
* Instantiates a new Vendor license facade.
@@ -106,32 +97,7 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
}
@Override
- public Version checkin(String vendorLicenseModelId, String user) {
- Version newVersion = versioningManager
- .checkin(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user, null);
- updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
- return newVersion;
- }
-
- @Override
- public Version submit(String vendorLicenseModelId, String user) {
- validateCompletedVendorLicenseModel(vendorLicenseModelId, user);
- Version newVersion = versioningManager
- .submit(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user, null);
- updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
- return newVersion;
- }
-
- @Override
- public FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup, String user) {
- Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
- getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Read,
- user), user);
- featureGroup.setVersion(version);
- return getFeatureGroup(featureGroup);
- }
-
- private FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup) {
+ public FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup) {
FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
VersioningUtil
.validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
@@ -142,8 +108,8 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
}
@Override
- public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user) {
- FeatureGroupEntity retrieved = getFeatureGroup(featureGroup, user);
+ public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup) {
+ FeatureGroupEntity retrieved = getFeatureGroup(featureGroup);
FeatureGroupModel featureGroupModel = new FeatureGroupModel();
featureGroupModel.setFeatureGroup(retrieved);
@@ -164,9 +130,9 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
@Override
public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
- String licenseAgreementId, String user) {
+ String licenseAgreementId) {
LicenseAgreementEntity retrieved =
- getLicenseAgreement(vlmId, version, licenseAgreementId, user);
+ getLicenseAgreement(vlmId, version, licenseAgreementId);
LicenseAgreementModel licenseAgreementModel = new LicenseAgreementModel();
licenseAgreementModel.setLicenseAgreement(retrieved);
@@ -180,103 +146,71 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
}
@Override
- public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool,
- String user) {
- entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(),
- getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user));
- //entitlementPool.setId(CommonMethods.nextUuId());
+ public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool) {
entitlementPool.setVersionUuId(CommonMethods.nextUuId());
UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
- entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion().toString(),
+ entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion().getId(),
entitlementPool.getName());
entitlementPoolDao.create(entitlementPool);
- updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(),
- entitlementPool.getVersion());
return entitlementPool;
}
@Override
- public void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user) {
- entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(),
- getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user));
+ public void updateEntitlementPool(EntitlementPoolEntity entitlementPool) {
EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
VersioningUtil
.validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
-
+ if (retrieved.equals(entitlementPool)) {
+ return;
+ }
UniqueValueUtil.updateUniqueValue(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
retrieved.getName(), entitlementPool.getName(), entitlementPool.getVendorLicenseModelId(),
- entitlementPool.getVersion().toString());
+ entitlementPool.getVersion().getId());
entitlementPool.setVersionUuId(CommonMethods.nextUuId());
entitlementPoolDao.update(entitlementPool);
-
- updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(),
- entitlementPool.getVersion());
-
}
@Override
- public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
- String user) {
- return licenseKeyGroupDao.list(new LicenseKeyGroupEntity(vlmId, VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
- null));
+ public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version) {
+ return licenseKeyGroupDao.list(new LicenseKeyGroupEntity(vlmId, version, null));
}
@Override
- public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version,
- String user) {
- return entitlementPoolDao.list(new EntitlementPoolEntity(vlmId, VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
- null));
+ public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version) {
+ return entitlementPoolDao.list(new EntitlementPoolEntity(vlmId, version, null));
}
@Override
- public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
- licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
- getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user));
+ public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
+ if (retrieved.equals(licenseKeyGroup)) {
+ return;
+ }
licenseKeyGroup.setVersionUuId((CommonMethods.nextUuId()));
VersioningUtil
.validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
UniqueValueUtil.updateUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
retrieved.getName(), licenseKeyGroup.getName(), licenseKeyGroup.getVendorLicenseModelId(),
- licenseKeyGroup.getVersion().toString());
+ licenseKeyGroup.getVersion().getId());
licenseKeyGroupDao.update(licenseKeyGroup);
-
- updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
- licenseKeyGroup.getVersion());
}
@Override
- public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
- String user) {
- licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
- getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user));
- //licenseKeyGroup.setId(CommonMethods.nextUuId());
+ public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
licenseKeyGroup.setVersionUuId(CommonMethods.nextUuId());
UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
- licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion().toString(),
+ licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion().getId(),
licenseKeyGroup.getName());
licenseKeyGroupDao.create(licenseKeyGroup);
- updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
- licenseKeyGroup.getVersion());
return licenseKeyGroup;
}
@Override
- public VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version,
- String user) {
+ public VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
- VersionInfo versionInfo = getVersionInfo(vlmId, VersionableEntityAction.Read, user);
-
- VendorLicenseModelEntity vendorLicenseModel = vendorLicenseModelDao.get(
- new VendorLicenseModelEntity(vlmId,
- VersioningUtil.resolveVersion(version, versionInfo, user)));
+ VendorLicenseModelEntity vendorLicenseModel =
+ vendorLicenseModelDao.get(new VendorLicenseModelEntity(vlmId, version));
if (vendorLicenseModel == null) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.GET_VLM, ErrorLevel.ERROR.name(),
@@ -285,90 +219,61 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
}
mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
- return new VersionedVendorLicenseModel(vendorLicenseModel, versionInfo);
- }
-
- @Override
- public VendorLicenseModelEntity createVendorLicenseModel(
- VendorLicenseModelEntity vendorLicenseModelEntity, String user) {
-
- mdcDataDebugMessage.debugEntryMessage(null, null);
-
- UniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME,
- vendorLicenseModelEntity.getVendorName());
- //vendorLicenseModelEntity.setId(CommonMethods.nextUuId());
-
- vendorLicenseModelDao.create(vendorLicenseModelEntity);
- UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME,
- vendorLicenseModelEntity.getVendorName());
-
- Version version = versioningManager
- .create(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelEntity.getId(), user);
- vendorLicenseModelEntity.setVersion(version);
-
- mdcDataDebugMessage.debugExitMessage(null, null);
- return vendorLicenseModelEntity;
+ return vendorLicenseModel;
}
@Override
- public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
- String user) {
- Version version = VersioningUtil.resolveVersion(licenseAgreement.getVersion(),
- getVersionInfo(licenseAgreement.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- licenseAgreement.setVersion(version);
+ public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement) {
//licenseAgreement.setId(CommonMethods.nextUuId());
VersioningUtil.validateEntitiesExistence(licenseAgreement.getFeatureGroupIds(),
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version, null),
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion(),
+ null),
featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
UniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
- licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().toString(),
+ licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().getId(),
licenseAgreement.getName());
licenseAgreementDao.create(licenseAgreement);
UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
- licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().toString(),
+ licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().getId(),
licenseAgreement.getName());
if (licenseAgreement.getFeatureGroupIds() != null) {
for (String addedFgId : licenseAgreement.getFeatureGroupIds()) {
featureGroupDao.addReferencingLicenseAgreement(
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version,
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
+ licenseAgreement.getVersion(),
addedFgId), licenseAgreement.getId());
}
}
- updateVlmLastModificationTime(licenseAgreement.getVendorLicenseModelId(),
- licenseAgreement.getVersion());
-
return licenseAgreement;
}
@Override
- public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user) {
- Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
- getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user), user);
- //featureGroup.setId(CommonMethods.nextUuId());
- featureGroup.setVersion(version);
+ public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup) {
VersioningUtil.validateEntitiesExistence(featureGroup.getLicenseKeyGroupIds(),
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, null),
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
+ null),
licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
VersioningUtil.validateEntitiesExistence(featureGroup.getEntitlementPoolIds(),
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, null),
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
+ null),
entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
UniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
- featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().toString(),
+ featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().getId(),
featureGroup.getName());
featureGroupDao.create(featureGroup);
UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
- featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().toString(),
+ featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().getId(),
featureGroup.getName());
if (featureGroup.getLicenseKeyGroupIds() != null) {
for (String addedLkgId : featureGroup.getLicenseKeyGroupIds()) {
licenseKeyGroupDao.addReferencingFeatureGroup(
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, addedLkgId),
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(), addedLkgId),
featureGroup.getId());
}
}
@@ -376,27 +281,20 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
if (featureGroup.getEntitlementPoolIds() != null) {
for (String addedEpId : featureGroup.getEntitlementPoolIds()) {
entitlementPoolDao.addReferencingFeatureGroup(
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, addedEpId),
- featureGroup.getId());
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
+ featureGroup.getVersion(), addedEpId), featureGroup.getId());
}
}
-
- updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(),
- featureGroup.getVersion());
-
return featureGroup;
}
@Override
- public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version,
- String user) {
+ public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version) {
Collection<FeatureGroupEntity> featureGroupEntities =
- featureGroupDao.list(new FeatureGroupEntity(vlmId, VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user),
- user), null));
+ featureGroupDao.list(new FeatureGroupEntity(vlmId, version, null));
featureGroupEntities.stream()
.filter(fgEntity -> Objects.isNull(fgEntity.getManufacturerReferenceNumber()))
- .forEach(fgEntity -> updateManufacturerNumberInFeatureGroup(fgEntity));
+ .forEach(this::updateManufacturerNumberInFeatureGroup);
return featureGroupEntities;
}
@@ -405,23 +303,22 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
public Collection<ErrorCode> validateLicensingData(String vlmId, Version version,
String licenseAgreementId,
Collection<String> featureGroupIds) {
- try {
+ // TODO: 5/21/2017 validate version exists and final
+/* try {
VersionInfo versionInfo = getVersionInfo(vlmId, VersionableEntityAction.Read, "");
if (version == null || !version.isFinal()
|| !versionInfo.getViewableVersions().contains(version)) {
return Collections.singletonList(new RequestedVersionInvalidErrorBuilder().build());
}
} catch (CoreException exception) {
- log.debug("",exception);
return Collections.singletonList(exception.code());
- }
+ }*/
List<ErrorCode> errorMessages = new ArrayList<>();
try {
- getLicenseAgreement(vlmId, licenseAgreementId, version);
+ getLicenseAgreement(vlmId, version, licenseAgreementId);
} catch (CoreException exception) {
- log.debug("",exception);
errorMessages.add(exception.code());
}
@@ -438,7 +335,6 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
version).build());
}
} catch (CoreException exception) {
- log.debug("",exception);
errorMessages.add(exception.code());
}
}
@@ -447,71 +343,34 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
}
@Override
- public VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action,
- String user) {
- return versioningManager
- .getEntityVersionInfo(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user,
- action);
+ public LicenseAgreementEntity getLicenseAgreement(String vlmId, Version version,
+ String licenseAgreementId) {
+ LicenseAgreementEntity input = new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
+ LicenseAgreementEntity retrieved = licenseAgreementDao.get(input);
+ VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE);
+ return retrieved;
}
@Override
- public void updateVlmLastModificationTime(String vendorLicenseModelId, Version version) {
- VendorLicenseModelEntity retrieved =
- vendorLicenseModelDao.get(new VendorLicenseModelEntity(vendorLicenseModelId, version));
- vendorLicenseModelDao.update(retrieved);
+ public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId) {
+ return limitDao.list(new LimitEntity(vlmId, version, epLkgId, null));
}
@Override
- public LicenseAgreementEntity getLicenseAgreement(String vlmId, Version version,
- String licenseAgreementId, String user) {
- return getLicenseAgreement(vlmId, licenseAgreementId, VersioningUtil
- .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());
+ public LimitEntity createLimit(LimitEntity limit) {
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());
+ public void updateLimit(LimitEntity limit) {
limitDao.update(limit);
- updateVlmLastModificationTime(limit.getVendorLicenseModelId(),
- limit.getVersion());
- }
-
- private LicenseAgreementEntity getLicenseAgreement(String vlmId, String licenseAgreementId,
- Version version) {
- LicenseAgreementEntity input = new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
- LicenseAgreementEntity retrieved = licenseAgreementDao.get(input);
- VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE);
- return retrieved;
}
private void updateManufacturerNumberInFeatureGroup(FeatureGroupEntity featureGroupEntity) {
if (CollectionUtils.isNotEmpty(featureGroupEntity.getEntitlementPoolIds())) {
Object[] entitlementPoolIdsList = featureGroupEntity.getEntitlementPoolIds().toArray();
- if (entitlementPoolIdsList != null && entitlementPoolIdsList.length > 0) {
+ if (entitlementPoolIdsList.length > 0) {
String entitlementPoolId = entitlementPoolIdsList[0].toString();
EntitlementPoolEntity entitlementPoolEntity =
new EntitlementPoolEntity(featureGroupEntity.getVendorLicenseModelId(),
@@ -523,35 +382,40 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
}
}
}
- private void validateCompletedVendorLicenseModel(String vendorLicenseModelId, String user) {
+
+ @Override
+ public void validate(String vendorLicenseModelId, Version version) {
Collection<String> allFeatureGroupEntities = new HashSet<>();
- Version version = VersioningUtil.resolveVersion(null,
- getVersionInfo(vendorLicenseModelId, VersionableEntityAction.Read, user), user);
Collection<LicenseAgreementEntity> licenseAgreements = licenseAgreementDao
- .list(new LicenseAgreementEntity(vendorLicenseModelId, version, null));
+ .list(new LicenseAgreementEntity(vendorLicenseModelId, version, null));
if (CollectionUtils.isNotEmpty(licenseAgreements)) {
licenseAgreements.forEach(licenseAgreement -> {
if (CollectionUtils.isEmpty(licenseAgreement.getFeatureGroupIds())) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
+ LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
throw new CoreException(
- new SubmitUncompletedLicenseModelErrorBuilder(SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG).build());
+ new SubmitUncompletedLicenseModelErrorBuilder(
+ SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG).build());
}
allFeatureGroupEntities.addAll(licenseAgreement.getFeatureGroupIds());
});
allFeatureGroupEntities.forEach(fg -> {
- FeatureGroupEntity featureGroupEntity = featureGroupDao.get(new FeatureGroupEntity(vendorLicenseModelId, version, fg));
- if(CollectionUtils.isEmpty(featureGroupEntity.getEntitlementPoolIds())) {
+ FeatureGroupEntity featureGroupEntity =
+ featureGroupDao.get(new FeatureGroupEntity(vendorLicenseModelId, version, fg));
+ if (CollectionUtils.isEmpty(featureGroupEntity.getEntitlementPoolIds())) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
+ LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
throw new CoreException(
- new SubmitUncompletedLicenseModelErrorBuilder(SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP).build());
+ new SubmitUncompletedLicenseModelErrorBuilder(
+ SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP).build());
}
});
}
}
+
+
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java
index 7cb3e2e844..c62061e529 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/healing/impl/SimpleHealingServiceImpl.java
@@ -40,14 +40,14 @@ import java.util.UUID;
public class SimpleHealingServiceImpl implements HealingService {
private static final EntitlementPoolDao entitlementPoolDao =
- EntitlementPoolDaoFactory.getInstance().createInterface();
+ EntitlementPoolDaoFactory.getInstance().createInterface();
private static final LicenseKeyGroupDao licenseKeyGroupDao =
- LicenseKeyGroupDaoFactory.getInstance().createInterface();
+ LicenseKeyGroupDaoFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@Override
- public VersionableEntity heal(VersionableEntity toHeal, String user) {
- return handleMissingVersionId(toHeal, user);
+ public VersionableEntity heal(VersionableEntity toHeal) {
+ return handleMissingVersionId(toHeal);
}
@Override
@@ -59,10 +59,10 @@ public class SimpleHealingServiceImpl implements HealingService {
}
}
- private VersionableEntity handleMissingVersionId(VersionableEntity toHeal, String user) {
+ private VersionableEntity handleMissingVersionId(VersionableEntity toHeal) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
if (toHeal != null && toHeal.getVersionUuId() != null) {
return toHeal;
@@ -76,13 +76,13 @@ public class SimpleHealingServiceImpl implements HealingService {
licenseKeyGroupDao.update((LicenseKeyGroupEntity) toHeal);
} else {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
+ LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
throw new UnsupportedOperationException(
- "Unsupported operation for 1610 release/1607->1610 migration.");
+ "Unsupported operation for 1610 release/1607->1610 migration.");
}
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
return toHeal;
}
}
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 6dbed22db5..07f19b1e2b 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
@@ -20,9 +20,6 @@
package org.openecomp.sdc.vendorlicense.licenseartifacts.impl;
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH;
-import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VNF_ARTIFACT_NAME_WITH_PATH;
-
import org.apache.commons.collections.CollectionUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
@@ -58,15 +55,14 @@ import static org.openecomp.sdc.vendorlicense.licenseartifacts.impl.util.VendorL
public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifactsService {
public static final VendorLicenseFacade vendorLicenseFacade =
- VendorLicenseFacadeFactory.getInstance().createInterface();
+ VendorLicenseFacadeFactory.getInstance().createInterface();
public static final HealingService healingService =
- HealingServiceFactory.getInstance().createInterface();
+ HealingServiceFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private static byte[] createVnfArtifact(String vspId, String vlmId, Version vlmVersion,
- String vendorName,
- List<String> featureGroups, String user) {
+ private static byte[] createVnfArtifact(String vspId, String vlmId, Version vlmVersion, String vendorName,
+ List<String> featureGroups) {
mdcDataDebugMessage.debugEntryMessage("VLM name", vendorName);
@@ -78,30 +74,31 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts
if (featureGroups != null) {
for (String featureGroupId : featureGroups) {
FeatureGroupModel featureGroupModel = vendorLicenseFacade
- .getFeatureGroupModel(new FeatureGroupEntity(vlmId, vlmVersion, featureGroupId), user);
+ .getFeatureGroupModel(new FeatureGroupEntity(vlmId, vlmVersion, featureGroupId));
Set<EntitlementPoolEntity> entitlementPoolEntities =
- featureGroupModel.getEntitlementPools();
+ featureGroupModel.getEntitlementPools();
for (EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities) {
entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
- entitlementPoolEntity.getId(), user));
+ entitlementPoolEntity.getId()));
entitlementPoolEntity.setManufacturerReferenceNumber(featureGroupModel.
- getEntityManufacturerReferenceNumber());
+ getEntityManufacturerReferenceNumber());
}
+
Set<LicenseKeyGroupEntity> licenseKeyGroupEntities =
- featureGroupModel.getLicenseKeyGroups();
+ featureGroupModel.getLicenseKeyGroups();
for (LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
- licenseKeyGroupEntity.getId(), user));
+ licenseKeyGroupEntity.getId()));
licenseKeyGroupEntity.setManufacturerReferenceNumber(featureGroupModel.
- getEntityManufacturerReferenceNumber());
+ getEntityManufacturerReferenceNumber());
}
featureGroupModel.setEntitlementPools(entitlementPoolEntities.stream().map(
- entitlementPoolEntity -> (EntitlementPoolEntity) healingService
- .heal(entitlementPoolEntity, user)).collect(Collectors.toSet()));
+ entitlementPoolEntity -> (EntitlementPoolEntity) healingService
+ .heal(entitlementPoolEntity)).collect(Collectors.toSet()));
featureGroupModel.setLicenseKeyGroups(licenseKeyGroupEntities.stream().map(
- licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService
- .heal(licenseKeyGroupEntity, user)).collect(Collectors.toSet()));
+ licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService
+ .heal(licenseKeyGroupEntity)).collect(Collectors.toSet()));
artifact.getFeatureGroups().add(featureGroupModel);
}
}
@@ -110,7 +107,7 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts
return artifact.toXml().getBytes();
}
- private static byte[] createVendorLicenseArtifact(String vlmId, String vendorName, String user) {
+ private static byte[] createVendorLicenseArtifact(String vlmId, String vendorName) {
mdcDataDebugMessage.debugEntryMessage("VLM name", vendorName);
@@ -122,40 +119,37 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts
List<Version> finalVersions = getFinalVersionsForVlm(vlmId);
for (Version finalVersion : finalVersions) {
- Collection<EntitlementPoolEntity> coll = vendorLicenseFacade.listEntitlementPools(vlmId,
- finalVersion, user);
- coll.stream().forEach(entitlementPoolEntity -> {
+ Collection<EntitlementPoolEntity> eps =
+ vendorLicenseFacade.listEntitlementPools(vlmId, finalVersion);
+ eps.forEach(entitlementPoolEntity -> {
entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, finalVersion,
- entitlementPoolEntity.getId(), user));
+ entitlementPoolEntity.getId()));
Optional<String> manufacturerReferenceNumber = getFeatureGroupManufactureRefNumber
- (entitlementPoolEntity.getReferencingFeatureGroups(), vlmId, finalVersion, user);
+ (entitlementPoolEntity.getReferencingFeatureGroups(), vlmId, finalVersion);
manufacturerReferenceNumber
- .ifPresent(entitlementPoolEntity::setManufacturerReferenceNumber);
+ .ifPresent(entitlementPoolEntity::setManufacturerReferenceNumber);
});
+ entitlementPoolEntities.addAll(eps);
- entitlementPoolEntities.addAll(coll);
+ Collection<LicenseKeyGroupEntity> lkgs =
+ vendorLicenseFacade.listLicenseKeyGroups(vlmId, finalVersion);
- Collection<LicenseKeyGroupEntity> coll2 = vendorLicenseFacade.listLicenseKeyGroups(vlmId,
- finalVersion, user);
-
- coll2.stream().forEach(licenseKeyGroupEntity -> {
+ lkgs.forEach(licenseKeyGroupEntity -> {
licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, finalVersion,
- licenseKeyGroupEntity.getId(), user));
+ licenseKeyGroupEntity.getId()));
Optional<String> manufacturerReferenceNumber = getFeatureGroupManufactureRefNumber
- (licenseKeyGroupEntity.getReferencingFeatureGroups(), vlmId, finalVersion, user);
+ (licenseKeyGroupEntity.getReferencingFeatureGroups(), vlmId, finalVersion);
manufacturerReferenceNumber
- .ifPresent(licenseKeyGroupEntity::setManufacturerReferenceNumber);
+ .ifPresent(licenseKeyGroupEntity::setManufacturerReferenceNumber);
});
-
- licenseKeyGroupEntities.addAll(coll2);
+ licenseKeyGroupEntities.addAll(lkgs);
}
+
entitlementPoolEntities =
- healEPs(user, filterChangedEntities(prepareForFiltering(entitlementPoolEntities, user,
- true)));
+ healEPs(filterChangedEntities(prepareForFiltering(entitlementPoolEntities, true)));
licenseKeyGroupEntities =
- healLkgs(user, filterChangedEntities(prepareForFiltering(licenseKeyGroupEntities, user,
- false)));
+ healLkgs(filterChangedEntities(prepareForFiltering(licenseKeyGroupEntities, false)));
vendorLicenseArtifact.setEntitlementPoolEntities(entitlementPoolEntities);
vendorLicenseArtifact.setLicenseKeyGroupEntities(licenseKeyGroupEntities);
@@ -165,21 +159,20 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts
private static Optional<String> getFeatureGroupManufactureRefNumber(Set<String> featureGroupIds,
String vlmId,
- Version finalVersion,
- String user) {
+ Version finalVersion) {
String manufactureReferenceNumber = null;
if (CollectionUtils.isNotEmpty(featureGroupIds)) {
Object[] featureGroupIdsList = featureGroupIds.toArray();
if (featureGroupIdsList.length > 0) {
FeatureGroupEntity featureGroup =
- vendorLicenseFacade.getFeatureGroup(new FeatureGroupEntity(vlmId, finalVersion,
- featureGroupIdsList[0].toString()), user);
+ vendorLicenseFacade.getFeatureGroup(new FeatureGroupEntity(vlmId, finalVersion,
+ featureGroupIdsList[0].toString()));
manufactureReferenceNumber = featureGroup != null ? featureGroup
- .getManufacturerReferenceNumber() : null;
+ .getManufacturerReferenceNumber() : null;
}
}
return manufactureReferenceNumber != null ? Optional.of(manufactureReferenceNumber) :
- Optional.empty();
+ Optional.empty();
}
@@ -190,22 +183,21 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts
* @param vlmId vlmId
* @param vlmVersion vlmVersion
* @param featureGroups featureGroups
- * @param user user
* @return FileContentHandler
*/
public FileContentHandler createLicenseArtifacts(String vspId, String vlmId, Version vlmVersion,
- List<String> featureGroups, String user) {
+ List<String> featureGroups) {
mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
FileContentHandler artifacts = new FileContentHandler();
- String vendorName = getVendorName(vlmId, user);
+ String vendorName = getVendorName(vlmId);
artifacts.addFile(VNF_ARTIFACT_NAME_WITH_PATH,
- createVnfArtifact(vspId, vlmId, vlmVersion, vendorName, featureGroups, user));
+ createVnfArtifact(vspId, vlmId, vlmVersion, vendorName, featureGroups));
artifacts.addFile(VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH,
- createVendorLicenseArtifact(vlmId, vendorName, user));
+ createVendorLicenseArtifact(vlmId, vendorName));
mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
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 b2cb710eec..91a73b6377 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
@@ -38,11 +38,11 @@ import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinF
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")
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 ac45528acd..70ef26f573 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
@@ -62,12 +62,18 @@ public abstract class MixinEntitlementPoolEntityForVendorLicenseArtifact {
@JsonProperty(value = "version")
abstract String getVersionForArtifact();
- @JsonProperty(value = "start-date")
+ @JsonIgnore
abstract String getStartDate();
- @JsonProperty(value = "expiry-date")
+ @JsonIgnore
abstract String getExpiryDate();
+ @JsonProperty(value = "start-date")
+ abstract String getIsoFormatStartDate();
+
+ @JsonProperty(value = "expiry-date")
+ abstract String getIsoFormatExpiryDate();
+
@JsonIgnore
abstract String getVendorLicenseModelId();
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 ad1a9a6bdf..7618b7a54f 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
@@ -42,7 +42,7 @@ public abstract class MixinEntitlementPoolEntityForVnfArtifact {
@JsonProperty(value = "threshold-value")
abstract ThresholdForXml getThresholdForArtifact();
- @JsonIgnore
+ @JsonProperty(value = "entitlement-pool-invariant-uuid")
abstract String getId();
@JsonProperty(value = "manufacturer-reference-number")
@@ -60,7 +60,7 @@ public abstract class MixinEntitlementPoolEntityForVnfArtifact {
@JsonIgnore
abstract String getVersion();
- @JsonIgnore
+ @JsonProperty(value = "version")
abstract String getVersionForArtifact();
@JsonIgnore
@@ -72,12 +72,18 @@ public abstract class MixinEntitlementPoolEntityForVnfArtifact {
@JsonIgnore
abstract float getThresholdValue();
- @JsonProperty(value = "start-date")
+ @JsonIgnore
abstract String getStartDate();
- @JsonProperty(value = "expiry-date")
+ @JsonIgnore
abstract String getExpiryDate();
+ @JsonProperty(value = "start-date")
+ abstract String getIsoFormatStartDate();
+
+ @JsonProperty(value = "expiry-date")
+ abstract String getIsoFormatExpiryDate();
+
@JsonIgnore
abstract ChoiceOrOther<EntitlementMetric> getEntitlementMetric();
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 5a8e9966cc..eeaa7c0a3a 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
@@ -79,12 +79,18 @@ public abstract class MixinLicenseKeyGroupEntityForVendorLicenseArtifact {
@JsonIgnore
abstract Collection<LimitEntity> getLimits();
- @JsonProperty(value = "start-date")
+ @JsonIgnore
abstract String getStartDate();
- @JsonProperty(value = "expiry-date")
+ @JsonIgnore
abstract String getExpiryDate();
+ @JsonProperty(value = "start-date")
+ abstract String getIsoFormatStartDate();
+
+ @JsonProperty(value = "expiry-date")
+ abstract String getIsoFormatExpiryDate();
+
@JsonProperty(value = "threshold-value")
abstract ThresholdForXml getThresholdForArtifact();
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 4af4b592a9..f560f363a1 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
@@ -34,7 +34,7 @@ import java.util.Collection;
import java.util.Set;
public abstract class MixinLicenseKeyGroupEntityForVnfArtifact {
- @JsonIgnore
+ @JsonProperty(value = "license-key-group-invariant-uuid")
abstract String getId();
@JsonProperty(value = "manufacturer-reference-number")
@@ -46,7 +46,7 @@ public abstract class MixinLicenseKeyGroupEntityForVnfArtifact {
@JsonIgnore
abstract String getVersion();
- @JsonIgnore
+ @JsonProperty(value = "version")
abstract String getVersionForArtifact();
@JsonIgnore
@@ -87,12 +87,18 @@ public abstract class MixinLicenseKeyGroupEntityForVnfArtifact {
@JsonIgnore
abstract Collection<LimitEntity> getLimits();
- @JsonProperty(value = "start-date")
+ @JsonIgnore
abstract String getStartDate();
- @JsonProperty(value = "expiry-date")
+ @JsonIgnore
abstract String getExpiryDate();
+ @JsonProperty(value = "start-date")
+ abstract String getIsoFormatStartDate();
+
+ @JsonProperty(value = "expiry-date")
+ abstract String getIsoFormatExpiryDate();
+
@JsonIgnore
abstract String getThresholdUnits();
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/util/VendorLicenseArtifactsServiceUtils.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java
index 502aa350b9..bd209f9e81 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java
@@ -27,16 +27,19 @@ import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
import org.openecomp.sdc.vendorlicense.healing.HealingService;
import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.VendorLicenseArtifactsServiceImpl;
+import org.openecomp.sdc.versioning.ItemManagerFactory;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.stream.Collectors;
/**
* @author katyr
@@ -45,7 +48,7 @@ import java.util.Set;
public class VendorLicenseArtifactsServiceUtils {
private static final HealingService healingService =
- HealingServiceFactory.getInstance().createInterface();
+ HealingServiceFactory.getInstance().createInterface();
/**
* maps the entities by id
@@ -53,7 +56,7 @@ public class VendorLicenseArtifactsServiceUtils {
* @return a Map of id -> list of versionable entities with that id
*/
private static MultiValuedMap<String, VersionableEntity> mapById(
- Collection<? extends VersionableEntity> versionableEntities) {
+ Collection<? extends VersionableEntity> versionableEntities) {
MultiValuedMap<String, VersionableEntity> mappedById = new ArrayListValuedHashMap<>();
for (VersionableEntity ve : versionableEntities) {
mappedById.put(ve.getId(), ve);
@@ -62,17 +65,18 @@ public class VendorLicenseArtifactsServiceUtils {
}
/**
- * For all entities with same id, only entities that differ from one another will be returned.
- * If no change has occured, the entity with the earlier VLM version will be returned.
- * If only one version of said entities exists it will be returned
+ * For all entities with same id, only entities that differ from one another will be returned.
+ * If no change has occured, the entity with the earlier VLM version will be returned.
+ * If only one version of said entities exists it will be returned
+ *
* @return a list of entities that has been changed
*/
public static List<VersionableEntity> filterChangedEntities(
- Collection<? extends VersionableEntity> versionableEntities) {
+ Collection<? extends VersionableEntity> versionableEntities) {
MultiValuedMap<String, VersionableEntity> entitiesById = mapById(
- versionableEntities);
+ versionableEntities);
MultiValuedMap<String, VersionableEntity> entitiesByVersionUuId =
- new ArrayListValuedHashMap<>();
+ new ArrayListValuedHashMap<>();
List<VersionableEntity> changedOnly = new ArrayList<>();
for (String epId : entitiesById.keySet()) {
@@ -85,7 +89,7 @@ public class VendorLicenseArtifactsServiceUtils {
//for every list of eps which have the same uuid, get the one with the earliest vlm version.
for (String versionUid : entitiesByVersionUuId.keySet()) {
List<VersionableEntity> versionableEntitiesForUuid =
- (List<VersionableEntity>) entitiesByVersionUuId.get(versionUid);
+ (List<VersionableEntity>) entitiesByVersionUuId.get(versionUid);
versionableEntitiesForUuid.sort(new VersionableEntitySortByVlmMajorVersion());
changedOnly.add(versionableEntitiesForUuid.get(0));
}
@@ -93,40 +97,38 @@ public class VendorLicenseArtifactsServiceUtils {
return changedOnly;
}
- public static Set<LicenseKeyGroupEntity> healLkgs(String user,
- Collection<? extends VersionableEntity> licenseKeyGroupEntities) {
+ public static Set<LicenseKeyGroupEntity> healLkgs(
+ Collection<? extends VersionableEntity> licenseKeyGroupEntities) {
Set<LicenseKeyGroupEntity> healed = new HashSet<>();
for (VersionableEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
healed.add((LicenseKeyGroupEntity) VendorLicenseArtifactsServiceImpl.healingService
- .heal(licenseKeyGroupEntity, user));
+ .heal(licenseKeyGroupEntity));
}
return healed;
}
- public static Set<EntitlementPoolEntity> healEPs(String user,
- Collection<? extends VersionableEntity> entitlementPoolEntities) {
+ public static Set<EntitlementPoolEntity> healEPs(
+ Collection<? extends VersionableEntity> entitlementPoolEntities) {
Set<EntitlementPoolEntity> healed = new HashSet<>();
for (VersionableEntity entitlementPoolEntity : entitlementPoolEntities) {
healed.add((EntitlementPoolEntity) VendorLicenseArtifactsServiceImpl.healingService
- .heal(entitlementPoolEntity, user));
+ .heal(entitlementPoolEntity));
}
return healed;
}
public static List<Version> getFinalVersionsForVlm(String vlmId) {
- VersionInfo versionInfo =
- VendorLicenseArtifactsServiceImpl.vendorLicenseFacade
- .getVersionInfo(vlmId, VersionableEntityAction.Read, "");
- return versionInfo.getFinalVersions();
-
+ VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface();
+ return versioningManager.list(vlmId).stream()
+ .filter(version -> VersionStatus.Certified == version.getStatus())
+ .map(certifiedVersion -> versioningManager.get(vlmId, certifiedVersion)) //sync to private
+ .collect(Collectors.toList());
}
- public static String getVendorName(String vendorLicenseModelId, String user) {
- return VendorLicenseArtifactsServiceImpl.vendorLicenseFacade
- .getVendorLicenseModel(vendorLicenseModelId, null, user)
- .getVendorLicenseModel().getVendorName();
+ public static String getVendorName(String vendorLicenseModelId) {
+ return ItemManagerFactory.getInstance().createInterface().get(vendorLicenseModelId).getName();
}
@@ -140,38 +142,36 @@ public class VendorLicenseArtifactsServiceUtils {
* to healing as before. For VLMs created post-bugfix this code should not update any element
*/
public static Collection<? extends VersionableEntity> prepareForFiltering(Collection<? extends
- VersionableEntity> versionableEntities, String user, boolean isEP) {
+ VersionableEntity> versionableEntities, boolean isEP) {
MultiValuedMap<String, VersionableEntity> entitiesById = mapById(
- versionableEntities);
+ versionableEntities);
for (String epId : entitiesById.keySet()) {
List<VersionableEntity> versionableEntitiesForId = new ArrayList<>();
versionableEntitiesForId.addAll(entitiesById.get(epId));
versionableEntitiesForId.sort(new VersionableEntitySortByVlmMajorVersion());
- healingService.heal(versionableEntitiesForId.get(0), user);
+ healingService.heal(versionableEntitiesForId.get(0));
for (int i = 1; i < versionableEntitiesForId.size(); i++) {
if (isEP) {
EntitlementPoolEntity current = (EntitlementPoolEntity) versionableEntitiesForId.get(i);
EntitlementPoolEntity previous = (EntitlementPoolEntity) versionableEntitiesForId
- .get(i - 1);
+ .get(i - 1);
if (current.equals(previous) && current.getVersionUuId() == null) {
current.setVersionUuId(previous.getVersionUuId());
healingService.persistNoHealing(current);
} else {
- versionableEntitiesForId.set(i, healingService.heal(versionableEntitiesForId.get(i),
- user));
+ versionableEntitiesForId.set(i, healingService.heal(versionableEntitiesForId.get(i)));
}
} else {
LicenseKeyGroupEntity current = (LicenseKeyGroupEntity) versionableEntitiesForId.get(i);
LicenseKeyGroupEntity previous = (LicenseKeyGroupEntity) versionableEntitiesForId
- .get(i - 1);
+ .get(i - 1);
if (current.equals(previous) && current.getVersionUuId() == null) {
current.setVersionUuId(previous.getVersionUuId());
healingService.persistNoHealing(current);
} else {
- versionableEntitiesForId.set(i, healingService.heal(versionableEntitiesForId.get(i),
- user));
+ versionableEntitiesForId.set(i, healingService.heal(versionableEntitiesForId.get(i)));
}