From 61070c9c6b665fdea79b3ccdfeafc3a6b50d262e Mon Sep 17 00:00:00 2001 From: Avi Ziv Date: Wed, 26 Jul 2017 17:37:57 +0300 Subject: [SDC] Full OnBoard health-check and NFoD support Change-Id: I606f8a52c7e6d2bd5558f824957d890e552c5423 Signed-off-by: Avi Ziv --- .../pom.xml.versionsBackup | 55 --------- .../dao/types/EntitlementPoolEntity.java | 137 ++++----------------- .../dao/types/LicenseKeyGroupEntity.java | 92 +++++++++++++- .../dao/types/xml/OperationalScopeForXml.java | 38 ++++++ .../vendorlicense/facade/VendorLicenseFacade.java | 3 + 5 files changed, 151 insertions(+), 174 deletions(-) delete mode 100644 openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml.versionsBackup create mode 100644 openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/xml/OperationalScopeForXml.java (limited to 'openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api') diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml.versionsBackup deleted file mode 100644 index fc22abcf38..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml.versionsBackup +++ /dev/null @@ -1,55 +0,0 @@ - - 4.0.0 - - openecomp-sdc-vendor-license-api - openecomp-sdc-vendor-license-api - - org.openecomp.sdc - openecomp-sdc-lib - 1.0-SNAPSHOT - ../.. - - - - org.openecomp.core - openecomp-facade-core - ${project.version} - - - org.openecomp.sdc - openecomp-sdc-versioning-core - ${project.version} - - - org.openecomp.core - openecomp-nosqldb-core - ${project.version} - - - javax.el - javax.el-api - ${javax.el-api.version} - - - org.glassfish.web - javax.el - 2.2.4 - - - com.fasterxml.jackson.core - jackson-annotations - 2.7.4 - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - 2.7.4 - - - org.codehaus.woodstox - woodstox-core-asl - 4.4.1 - - - \ No newline at end of file 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 ce225931f5..dce2939ae5 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,12 +26,10 @@ 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.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.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; import org.openecomp.sdc.versioning.dao.types.VersionableEntity; @@ -65,25 +63,12 @@ public class EntitlementPoolEntity implements VersionableEntity { @Enumerated private ThresholdUnit thresholdUnit; - @Column(name = "entitlement_metric") - @Frozen - private ChoiceOrOther entitlementMetric; private String increments; - @Column(name = "aggregation_func") - @Frozen - private ChoiceOrOther aggregationFunction; - @Column(name = "operational_scope") @Frozen private MultiChoiceOrOther operationalScope; - @Frozen - private ChoiceOrOther time; - - @Column(name = "manufacturer_ref_num") - private String manufacturerReferenceNumber; - @Column(name = "ref_fg_ids") private Set referencingFeatureGroups = new HashSet<>(); @@ -96,6 +81,9 @@ public class EntitlementPoolEntity implements VersionableEntity { private Collection limits; + //Defined and used only for License Artifcat XMLs + private String manufacturerReferenceNumber; + public EntitlementPoolEntity() { } @@ -200,15 +188,6 @@ public class EntitlementPoolEntity implements VersionableEntity { this.thresholdUnit = thresholdUnits; } - public ChoiceOrOther getEntitlementMetric() { - return entitlementMetric; - } - - public void setEntitlementMetric(ChoiceOrOther entitlementMetric) { - entitlementMetric.resolveEnum(EntitlementMetric.class); - this.entitlementMetric = entitlementMetric; - } - public String getIncrements() { return increments; } @@ -217,15 +196,6 @@ public class EntitlementPoolEntity implements VersionableEntity { this.increments = increments; } - public ChoiceOrOther getAggregationFunction() { - return aggregationFunction; - } - - public void setAggregationFunction(ChoiceOrOther aggregationFunction) { - aggregationFunction.resolveEnum(AggregationFunction.class); - this.aggregationFunction = aggregationFunction; - } - public MultiChoiceOrOther getOperationalScope() { return operationalScope; } @@ -237,23 +207,6 @@ public class EntitlementPoolEntity implements VersionableEntity { this.operationalScope = operationalScope; } - public ChoiceOrOther getTime() { - return time; - } - - public void setTime(ChoiceOrOther time) { - time.resolveEnum(EntitlementTime.class); - this.time = time; - } - - public String getManufacturerReferenceNumber() { - return manufacturerReferenceNumber; - } - - public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) { - this.manufacturerReferenceNumber = manufacturerReferenceNumber; - } - /** * Gets threshold for artifact. * @@ -274,35 +227,6 @@ public class EntitlementPoolEntity implements VersionableEntity { return version.toString(); } - /** - * Gets entitlement metric for artifact. - * - * @return the entitlement metric for artifact - */ - public EntitlementMetricForXml getEntitlementMetricForArtifact() { - EntitlementMetricForXml metric = new EntitlementMetricForXml(); - if (entitlementMetric != null) { - metric.setValue(entitlementMetric.getResult()); - } else { - metric.setValue(null); - } - return metric; - } - - /** - * Gets time for artifact. - * - * @return the time for artifact - */ - public EntitlementTimeForXml getTimeForArtifact() { - EntitlementTimeForXml timeForXml = new EntitlementTimeForXml(); - if (time != null) { - timeForXml.setValue(time.getResult()); - } - - return timeForXml; - } - public String getStartDate() { return startDate; } @@ -334,7 +258,7 @@ public class EntitlementPoolEntity implements VersionableEntity { if(obj.getType().equals(LimitType.ServiceProvider)){ LimitXml xmlObj = new LimitXml(); xmlObj.setDescription(obj.getDescription()); - xmlObj.setMetric(obj.getMetric().toString()); + xmlObj.setMetric(obj.getMetric()!=null?obj.getMetric().name():null); 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); @@ -357,7 +281,7 @@ public class EntitlementPoolEntity implements VersionableEntity { if(obj.getType().equals(LimitType.Vendor)){ LimitXml xmlObj = new LimitXml(); xmlObj.setDescription(obj.getDescription()); - xmlObj.setMetric(obj.getMetric().toString()); + xmlObj.setMetric(obj.getMetric()!=null?obj.getMetric().name():null); 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); @@ -378,8 +302,7 @@ public class EntitlementPoolEntity implements VersionableEntity { public int hashCode() { return Objects .hash(vendorLicenseModelId, version, id, name, description, thresholdValue, thresholdUnit, - entitlementMetric, increments, aggregationFunction, operationalScope, time, - manufacturerReferenceNumber, referencingFeatureGroups, startDate, expiryDate); + increments, operationalScope, referencingFeatureGroups, startDate, expiryDate); } @Override @@ -397,12 +320,8 @@ public class EntitlementPoolEntity implements VersionableEntity { && Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(thresholdUnit, that.thresholdUnit) - && Objects.equals(entitlementMetric, that.entitlementMetric) && Objects.equals(increments, that.increments) - && Objects.equals(aggregationFunction, that.aggregationFunction) && Objects.equals(operationalScope, that.operationalScope) - && Objects.equals(time, that.time) - && Objects.equals(manufacturerReferenceNumber, that.manufacturerReferenceNumber) && Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups) && Objects.equals(startDate, that.startDate) && Objects.equals(expiryDate, that.expiryDate); @@ -418,12 +337,8 @@ public class EntitlementPoolEntity implements VersionableEntity { + ", description='" + description + '\'' + ", thresholdValue=" + thresholdValue + ", thresholdUnit='" + thresholdUnit + '\'' - + ", entitlementMetric=" + entitlementMetric + ", increments='" + increments + '\'' - + ", aggregationFunction=" + aggregationFunction + ", operationalScope=" + operationalScope - + ", time=" + time - + ", manufacturerReferenceNumber='" + manufacturerReferenceNumber + '\'' + ", referencingFeatureGroups=" + referencingFeatureGroups + ", version_uuid=" + versionUuId + ", startDate=" + startDate @@ -431,31 +346,27 @@ public class EntitlementPoolEntity implements VersionableEntity { + '}'; } - /** - * Gets aggregation function for artifact. - * - * @return the aggregation function for artifact - */ - public AggregationFunctionForXml getAggregationFunctionForArtifact() { - AggregationFunctionForXml aggregationFunctionForXml = new AggregationFunctionForXml(); - if (entitlementMetric != null) { - aggregationFunctionForXml.setValue(aggregationFunction.getResult()); - } else { - aggregationFunctionForXml.setValue(null); - } - return aggregationFunctionForXml; - } - /** * Gets operational scope for artifact. * * @return the operational scope for artifact */ - public Set getOperationalScopeForArtifact() { + public OperationalScopeForXml getOperationalScopeForArtifact() { + OperationalScopeForXml obj = new OperationalScopeForXml(); if (operationalScope != null) { - return operationalScope.getResults(); - } else { - return null; + if(operationalScope.getResults().size() > 0) { + obj.setValue(operationalScope.getResults()); + } } + return obj; + } + + //Defined and used only for License Artifcat XMLs + public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) { + this.manufacturerReferenceNumber = manufacturerReferenceNumber; + } + + public String getManufacturerReferenceNumber() { + return manufacturerReferenceNumber; } } 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 654093de28..d5efd59a6b 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 @@ -29,6 +29,8 @@ 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.vendorlicense.dao.types.xml.OperationalScopeForXml; +import org.openecomp.sdc.vendorlicense.dao.types.xml.ThresholdForXml; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.dao.types.VersionableEntity; @@ -61,8 +63,17 @@ public class LicenseKeyGroupEntity implements VersionableEntity { private Set referencingFeatureGroups = new HashSet<>(); @Column(name = "version_uuid") private String versionUuId; + private Integer thresholdValue; + private ThresholdUnit thresholdUnits; + private String increments; private Collection limits; + private String startDate; + private String expiryDate; + + //Defined and used only for License Artifcat XMLs + private String manufacturerReferenceNumber; + public LicenseKeyGroupEntity() { } @@ -167,6 +178,37 @@ public class LicenseKeyGroupEntity implements VersionableEntity { this.referencingFeatureGroups = referencingFeatureGroups; } + public Integer getThresholdValue() { + return thresholdValue; + } + + public void setThresholdValue(Integer thresholdValue) { + this.thresholdValue = thresholdValue; + } + + public ThresholdUnit getThresholdUnits() { + return thresholdUnits; + } + + public void setThresholdUnits(ThresholdUnit thresholdUnit) { + this.thresholdUnits = thresholdUnit; + } + + public String getIncrements() { + return increments; + } + + public void setIncrements(String increments) { + this.increments = increments; + } + + public ThresholdForXml getThresholdForArtifact() { + ThresholdForXml threshold = new ThresholdForXml(); + threshold.setUnit(getThresholdUnits() == null ? null : getThresholdUnits().name()); + threshold.setValue(getThresholdValue()); + return threshold; + } + public Collection getLimits() { return limits; } @@ -221,11 +263,28 @@ public class LicenseKeyGroupEntity implements VersionableEntity { return null; } + 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; + } + @Override public int hashCode() { return Objects .hash(vendorLicenseModelId, version, id, name, description, type, operationalScope, - referencingFeatureGroups); + referencingFeatureGroups, startDate, expiryDate, + thresholdValue, thresholdUnits, increments); } @Override @@ -243,7 +302,12 @@ public class LicenseKeyGroupEntity implements VersionableEntity { && Objects.equals(description, that.description) && type == that.type && Objects.equals(operationalScope, that.operationalScope) - && Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups); + && Objects.equals(referencingFeatureGroups, that.referencingFeatureGroups) + && Objects.equals(startDate, that.startDate) + && Objects.equals(expiryDate, that.expiryDate) + && Objects.equals(thresholdValue, that.thresholdValue) + && Objects.equals(thresholdUnits, that.thresholdUnits) + && Objects.equals(increments, that.increments); } @Override @@ -257,6 +321,11 @@ public class LicenseKeyGroupEntity implements VersionableEntity { + ", operationalScope=" + operationalScope + ", referencingFeatureGroups=" + referencingFeatureGroups + ", versionUuId='" + versionUuId + '\'' + + ", startDate=" + startDate + + ", expiryDate=" + expiryDate + + ", thresholdValue='" + thresholdValue + '\'' + + ", thresholdUnits='" + thresholdUnits + '\'' + + ", increments='" + increments + '\'' + '}'; } @@ -265,12 +334,14 @@ public class LicenseKeyGroupEntity implements VersionableEntity { * * @return the operational scope for artifact */ - public Set getOperationalScopeForArtifact() { + public OperationalScopeForXml getOperationalScopeForArtifact() { + OperationalScopeForXml obj = new OperationalScopeForXml(); if (operationalScope != null) { - return operationalScope.getResults(); - } else { - return null; + if(operationalScope.getResults().size() > 0) { + obj.setValue(operationalScope.getResults()); + } } + return obj; } /** @@ -295,4 +366,13 @@ public class LicenseKeyGroupEntity implements VersionableEntity { } return typeXml; } + + //Defined and used only for License Artifcat XMLs + public String getManufacturerReferenceNumber() { + return manufacturerReferenceNumber; + } + + public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) { + this.manufacturerReferenceNumber = manufacturerReferenceNumber; + } } 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/OperationalScopeForXml.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/OperationalScopeForXml.java new file mode 100644 index 0000000000..f51a4127c0 --- /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/OperationalScopeForXml.java @@ -0,0 +1,38 @@ +/*- + * ============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 java.util.Set; + +public class OperationalScopeForXml { + Set value; + + @JacksonXmlElementWrapper(localName = "value", useWrapping = false) + public Set getValue() { + return value; + } + + public void setValue(Set 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/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 9ab7c0c64d..3d27de3a88 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 @@ -76,6 +76,9 @@ public interface VendorLicenseFacade { LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement, String user); + Collection listFeatureGroups(String vlmId, Version version, + String user); + FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user); -- cgit 1.2.3-korg