summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main
diff options
context:
space:
mode:
authorAvi Ziv <avi.ziv@amdocs.com>2017-07-18 19:45:38 +0300
committerAvi Ziv <avi.ziv@amdocs.com>2017-07-18 19:45:38 +0300
commitb8e2faf476202b6ffe61bc3a9a37df1304881d40 (patch)
treef78b8c0517d8e16c5ae610bf8b49f68ea8a312a1 /openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main
parent75aacbbe1acf78fa53378f07f0a8c7769449a17e (diff)
[SDC] Onboarding 1710 rebase.
Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535 Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/EntitlementPoolDao.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LimitDao.java10
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LimitDaoFactory.java10
-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.java100
-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/FeatureGroupEntity.java17
-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/FeatureGroupModel.java4
-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.java62
-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.java193
-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/LimitType.java10
-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/MultiChoiceOrOther.java16
-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/xml/LimitForXml.java42
-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/xml/LimitXml.java95
-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/xml/ThresholdForXml.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/InvalidDateErrorBuilder.java43
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseErrorCodes.java8
-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.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/resources/factoryConfiguration.json4
17 files changed, 609 insertions, 21 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/EntitlementPoolDao.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/EntitlementPoolDao.java
index 28524e8977..b42f64de7c 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/EntitlementPoolDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/EntitlementPoolDao.java
@@ -35,6 +35,8 @@ public interface EntitlementPoolDao extends VersionableDao, BaseDao<EntitlementP
EntitlementPoolEntity get(EntitlementPoolEntity entitlementPool);
+ String getManufacturerReferenceNumber(EntitlementPoolEntity entitlementPoolEntity);
+
Collection<EntitlementPoolEntity> list(EntitlementPoolEntity entitlementPool);
long count(EntitlementPoolEntity entitlementPool);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LimitDao.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LimitDao.java
new file mode 100644
index 0000000000..49112ecf9f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LimitDao.java
@@ -0,0 +1,10 @@
+package org.openecomp.sdc.vendorlicense.dao;
+
+import org.openecomp.core.dao.BaseDao;
+import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
+import org.openecomp.sdc.versioning.dao.VersionableDao;
+
+public interface LimitDao extends VersionableDao, BaseDao<LimitEntity> {
+
+ boolean isLimitPresent(LimitEntity limitEntity);
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LimitDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LimitDaoFactory.java
new file mode 100644
index 0000000000..72e8f42e78
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LimitDaoFactory.java
@@ -0,0 +1,10 @@
+package org.openecomp.sdc.vendorlicense.dao;
+
+import org.openecomp.core.factory.api.AbstractComponentFactory;
+import org.openecomp.core.factory.api.AbstractFactory;
+
+public abstract class LimitDaoFactory extends AbstractComponentFactory<LimitDao> {
+ public static LimitDaoFactory getInstance() {
+ return AbstractFactory.getInstance(LimitDaoFactory.class);
+ }
+}
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 0a704721d5..ce225931f5 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
@@ -30,9 +30,12 @@ import org.openecomp.sdc.vendorlicense.dao.types.xml.AggregationFunctionForXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementMetricForXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementTimeForXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.ThresholdForXml;
+import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitXml;
+import org.openecomp.sdc.vendorlicense.dao.types.xml.LimitForXml;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
@@ -56,7 +59,7 @@ public class EntitlementPoolEntity implements VersionableEntity {
private String description;
@Column(name = "threshold")
- private int thresholdValue;
+ private Integer thresholdValue;
@Column(name = "threshold_unit")
@Enumerated
@@ -87,6 +90,12 @@ public class EntitlementPoolEntity implements VersionableEntity {
@Column(name = "version_uuid")
private String versionUuId;
+
+ private String startDate;
+ private String expiryDate;
+
+ private Collection<LimitEntity> limits;
+
public EntitlementPoolEntity() {
}
@@ -175,11 +184,11 @@ public class EntitlementPoolEntity implements VersionableEntity {
this.description = description;
}
- public int getThresholdValue() {
+ public Integer getThresholdValue() {
return thresholdValue;
}
- public void setThresholdValue(int thresholdValue) {
+ public void setThresholdValue(Integer thresholdValue) {
this.thresholdValue = thresholdValue;
}
@@ -222,7 +231,9 @@ public class EntitlementPoolEntity implements VersionableEntity {
}
public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) {
- operationalScope.resolveEnum(OperationalScope.class);
+ if(operationalScope != null) {
+ operationalScope.resolveEnum(OperationalScope.class);
+ }
this.operationalScope = operationalScope;
}
@@ -292,12 +303,83 @@ public class EntitlementPoolEntity implements VersionableEntity {
return timeForXml;
}
+ public String getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(String startDate) {
+ this.startDate = startDate;
+ }
+
+ public String getExpiryDate() {
+ return expiryDate;
+ }
+
+ public void setExpiryDate(String expiryDate) {
+ this.expiryDate = expiryDate;
+ }
+
+ public Collection<LimitEntity> getLimits() {
+ return limits;
+ }
+
+ public void setLimits(Collection<LimitEntity> limits) {
+ this.limits = limits;
+ }
+
+ public LimitForXml getSPLimits(){
+ if(limits != null){
+ Set<LimitXml> hs = new HashSet<>();
+ for(LimitEntity obj : limits){
+ if(obj.getType().equals(LimitType.ServiceProvider)){
+ LimitXml xmlObj = new LimitXml();
+ xmlObj.setDescription(obj.getDescription());
+ xmlObj.setMetric(obj.getMetric().toString());
+ xmlObj.setValues(obj.getValue()!=null?Integer.toString(obj.getValue()):null);
+ xmlObj.setUnit(obj.getUnit()!=null?Integer.toString(obj.getUnit()):null);
+ xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+ xmlObj.setTime(obj.getTime()!=null?obj.getTime().name():null);
+ hs.add(xmlObj);
+ }
+ }
+ LimitForXml spLimitForXml = new LimitForXml();
+ spLimitForXml.setLimits(hs);
+ return spLimitForXml;
+ }
+
+ return null;
+ }
+
+ public LimitForXml getVendorLimits(){
+ if(limits != null){
+ Set<LimitXml> hs = new HashSet<>();
+ for(LimitEntity obj : limits){
+ if(obj.getType().equals(LimitType.Vendor)){
+ LimitXml xmlObj = new LimitXml();
+ xmlObj.setDescription(obj.getDescription());
+ xmlObj.setMetric(obj.getMetric().toString());
+ xmlObj.setValues(obj.getValue()!=null?Integer.toString(obj.getValue()):null);
+ xmlObj.setUnit(obj.getUnit()!=null?Integer.toString(obj.getUnit()):null);
+ xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+ xmlObj.setTime(obj.getTime()!=null?obj.getTime().name():null);
+ hs.add(xmlObj);
+ }
+ }
+ LimitForXml vendorLimitForXml = new LimitForXml();
+ vendorLimitForXml.setLimits(hs);
+ return vendorLimitForXml;
+ }
+
+ return null;
+ }
+
+
@Override
public int hashCode() {
return Objects
.hash(vendorLicenseModelId, version, id, name, description, thresholdValue, thresholdUnit,
entitlementMetric, increments, aggregationFunction, operationalScope, time,
- manufacturerReferenceNumber, referencingFeatureGroups);
+ manufacturerReferenceNumber, referencingFeatureGroups, startDate, expiryDate);
}
@Override
@@ -309,7 +391,7 @@ public class EntitlementPoolEntity implements VersionableEntity {
return false;
}
EntitlementPoolEntity that = (EntitlementPoolEntity) obj;
- return Float.compare(that.thresholdValue, thresholdValue) == 0
+ return Objects.equals(that.thresholdValue, thresholdValue)
&& Objects.equals(vendorLicenseModelId, that.vendorLicenseModelId)
&& Objects.equals(id, that.id)
&& Objects.equals(name, that.name)
@@ -321,7 +403,9 @@ public class EntitlementPoolEntity implements VersionableEntity {
&& Objects.equals(operationalScope, that.operationalScope)
&& Objects.equals(time, that.time)
&& Objects.equals(manufacturerReferenceNumber, that.manufacturerReferenceNumber)
- && Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups);
+ && Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups)
+ && Objects.equals(startDate, that.startDate)
+ && Objects.equals(expiryDate, that.expiryDate);
}
@Override
@@ -342,6 +426,8 @@ public class EntitlementPoolEntity implements VersionableEntity {
+ ", manufacturerReferenceNumber='" + manufacturerReferenceNumber + '\''
+ ", referencingFeatureGroups=" + referencingFeatureGroups
+ ", version_uuid=" + versionUuId
+ + ", startDate=" + startDate
+ + ", expiryDate=" + expiryDate
+ '}';
}
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/FeatureGroupEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/FeatureGroupEntity.java
index a297f8aa63..f1fc1a96f1 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/FeatureGroupEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/FeatureGroupEntity.java
@@ -49,6 +49,8 @@ public class FeatureGroupEntity implements VersionableEntity {
private String description;
@Column(name = "part_num")
private String partNumber;
+ @Column(name = "manufacturer_ref_num")
+ private String manufacturerReferenceNumber;
@Column(name = "lkg_ids")
private Set<String> licenseKeyGroupIds = new HashSet<>();
@Column(name = "ep_ids")
@@ -134,6 +136,14 @@ public class FeatureGroupEntity implements VersionableEntity {
this.partNumber = partNumber;
}
+ public String getManufacturerReferenceNumber() {
+ return manufacturerReferenceNumber;
+ }
+
+ public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) {
+ this.manufacturerReferenceNumber = manufacturerReferenceNumber;
+ }
+
public Set<String> getLicenseKeyGroupIds() {
return licenseKeyGroupIds;
}
@@ -161,8 +171,9 @@ public class FeatureGroupEntity implements VersionableEntity {
@Override
public int hashCode() {
return Objects
- .hash(vendorLicenseModelId, version, id, name, description, partNumber, licenseKeyGroupIds,
- entitlementPoolIds, referencingLicenseAgreements);
+ .hash(vendorLicenseModelId, version, id, name, description, partNumber,
+ manufacturerReferenceNumber, licenseKeyGroupIds, entitlementPoolIds,
+ referencingLicenseAgreements);
}
@Override
@@ -180,6 +191,7 @@ public class FeatureGroupEntity implements VersionableEntity {
&& Objects.equals(name, that.name)
&& Objects.equals(description, that.description)
&& Objects.equals(partNumber, that.partNumber)
+ && Objects.equals(manufacturerReferenceNumber, that.manufacturerReferenceNumber)
&& Objects.equals(licenseKeyGroupIds, that.licenseKeyGroupIds)
&& Objects.equals(entitlementPoolIds, that.entitlementPoolIds)
&& Objects.equals(referencingLicenseAgreements, that.referencingLicenseAgreements);
@@ -194,6 +206,7 @@ public class FeatureGroupEntity implements VersionableEntity {
+ ", name='" + name + '\''
+ ", description='" + description + '\''
+ ", partNumber='" + partNumber + '\''
+ + ", manufacturerReferenceNumber='" + manufacturerReferenceNumber + '\''
+ ", licenseKeyGroupIds=" + licenseKeyGroupIds
+ ", entitlementPoolIds=" + entitlementPoolIds
+ ", referencingLicenseAgreements=" + referencingLicenseAgreements
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/FeatureGroupModel.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/FeatureGroupModel.java
index 174cbbb9b9..7e4ba8051e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/FeatureGroupModel.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/FeatureGroupModel.java
@@ -70,5 +70,9 @@ public class FeatureGroupModel {
return featureGroup.getPartNumber();
}
+ public String getEntityManufacturerReferenceNumber(){
+ return featureGroup.getManufacturerReferenceNumber();
+ }
+
}
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 07641594c2..654093de28 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
@@ -27,9 +27,12 @@ import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
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.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
@@ -59,6 +62,7 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
@Column(name = "version_uuid")
private String versionUuId;
+ private Collection<LimitEntity> limits;
public LicenseKeyGroupEntity() {
}
@@ -149,7 +153,9 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
}
public void setOperationalScope(MultiChoiceOrOther<OperationalScope> operationalScope) {
- operationalScope.resolveEnum(OperationalScope.class);
+ if(operationalScope != null) {
+ operationalScope.resolveEnum(OperationalScope.class);
+ }
this.operationalScope = operationalScope;
}
@@ -161,6 +167,60 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
this.referencingFeatureGroups = referencingFeatureGroups;
}
+ public Collection<LimitEntity> getLimits() {
+ return limits;
+ }
+
+ public void setLimits(Collection<LimitEntity> limits) {
+ this.limits = limits;
+ }
+
+ public LimitForXml getSPLimits(){
+ if(limits != null){
+ Set<LimitXml> hs = new HashSet<>();
+ for(LimitEntity obj : limits){
+ if(obj.getType().equals(LimitType.ServiceProvider)){
+ LimitXml xmlObj = new LimitXml();
+ xmlObj.setDescription(obj.getDescription());
+ xmlObj.setMetric(obj.getMetric().toString());
+ xmlObj.setValues(obj.getValue()!=null?Integer.toString(obj.getValue()):null);
+ xmlObj.setUnit(obj.getUnit()!=null?Integer.toString(obj.getUnit()):null);
+ xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+ xmlObj.setTime(obj.getTime()!=null?obj.getTime().name():null);
+ hs.add(xmlObj);
+ }
+ }
+ LimitForXml spLimitForXml = new LimitForXml();
+ spLimitForXml.setLimits(hs);
+ return spLimitForXml;
+ }
+
+ return null;
+ }
+
+ public LimitForXml getVendorLimits(){
+ if(limits != null){
+ Set<LimitXml> hs = new HashSet<>();
+ for(LimitEntity obj : limits){
+ if(obj.getType().equals(LimitType.Vendor)){
+ LimitXml xmlObj = new LimitXml();
+ xmlObj.setDescription(obj.getDescription());
+ xmlObj.setMetric(obj.getMetric().toString());
+ xmlObj.setValues(obj.getValue()!=null?Integer.toString(obj.getValue()):null);
+ xmlObj.setUnit(obj.getUnit()!=null?Integer.toString(obj.getUnit()):null);
+ xmlObj.setAggregationFunction(obj.getAggregationFunction()!=null?obj.getAggregationFunction().name():null);
+ xmlObj.setTime(obj.getTime()!=null?obj.getTime().name():null);
+ hs.add(xmlObj);
+ }
+ }
+ LimitForXml vendorLimitForXml = new LimitForXml();
+ vendorLimitForXml.setLimits(hs);
+ return vendorLimitForXml;
+ }
+
+ return null;
+ }
+
@Override
public int hashCode() {
return Objects
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
new file mode 100644
index 0000000000..ba9c38f453
--- /dev/null
+++ 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
@@ -0,0 +1,193 @@
+package org.openecomp.sdc.vendorlicense.dao.types;
+
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
+
+import java.util.Objects;
+
+public class LimitEntity implements VersionableEntity {
+ private static final String ENTITY_TYPE = "Limit";
+
+ private String id;
+ private String vendorLicenseModelId;
+ private String epLkgId;
+ private String name;
+ private LimitType type;
+ private String description;
+ private EntitlementMetric metric;
+ private Version version;
+ private Integer value;
+ private Integer unit;
+ private AggregationFunction aggregationFunction;
+ private EntitlementTime time;
+
+ public LimitEntity() {
+ }
+
+ public LimitEntity(String vlmId, Version version, String epLkgId, String id) {
+ this.vendorLicenseModelId = vlmId;
+ this.version = version;
+ this.epLkgId = epLkgId;
+ this.id = id;
+ }
+
+ public Integer getUnit() {
+ return unit;
+ }
+
+ public void setUnit(Integer unit) {
+ this.unit = unit;
+ }
+
+ public AggregationFunction getAggregationFunction() {
+ return aggregationFunction;
+ }
+
+ public void setAggregationFunction(
+ AggregationFunction aggregationFunction) {
+ this.aggregationFunction = aggregationFunction;
+ }
+
+ public EntitlementTime getTime() {
+ return time;
+ }
+
+ public void setTime(EntitlementTime time) {
+ this.time = time;
+ }
+
+
+ @Override
+ public String getEntityType() {
+ return ENTITY_TYPE;
+ }
+
+ @Override
+ public String getFirstClassCitizenId() {
+ return getVendorLicenseModelId();
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public Version getVersion() {
+ return version;
+ }
+
+ public String getEpLkgId() {
+ return epLkgId;
+ }
+
+ public void setEpLkgId(String epLkgId) {
+ this.epLkgId = epLkgId;
+ }
+
+ @Override
+ public void setVersion(Version version) {
+ this.version = version;
+ }
+
+ public String getVendorLicenseModelId() {
+ return vendorLicenseModelId;
+ }
+
+ public void setVendorLicenseModelId(String vendorLicenseModelId) {
+ this.vendorLicenseModelId = vendorLicenseModelId;
+ }
+
+ public LimitType getType() {
+ return type;
+ }
+
+ public void setType(LimitType type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public EntitlementMetric getMetric() {
+ return metric;
+ }
+
+ public void setMetric(EntitlementMetric metric) {
+ this.metric = metric;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Integer getValue() {
+ return value;
+ }
+
+ public void setValue(Integer value) {
+ this.value = value;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(vendorLicenseModelId, version, epLkgId, id, name, description, type,
+ metric, unit, time, aggregationFunction, value);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null || getClass() != obj.getClass()) {
+ return false;
+ }
+ 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);
+
+ }
+
+ @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
+
+ + '}';
+ }
+
+}
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/LimitType.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitType.java
new file mode 100644
index 0000000000..ff0eff8042
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LimitType.java
@@ -0,0 +1,10 @@
+package org.openecomp.sdc.vendorlicense.dao.types;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum LimitType {
+ ServiceProvider,
+ Vendor;
+
+}
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/MultiChoiceOrOther.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/MultiChoiceOrOther.java
index 165260f9c5..36f54ac45e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/MultiChoiceOrOther.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/MultiChoiceOrOther.java
@@ -102,13 +102,15 @@ public class MultiChoiceOrOther<E extends Enum<E>> {
}
private Set<String> resolveResult() {
- results = new HashSet<>();
- if (choices.size() == 1 && OTHER_ENUM_VALUE.equals(choices.iterator().next().name())) {
- results.add(other);
- } else {
- for (E choice : choices) {
- results.add(choice.name());
- }
+ if (choices != null) {
+ results = new HashSet<>();
+ if(choices.size() == 1 && OTHER_ENUM_VALUE.equals(choices.iterator().next().name())) {
+ results.add(other);
+ } else {
+ for (E choice : choices) {
+ results.add(choice.name());
+ }
+ }
}
return results;
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/xml/LimitForXml.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/LimitForXml.java
new file mode 100644
index 0000000000..0a3680b719
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/LimitForXml.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.vendorlicense.dao.types.xml;
+
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+
+import java.util.Set;
+
+public class LimitForXml {
+
+ Set<LimitXml> limits;
+
+ @JacksonXmlProperty(isAttribute = false, localName = "limit")
+ @JacksonXmlElementWrapper(localName = "limits", useWrapping = false)
+ public Set<LimitXml> getLimits() {
+ return limits;
+ }
+
+ public void setLimits(
+ Set<LimitXml> limits) {
+ this.limits = limits;
+ }
+}
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/xml/LimitXml.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/LimitXml.java
new file mode 100644
index 0000000000..9cc1aed72b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/LimitXml.java
@@ -0,0 +1,95 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.vendorlicense.dao.types.xml;
+
+public class LimitXml {
+ String description;
+ String metric;
+ String values;
+ String unit;
+ String time;
+ String aggregationFunction;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getMetric() {
+ return metric;
+ }
+
+ public void setMetric(String metric) {
+ this.metric = metric;
+ }
+
+ public String getValues() {
+ return values;
+ }
+
+ public void setValues(String values) {
+ this.values = values;
+ }
+
+ public String getUnit() {
+ return unit;
+ }
+
+ public void setUnit(String unit) {
+ this.unit = unit;
+ }
+
+ public String getTime() {
+ return time;
+ }
+
+ public void setTime(String time) {
+ this.time = time;
+ }
+
+ public String getAggregationFunction() {
+ return aggregationFunction;
+ }
+
+ public void setAggregationFunction(String aggregationFunction) {
+ this.aggregationFunction = aggregationFunction;
+ }
+
+ public EntitlementTimeForXml getTimeForArtifact() {
+ EntitlementTimeForXml timeForXml = new EntitlementTimeForXml();
+ if (time != null) {
+ timeForXml.setValue(time);
+ }
+
+ return timeForXml;
+ }
+
+ public AggregationFunctionForXml getAggregationFunctionForArtifact() {
+ AggregationFunctionForXml aggregationFunctionForXml = new AggregationFunctionForXml();
+ if (aggregationFunction != null) {
+ aggregationFunctionForXml.setValue(aggregationFunction);
+ }
+ return aggregationFunctionForXml;
+ }
+}
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/xml/ThresholdForXml.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/ThresholdForXml.java
index 11627160ad..a50b815069 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/ThresholdForXml.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/ThresholdForXml.java
@@ -22,7 +22,7 @@ package org.openecomp.sdc.vendorlicense.dao.types.xml;
public class ThresholdForXml {
String unit;
- int value;
+ Integer value;
public String getUnit() {
return unit;
@@ -32,11 +32,11 @@ public class ThresholdForXml {
this.unit = unit;
}
- public int getValue() {
+ public Integer getValue() {
return value;
}
- public void setValue(int value) {
+ public void setValue(Integer value) {
this.value = value;
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/InvalidDateErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/InvalidDateErrorBuilder.java
new file mode 100644
index 0000000000..e1857532a8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/InvalidDateErrorBuilder.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.vendorlicense.errors;
+
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+public class InvalidDateErrorBuilder {
+
+ private static final String DATE_RANGE_INVALID = "Vendor license model with id %s has invalid " +
+ "date range.";
+
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ public InvalidDateErrorBuilder(String vendorLicenseModelId){
+ builder.withId(VendorLicenseErrorCodes.DATE_RANGE_INVALID);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(String.format(DATE_RANGE_INVALID, vendorLicenseModelId));
+ }
+
+ public ErrorCode build() {
+ return builder.build();
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseErrorCodes.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseErrorCodes.java
index 98f773860c..e8c252f7be 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseErrorCodes.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/VendorLicenseErrorCodes.java
@@ -26,4 +26,12 @@ public class VendorLicenseErrorCodes {
public static final String VENDOR_LICENSE_MODEL_NOT_FOUND = "VENDOR_LICENSE_MODEL_NOT_FOUND";
public static final String SUBMIT_UNCOMPLETED_LICENSE_MODEL = "SUBMIT_UNCOMPLETED_LICENSE_MODEL";
public static final String LICENSING_DATA_INVALID = "LICENSING_DATA_INVALID";
+
+ public static final String LIMIT_INVALID_TYPE = "LIMIT_INVALID_TYPE";
+ public static final String LIMIT_INVALID_METRIC = "LIMIT_INVALID_METRIC";
+ public static final String LIMIT_INVALID_AGGREGATIONFUNCTION = "LIMIT_INVALID_AGGREGATIONFUNCTION";
+ public static final String LIMIT_INVALID_TIME = "LIMIT_INVALID_TIME";
+ public static final String DUPLICATE_LIMIT_NAME_NOT_ALLOWED =
+ "DUPLICATE_LIMIT_NAME_NOT_ALLOWED";
+ public static final String DATE_RANGE_INVALID = "DATE_RANGE_INVALID";
}
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 ecff0f56d6..9ab7c0c64d 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
@@ -27,6 +27,7 @@ import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -86,4 +87,11 @@ public interface VendorLicenseFacade {
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);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/resources/factoryConfiguration.json
index 7f59b42103..6c7f30d119 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/resources/factoryConfiguration.json
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/resources/factoryConfiguration.json
@@ -6,6 +6,8 @@
"org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory": "org.openecomp.sdc.vendorlicense.dao.impl.LicenseAgreementDaoFactoryImpl",
"org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory": "org.openecomp.sdc.vendorlicense.dao.impl.FeatureGroupDaoFactoryImpl",
"org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory": "org.openecomp.sdc.vendorlicense.dao.impl.LicenseKeyGroupDaoFactoryImpl",
- "org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory": "org.openecomp.sdc.vendorlicense.dao.impl.EntitlementPoolDaoFactoryImpl"
+ "org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory": "org.openecomp.sdc.vendorlicense.dao.impl.EntitlementPoolDaoFactoryImpl",
+ "org.openecomp.sdc.vendorlicense.dao.LimitDaoFactory": "org.openecomp.sdc.vendorlicense.dao.impl.LimitDaoFactoryImpl"
+
} \ No newline at end of file