summaryrefslogtreecommitdiffstats
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/pom.xml19
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml.versionsBackup55
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseConstants.java3
-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.java11
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDao.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/FeatureGroupDaoFactory.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseAgreementDao.java18
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDao.java14
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDaoFactory.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/VendorLicenseModelDao.java1
-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/AggregationFunction.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/types/ChoiceOrOther.java27
-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/EntitlementMetric.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/types/EntitlementPoolEntity.java93
-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/EntitlementTime.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/types/FeatureGroupEntity.java53
-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.java9
-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/LicenseAgreementEntity.java32
-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.java75
-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/LicenseKeyType.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/types/LicenseTerm.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/types/MultiChoiceOrOther.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/OperationalScope.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/types/VendorLicenseModelEntity.java21
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/SubmitUncompletedLicenseModelErrorBuilder.java37
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/UncompletedVendorLicenseModelErrorType.java28
-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.java1
-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-core/pom.xml24
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml.versionsBackup53
-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/EntitlementPoolCassandraDaoImpl.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/EntitlementPoolDaoFactoryImpl.java5
-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.java43
-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/FeatureGroupDaoFactoryImpl.java5
-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/LicenseAgreementCassandraDaoImpl.java1
-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/LicenseAgreementDaoFactoryImpl.java5
-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/LicenseKeyGroupCassandraDaoImpl.java9
-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/LicenseKeyGroupDaoFactoryImpl.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/VendorLicenseModelCassandraDaoImpl.java13
-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/VendorLicenseModelDaoFactoryImpl.java5
-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/ElementPropertyName.java6
-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/ElementType.java6
-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.java291
-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.java326
-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.java249
-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.java243
-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/RelationType.java10
-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/StructureElement.java9
-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.java138
-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.java68
-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.java291
-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.java28
-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.java174
-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/XmlArtifact.java13
-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.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/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java3
-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/MixinFeatureGroupModel.java2
-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.java6
-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.java5
-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.java132
-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/VersionableEntitySortByVlmMajorVersion.java38
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/pom.xml12
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/pom.xml.versionsBackup23
64 files changed, 2293 insertions, 530 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml
index 8062999c55..30ed034e53 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml
@@ -2,6 +2,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+ <name>openecomp-sdc-vendor-license-api</name>
+ <artifactId>openecomp-sdc-vendor-license-api</artifactId>
<parent>
<groupId>org.openecomp.sdc</groupId>
<artifactId>openecomp-sdc-lib</artifactId>
@@ -9,12 +11,9 @@
<relativePath>../..</relativePath>
</parent>
- <name>openecomp-sdc-vendor-license-api</name>
- <artifactId>openecomp-sdc-vendor-license-api</artifactId>
-
<dependencies>
<dependency>
- <groupId>org.openecomp.sdc</groupId>
+ <groupId>org.openecomp.core</groupId>
<artifactId>openecomp-facade-core</artifactId>
<version>${project.version}</version>
</dependency>
@@ -24,7 +23,7 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.openecomp.sdc</groupId>
+ <groupId>org.openecomp.core</groupId>
<artifactId>openecomp-nosqldb-core</artifactId>
<version>${project.version}</version>
</dependency>
@@ -36,22 +35,22 @@
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
- <version>2.2.4</version>
+ <version>${javax.el.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
- <version>2.7.4</version>
+ <version>${jackson.annotations.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
- <version>2.7.4</version>
+ <version>${jackson.dataformat.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
- <version>4.4.1</version>
+ <version>${woodstox.version}</version>
</dependency>
</dependencies>
-</project> \ No newline at end of file
+</project>
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
new file mode 100644
index 0000000000..fc22abcf38
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/pom.xml.versionsBackup
@@ -0,0 +1,55 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>openecomp-sdc-vendor-license-api</name>
+ <artifactId>openecomp-sdc-vendor-license-api</artifactId>
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-versioning-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-nosqldb-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>javax.el-api</artifactId>
+ <version>${javax.el-api.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.web</groupId>
+ <artifactId>javax.el</artifactId>
+ <version>2.2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>2.7.4</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
+ <artifactId>jackson-dataformat-xml</artifactId>
+ <version>2.7.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>woodstox-core-asl</artifactId>
+ <version>4.4.1</version>
+ </dependency>
+ </dependencies>
+</project> \ 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/VendorLicenseConstants.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseConstants.java
index 2a1930d626..82fdf045db 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseConstants.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseConstants.java
@@ -32,6 +32,8 @@ public final class VendorLicenseConstants {
public static final String VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH =
EXTERNAL_ARTIFACTS_DIR + File.separator + "vendor-license-model.xml";
public static final String VENDOR_LICENSE_MODEL_ARTIFACT_REGEX_REMOVE = " xmlns=\"\"";
+ public static final String UNSUPPORTED_OPERATION_ERROR =
+ "An error has occurred: Unsupported operation for 1707 release.";
public final class UniqueValues {
public static final String VENDOR_NAME = "Vendor name";
@@ -39,5 +41,6 @@ public final class VendorLicenseConstants {
public static final String FEATURE_GROUP_NAME = "Feature Group name";
public static final String ENTITLEMENT_POOL_NAME = "Entitlement Pool name";
public static final String LICENSE_KEY_GROUP_NAME = "License Key Group name";
+
}
}
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 c507e6946a..28524e8977 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
@@ -20,12 +20,23 @@
package org.openecomp.sdc.vendorlicense.dao;
+
import org.openecomp.core.dao.BaseDao;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
import org.openecomp.sdc.versioning.dao.VersionableDao;
+import java.util.Collection;
+
public interface EntitlementPoolDao extends VersionableDao, BaseDao<EntitlementPoolEntity> {
+ void create(EntitlementPoolEntity entitlementPool);
+
+ void delete(EntitlementPoolEntity entitlementPool);
+
+ EntitlementPoolEntity get(EntitlementPoolEntity entitlementPool);
+
+ Collection<EntitlementPoolEntity> list(EntitlementPoolEntity entitlementPool);
+
long count(EntitlementPoolEntity entitlementPool);
void deleteAll(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/FeatureGroupDao.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDao.java
index a5db802861..3a7ce9ac04 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDao.java
@@ -24,10 +24,20 @@ import org.openecomp.core.dao.BaseDao;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
import org.openecomp.sdc.versioning.dao.VersionableDao;
+import java.util.Collection;
import java.util.Set;
+
public interface FeatureGroupDao extends VersionableDao, BaseDao<FeatureGroupEntity> {
+ void delete(FeatureGroupEntity featureGroup);
+
+ void create(FeatureGroupEntity featureGroup);
+
+ FeatureGroupEntity get(FeatureGroupEntity entity);
+
+ Collection<FeatureGroupEntity> list(FeatureGroupEntity entity);
+
long count(FeatureGroupEntity featureGroup);
void deleteAll(FeatureGroupEntity featureGroup);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDaoFactory.java
index 58832e12ae..5a32ee420a 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/FeatureGroupDaoFactory.java
@@ -24,6 +24,7 @@ import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
+
public abstract class FeatureGroupDaoFactory extends AbstractComponentFactory<FeatureGroupDao> {
public static FeatureGroupDaoFactory getInstance() {
return AbstractFactory.getInstance(FeatureGroupDaoFactory.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/LicenseAgreementDao.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseAgreementDao.java
index df5e972422..8e2e4889ba 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseAgreementDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseAgreementDao.java
@@ -1,8 +1,8 @@
/*-
- * ============LICENSE_START=======================================================
+ * ============LICENSE_SLicenseAgreementEntityARLicenseAgreementEntity=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 ALicenseAgreementEntity&LicenseAgreementEntity 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.
@@ -12,7 +12,7 @@
*
* 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.
+ * WILicenseAgreementEntityHOULicenseAgreementEntity WARRANLicenseAgreementEntityIES OR CONDILicenseAgreementEntityIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
@@ -24,9 +24,10 @@ import org.openecomp.core.dao.BaseDao;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
import org.openecomp.sdc.versioning.dao.VersionableDao;
+import java.util.Collection;
import java.util.Set;
-public interface LicenseAgreementDao extends VersionableDao, BaseDao<LicenseAgreementEntity> {
+public interface LicenseAgreementDao extends VersionableDao{
long count(LicenseAgreementEntity entity);
@@ -37,4 +38,13 @@ public interface LicenseAgreementDao extends VersionableDao, BaseDao<LicenseAgre
void updateColumnsAndDeltaFeatureGroupIds(LicenseAgreementEntity licenseAgreement,
Set<String> addedFeatureGroupIds,
Set<String> removedFeatureGroupIds);
+ Collection<LicenseAgreementEntity> list(LicenseAgreementEntity entity);
+
+ void create(LicenseAgreementEntity entity);
+
+ void update(LicenseAgreementEntity entity);
+
+ LicenseAgreementEntity get(LicenseAgreementEntity entity);
+
+ void delete(LicenseAgreementEntity entity);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDao.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDao.java
index 43e380d9b9..4e0ce93ed4 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDao.java
@@ -20,12 +20,26 @@
package org.openecomp.sdc.vendorlicense.dao;
+
import org.openecomp.core.dao.BaseDao;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
import org.openecomp.sdc.versioning.dao.VersionableDao;
+import java.util.Collection;
+
+
public interface LicenseKeyGroupDao extends VersionableDao, BaseDao<LicenseKeyGroupEntity> {
+ void create(LicenseKeyGroupEntity licenseKeyGroup);
+
+ void delete(LicenseKeyGroupEntity licenseKeyGroup);
+
+ LicenseKeyGroupEntity get(LicenseKeyGroupEntity licenseKeyGroup);
+
+ Collection<LicenseKeyGroupEntity> list(LicenseKeyGroupEntity licenseKeyGroup);
+
+ long count(LicenseKeyGroupEntity licenseKeyGroup);
+
void deleteAll(LicenseKeyGroupEntity licenseKeyGroup);
void addReferencingFeatureGroup(LicenseKeyGroupEntity licenseKeyGroup, String featureGroupId);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDaoFactory.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDaoFactory.java
index 1f887390db..8c76c46301 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDaoFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/LicenseKeyGroupDaoFactory.java
@@ -23,6 +23,7 @@ package org.openecomp.sdc.vendorlicense.dao;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
+
public abstract class LicenseKeyGroupDaoFactory
extends AbstractComponentFactory<LicenseKeyGroupDao> {
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/VendorLicenseModelDao.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/VendorLicenseModelDao.java
index b8e39bc496..0bb2e62b41 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/VendorLicenseModelDao.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/VendorLicenseModelDao.java
@@ -25,5 +25,4 @@ import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
import org.openecomp.sdc.versioning.dao.VersionableDao;
public interface VendorLicenseModelDao extends VersionableDao, BaseDao<VendorLicenseModelEntity> {
-// void updateLastModificationTime(VendorLicenseModelEntity vendorLicenseModel);
}
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/AggregationFunction.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/AggregationFunction.java
index 9a5af213c4..5b5a97f92b 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/AggregationFunction.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/AggregationFunction.java
@@ -23,5 +23,5 @@ package org.openecomp.sdc.vendorlicense.dao.types;
public enum AggregationFunction {
Peak,
Average,
- Other
+ Other;
}
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/ChoiceOrOther.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/ChoiceOrOther.java
index ca7a09b0df..4483c67b65 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/ChoiceOrOther.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/ChoiceOrOther.java
@@ -25,6 +25,12 @@ import com.datastax.driver.mapping.annotations.UDT;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerErrorDescription;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
@UDT(keyspace = "dox", name = "choice_or_other")
public class ChoiceOrOther<E extends Enum<E>> {
@@ -110,10 +116,13 @@ public class ChoiceOrOther<E extends Enum<E>> {
try {
choice = E.valueOf(enumClass, result);
- } catch (IllegalArgumentException e0) {
+ } catch (IllegalArgumentException exception) {
try {
choice = E.valueOf(enumClass, OTHER_ENUM_VALUE);
} catch (IllegalArgumentException ex) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.VALIDATE_CHOICE_VALUE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
throw new CoreException(new ErrorCode.ErrorCodeBuilder()
.withId(CHOICE_OR_OTHER_INVALID_ENUM_ERR_ID)
.withMessage(CHOICE_OR_OTHER_INVALID_ENUM_MSG)
@@ -124,6 +133,14 @@ public class ChoiceOrOther<E extends Enum<E>> {
}
@Override
+ public int hashCode() {
+ int result1 = choice != null ? choice.hashCode() : 0;
+ result1 = 31 * result1 + (other != null ? other.hashCode() : 0);
+ result1 = 31 * result1 + (result != null ? result.hashCode() : 0);
+ return result1;
+ }
+
+ @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
@@ -143,12 +160,4 @@ public class ChoiceOrOther<E extends Enum<E>> {
return result != null ? result.equals(that.result) : that.result == null;
}
-
- @Override
- public int hashCode() {
- int result1 = choice != null ? choice.hashCode() : 0;
- result1 = 31 * result1 + (other != null ? other.hashCode() : 0);
- result1 = 31 * result1 + (result != null ? result.hashCode() : 0);
- return result1;
- }
}
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/EntitlementMetric.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementMetric.java
index 42cc231273..23423dc241 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementMetric.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementMetric.java
@@ -33,5 +33,5 @@ public enum EntitlementMetric {
Units_TB,
Units_MB,
Units_GB,
- Other
+ Other;
}
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 8964458181..0a704721d5 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
@@ -55,7 +55,6 @@ public class EntitlementPoolEntity implements VersionableEntity {
private String name;
private String description;
-
@Column(name = "threshold")
private int thresholdValue;
@@ -114,14 +113,6 @@ public class EntitlementPoolEntity implements VersionableEntity {
return getVendorLicenseModelId();
}
- public String getVendorLicenseModelId() {
- return vendorLicenseModelId;
- }
-
- public void setVendorLicenseModelId(String vendorLicenseModelId) {
- this.vendorLicenseModelId = vendorLicenseModelId;
- }
-
@Override
public String getId() {
return id;
@@ -142,6 +133,24 @@ public class EntitlementPoolEntity implements VersionableEntity {
this.version = version;
}
+ @Override
+ public String getVersionUuId() {
+ return versionUuId;
+ }
+
+ @Override
+ public void setVersionUuId(String uuId) {
+ versionUuId = uuId;
+ }
+
+ public String getVendorLicenseModelId() {
+ return vendorLicenseModelId;
+ }
+
+ public void setVendorLicenseModelId(String vendorLicenseModelId) {
+ this.vendorLicenseModelId = vendorLicenseModelId;
+ }
+
public Set<String> getReferencingFeatureGroups() {
return referencingFeatureGroups;
}
@@ -234,13 +243,11 @@ public class EntitlementPoolEntity implements VersionableEntity {
this.manufacturerReferenceNumber = manufacturerReferenceNumber;
}
-
/**
* Gets threshold for artifact.
*
* @return the threshold for artifact
*/
- //util methods for XML
public ThresholdForXml getThresholdForArtifact() {
ThresholdForXml threshold = new ThresholdForXml();
threshold.setUnit(getThresholdUnit() == null ? null : getThresholdUnit().name());
@@ -249,6 +256,14 @@ public class EntitlementPoolEntity implements VersionableEntity {
}
/**
+ * Gets version for artifact.
+ * @return version in format suitable for artifact
+ */
+ public String getVersionForArtifact() {
+ return version.toString();
+ }
+
+ /**
* Gets entitlement metric for artifact.
*
* @return the entitlement metric for artifact
@@ -277,26 +292,12 @@ public class EntitlementPoolEntity implements VersionableEntity {
return timeForXml;
}
-
@Override
- public String toString() {
- return "EntitlementPoolEntity{"
- + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
- + ", version=" + version
- + ", id='" + id + '\''
- + ", name='" + name + '\''
- + ", description='" + description + '\''
- + ", thresholdValue=" + thresholdValue
- + ", thresholdUnit='" + thresholdUnit + '\''
- + ", entitlementMetric=" + entitlementMetric
- + ", increments='" + increments + '\''
- + ", aggregationFunction=" + aggregationFunction
- + ", operationalScope=" + operationalScope
- + ", time=" + time
- + ", manufacturerReferenceNumber='" + manufacturerReferenceNumber + '\''
- + ", referencingFeatureGroups=" + referencingFeatureGroups
- + ", version_uuid=" + versionUuId
- + '}';
+ public int hashCode() {
+ return Objects
+ .hash(vendorLicenseModelId, version, id, name, description, thresholdValue, thresholdUnit,
+ entitlementMetric, increments, aggregationFunction, operationalScope, time,
+ manufacturerReferenceNumber, referencingFeatureGroups);
}
@Override
@@ -310,7 +311,6 @@ public class EntitlementPoolEntity implements VersionableEntity {
EntitlementPoolEntity that = (EntitlementPoolEntity) obj;
return Float.compare(that.thresholdValue, thresholdValue) == 0
&& 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)
@@ -325,11 +325,24 @@ public class EntitlementPoolEntity implements VersionableEntity {
}
@Override
- public int hashCode() {
- return Objects
- .hash(vendorLicenseModelId, version, id, name, description, thresholdValue, thresholdUnit,
- entitlementMetric, increments, aggregationFunction, operationalScope, time,
- manufacturerReferenceNumber, referencingFeatureGroups);
+ public String toString() {
+ return "EntitlementPoolEntity{"
+ + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
+ + ", version=" + version
+ + ", id='" + id + '\''
+ + ", name='" + name + '\''
+ + ", description='" + description + '\''
+ + ", thresholdValue=" + thresholdValue
+ + ", thresholdUnit='" + thresholdUnit + '\''
+ + ", entitlementMetric=" + entitlementMetric
+ + ", increments='" + increments + '\''
+ + ", aggregationFunction=" + aggregationFunction
+ + ", operationalScope=" + operationalScope
+ + ", time=" + time
+ + ", manufacturerReferenceNumber='" + manufacturerReferenceNumber + '\''
+ + ", referencingFeatureGroups=" + referencingFeatureGroups
+ + ", version_uuid=" + versionUuId
+ + '}';
}
/**
@@ -359,12 +372,4 @@ public class EntitlementPoolEntity implements VersionableEntity {
return null;
}
}
-
- public String getVersionUuId() {
- return versionUuId;
- }
-
- public void setVersionUuId(String uuId) {
- versionUuId = uuId;
- }
}
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/EntitlementTime.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementTime.java
index 5005075122..78576d1e7d 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementTime.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementTime.java
@@ -26,5 +26,5 @@ public enum EntitlementTime { //TODO MetricTime ? ask Segev...
Month,
Quarter,
Year,
- Other
+ Other;
}
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 de5bd2e1c5..a297f8aa63 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
@@ -28,7 +28,6 @@ import com.datastax.driver.mapping.annotations.Table;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
-
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
@@ -83,12 +82,14 @@ public class FeatureGroupEntity implements VersionableEntity {
return getVendorLicenseModelId();
}
- public String getVendorLicenseModelId() {
- return vendorLicenseModelId;
+ @Override
+ public String getId() {
+ return id;
}
- public void setVendorLicenseModelId(String vendorLicenseModelId) {
- this.vendorLicenseModelId = vendorLicenseModelId;
+ @Override
+ public void setId(String id) {
+ this.id = id;
}
@Override
@@ -101,14 +102,12 @@ public class FeatureGroupEntity implements VersionableEntity {
this.version = version;
}
- @Override
- public String getId() {
- return id;
+ public String getVendorLicenseModelId() {
+ return vendorLicenseModelId;
}
- @Override
- public void setId(String id) {
- this.id = id;
+ public void setVendorLicenseModelId(String vendorLicenseModelId) {
+ this.vendorLicenseModelId = vendorLicenseModelId;
}
public String getName() {
@@ -160,18 +159,10 @@ public class FeatureGroupEntity implements VersionableEntity {
}
@Override
- public String toString() {
- return "FeatureGroupEntity{"
- + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
- + ", version=" + version
- + ", id='" + id + '\''
- + ", name='" + name + '\''
- + ", description='" + description + '\''
- + ", partNumber='" + partNumber + '\''
- + ", licenseKeyGroupIds=" + licenseKeyGroupIds
- + ", entitlementPoolIds=" + entitlementPoolIds
- + ", referencingLicenseAgreements=" + referencingLicenseAgreements
- + '}';
+ public int hashCode() {
+ return Objects
+ .hash(vendorLicenseModelId, version, id, name, description, partNumber, licenseKeyGroupIds,
+ entitlementPoolIds, referencingLicenseAgreements);
}
@Override
@@ -195,9 +186,17 @@ public class FeatureGroupEntity implements VersionableEntity {
}
@Override
- public int hashCode() {
- return Objects
- .hash(vendorLicenseModelId, version, id, name, description, partNumber, licenseKeyGroupIds,
- entitlementPoolIds, referencingLicenseAgreements);
+ public String toString() {
+ return "FeatureGroupEntity{"
+ + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
+ + ", version=" + version
+ + ", id='" + id + '\''
+ + ", name='" + name + '\''
+ + ", description='" + description + '\''
+ + ", partNumber='" + partNumber + '\''
+ + ", 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 78e081760c..174cbbb9b9 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
@@ -41,14 +41,14 @@ public class FeatureGroupModel {
return entitlementPools;
}
- public Set<LicenseKeyGroupEntity> getLicenseKeyGroups() {
- return licenseKeyGroups;
- }
-
public void setEntitlementPools(Set<EntitlementPoolEntity> entitlementPools) {
this.entitlementPools = entitlementPools;
}
+ public Set<LicenseKeyGroupEntity> getLicenseKeyGroups() {
+ return licenseKeyGroups;
+ }
+
public void setLicenseKeyGroups(Set<LicenseKeyGroupEntity> licenseKeyGroups) {
this.licenseKeyGroups = licenseKeyGroups;
}
@@ -72,4 +72,3 @@ public class FeatureGroupModel {
}
-
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/LicenseAgreementEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseAgreementEntity.java
index a6e46bf44c..7f7dab684a 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseAgreementEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseAgreementEntity.java
@@ -86,12 +86,14 @@ public class LicenseAgreementEntity implements VersionableEntity {
return getVendorLicenseModelId();
}
- public String getVendorLicenseModelId() {
- return vendorLicenseModelId;
+ @Override
+ public String getId() {
+ return id;
}
- public void setVendorLicenseModelId(String vendorLicenseModelId) {
- this.vendorLicenseModelId = vendorLicenseModelId;
+ @Override
+ public void setId(String id) {
+ this.id = id;
}
@Override
@@ -104,14 +106,12 @@ public class LicenseAgreementEntity implements VersionableEntity {
this.version = version;
}
- @Override
- public String getId() {
- return id;
+ public String getVendorLicenseModelId() {
+ return vendorLicenseModelId;
}
- @Override
- public void setId(String id) {
- this.id = id;
+ public void setVendorLicenseModelId(String vendorLicenseModelId) {
+ this.vendorLicenseModelId = vendorLicenseModelId;
}
public String getName() {
@@ -156,6 +156,12 @@ public class LicenseAgreementEntity implements VersionableEntity {
}
@Override
+ public int hashCode() {
+ return Objects.hash(vendorLicenseModelId, version, id, name, description, licenseTerm,
+ requirementsAndConstrains, featureGroupIds);
+ }
+
+ @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
@@ -173,10 +179,4 @@ public class LicenseAgreementEntity implements VersionableEntity {
&& Objects.equals(requirementsAndConstrains, that.requirementsAndConstrains)
&& Objects.equals(featureGroupIds, that.featureGroupIds);
}
-
- @Override
- public int hashCode() {
- return Objects.hash(vendorLicenseModelId, version, id, name, description, licenseTerm,
- requirementsAndConstrains, featureGroupIds);
- }
}
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 2a7e936cb3..07641594c2 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
@@ -30,7 +30,6 @@ import org.openecomp.sdc.vendorlicense.dao.types.xml.LicenseKeyTypeForXml;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
-
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
@@ -87,14 +86,6 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
return getVendorLicenseModelId();
}
- public String getVendorLicenseModelId() {
- return vendorLicenseModelId;
- }
-
- public void setVendorLicenseModelId(String vendorLicenseModelId) {
- this.vendorLicenseModelId = vendorLicenseModelId;
- }
-
public String getId() {
return id;
}
@@ -111,6 +102,24 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
this.version = version;
}
+ @Override
+ public String getVersionUuId() {
+ return versionUuId;
+ }
+
+ @Override
+ public void setVersionUuId(String uuId) {
+ versionUuId = uuId;
+ }
+
+ public String getVendorLicenseModelId() {
+ return vendorLicenseModelId;
+ }
+
+ public void setVendorLicenseModelId(String vendorLicenseModelId) {
+ this.vendorLicenseModelId = vendorLicenseModelId;
+ }
+
public String getName() {
return name;
}
@@ -153,17 +162,10 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
}
@Override
- public String toString() {
- return "LicenseKeyGroupEntity{" + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
- + ", version=" + version
- + ", id='" + id + '\''
- + ", name='" + name + '\''
- + ", description='" + description + '\''
- + ", type=" + type
- + ", operationalScope=" + operationalScope
- + ", referencingFeatureGroups=" + referencingFeatureGroups
- + ", versionUuId='" + versionUuId + '\''
- + '}';
+ public int hashCode() {
+ return Objects
+ .hash(vendorLicenseModelId, version, id, name, description, type, operationalScope,
+ referencingFeatureGroups);
}
@Override
@@ -176,7 +178,6 @@ 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)
@@ -186,10 +187,17 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
}
@Override
- public int hashCode() {
- return Objects
- .hash(vendorLicenseModelId, version, id, name, description, type, operationalScope,
- referencingFeatureGroups);
+ public String toString() {
+ return "LicenseKeyGroupEntity{" + "vendorLicenseModelId='" + vendorLicenseModelId + '\''
+ + ", version=" + version
+ + ", id='" + id + '\''
+ + ", name='" + name + '\''
+ + ", description='" + description + '\''
+ + ", type=" + type
+ + ", operationalScope=" + operationalScope
+ + ", referencingFeatureGroups=" + referencingFeatureGroups
+ + ", versionUuId='" + versionUuId + '\''
+ + '}';
}
/**
@@ -206,6 +214,14 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
}
/**
+ * Gets version for artifact.
+ * @return version in format suitable for artifact
+ */
+ public String getVersionForArtifact() {
+ return version.toString();
+ }
+
+ /**
* Gets type for artifact.
*
* @return the type for artifact
@@ -219,13 +235,4 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
}
return typeXml;
}
-
-
- public String getVersionUuId() {
- return versionUuId;
- }
-
- public void setVersionUuId(String uuId) {
- versionUuId = uuId;
- }
}
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/LicenseKeyType.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyType.java
index 3ba913de31..35e6f217e8 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyType.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyType.java
@@ -23,5 +23,5 @@ package org.openecomp.sdc.vendorlicense.dao.types;
public enum LicenseKeyType {
Universal,
Unique,
- One_Time
+ One_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/LicenseTerm.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseTerm.java
index 729a985473..b8a7f9d09b 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseTerm.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseTerm.java
@@ -24,5 +24,5 @@ public enum LicenseTerm {
Fixed_Term,
Perpetual,
Unlimited,
- Other
+ Other;
}
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 df9d6887ce..165260f9c5 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
@@ -25,6 +25,12 @@ import com.datastax.driver.mapping.annotations.UDT;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerErrorDescription;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import java.util.HashSet;
import java.util.Set;
@@ -127,10 +133,14 @@ public class MultiChoiceOrOther<E extends Enum<E>> {
String result = results.iterator().next();
try {
choices.add(E.valueOf(enumClass, result));
- } catch (IllegalArgumentException illegalArgumentException) {
+ } catch (IllegalArgumentException exception) {
try {
choices.add(E.valueOf(enumClass, OTHER_ENUM_VALUE));
} catch (IllegalArgumentException ex) {
+
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.VALIDATE_CHOICE_VALUE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
throw new CoreException(new ErrorCode.ErrorCodeBuilder()
.withId(MULTI_CHOICE_OR_OTHER_INVALID_ENUM_ERR_ID)
.withMessage(MULTI_CHOICE_OR_OTHER_INVALID_ENUM_MSG)
@@ -142,6 +152,14 @@ public class MultiChoiceOrOther<E extends Enum<E>> {
}
@Override
+ public int hashCode() {
+ int result = choices != null ? choices.hashCode() : 0;
+ result = 31 * result + (other != null ? other.hashCode() : 0);
+ result = 31 * result + (results != null ? results.hashCode() : 0);
+ return result;
+ }
+
+ @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
@@ -161,12 +179,4 @@ public class MultiChoiceOrOther<E extends Enum<E>> {
return results != null ? results.equals(that.results) : that.results == null;
}
-
- @Override
- public int hashCode() {
- int result = choices != null ? choices.hashCode() : 0;
- result = 31 * result + (other != null ? other.hashCode() : 0);
- result = 31 * result + (results != null ? results.hashCode() : 0);
- return result;
- }
}
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/OperationalScope.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/OperationalScope.java
index ed9497d30b..69cdb2dabb 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/OperationalScope.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/OperationalScope.java
@@ -28,5 +28,5 @@ public enum OperationalScope {
VM,
CPU,
Core,
- Other
+ Other;
}
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 ea93b1ab4f..b57b850f60 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
@@ -42,9 +42,6 @@ public class VendorLicenseModelEntity implements VersionableEntity {
@Frozen
private Version version;
- // @Column(name = "last_modification_time")
- // private Date lastModificationTime;
-
@Column(name = "vendor_name")
private String vendorName;
private String description;
@@ -115,6 +112,11 @@ public class VendorLicenseModelEntity implements VersionableEntity {
}
@Override
+ public int hashCode() {
+ return Objects.hash(id, version, vendorName, description, iconRef);
+ }
+
+ @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
@@ -130,19 +132,6 @@ public class VendorLicenseModelEntity implements VersionableEntity {
&& Objects.equals(iconRef, that.iconRef);
}
- @Override
- public int hashCode() {
- return Objects.hash(id, version, vendorName, description, iconRef);
- }
-
- // public Date getLastModificationTime() {
- // return lastModificationTime;
- // }
- //
- // public void setLastModificationTime(Date lastModificationTime) {
- // this.lastModificationTime = lastModificationTime;
- // }
-
public Long getWritetimeMicroSeconds() {
return writetimeMicroSeconds;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/SubmitUncompletedLicenseModelErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/SubmitUncompletedLicenseModelErrorBuilder.java
index 0a00cff8ea..4cf134c262 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/SubmitUncompletedLicenseModelErrorBuilder.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/SubmitUncompletedLicenseModelErrorBuilder.java
@@ -25,26 +25,23 @@ import org.openecomp.sdc.common.errors.ErrorCode;
public class SubmitUncompletedLicenseModelErrorBuilder {
- private static final String SUBMIT_UNCOMPLETED_LICENSE_MODEL_MSG =
- "Uncompleted vendor license model %s cannot be submitted. "
- + "It must contain license_agreement(s) that all feature groups "
- + "contain at least one entitlement pool.";
- private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
-
- /**
- * Instantiates a new Submit uncompleted license model error builder.
- *
- * @param vlmId the vlm id
- */
- public SubmitUncompletedLicenseModelErrorBuilder(String vlmId) {
- builder.withId(VendorLicenseErrorCodes.SUBMIT_UNCOMPLETED_LICENSE_MODEL);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(SUBMIT_UNCOMPLETED_LICENSE_MODEL_MSG, vlmId));
- }
-
- public ErrorCode build() {
- return builder.build();
- }
+
+ private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
+
+ /**
+ * Instantiates a new Submit uncompleted license model error builder.
+ *
+ * @param error
+ */
+ public SubmitUncompletedLicenseModelErrorBuilder(UncompletedVendorLicenseModelErrorType error) {
+ builder.withId(VendorLicenseErrorCodes.SUBMIT_UNCOMPLETED_LICENSE_MODEL);
+ builder.withCategory(ErrorCategory.APPLICATION);
+ builder.withMessage(error.getErrorMessage());
+ }
+
+ 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/UncompletedVendorLicenseModelErrorType.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/UncompletedVendorLicenseModelErrorType.java
new file mode 100644
index 0000000000..17632fb0ad
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/errors/UncompletedVendorLicenseModelErrorType.java
@@ -0,0 +1,28 @@
+package org.openecomp.sdc.vendorlicense.errors;
+
+/**
+ * Created by ayalaben on 5/8/2017
+ */
+public enum UncompletedVendorLicenseModelErrorType {
+
+ SUBMIT_UNCOMPLETED_VLM_MSG_MISSING_LA("Uncompleted vendor license model - cannot be submitted. \n"
+ + "It must contain a license agreement(s)."),
+
+ SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG("Uncompleted vendor license model - cannot be submitted. \n"
+ + "The license agreement(s) must contain at least one feature group."),
+
+ SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP("Uncompleted vendor license model - cannot be submitted. \n"
+ + "The feature group(s) must contain at least one entitlement pool.");
+
+
+ private String errorMessage;
+
+ UncompletedVendorLicenseModelErrorType(String errorMessage) {
+ this.errorMessage = errorMessage;
+ }
+
+ public String getErrorMessage() {
+ return errorMessage;
+ }
+}
+
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 4cd7a5bc1b..98f773860c 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
@@ -20,6 +20,7 @@
package org.openecomp.sdc.vendorlicense.errors;
+
public class VendorLicenseErrorCodes {
public static final String VENDOR_LICENSE_MODEL_NOT_FOUND = "VENDOR_LICENSE_MODEL_NOT_FOUND";
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 e36852d25f..ecff0f56d6 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
@@ -37,9 +37,9 @@ import java.util.Collection;
public interface VendorLicenseFacade {
- void checkin(String vendorLicenseModelId, String user);
+ Version checkin(String vendorLicenseModelId, String user);
- void submit(String vendorLicenseModelId, String user);
+ Version submit(String vendorLicenseModelId, String user);
FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup, String user);
@@ -53,8 +53,6 @@ public interface VendorLicenseFacade {
EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
- LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
-
void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user);
Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
@@ -65,6 +63,8 @@ public interface VendorLicenseFacade {
void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+ LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user);
+
VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version, String user);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml
index 94d2bdc45a..7ac5aef2f7 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml
@@ -5,6 +5,7 @@
<name>openecomp-sdc-vendor-license-core</name>
<artifactId>openecomp-sdc-vendor-license-core</artifactId>
+
<parent>
<groupId>org.openecomp.sdc</groupId>
<artifactId>openecomp-sdc-lib</artifactId>
@@ -18,12 +19,22 @@
<artifactId>openecomp-sdc-vendor-license-api</artifactId>
<version>${project.version}</version>
</dependency>
-
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-zusammen-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-zusammen-core</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
- <version>1.10.19</version>
+ <version>${mockito.all.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
@@ -41,8 +52,13 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
- <version>RELEASE</version>
+ <version>4.11</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
+ <artifactId>jackson-dataformat-xml</artifactId>
+ <version>${jackson.dataformat.version}</version>
</dependency>
</dependencies>
-</project> \ No newline at end of file
+</project>
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml.versionsBackup
new file mode 100644
index 0000000000..b1141fc5cd
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml.versionsBackup
@@ -0,0 +1,53 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>openecomp-sdc-vendor-license-core</name>
+ <artifactId>openecomp-sdc-vendor-license-core</artifactId>
+
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-license-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ <version>1.10.19</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <version>6.8.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>snakeyaml</artifactId>
+ <groupId>org.yaml</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ <version>4.11</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.dataformat</groupId>
+ <artifactId>jackson-dataformat-xml</artifactId>
+ <version>2.7.4</version>
+ </dependency>
+ </dependencies>
+
+</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/EntitlementPoolCassandraDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/EntitlementPoolCassandraDaoImpl.java
index 1722f8f8de..496e653ef0 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/EntitlementPoolCassandraDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/EntitlementPoolCassandraDaoImpl.java
@@ -133,7 +133,7 @@ public class EntitlementPoolCassandraDaoImpl extends CassandraBaseDao<Entitlemen
@Query(
"UPDATE entitlement_pool SET ref_fg_ids = ref_fg_ids + ? WHERE vlm_id=? AND version=? "
- + "AND ep_id=?")
+ + " AND ep_id=?")
ResultSet addReferencingFeatureGroups(Set<String> referencingFeatureGroups,
String vendorLicenseModelId,
UDTValue vendorLicenseModelVersion, String id);
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/EntitlementPoolDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/EntitlementPoolDaoFactoryImpl.java
index c1046f79cd..dba631a6ed 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/EntitlementPoolDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/EntitlementPoolDaoFactoryImpl.java
@@ -20,11 +20,14 @@
package org.openecomp.sdc.vendorlicense.dao.impl;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.EntitlementPoolZusammenDaoImpl;
+
public class EntitlementPoolDaoFactoryImpl extends EntitlementPoolDaoFactory {
- private static EntitlementPoolDao INSTANCE = new EntitlementPoolCassandraDaoImpl();
+ private static EntitlementPoolDao INSTANCE = new EntitlementPoolZusammenDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface());
@Override
public EntitlementPoolDao createInterface() {
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 86957a02c7..2568d719e2 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,6 +20,8 @@
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;
@@ -45,7 +47,6 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
-
public class FeatureGroupCassandraDaoImpl extends CassandraBaseDao<FeatureGroupEntity>
implements FeatureGroupDao {
@@ -95,6 +96,12 @@ public class FeatureGroupCassandraDaoImpl extends CassandraBaseDao<FeatureGroupE
}
@Override
+ public void deleteAll(FeatureGroupEntity entity) {
+ accessor.deleteByVlmVersion(entity.getVendorLicenseModelId(),
+ versionMapper.toUDT(entity.getVersion())).all();
+ }
+
+ @Override
public void updateFeatureGroup(FeatureGroupEntity entity,
Set<String> addedEntitlementPools,
Set<String> removedEntitlementPools,
@@ -115,18 +122,6 @@ public class FeatureGroupCassandraDaoImpl extends CassandraBaseDao<FeatureGroupE
}
@Override
- public Collection<FeatureGroupEntity> list(FeatureGroupEntity entity) {
- return accessor.listByVlmVersion(entity.getVendorLicenseModelId(),
- versionMapper.toUDT(entity.getVersion())).all();
- }
-
- @Override
- public void deleteAll(FeatureGroupEntity entity) {
- accessor.deleteByVlmVersion(entity.getVendorLicenseModelId(),
- versionMapper.toUDT(entity.getVersion())).all();
- }
-
- @Override
public void addReferencingLicenseAgreement(FeatureGroupEntity entity, String licenseAgreementId) {
accessor.addReferencingLicenseAgreements(CommonMethods.toSingleElementSet(licenseAgreementId),
entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()), entity.getId());
@@ -143,16 +138,22 @@ public class FeatureGroupCassandraDaoImpl extends CassandraBaseDao<FeatureGroupE
@Override
public void removeEntitlementPool(FeatureGroupEntity entity, String entitlementPoolId) {
- accessor.removeEntitlementPools(CommonMethods.toSingleElementSet(entitlementPoolId),
+ accessor.removeEntitlementPools(toSingleElementSet(entitlementPoolId),
entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()), entity.getId());
}
@Override
public void removeLicenseKeyGroup(FeatureGroupEntity entity, String licenseKeyGroupId) {
- accessor.removeLicenseKeyGroup(CommonMethods.toSingleElementSet(licenseKeyGroupId),
+ accessor.removeLicenseKeyGroup(toSingleElementSet(licenseKeyGroupId),
entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()), entity.getId());
}
+ @Override
+ public Collection<FeatureGroupEntity> list(FeatureGroupEntity entity) {
+ return accessor.listByVlmVersion(entity.getVendorLicenseModelId(),
+ versionMapper.toUDT(entity.getVersion())).all();
+ }
+
@Accessor
interface FeatureGroupAccessor {
@@ -167,8 +168,8 @@ public class FeatureGroupCassandraDaoImpl extends CassandraBaseDao<FeatureGroupE
@Query(
"update feature_group set name=?,description=?, part_num=?, ep_ids=ep_ids+ ?,"
- + "ep_ids=ep_ids-?, lkg_ids=lkg_ids+?,lkg_ids=lkg_ids-? WHERE "
- + "vlm_id=? AND version=? AND fg_id=?")
+ + "ep_ids=ep_ids-?, lkg_ids=lkg_ids+?,lkg_ids=lkg_ids-? WHERE vlm_id=? AND version=? "
+ + "AND fg_id=?")
ResultSet updateColumnsAndDeltaFeatureGroupIds(String name, String description,
String partNumber,
Set<String> addedEntitlementPools,
@@ -179,15 +180,15 @@ public class FeatureGroupCassandraDaoImpl extends CassandraBaseDao<FeatureGroupE
String id);
@Query(
- "UPDATE feature_group SET ref_la_ids = ref_la_ids "
- + "+ ? WHERE vlm_id=? AND version=? AND fg_id=?")
+ "UPDATE feature_group SET ref_la_ids = ref_la_ids + ? WHERE vlm_id=? AND version=? "
+ + "AND fg_id=?")
ResultSet addReferencingLicenseAgreements(Set<String> licenseAgreementIds,
String vendorLicenseModelId, UDTValue version,
String id);
@Query(
- "UPDATE feature_group SET ref_la_ids = ref_la_ids - ? "
- + "WHERE vlm_id=? AND version=? AND fg_id=?")
+ "UPDATE feature_group SET ref_la_ids = ref_la_ids - ? WHERE vlm_id=? AND version=? AND "
+ + "fg_id=?")
ResultSet removeReferencingLicenseAgreements(Set<String> licenseAgreementIds,
String vendorLicenseModelId, UDTValue version,
String id);
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/FeatureGroupDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/FeatureGroupDaoFactoryImpl.java
index 941b2b5ecc..830ca4c6c4 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/FeatureGroupDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/FeatureGroupDaoFactoryImpl.java
@@ -20,11 +20,14 @@
package org.openecomp.sdc.vendorlicense.dao.impl;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.FeatureGroupDaoZusammenImpl;
+
public class FeatureGroupDaoFactoryImpl extends FeatureGroupDaoFactory {
- private static FeatureGroupDao INSTANCE = new FeatureGroupCassandraDaoImpl();
+ private static FeatureGroupDao INSTANCE = new FeatureGroupDaoZusammenImpl(ZusammenAdaptorFactory.getInstance().createInterface());
@Override
public FeatureGroupDao createInterface() {
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/LicenseAgreementCassandraDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LicenseAgreementCassandraDaoImpl.java
index 6a7cc2aa60..3b5a3b3bb4 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LicenseAgreementCassandraDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LicenseAgreementCassandraDaoImpl.java
@@ -46,6 +46,7 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+
public class LicenseAgreementCassandraDaoImpl extends CassandraBaseDao<LicenseAgreementEntity>
implements LicenseAgreementDao {
private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
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/LicenseAgreementDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LicenseAgreementDaoFactoryImpl.java
index d92e2562e9..2c1b915200 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LicenseAgreementDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LicenseAgreementDaoFactoryImpl.java
@@ -20,11 +20,14 @@
package org.openecomp.sdc.vendorlicense.dao.impl;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.LicenseAgreementDaoZusammenImpl;
public class LicenseAgreementDaoFactoryImpl extends LicenseAgreementDaoFactory {
- private static LicenseAgreementDao INSTANCE = new LicenseAgreementCassandraDaoImpl();
+ private static LicenseAgreementDao INSTANCE = new LicenseAgreementDaoZusammenImpl(
+ ZusammenAdaptorFactory.getInstance().createInterface());
@Override
public LicenseAgreementDao createInterface() {
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/LicenseKeyGroupCassandraDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LicenseKeyGroupCassandraDaoImpl.java
index c6952c8d03..96eecc9747 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LicenseKeyGroupCassandraDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LicenseKeyGroupCassandraDaoImpl.java
@@ -89,6 +89,11 @@ public class LicenseKeyGroupCassandraDaoImpl extends CassandraBaseDao<LicenseKey
}
@Override
+ public long count(LicenseKeyGroupEntity licenseKeyGroup) {
+ return 0;
+ }
+
+ @Override
public void deleteAll(LicenseKeyGroupEntity entity) {
accessor.deleteByVlmVersion(entity.getVendorLicenseModelId(),
versionMapper.toUDT(entity.getVersion())).all();
@@ -115,8 +120,8 @@ public class LicenseKeyGroupCassandraDaoImpl extends CassandraBaseDao<LicenseKey
Result<LicenseKeyGroupEntity> deleteByVlmVersion(String vendorLicenseModelId, UDTValue version);
@Query(
- "UPDATE license_key_group SET ref_fg_ids = ref_fg_ids + ? WHERE vlm_id=? AND version=?"
- + " AND lkg_id=?")
+ "UPDATE license_key_group SET ref_fg_ids = ref_fg_ids + ? WHERE vlm_id=? AND version=? "
+ + "AND lkg_id=?")
ResultSet addReferencingFeatureGroups(Set<String> referencingFeatureGroups,
String vendorLicenseModelId, UDTValue version, String id);
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/LicenseKeyGroupDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LicenseKeyGroupDaoFactoryImpl.java
index 16d1fd2a3e..407e24d906 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LicenseKeyGroupDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/LicenseKeyGroupDaoFactoryImpl.java
@@ -20,11 +20,13 @@
package org.openecomp.sdc.vendorlicense.dao.impl;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.LicenseKeyGroupZusammenDaoImpl;
public class LicenseKeyGroupDaoFactoryImpl extends LicenseKeyGroupDaoFactory {
- private static LicenseKeyGroupDao INSTANCE = new LicenseKeyGroupCassandraDaoImpl();
+ private static LicenseKeyGroupDao INSTANCE = new LicenseKeyGroupZusammenDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface());
@Override
public LicenseKeyGroupDao createInterface() {
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/VendorLicenseModelCassandraDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/VendorLicenseModelCassandraDaoImpl.java
index 4d08d98bd7..b52f4ba9dd 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/VendorLicenseModelCassandraDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/VendorLicenseModelCassandraDaoImpl.java
@@ -37,7 +37,8 @@ import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
import java.util.Collection;
public class VendorLicenseModelCassandraDaoImpl extends CassandraBaseDao<VendorLicenseModelEntity>
- implements VendorLicenseModelDao {
+ implements
+ VendorLicenseModelDao {
private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
private static Mapper<VendorLicenseModelEntity> mapper =
@@ -71,21 +72,11 @@ public class VendorLicenseModelCassandraDaoImpl extends CassandraBaseDao<VendorL
return accessor.getAll().all();
}
- // @Override
- // public void updateLastModificationTime(VendorLicenseModelEntity vendorLicenseModel){
- // accessor.updateLastModificationTime(vendorLicenseModel.getLastModificationTime(),
- // vendorLicenseModel.getId(), versionMapper.toUDT(vendorLicenseModel.getVersion()));
- // }
-
@Accessor
interface VendorLicenseModelAccessor {
@Query("SELECT * FROM vendor_license_model")
Result<VendorLicenseModelEntity> getAll();
- // @Query("UPDATE vendor_license_model set last_modification_time
- // = ? where vlm_id = ? and version = ?")
- // ResultSet updateLastModificationTime(Date lastModificationTime,
- // String vlmId, UDTValue version);
}
}
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/VendorLicenseModelDaoFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/VendorLicenseModelDaoFactoryImpl.java
index d218ca4907..79d0677da7 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/VendorLicenseModelDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/VendorLicenseModelDaoFactoryImpl.java
@@ -20,12 +20,15 @@
package org.openecomp.sdc.vendorlicense.dao.impl;
+import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.VendorLicenseModelDaoZusammenImpl;
public class VendorLicenseModelDaoFactoryImpl extends VendorLicenseModelDaoFactory {
- private static VendorLicenseModelDao INSTANCE = new VendorLicenseModelCassandraDaoImpl();
+ private static VendorLicenseModelDao INSTANCE = new VendorLicenseModelDaoZusammenImpl(
+ ZusammenAdaptorFactory.getInstance().createInterface());
@Override
public VendorLicenseModelDao createInterface() {
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/ElementPropertyName.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/ElementPropertyName.java
new file mode 100644
index 0000000000..560402abf2
--- /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/ElementPropertyName.java
@@ -0,0 +1,6 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen;
+
+public enum ElementPropertyName {
+ type,
+ compositionData
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/ElementType.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/ElementType.java
new file mode 100644
index 0000000000..4d9c0fa98c
--- /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/ElementType.java
@@ -0,0 +1,6 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen;
+
+public enum ElementType {
+
+
+}
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
new file mode 100644
index 0000000000..f133aaad9a
--- /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/EntitlementPoolZusammenDaoImpl.java
@@ -0,0 +1,291 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
+import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
+import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime;
+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 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.
+ */
+public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
+
+ private ZusammenAdaptor zusammenAdaptor;
+
+ public EntitlementPoolZusammenDaoImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ //no need
+ }
+
+ @Override
+ public void create(EntitlementPoolEntity entitlementPool) {
+ ZusammenElement entitlementPoolElement =
+ buildEntitlementPoolElement(entitlementPool, Action.CREATE);
+
+ ZusammenElement entitlementPoolsElement =
+ VlmZusammenUtil.buildStructuralElement(StructureElement.EntitlementPools, null);
+
+ 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)),
+ entitlementPoolsElement, "Create entitlement pool");
+
+ savedElement.ifPresent(element -> entitlementPool
+ .setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ }
+
+ @Override
+ public void update(EntitlementPoolEntity entitlementPool) {
+ ZusammenElement entitlmentpoolElement =
+ buildEntitlementPoolElement(entitlementPool, Action.UPDATE);
+
+ SessionContext context = ZusammenUtil.createSessionContext();
+ Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
+ zusammenAdaptor.saveElement(context, new ElementContext(itemId,
+ VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)), 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()));
+
+ return zusammenAdaptor.getElementInfo(context, elementContext, new Id(entitlementPool.getId()))
+ .map(elementInfo -> mapElementInfoToEntitlementPool(
+ entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(), elementInfo))
+ .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()));
+
+ Id itemId = new Id(entitlementPool.getVendorLicenseModelId());
+ ElementContext elementContext =
+ new ElementContext(itemId,
+ VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+ zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
+ "delete entitlement pool. id:" + entitlementPool.getId() + ".");
+ }
+
+ @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()));
+
+ return zusammenAdaptor
+ .listElementsByName(context, elementContext, null, StructureElement.EntitlementPools.name())
+ .stream().map(elementInfo -> mapElementInfoToEntitlementPool(
+ entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(), elementInfo))
+ .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()));
+
+ return zusammenAdaptor
+ .listElementsByName(context, elementContext, null, StructureElement.EntitlementPools.name())
+ .size();
+ }
+
+ @Override
+ 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));
+
+ Optional<ElementInfo> elementInfo =
+ zusammenAdaptor.getElementInfo(context, elementContext, new Id(entitlementPool.getId()));
+
+ if (elementInfo.isPresent()) {
+ ZusammenElement zusammenElement = VlmZusammenUtil.getZusammenElement(elementInfo.get());
+ zusammenElement.setAction(Action.UPDATE);
+ zusammenElement.setRelations(elementInfo.get().getRelations().stream()
+ .filter(relation -> !referencingFeatureGroupId
+ .equals(relation.getEdge2().getElementId().getValue()))
+ .collect(Collectors.toList()));
+
+ zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
+ "remove referencing feature group");
+ }
+ }
+
+ @Override
+ 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));
+
+ Optional<ElementInfo> elementInfo =
+ zusammenAdaptor.getElementInfo(context, elementContext, new Id(entitlementPool.getId()));
+
+ if (elementInfo.isPresent()) {
+ ZusammenElement zusammenElement = VlmZusammenUtil.getZusammenElement(elementInfo.get());
+ zusammenElement.setAction(Action.UPDATE);
+ if (zusammenElement.getRelations() == null) {
+ zusammenElement.setRelations(new ArrayList<>());
+ }
+ zusammenElement.getRelations().add(VlmZusammenUtil
+ .createRelation(RelationType.EntitlmentPoolToReferencingFeatureGroup,
+ referencingFeatureGroupId));
+ zusammenAdaptor
+ .saveElement(context, elementContext, zusammenElement, "add referencing feature group");
+ }
+ }
+
+ @Override
+ public void deleteAll(EntitlementPoolEntity entitlementPool) {
+ //not supported
+ }
+
+ private ZusammenElement buildEntitlementPoolElement(EntitlementPoolEntity entitlementPool,
+ Action action) {
+ ZusammenElement entitlementPoolElement = new ZusammenElement();
+ entitlementPoolElement.setAction(action);
+ if (entitlementPool.getId() != null) {
+ entitlementPoolElement.setElementId(new Id(entitlementPool.getId()));
+ }
+ Info info = new Info();
+ info.setName(entitlementPool.getName());
+ info.setDescription(entitlementPool.getDescription());
+ info.addProperty("thresholdValue", entitlementPool.getThresholdValue());
+ info.addProperty("threshold_unit", entitlementPool.getThresholdUnit());
+ info.addProperty("entitlement_metric", entitlementPool.getEntitlementMetric());
+ info.addProperty("increments", entitlementPool.getIncrements());
+ info.addProperty("aggregation_func", entitlementPool.getAggregationFunction());
+ info.addProperty("operational_scope", entitlementPool.getOperationalScope());
+ info.addProperty("EntitlementTime", entitlementPool.getTime());
+ info.addProperty("manufacturerReferenceNumber",
+ entitlementPool.getManufacturerReferenceNumber());
+ entitlementPoolElement.setInfo(info);
+
+ if (entitlementPool.getReferencingFeatureGroups() != null &&
+ entitlementPool.getReferencingFeatureGroups().size() > 0) {
+ entitlementPoolElement.setRelations(entitlementPool.getReferencingFeatureGroups().stream()
+ .map(rel -> VlmZusammenUtil
+ .createRelation(RelationType.EntitlmentPoolToReferencingFeatureGroup, rel))
+ .collect(Collectors.toList()));
+ }
+ 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
+ .setThresholdValue(toInteger(elementInfo.getInfo().getProperty("thresholdValue")));
+ entitlmentPool.setThresholdUnit(
+ ThresholdUnit.valueOf(elementInfo.getInfo().getProperty("threshold_unit")));
+ entitlmentPool.setEntitlementMetric(
+ getEntitlementMetricCoiceOrOther(elementInfo.getInfo().getProperty("entitlement_metric")));
+ entitlmentPool.setIncrements(elementInfo.getInfo().getProperty("increments"));
+ entitlmentPool.setAggregationFunction(
+ getAggregationFuncCoiceOrOther(elementInfo.getInfo().getProperty("aggregation_func")));
+ entitlmentPool.setOperationalScope(getOperationalScopeMultiChoiceOrOther(
+ elementInfo.getInfo().getProperty("operational_scope")));
+ entitlmentPool.setTime(
+ getEntitlementTimeCoiceOrOther(elementInfo.getInfo().getProperty("EntitlementTime")));
+ entitlmentPool.setManufacturerReferenceNumber(
+ elementInfo.getInfo().getProperty("manufacturerReferenceNumber"));
+
+ 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 ChoiceOrOther<AggregationFunction> getAggregationFuncCoiceOrOther(
+ Map aggregationFunction) {
+ return new ChoiceOrOther<>
+ (AggregationFunction.valueOf((String) aggregationFunction.get("choice")),
+ (String) aggregationFunction.get("other"));
+ }
+
+ private ChoiceOrOther<EntitlementMetric> getEntitlementMetricCoiceOrOther(Map entitlementMetric) {
+ return new ChoiceOrOther<>(EntitlementMetric.valueOf((String) entitlementMetric.get("choice")
+ ), (String) entitlementMetric.get("other"));
+ }
+
+ private ChoiceOrOther<EntitlementTime> getEntitlementTimeCoiceOrOther(Map entitlementTime) {
+ return new ChoiceOrOther<>(EntitlementTime.valueOf((String) entitlementTime.get("choice")),
+ (String) entitlementTime.get("other"));
+ }
+
+ private MultiChoiceOrOther<OperationalScope> getOperationalScopeMultiChoiceOrOther
+ (Map<String, Object>
+ operationalScope) {
+ Set<OperationalScope> choices = new HashSet<>();
+ ((List<String>) operationalScope.get("choices")).
+ forEach(choice -> choices.add(OperationalScope.valueOf(choice)));
+
+ return new MultiChoiceOrOther<>(choices, (String) operationalScope.get("other"));
+ }
+
+ 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/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
new file mode 100644
index 0000000000..ee6ffbfca2
--- /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/FeatureGroupDaoZusammenImpl.java
@@ -0,0 +1,326 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import com.amdocs.zusammen.datatypes.item.Relation;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+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.
+ */
+public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao {
+
+ private ZusammenAdaptor zusammenAdaptor;
+
+ public FeatureGroupDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ //no need
+ }
+
+ @Override
+ public void create(FeatureGroupEntity featureGroup) {
+ ZusammenElement featureGroupElement =
+ buildFeatureGroupElement(featureGroup, Action.CREATE);
+
+ ZusammenElement featureGroupsElement =
+ VlmZusammenUtil.buildStructuralElement(StructureElement.FeatureGroups, null);
+
+ 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");
+
+ savedElement.ifPresent(element -> featureGroup
+ .setId(element.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,
+ 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()));
+
+ return zusammenAdaptor.getElementInfo(context, elementContext, new Id(featureGroup.getId()))
+ .map(elementInfo -> mapElementInfoToFeatureGroup(
+ featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), elementInfo))
+ .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));
+ 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()));
+
+ return zusammenAdaptor
+ .listElementsByName(context, elementContext, null, StructureElement.FeatureGroups.name())
+ .stream().map(elementInfo -> mapElementInfoToFeatureGroup(
+ featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(), elementInfo))
+ .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()));
+
+ return zusammenAdaptor
+ .listElementsByName(context, elementContext, null, StructureElement.FeatureGroups.name())
+ .size();
+ }
+
+ @Override
+ public void removeEntitlementPool(FeatureGroupEntity featureGroup, String entitlementPoolId) {
+ removeRelationToContainedEntity(featureGroup, entitlementPoolId, "entitlement pool");
+ }
+
+ @Override
+ public void removeLicenseKeyGroup(FeatureGroupEntity featureGroup, String licenseKeyGroupId) {
+ removeRelationToContainedEntity(featureGroup, licenseKeyGroupId, "license Key Group");
+ }
+
+ 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));
+
+ Optional<ElementInfo> elementInfo = zusammenAdaptor.getElementInfo(context,
+ elementContext, new Id(featureGroup.getId()));
+ if (elementInfo.isPresent()) {
+ ZusammenElement zusammenElement = VlmZusammenUtil.getZusammenElement(elementInfo.get());
+ zusammenElement.setAction(Action.UPDATE);
+ zusammenElement.setRelations(elementInfo.get().getRelations().stream()
+ .filter(
+ relation -> !containedEntityId.equals(relation.getEdge2().getElementId().getValue()))
+ .collect(Collectors.toList()));
+ zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
+ String.format("remove %s", containedEntityType));
+ }
+ }
+
+ @Override
+ 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));
+
+ Optional<ElementInfo> elementInfo = zusammenAdaptor.getElementInfo(context,
+ elementContext, new Id(featureGroup.getId()));
+ if (elementInfo.isPresent()) {
+ FeatureGroupEntity currentFeatureGroup =
+ mapElementInfoToFeatureGroup(featureGroup.getId(), featureGroup.getVersion(),
+ elementInfo.get());
+
+ currentFeatureGroup.getEntitlementPoolIds().removeAll(removedEntitlementPools);
+ currentFeatureGroup.getEntitlementPoolIds().addAll(addedEntitlementPools);
+ if (featureGroupElement.getRelations() == null) {
+ featureGroupElement.setRelations(new ArrayList<>());
+ }
+ featureGroupElement.getRelations()
+ .addAll(currentFeatureGroup.getEntitlementPoolIds().stream()
+ .map(relation -> VlmZusammenUtil
+ .createRelation(RelationType.FeatureGroupToEntitlmentPool, relation))
+ .collect(Collectors.toList()));
+
+ currentFeatureGroup.getLicenseKeyGroupIds().removeAll(removedLicenseKeyGroups);
+ currentFeatureGroup.getLicenseKeyGroupIds().addAll(addedLicenseKeyGroups);
+ featureGroupElement.getRelations()
+ .addAll(currentFeatureGroup.getLicenseKeyGroupIds().stream()
+ .map(relation -> VlmZusammenUtil
+ .createRelation(RelationType.FeatureGroupToLicenseKeyGroup, relation))
+ .collect(Collectors.toList()));
+
+ zusammenAdaptor
+ .saveElement(context, elementContext, featureGroupElement, "update feature group");
+ }
+ }
+
+ @Override
+ public void deleteAll(FeatureGroupEntity featureGroup) {
+ //not supported
+ }
+
+
+ @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));
+
+ Optional<ElementInfo> elementInfo =
+ zusammenAdaptor.getElementInfo(context, elementContext, new Id(featureGroup.getId()));
+ if (elementInfo.isPresent()) {
+ ZusammenElement zusammenElement = VlmZusammenUtil.getZusammenElement(elementInfo.get());
+ zusammenElement.setAction(Action.UPDATE);
+ zusammenElement.getRelations().add(VlmZusammenUtil
+ .createRelation(RelationType.FeatureGroupToReferencingLicenseAgreement,
+ licenseAgreementId));
+ zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
+ "add referencing license agreement");
+ }
+ }
+
+ @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));
+
+ Optional<ElementInfo> elementInfo =
+ zusammenAdaptor.getElementInfo(context, elementContext, new Id(featureGroup.getId()));
+ if (elementInfo.isPresent()) {
+ ZusammenElement zusammenElement = VlmZusammenUtil.getZusammenElement(elementInfo.get());
+ zusammenElement.setAction(Action.UPDATE);
+ zusammenElement.setRelations(elementInfo.get().getRelations().stream()
+ .filter(
+ relation -> !licenseAgreementId.equals(relation.getEdge2().getElementId().getValue()))
+ .collect(Collectors.toList()));
+
+ zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
+ "remove referencing license agreement");
+ }
+ }
+
+ private ZusammenElement buildFeatureGroupElement(FeatureGroupEntity featureGroup, Action action) {
+ ZusammenElement featureGroupElement = new ZusammenElement();
+ featureGroupElement.setAction(action);
+ if (featureGroup.getId() != null) {
+ featureGroupElement.setElementId(new Id(featureGroup.getId()));
+ }
+ Info info = new Info();
+ info.setName(featureGroup.getName());
+ info.setDescription(featureGroup.getDescription());
+ info.addProperty("partNumber", featureGroup.getPartNumber());
+ featureGroupElement.setInfo(info);
+
+ featureGroupElement.setRelations(new ArrayList<>());
+
+ if (featureGroup.getEntitlementPoolIds() != null &&
+ featureGroup.getEntitlementPoolIds().size() > 0) {
+ featureGroupElement.getRelations().addAll(featureGroup.getEntitlementPoolIds().stream()
+ .map(rel -> VlmZusammenUtil
+ .createRelation(RelationType.FeatureGroupToEntitlmentPool, rel))
+ .collect(Collectors.toList()));
+ }
+
+ if (featureGroup.getLicenseKeyGroupIds() != null &&
+ featureGroup.getLicenseKeyGroupIds().size() > 0) {
+ featureGroupElement.getRelations()
+ .addAll(featureGroup.getLicenseKeyGroupIds().stream()
+ .map(rel -> VlmZusammenUtil
+ .createRelation(RelationType.FeatureGroupToLicenseKeyGroup, rel))
+ .collect(Collectors.toList()));
+ }
+
+ if (featureGroup.getReferencingLicenseAgreements() != null &&
+ featureGroup.getReferencingLicenseAgreements().size() > 0) {
+ featureGroupElement.getRelations()
+ .addAll(featureGroup.getReferencingLicenseAgreements().stream()
+ .map(rel -> VlmZusammenUtil
+ .createRelation(RelationType.FeatureGroupToReferencingLicenseAgreement,
+ rel))
+ .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"));
+
+ 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
new file mode 100644
index 0000000000..55bbae9b33
--- /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/LicenseAgreementDaoZusammenImpl.java
@@ -0,0 +1,249 @@
+/*-
+ * ============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.impl.zusammen;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
+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 org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+
+public class LicenseAgreementDaoZusammenImpl implements LicenseAgreementDao {
+
+ private ZusammenAdaptor zusammenAdaptor;
+
+ public LicenseAgreementDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ //no need
+ }
+
+ @Override
+ public void create(LicenseAgreementEntity licenseAgreement) {
+ ZusammenElement licenseAgreementElement =
+ buildLicenseAgreementElement(licenseAgreement, Action.CREATE);
+ ZusammenElement licenseAgreementsElement =
+ VlmZusammenUtil.buildStructuralElement(StructureElement.LicenseAgreements, null);
+ 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()));
+ }
+
+ @Override
+ public void update(LicenseAgreementEntity licenseAgreement) {
+ 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,
+ 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()));
+
+ return zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseAgreement.getId()))
+ .map(elementInfo -> mapElementInfoToLicenseAgreement(
+ licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion(), elementInfo))
+ .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));
+ zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
+ "delete license agreement. id:" + licenseAgreement.getId() + ".");
+ }
+
+
+ @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()));
+
+ return zusammenAdaptor
+ .listElementsByName(context, elementContext, null,
+ StructureElement.LicenseAgreements.name())
+ .stream().map(elementInfo -> mapElementInfoToLicenseAgreement(
+ licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion(), elementInfo))
+ .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()));
+
+ return zusammenAdaptor.listElementsByName(context, elementContext, null,
+ StructureElement.LicenseAgreements.name())
+ .size();
+ }
+
+ @Override
+ public void deleteAll(LicenseAgreementEntity entity) {
+ //not supported
+ }
+
+ @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));
+
+ Optional<ElementInfo> elementInfo = zusammenAdaptor.getElementInfo(context,
+ elementContext, new Id(licenseAgreement.getId()));
+ if (elementInfo.isPresent()) {
+ ZusammenElement zusammenElement = VlmZusammenUtil.getZusammenElement(elementInfo.get());
+ zusammenElement.setAction(Action.UPDATE);
+ zusammenElement.setRelations(elementInfo.get().getRelations().stream()
+ .filter(relation -> !featureGroupId.equals(relation.getEdge2().getElementId().getValue()))
+ .collect(Collectors.toList()));
+ zusammenAdaptor.saveElement(context, elementContext, zusammenElement, "remove feature group");
+ }
+ }
+
+ @Override
+ public void updateColumnsAndDeltaFeatureGroupIds(LicenseAgreementEntity licenseAgreement,
+ Set<String> addedFeatureGroupIds,
+ Set<String> removedFeatureGroupIds) {
+ 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));
+
+ Optional<ElementInfo> elementInfo =
+ zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseAgreement.getId()));
+ if (elementInfo.isPresent()) {
+ LicenseAgreementEntity currentLicenseAgreement =
+ mapElementInfoToLicenseAgreement(licenseAgreement.getId(), licenseAgreement.getVersion(),
+ elementInfo.get());
+
+ currentLicenseAgreement.getFeatureGroupIds().removeAll(removedFeatureGroupIds);
+ currentLicenseAgreement.getFeatureGroupIds().addAll(addedFeatureGroupIds);
+ licenseAgreementElement.setRelations(currentLicenseAgreement.getFeatureGroupIds().stream()
+ .map(relation -> VlmZusammenUtil
+ .createRelation(RelationType.LicenseAgreementToFeatureGroup, relation))
+ .collect(Collectors.toList()));
+ zusammenAdaptor.saveElement(context, elementContext, licenseAgreementElement,
+ "update license agreement");
+ }
+ }
+
+ 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()));
+ }
+ Info info = new Info();
+ info.setName(licenseAgreement.getName());
+ info.setDescription(licenseAgreement.getDescription());
+ info.addProperty("licenseTerm", licenseAgreement.getLicenseTerm());
+ info.addProperty("requirementsAndConstrains", licenseAgreement.getRequirementsAndConstrains());
+ licenseAgreementElement.setInfo(info);
+
+ if (licenseAgreement.getFeatureGroupIds() != null &&
+ licenseAgreement.getFeatureGroupIds().size() > 0) {
+ licenseAgreementElement.setRelations(licenseAgreement.getFeatureGroupIds().stream()
+ .map(rel -> VlmZusammenUtil
+ .createRelation(RelationType.LicenseAgreementToFeatureGroup, rel))
+ .collect(Collectors.toList()));
+ }
+ return licenseAgreementElement;
+ }
+}
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
new file mode 100644
index 0000000000..bf1899cb04
--- /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/LicenseKeyGroupZusammenDaoImpl.java
@@ -0,0 +1,243 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen;
+
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
+import com.amdocs.zusammen.adaptor.inbound.api.types.item.ZusammenElement;
+import com.amdocs.zusammen.datatypes.Id;
+import com.amdocs.zusammen.datatypes.SessionContext;
+import com.amdocs.zusammen.datatypes.item.Action;
+import com.amdocs.zusammen.datatypes.item.ElementContext;
+import com.amdocs.zusammen.datatypes.item.Info;
+import org.openecomp.core.zusammen.api.ZusammenAdaptor;
+import org.openecomp.core.zusammen.api.ZusammenUtil;
+import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
+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.versioning.dao.types.Version;
+
+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.
+ */
+public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao {
+ private ZusammenAdaptor zusammenAdaptor;
+
+ public LicenseKeyGroupZusammenDaoImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ //no need
+ }
+
+ @Override
+ public void create(LicenseKeyGroupEntity licenseKeyGroup) {
+ ZusammenElement licenseKeyGroupElement =
+ buildLicenseKeyGroupElement(licenseKeyGroup, Action.CREATE);
+
+ ZusammenElement lkgsElement =
+ VlmZusammenUtil.buildStructuralElement(StructureElement.LicenseKeyGroups, null);
+ 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");
+
+ savedElement.ifPresent(element -> licenseKeyGroup
+ .setId(element.getSubElements().iterator().next().getElementId().getValue()));
+ }
+
+ @Override
+ public void update(LicenseKeyGroupEntity licenseKeyGroup) {
+ ZusammenElement locenseKeyGroupElement =
+ buildLicenseKeyGroupElement(licenseKeyGroup, Action.UPDATE);
+
+ SessionContext context = ZusammenUtil.createSessionContext();
+ Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
+ zusammenAdaptor.saveElement(context, new ElementContext(itemId,
+ VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)),
+ locenseKeyGroupElement,
+ 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()));
+
+ return zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseKeyGroup.getId()))
+ .map(elementInfo -> mapElementInfoToLicenseKeyGroup(
+ licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(), elementInfo))
+ .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()));
+
+ Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId());
+ ElementContext elementContext = new ElementContext(itemId,
+ VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor));
+
+ zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
+ "delete license key group. id:" + licenseKeyGroup.getId() + ".");
+ }
+
+ @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()));
+
+ return zusammenAdaptor
+ .listElementsByName(context, elementContext, null, StructureElement.LicenseKeyGroups.name())
+ .stream().map(elementInfo -> mapElementInfoToLicenseKeyGroup(
+ licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(), elementInfo))
+ .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()));
+
+ return zusammenAdaptor
+ .listElementsByName(context, elementContext, null, StructureElement.LicenseKeyGroups.name())
+ .size();
+ }
+
+ @Override
+ public void deleteAll(LicenseKeyGroupEntity licenseKeyGroup) {
+ //not supported
+ }
+
+ @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));
+
+ Optional<ElementInfo> elementInfo =
+ zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseKeyGroup.getId()));
+
+ if (elementInfo.isPresent()) {
+ ZusammenElement zusammenElement = VlmZusammenUtil.getZusammenElement(elementInfo.get());
+ zusammenElement.setAction(Action.UPDATE);
+ zusammenElement.setRelations(elementInfo.get().getRelations().stream()
+ .filter(relation -> !featureGroupId
+ .equals(relation.getEdge2().getElementId().getValue()))
+ .collect(Collectors.toList()));
+
+ zusammenAdaptor.saveElement(context, elementContext, zusammenElement,
+ "remove referencing feature group");
+ }
+ }
+
+ @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));
+
+ Optional<ElementInfo> elementInfo =
+ zusammenAdaptor.getElementInfo(context, elementContext, new Id(licenseKeyGroup.getId()));
+
+ if (elementInfo.isPresent()) {
+ ZusammenElement zusammenElement = VlmZusammenUtil.getZusammenElement(elementInfo.get());
+ zusammenElement.setAction(Action.UPDATE);
+ if (zusammenElement.getRelations() == null) {
+ zusammenElement.setRelations(new ArrayList<>());
+ }
+ zusammenElement.getRelations().add(VlmZusammenUtil
+ .createRelation(RelationType.LicenseKeyGroupToReferencingFeatureGroup,
+ featureGroupId));
+ zusammenAdaptor
+ .saveElement(context, elementContext, zusammenElement, "add referencing feature group");
+ }
+ }
+
+ private ZusammenElement buildLicenseKeyGroupElement(LicenseKeyGroupEntity licenseKeyGroup,
+ Action action) {
+ ZusammenElement lkgElement = new ZusammenElement();
+ lkgElement.setAction(action);
+ if (licenseKeyGroup.getId() != null) {
+ lkgElement.setElementId(new Id(licenseKeyGroup.getId()));
+ }
+ Info info = new Info();
+ info.setName(licenseKeyGroup.getName());
+ info.setDescription(licenseKeyGroup.getDescription());
+ info.addProperty("LicenseKeyType", licenseKeyGroup.getType());
+ info.addProperty("operational_scope", licenseKeyGroup.getOperationalScope());
+ lkgElement.setInfo(info);
+
+ 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
+ .setType(LicenseKeyType.valueOf(elementInfo.getInfo().getProperty("LicenseKeyType")));
+ licenseKeyGroup.setOperationalScope(getOperationalScopeMultiChoiceOrOther(
+ elementInfo.getInfo().getProperty("operational_scope")));
+
+ 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) {
+
+ Set<OperationalScope> choices = new HashSet<>();
+ ((List<String>) operationalScope.get("choices")).
+ forEach(choice -> choices.add(OperationalScope.valueOf(choice)));
+
+ return new MultiChoiceOrOther<>(choices, (String) operationalScope.get("other"));
+ }
+
+
+}
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/RelationType.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/RelationType.java
new file mode 100644
index 0000000000..5ce0433f50
--- /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/RelationType.java
@@ -0,0 +1,10 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen;
+
+public enum RelationType {
+ LicenseAgreementToFeatureGroup,
+ FeatureGroupToEntitlmentPool,
+ FeatureGroupToLicenseKeyGroup,
+ FeatureGroupToReferencingLicenseAgreement,
+ EntitlmentPoolToReferencingFeatureGroup,
+ LicenseKeyGroupToReferencingFeatureGroup
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/StructureElement.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/StructureElement.java
new file mode 100644
index 0000000000..767fa52d44
--- /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/StructureElement.java
@@ -0,0 +1,9 @@
+package org.openecomp.sdc.vendorlicense.dao.impl.zusammen;
+
+public enum StructureElement {
+ General,
+ LicenseAgreements,
+ FeatureGroups,
+ EntitlementPools,
+ LicenseKeyGroups
+}
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
new file mode 100644
index 0000000000..cd1ef0fbcf
--- /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/VendorLicenseModelDaoZusammenImpl.java
@@ -0,0 +1,138 @@
+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.vendorlicense.dao.VendorLicenseModelDao;
+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 {
+
+ private ZusammenAdaptor zusammenAdaptor;
+
+ public VendorLicenseModelDaoZusammenImpl(ZusammenAdaptor zusammenAdaptor) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ }
+
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ VersionableEntityMetadata metadata =
+ new VersionableEntityMetadata(VersionableEntityStoreType.Zusammen, "vlm", null, null);
+
+ VersioningManagerFactory.getInstance().createInterface()
+ .register(versionableEntityType, metadata);
+ }
+
+ @Override
+ public Collection<VendorLicenseModelEntity> list(VendorLicenseModelEntity entity) {
+ return zusammenAdaptor.listItems(ZusammenUtil.createSessionContext()).stream()
+ .map(item -> mapInfoToVlm(
+ item.getId().getValue(), null, item.getInfo(),
+ item.getModificationTime(), item.getCreationTime()))
+ .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());
+
+ 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
+ }
+
+ @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),
+ 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()));
+
+ return zusammenAdaptor
+ .getElementInfoByName(context, elementContext, null, StructureElement.General.name())
+ .map(generalElementInfo -> mapInfoToVlm(
+ vendorLicenseModel.getId(), vendorLicenseModel.getVersion(),
+ generalElementInfo.getInfo(),
+ itemVersion.getModificationTime(), itemVersion.getCreationTime()))
+ .orElse(null);
+ }
+
+ @Override
+ public void delete(VendorLicenseModelEntity entity) {
+
+ }
+
+ private Info mapVlmToZusammenItemInfo(VendorLicenseModelEntity vendorLicenseModel) {
+ Info info = new Info();
+ info.setName(vendorLicenseModel.getVendorName());
+ info.setDescription(vendorLicenseModel.getDescription());
+ info.addProperty("type", "vlm");
+ addVlmToInfo(info, vendorLicenseModel);
+ return info;
+ }
+
+ private ZusammenElement mapVlmToZusammenElement(VendorLicenseModelEntity vendorLicenseModel,
+ Action action) {
+ ZusammenElement generalElement =
+ VlmZusammenUtil.buildStructuralElement(StructureElement.General, action);
+ addVlmToInfo(generalElement.getInfo(), vendorLicenseModel);
+ return generalElement;
+ }
+
+ private void addVlmToInfo(Info info, VendorLicenseModelEntity vendorLicenseModel) {
+ info.addProperty(InfoPropertyName.name.name(), vendorLicenseModel.getVendorName());
+ info.addProperty(InfoPropertyName.description.name(), vendorLicenseModel.getDescription());
+ info.addProperty(InfoPropertyName.iconRef.name(), vendorLicenseModel.getIconRef());
+ }
+
+ private VendorLicenseModelEntity mapInfoToVlm(String vlmId, Version version, Info info,
+ Date modificationTime, Date creationTime) {
+ 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 {
+ name,
+ description,
+ iconRef
+ }
+}
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
new file mode 100644
index 0000000000..b2802bee66
--- /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/VlmZusammenUtil.java
@@ -0,0 +1,68 @@
+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());
+ zusammenElement.setInfo(elementInfo.getInfo());
+ zusammenElement.setRelations(elementInfo.getRelations());
+ zusammenElement.setSubElements(elementInfo.getSubElements().stream()
+ .map(VlmZusammenUtil::getZusammenElement)
+ .collect(Collectors.toList()));
+ return zusammenElement;
+ }
+
+ public static Relation createRelation(RelationType type, String to) {
+ Relation relation = new Relation();
+ relation.setType(type.name());
+ RelationEdge edge2 = new RelationEdge();
+ edge2.setElementId(new Id(to));
+ relation.setEdge2(edge2);
+ return relation;
+ }
+}
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 678a53583c..6f3573981c 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
@@ -24,6 +24,13 @@ 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.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerErrorDescription;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
@@ -60,64 +67,61 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
+import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP;
+import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG;
+import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_MISSING_LA;
-public class VendorLicenseFacadeImpl
- implements VendorLicenseFacade {
-
+public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
private static final VersioningManager versioningManager =
VersioningManagerFactory.getInstance().createInterface();
- private static final VendorLicenseModelDao vendorLicenseModelDao =
- VendorLicenseModelDaoFactory.getInstance().createInterface();
- private static final LicenseAgreementDao licenseAgreementDao =
- LicenseAgreementDaoFactory.getInstance().createInterface();
+ private static final VendorLicenseModelDao
+ vendorLicenseModelDao = VendorLicenseModelDaoFactory.getInstance().createInterface();
+ private static final LicenseAgreementDao
+ licenseAgreementDao = LicenseAgreementDaoFactory.getInstance().createInterface();
private static final FeatureGroupDao featureGroupDao =
FeatureGroupDaoFactory.getInstance().createInterface();
- private static final EntitlementPoolDao entitlementPoolDao =
- EntitlementPoolDaoFactory.getInstance().createInterface();
- private static final LicenseKeyGroupDao licenseKeyGroupDao =
- LicenseKeyGroupDaoFactory.getInstance().createInterface();
+ private static final EntitlementPoolDao
+ entitlementPoolDao = EntitlementPoolDaoFactory.getInstance().createInterface();
+ private static final LicenseKeyGroupDao
+ licenseKeyGroupDao = LicenseKeyGroupDaoFactory.getInstance().createInterface();
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
/**
* Instantiates a new Vendor license facade.
*/
public VendorLicenseFacadeImpl() {
- vendorLicenseModelDao
- .registerVersioning(VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
- licenseAgreementDao
- .registerVersioning(VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
- featureGroupDao
- .registerVersioning(VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
- entitlementPoolDao
- .registerVersioning(VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
- licenseKeyGroupDao
- .registerVersioning(VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
+ vendorLicenseModelDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
+ licenseAgreementDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
+ featureGroupDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
+ entitlementPoolDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
+ licenseKeyGroupDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
}
@Override
- public void checkin(String vendorLicenseModelId, String user) {
+ public Version checkin(String vendorLicenseModelId, String user) {
Version newVersion = versioningManager
- .checkin(VendorLicenseConstants
- .VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE,
- vendorLicenseModelId, user, null);
+ .checkin(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user, null);
updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
+ return newVersion;
}
@Override
- public void submit(String vendorLicenseModelId, String user) {
+ public Version submit(String vendorLicenseModelId, String user) {
validateCompletedVendorLicenseModel(vendorLicenseModelId, user);
Version newVersion = versioningManager
- .submit(VendorLicenseConstants
- .VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE,
- vendorLicenseModelId, user, null);
+ .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));
+ getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Read,
+ user), user);
featureGroup.setVersion(version);
return getFeatureGroup(featureGroup);
}
@@ -151,21 +155,6 @@ public class VendorLicenseFacadeImpl
}
@Override
- public LicenseAgreementEntity getLicenseAgreement(String vlmId, Version version,
- String licenseAgreementId, String user) {
- return getLicenseAgreement(vlmId, licenseAgreementId, VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user)));
- }
-
- 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;
- }
-
- @Override
public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
String licenseAgreementId, String user) {
LicenseAgreementEntity retrieved =
@@ -185,10 +174,10 @@ public class VendorLicenseFacadeImpl
@Override
public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool,
String user) {
- entitlementPool.setVersion(
+ entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(),
getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user).getActiveVersion());
- entitlementPool.setId(CommonMethods.nextUuId());
+ user), user));
+ //entitlementPool.setId(CommonMethods.nextUuId());
entitlementPool.setVersionUuId(CommonMethods.nextUuId());
UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion().toString(),
@@ -200,27 +189,10 @@ public class VendorLicenseFacadeImpl
}
@Override
- public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
- String user) {
- licenseKeyGroup.setVersion(
- getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user).getActiveVersion());
- licenseKeyGroup.setId(CommonMethods.nextUuId());
- licenseKeyGroup.setVersionUuId(CommonMethods.nextUuId());
- UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
- licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion().toString(),
- licenseKeyGroup.getName());
- licenseKeyGroupDao.create(licenseKeyGroup);
- updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
- licenseKeyGroup.getVersion());
- return licenseKeyGroup;
- }
-
- @Override
public void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user) {
- entitlementPool.setVersion(
+ entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(),
getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user).getActiveVersion());
+ user), user));
EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
VersioningUtil
.validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
@@ -240,21 +212,23 @@ public class VendorLicenseFacadeImpl
public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
String user) {
return licenseKeyGroupDao.list(new LicenseKeyGroupEntity(vlmId, VersioningUtil
- .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user)), null));
+ .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
+ 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)), null));
+ .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
+ null));
}
@Override
public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
- licenseKeyGroup.setVersion(
+ licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user).getActiveVersion());
+ user), user));
LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
licenseKeyGroup.setVersionUuId((CommonMethods.nextUuId()));
VersioningUtil
@@ -268,81 +242,93 @@ public class VendorLicenseFacadeImpl
licenseKeyGroup.getVersion());
}
-
@Override
- public VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action,
- String user) {
- return versioningManager
- .getEntityVersionInfo(VendorLicenseConstants
- .VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE,
- vendorLicenseModelId, user,
- action);
+ public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
+ String user) {
+ licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
+ getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
+ user), user));
+ //licenseKeyGroup.setId(CommonMethods.nextUuId());
+ licenseKeyGroup.setVersionUuId(CommonMethods.nextUuId());
+ UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
+ licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion().toString(),
+ licenseKeyGroup.getName());
+ licenseKeyGroupDao.create(licenseKeyGroup);
+ updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion());
+ return licenseKeyGroup;
}
@Override
public VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version,
String user) {
+ mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
+
VersionInfo versionInfo = getVersionInfo(vlmId, VersionableEntityAction.Read, user);
VendorLicenseModelEntity vendorLicenseModel = vendorLicenseModelDao.get(
- new VendorLicenseModelEntity(vlmId, VersioningUtil.resolveVersion(version, versionInfo)));
+ new VendorLicenseModelEntity(vlmId,
+ VersioningUtil.resolveVersion(version, versionInfo, user)));
if (vendorLicenseModel == null) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.GET_VLM, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.ENTITY_NOT_FOUND);
throw new CoreException(new VendorLicenseModelNotFoundErrorBuilder(vlmId).build());
}
+ mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
return new VersionedVendorLicenseModel(vendorLicenseModel, versionInfo);
}
@Override
public VendorLicenseModelEntity createVendorLicenseModel(
VendorLicenseModelEntity vendorLicenseModelEntity, String user) {
- UniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME,
- vendorLicenseModelEntity.getVendorName());
- vendorLicenseModelEntity.setId(CommonMethods.nextUuId());
- Version version = versioningManager
- .create(VendorLicenseConstants
- .VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE,
- vendorLicenseModelEntity.getId(), user);
- vendorLicenseModelEntity.setVersion(version);
+ mdcDataDebugMessage.debugEntryMessage(null, null);
- // vendorLicenseModelEntity.setLastModificationTime(new Date());
+ 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;
}
@Override
public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
String user) {
- Version activeVersion =
+ Version version = VersioningUtil.resolveVersion(licenseAgreement.getVersion(),
getVersionInfo(licenseAgreement.getVendorLicenseModelId(), VersionableEntityAction.Write,
- user).getActiveVersion();
- licenseAgreement.setVersion(activeVersion);
- licenseAgreement.setId(CommonMethods.nextUuId());
+ user), user);
+ licenseAgreement.setVersion(version);
+ //licenseAgreement.setId(CommonMethods.nextUuId());
VersioningUtil.validateEntitiesExistence(licenseAgreement.getFeatureGroupIds(),
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), activeVersion, null),
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version, null),
featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
+
UniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().toString(),
licenseAgreement.getName());
+ licenseAgreementDao.create(licenseAgreement);
+ UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
+ licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().toString(),
+ licenseAgreement.getName());
if (licenseAgreement.getFeatureGroupIds() != null) {
for (String addedFgId : licenseAgreement.getFeatureGroupIds()) {
featureGroupDao.addReferencingLicenseAgreement(
- new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), activeVersion,
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version,
addedFgId), licenseAgreement.getId());
}
}
-
- licenseAgreementDao.create(licenseAgreement);
- UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
- licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().toString(),
- licenseAgreement.getName());
-
updateVlmLastModificationTime(licenseAgreement.getVendorLicenseModelId(),
licenseAgreement.getVersion());
@@ -351,49 +337,48 @@ public class VendorLicenseFacadeImpl
@Override
public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user) {
- Version activeVersion =
- getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write, user)
- .getActiveVersion();
- featureGroup.setId(CommonMethods.nextUuId());
- featureGroup.setVersion(activeVersion);
+ Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
+ getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
+ user), user);
+ //featureGroup.setId(CommonMethods.nextUuId());
+ featureGroup.setVersion(version);
VersioningUtil.validateEntitiesExistence(featureGroup.getLicenseKeyGroupIds(),
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), activeVersion, null),
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, null),
licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
VersioningUtil.validateEntitiesExistence(featureGroup.getEntitlementPoolIds(),
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), activeVersion, null),
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, null),
entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
UniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().toString(),
featureGroup.getName());
+ featureGroupDao.create(featureGroup);
+ UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
+ featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().toString(),
+ featureGroup.getName());
+
if (featureGroup.getLicenseKeyGroupIds() != null) {
for (String addedLkgId : featureGroup.getLicenseKeyGroupIds()) {
licenseKeyGroupDao.addReferencingFeatureGroup(
- new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), activeVersion,
- addedLkgId), featureGroup.getId());
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, addedLkgId),
+ featureGroup.getId());
}
}
if (featureGroup.getEntitlementPoolIds() != null) {
for (String addedEpId : featureGroup.getEntitlementPoolIds()) {
entitlementPoolDao.addReferencingFeatureGroup(
- new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), activeVersion,
- addedEpId), featureGroup.getId());
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, addedEpId),
+ featureGroup.getId());
}
}
- featureGroupDao.create(featureGroup);
- UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
- featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().toString(),
- featureGroup.getName());
-
updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(),
featureGroup.getVersion());
return featureGroup;
}
-
@Override
public Collection<ErrorCode> validateLicensingData(String vlmId, Version version,
String licenseAgreementId,
@@ -404,16 +389,16 @@ public class VendorLicenseFacadeImpl
|| !versionInfo.getViewableVersions().contains(version)) {
return Collections.singletonList(new RequestedVersionInvalidErrorBuilder().build());
}
- } catch (CoreException coreException) {
- return Collections.singletonList(coreException.code());
+ } catch (CoreException exception) {
+ return Collections.singletonList(exception.code());
}
List<ErrorCode> errorMessages = new ArrayList<>();
try {
getLicenseAgreement(vlmId, licenseAgreementId, version);
- } catch (CoreException coreException) {
- errorMessages.add(coreException.code());
+ } catch (CoreException exception) {
+ errorMessages.add(exception.code());
}
for (String featureGroupId : featureGroupIds) {
@@ -428,8 +413,8 @@ public class VendorLicenseFacadeImpl
licenseAgreementId,
version).build());
}
- } catch (CoreException coreException) {
- errorMessages.add(coreException.code());
+ } catch (CoreException exception) {
+ errorMessages.add(exception.code());
}
}
@@ -437,42 +422,70 @@ public class VendorLicenseFacadeImpl
}
@Override
+ public VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action,
+ String user) {
+ return versioningManager
+ .getEntityVersionInfo(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user,
+ action);
+ }
+
+ @Override
public void updateVlmLastModificationTime(String vendorLicenseModelId, Version version) {
VendorLicenseModelEntity retrieved =
vendorLicenseModelDao.get(new VendorLicenseModelEntity(vendorLicenseModelId, version));
vendorLicenseModelDao.update(retrieved);
- // entity.setLastModificationTime(new Date());
- //
- // vendorLicenseModelDao.updateLastModificationTime(entity);
+ }
+
+ @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));
+ }
+
+ 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 validateCompletedVendorLicenseModel(String vendorLicenseModelId, String user) {
- Version activeVersion =
- getVersionInfo(vendorLicenseModelId, VersionableEntityAction.Read, user).getActiveVersion();
+ Version version = VersioningUtil.resolveVersion(null,
+ getVersionInfo(vendorLicenseModelId, VersionableEntityAction.Read, user), user);
Collection<LicenseAgreementEntity> licenseAgreements = licenseAgreementDao
- .list(new LicenseAgreementEntity(vendorLicenseModelId, activeVersion, null));
+ .list(new LicenseAgreementEntity(vendorLicenseModelId, version, null));
if (licenseAgreements == null || licenseAgreements.isEmpty()) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
throw new CoreException(
- new SubmitUncompletedLicenseModelErrorBuilder(vendorLicenseModelId).build());
+ new SubmitUncompletedLicenseModelErrorBuilder(SUBMIT_UNCOMPLETED_VLM_MSG_MISSING_LA).build());
}
for (LicenseAgreementEntity licenseAgreement : licenseAgreements) {
- if (licenseAgreement.getFeatureGroupIds() == null
- || licenseAgreement.getFeatureGroupIds().isEmpty()) {
+ if (licenseAgreement.getFeatureGroupIds() == null || licenseAgreement.getFeatureGroupIds().isEmpty()) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
throw new CoreException(
- new SubmitUncompletedLicenseModelErrorBuilder(vendorLicenseModelId).build());
+ new SubmitUncompletedLicenseModelErrorBuilder(SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG).build());
}
}
- Collection<FeatureGroupEntity> featureGroupEntities = featureGroupDao
- .list(new FeatureGroupEntity(vendorLicenseModelId, activeVersion, null));
+ Collection<FeatureGroupEntity> featureGroupEntities =
+ featureGroupDao.list(new FeatureGroupEntity(vendorLicenseModelId, version, null));
for (FeatureGroupEntity featureGroupEntity : featureGroupEntities) {
- if (featureGroupEntity.getEntitlementPoolIds() == null
- || featureGroupEntity.getEntitlementPoolIds().isEmpty()) {
+ if (featureGroupEntity.getEntitlementPoolIds() == null || featureGroupEntity.getEntitlementPoolIds().isEmpty()) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
throw new CoreException(
- new SubmitUncompletedLicenseModelErrorBuilder(vendorLicenseModelId).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 8f8f34e471..eeed3b069d 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
@@ -20,6 +20,14 @@
package org.openecomp.sdc.vendorlicense.healing.impl;
+import org.openecomp.sdc.common.utils.CommonUtil;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerErrorDescription;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
@@ -29,11 +37,14 @@ import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
import org.openecomp.sdc.vendorlicense.healing.HealingService;
import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
+import java.util.UUID;
+
public class SimpleHealingServiceImpl implements HealingService {
private static final EntitlementPoolDao entitlementPoolDao =
EntitlementPoolDaoFactory.getInstance().createInterface();
private static final LicenseKeyGroupDao licenseKeyGroupDao =
LicenseKeyGroupDaoFactory.getInstance().createInterface();
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
@Override
public VersionableEntity heal(VersionableEntity toHeal, String user) {
@@ -41,23 +52,30 @@ public class SimpleHealingServiceImpl implements HealingService {
}
private VersionableEntity handleMissingVersionId(VersionableEntity toHeal, String user) {
- if (toHeal.getVersionUuId() != null) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ if (toHeal != null && toHeal.getVersionUuId() != null) {
return toHeal;
}
-
if (toHeal instanceof EntitlementPoolEntity) {
- toHeal.setVersionUuId(toHeal.getId());
+ toHeal.setVersionUuId(UUID.randomUUID().toString());
entitlementPoolDao.update((EntitlementPoolEntity) toHeal);
} else if (toHeal instanceof LicenseKeyGroupEntity) {
- toHeal.setVersionUuId(toHeal.getId());
+ toHeal.setVersionUuId(UUID.randomUUID().toString());
licenseKeyGroupDao.update((LicenseKeyGroupEntity) toHeal);
} else {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
throw new UnsupportedOperationException(
"Unsupported operation for 1610 release/1607->1610 migration.");
//todo maybe errorbuilder?
}
+
+ mdcDataDebugMessage.debugExitMessage(null, 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 2f11b75a98..580fc6c0e5 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,11 +20,10 @@
package org.openecomp.sdc.vendorlicense.licenseartifacts.impl;
-import org.apache.commons.collections4.MultiValuedMap;
-import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.common.utils.CommonUtil;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorlicense.HealingServiceFactory;
-import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
@@ -35,166 +34,115 @@ import org.openecomp.sdc.vendorlicense.healing.HealingService;
import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.VendorLicenseArtifact;
import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.VnfLicenseArtifact;
+import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.util.VendorLicenseArtifactsServiceUtils;
import org.openecomp.sdc.versioning.dao.types.Version;
-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.HashMap;
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.VendorLicenseConstants.VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH;
+import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VNF_ARTIFACT_NAME_WITH_PATH;
+
public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifactsService {
- private static final VendorLicenseFacade vendorLicenseFacade = VendorLicenseFacadeFactory
- .getInstance().createInterface();
- private static final HealingService healingService = HealingServiceFactory
- .getInstance().createInterface();
+ public static final VendorLicenseFacade vendorLicenseFacade =
+ VendorLicenseFacadeFactory.getInstance().createInterface();
+ public static final HealingService healingService =
+ HealingServiceFactory.getInstance().createInterface();
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- /**
- * Create License Artifacts.
- *
- * @param vspId the vsp id
- * @param vlmId the vlm id
- * @param vlmVersion the vlm version
- * @param featureGroups the feature groups
- * @param user the user
- * @return FileContentHandler
- */
- public FileContentHandler createLicenseArtifacts(String vspId, String vlmId,
- Version vlmVersion,
- List<String> featureGroups, String user) {
- FileContentHandler artifacts = new FileContentHandler();
- String vendorName = getVendorName(vlmId, user);
- artifacts.addFile(VendorLicenseConstants.VNF_ARTIFACT_NAME_WITH_PATH,
- createVnfArtifact(vspId, vlmId, vlmVersion, vendorName, featureGroups, user));
- artifacts.addFile(VendorLicenseConstants.VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH,
- createVendorLicenseArtifact(vlmId, vendorName, user));
+ static byte[] createVnfArtifact(String vspId, String vlmId, Version vlmVersion, String vendorName,
+ List<String> featureGroups, String user) {
- return artifacts;
- }
- static byte[] createVnfArtifact(
- String vspId, String vlmId, Version vlmVersion,
- String vendorName, List<String> featureGroups,
- String user) {
+ mdcDataDebugMessage.debugEntryMessage("VLM name", vendorName);
+
VnfLicenseArtifact artifact = new VnfLicenseArtifact();
artifact.setVspId(vspId);
artifact.setVendorName(vendorName);
for (String featureGroupId : featureGroups) {
- FeatureGroupModel featureGroupModel =
- vendorLicenseFacade.getFeatureGroupModel(new FeatureGroupEntity(
- vlmId, vlmVersion, featureGroupId), user);
+ FeatureGroupModel featureGroupModel = vendorLicenseFacade
+ .getFeatureGroupModel(new FeatureGroupEntity(vlmId, vlmVersion, featureGroupId), user);
Set<EntitlementPoolEntity> entitlementPoolEntities = featureGroupModel.getEntitlementPools();
Set<LicenseKeyGroupEntity> licenseKeyGroupEntities = featureGroupModel.getLicenseKeyGroups();
- featureGroupModel.setEntitlementPools(
- entitlementPoolEntities.stream()
- .map(entitlementPoolEntity -> (EntitlementPoolEntity) healingService
- .heal(entitlementPoolEntity, user))
- .collect(Collectors.toSet()));
- featureGroupModel.setLicenseKeyGroups(
- licenseKeyGroupEntities.stream()
- .map(licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService
- .heal(licenseKeyGroupEntity, user))
- .collect(Collectors.toSet()));
+ featureGroupModel.setEntitlementPools(entitlementPoolEntities.stream().map(
+ entitlementPoolEntity -> (EntitlementPoolEntity) healingService
+ .heal(entitlementPoolEntity, user)).collect(Collectors.toSet()));
+ featureGroupModel.setLicenseKeyGroups(licenseKeyGroupEntities.stream().map(
+ licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService
+ .heal(licenseKeyGroupEntity, user)).collect(Collectors.toSet()));
artifact.getFeatureGroups().add(featureGroupModel);
}
+ mdcDataDebugMessage.debugExitMessage("VLM name", vendorName);
return artifact.toXml().getBytes();
}
-
static byte[] createVendorLicenseArtifact(String vlmId, String vendorName, String user) {
+
+
+ mdcDataDebugMessage.debugEntryMessage("VLM name", vendorName);
+
VendorLicenseArtifact vendorLicenseArtifact = new VendorLicenseArtifact();
vendorLicenseArtifact.setVendorName(vendorName);
Set<EntitlementPoolEntity> entitlementPoolEntities = new HashSet<>();
Set<LicenseKeyGroupEntity> licenseKeyGroupEntities = new HashSet<>();
- List<Version> finalVersions = getFinalVersionsForVlm(vlmId);
+ List<Version> finalVersions = VendorLicenseArtifactsServiceUtils.getFinalVersionsForVlm(vlmId);
for (Version finalVersion : finalVersions) {
- entitlementPoolEntities.addAll(
- vendorLicenseFacade.listEntitlementPools(vlmId, finalVersion, user));
- licenseKeyGroupEntities.addAll(
- vendorLicenseFacade.listLicenseKeyGroups(vlmId, finalVersion, user));
+ entitlementPoolEntities
+ .addAll(vendorLicenseFacade.listEntitlementPools(vlmId, finalVersion, user));
+ licenseKeyGroupEntities
+ .addAll(vendorLicenseFacade.listLicenseKeyGroups(vlmId, finalVersion, user));
}
- entitlementPoolEntities = healEPs(user, filterChangedEntities(entitlementPoolEntities));
- licenseKeyGroupEntities = healLkgs(user, filterChangedEntities(licenseKeyGroupEntities));
+ entitlementPoolEntities = VendorLicenseArtifactsServiceUtils
+ .healEPs(user,
+ VendorLicenseArtifactsServiceUtils.filterChangedEntities(entitlementPoolEntities));
+ licenseKeyGroupEntities = VendorLicenseArtifactsServiceUtils
+ .healLkgs(user,
+ VendorLicenseArtifactsServiceUtils.filterChangedEntities(licenseKeyGroupEntities));
vendorLicenseArtifact.setEntitlementPoolEntities(entitlementPoolEntities);
vendorLicenseArtifact.setLicenseKeyGroupEntities(licenseKeyGroupEntities);
- return vendorLicenseArtifact.toXml().getBytes();
- }
-
- private static List<VersionableEntity> filterChangedEntities(
- Collection<? extends VersionableEntity> versionableEntities) {
- MultiValuedMap<String, VersionableEntity> entitiesById = mapById(versionableEntities);
- Map<String, VersionableEntity> entitiesByVersionUuId = new HashMap<>();
- List<VersionableEntity> changedOnly = new ArrayList<>();
-
- for (String epId : entitiesById.keySet()) {
- Collection<VersionableEntity> versionableEntitiesForId = entitiesById.get(epId);
- for (VersionableEntity ep : versionableEntitiesForId) {
- entitiesByVersionUuId.put(ep.getVersionUuId(), ep);
- }
- }
- changedOnly.addAll(entitiesByVersionUuId.values());
-
- return changedOnly;
- }
-
- private static MultiValuedMap<String, VersionableEntity> mapById(
- Collection<? extends VersionableEntity> versionableEntities) {
- MultiValuedMap<String, VersionableEntity> mappedById = new ArrayListValuedHashMap<>();
- for (VersionableEntity ve : versionableEntities) {
- mappedById.put(ve.getId(), ve);
- }
- return mappedById;
+ mdcDataDebugMessage.debugExitMessage("VLM name", vendorName);
+ return vendorLicenseArtifact.toXml().getBytes();
}
- private static Set<LicenseKeyGroupEntity> healLkgs(
- String user, Collection<? extends VersionableEntity> licenseKeyGroupEntities) {
- Set<LicenseKeyGroupEntity> healed = new HashSet<>();
- for (VersionableEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
- healed.add((LicenseKeyGroupEntity) healingService.heal(licenseKeyGroupEntity, user));
- }
-
- return healed;
- }
+ /**
+ * Create License Artifacts.
+ * @param vspId vspId
+ * @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) {
- private static Set<EntitlementPoolEntity> healEPs(
- String user, Collection<? extends VersionableEntity> entitlementPoolEntities) {
- Set<EntitlementPoolEntity> healed = new HashSet<>();
- for (VersionableEntity entitlementPoolEntity : entitlementPoolEntities) {
- healed.add((EntitlementPoolEntity) healingService.heal(entitlementPoolEntity, user));
- }
- return healed;
- }
+ mdcDataDebugMessage.debugEntryMessage("VSP Id", vspId);
- private static List<Version> getFinalVersionsForVlm(String vlmId) {
- VersionInfo versionInfo = vendorLicenseFacade
- .getVersionInfo(vlmId, VersionableEntityAction.Read, "");
- return versionInfo.getFinalVersions();
+ FileContentHandler artifacts = new FileContentHandler();
+ String vendorName = VendorLicenseArtifactsServiceUtils.getVendorName(vlmId, user);
- }
+ artifacts.addFile(VNF_ARTIFACT_NAME_WITH_PATH,
+ createVnfArtifact(vspId, vlmId, vlmVersion, vendorName, featureGroups, user));
+ artifacts.addFile(VENDOR_LICENSE_MODEL_ARTIFACT_NAME_WITH_PATH,
+ createVendorLicenseArtifact(vlmId, vendorName, user));
+ mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
- private static String getVendorName(String vendorLicenseModelId, String user) {
- return vendorLicenseFacade
- .getVendorLicenseModel(vendorLicenseModelId, null, user)
- .getVendorLicenseModel().getVendorName();
+ return artifacts;
}
}
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 1f8607765a..f1da629960 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
@@ -36,11 +36,11 @@ import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinE
import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinFeatureGroupModel;
import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLicenseKeyGroupEntityForVnfArtifact;
+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/XmlArtifact.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/XmlArtifact.java
index 78d5e22412..3a3fbd16a3 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/XmlArtifact.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/XmlArtifact.java
@@ -22,6 +22,12 @@ package org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
+import org.openecomp.sdc.logging.types.LoggerConstants;
+import org.openecomp.sdc.logging.types.LoggerErrorCode;
+import org.openecomp.sdc.logging.types.LoggerErrorDescription;
+import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.errors.JsonErrorBuilder;
@@ -42,8 +48,11 @@ public abstract class XmlArtifact {
try {
xml = xmlMapper.writeValueAsString(this);
- } catch (com.fasterxml.jackson.core.JsonProcessingException jsonProcessingException) {
- throw new CoreException(new JsonErrorBuilder(jsonProcessingException.getMessage()).build());
+ } catch (com.fasterxml.jackson.core.JsonProcessingException exception) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.WRITE_ARTIFACT_XML, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_JSON);
+ throw new CoreException(new JsonErrorBuilder(exception.getMessage()).build());
}
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 1458fa80a7..020316f019 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
@@ -22,13 +22,14 @@ package org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementMetric;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementTime;
import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
+import org.openecomp.sdc.vendorlicense.dao.types.AggregationFunction;
import org.openecomp.sdc.vendorlicense.dao.types.xml.AggregationFunctionForXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementMetricForXml;
import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementTimeForXml;
@@ -36,6 +37,7 @@ import org.openecomp.sdc.vendorlicense.dao.types.xml.ThresholdForXml;
import java.util.Set;
+@JsonPropertyOrder({ "entitlement-pool-invariant-uuid", "entitlement-pool-uuid" })
public abstract class MixinEntitlementPoolEntityForVendorLicenseArtifact {
@JsonProperty(value = "threshold-value")
abstract ThresholdForXml getThresholdForArtifact();
@@ -43,24 +45,26 @@ public abstract class MixinEntitlementPoolEntityForVendorLicenseArtifact {
@JsonProperty(value = "entitlement-pool-uuid")
abstract String getVersionUuId();
- @JsonProperty(value = "manufacturer-reference-number")
- abstract String getManufacturerReferenceNumber();
-
@JsonIgnore
abstract Set<String> getReferencingFeatureGroups();
@JsonIgnore
abstract String getFirstClassCitizenId();
- @JsonIgnore
+ @JsonProperty(value = "entitlement-pool-invariant-uuid")
abstract String getId();
- @JsonIgnore
- abstract String getVersion();
+ @JsonProperty(value = "manufacturer-reference-number")
+ abstract String getManufacturerReferenceNumber();
+
+ @JsonProperty(value = "version")
+ abstract String getVersionForArtifact();
@JsonIgnore
abstract String getVendorLicenseModelId();
+
+
@JsonIgnore
abstract String getThresholdUnit();
@@ -79,7 +83,7 @@ public abstract class MixinEntitlementPoolEntityForVendorLicenseArtifact {
@JsonIgnore
abstract String getEntityType();
- @JacksonXmlProperty(isAttribute = false, localName = "value")
+ @JacksonXmlProperty(localName = "value")
@JacksonXmlElementWrapper(localName = "operational-scope")
abstract String getOperationalScopeForArtifact();
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 c4f2b4d4bd..064d17b8fa 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
@@ -59,6 +59,9 @@ public abstract class MixinEntitlementPoolEntityForVnfArtifact {
abstract String getVersion();
@JsonIgnore
+ abstract String getVersionForArtifact();
+
+ @JsonIgnore
abstract String getVendorLicenseModelId();
@JsonIgnore
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupModel.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupModel.java
index 1e76a74f4c..f5eb5f0bad 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupModel.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/mixins/MixinFeatureGroupModel.java
@@ -38,7 +38,7 @@ public abstract class MixinFeatureGroupModel {
@JacksonXmlElementWrapper(localName = "license-key-group-list")
abstract Set<LicenseKeyGroupEntity> getLicenseKeyGroups();
- @JacksonXmlProperty(isAttribute = false, localName = "internal-part-number")
+ @JacksonXmlProperty(isAttribute = false, localName = "part-number")
abstract String getEntityPartNumber();
@JacksonXmlProperty(isAttribute = false, localName = "feature-group-uuid")
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 ed3083afe3..b5fb2f4549 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
@@ -37,8 +37,8 @@ public abstract class MixinLicenseKeyGroupEntityForVendorLicenseArtifact {
@JsonIgnore
abstract Set<String> getReferencingFeatureGroups();
- @JsonIgnore
- abstract String getVersion();
+ @JsonProperty(value = "version")
+ abstract String getVersionForArtifact();
@JsonIgnore
abstract String getVendorLicenseModelId();
@@ -50,7 +50,7 @@ public abstract class MixinLicenseKeyGroupEntityForVendorLicenseArtifact {
@JsonIgnore
abstract String getFirstClassCitizenId();
- @JsonIgnore
+ @JsonProperty(value = "license-key-group-invariant-uuid")
abstract String getId();
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 6281c44830..ed171c6a4b 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
@@ -41,6 +41,9 @@ public abstract class MixinLicenseKeyGroupEntityForVnfArtifact {
abstract String getVersion();
@JsonIgnore
+ abstract String getVersionForArtifact();
+
+ @JsonIgnore
abstract String getVendorLicenseModelId();
@@ -54,7 +57,6 @@ public abstract class MixinLicenseKeyGroupEntityForVnfArtifact {
abstract String getFirstClassCitizenId();
-
@JsonIgnore
abstract ChoiceOrOther<OperationalScope> getOperationalScope();
@@ -71,4 +73,3 @@ public abstract class MixinLicenseKeyGroupEntityForVnfArtifact {
}
-
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
new file mode 100644
index 0000000000..f3e09766db
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VendorLicenseArtifactsServiceUtils.java
@@ -0,0 +1,132 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.vendorlicense.licenseartifacts.impl.util;
+
+import org.apache.commons.collections4.MultiValuedMap;
+import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
+import org.openecomp.sdc.vendorlicense.HealingServiceFactory;
+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.dao.types.Version;
+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;
+
+/**
+ * @author katyr
+ * @since January 10, 2017
+ */
+
+public class VendorLicenseArtifactsServiceUtils {
+ private static final HealingService healingService =
+ HealingServiceFactory.getInstance().createInterface();
+
+ /**
+ * maps the entities by id
+ *
+ * @return a Map of id -> list of versionable entities with that id
+ */
+ static MultiValuedMap<String, VersionableEntity> mapById(
+ Collection<? extends VersionableEntity> versionableEntities) {
+ MultiValuedMap<String, VersionableEntity> mappedById = new ArrayListValuedHashMap<>();
+ for (VersionableEntity ve : versionableEntities) {
+ mappedById.put(ve.getId(), ve);
+ }
+ return mappedById;
+ }
+
+ /**
+ * 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 entitity exists it will be returned
+ * @param versionableEntities
+ * @return a list of entities that has been changed
+ */
+ public static List<VersionableEntity> filterChangedEntities(
+ Collection<? extends VersionableEntity> versionableEntities) {
+ MultiValuedMap<String, VersionableEntity> entitiesById = mapById(
+ versionableEntities);
+ MultiValuedMap<String, VersionableEntity> entitiesByVersionUuId =
+ new ArrayListValuedHashMap<>();
+ List<VersionableEntity> changedOnly = new ArrayList<>();
+
+ for (String epId : entitiesById.keySet()) {
+ Collection<VersionableEntity> versionableEntitiesForId = entitiesById.get(epId);
+ for (VersionableEntity ep : versionableEntitiesForId) {
+ entitiesByVersionUuId.put(ep.getVersionUuId(), ep);
+ }
+ }
+
+ //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);
+ versionableEntitiesForUuid.sort(new VersionableEntitySortByVlmMajorVersion());
+ changedOnly.add(versionableEntitiesForUuid.get(0));
+ }
+
+ return changedOnly;
+ }
+
+ public static Set<LicenseKeyGroupEntity> healLkgs(String user,
+ Collection<? extends VersionableEntity> licenseKeyGroupEntities) {
+ Set<LicenseKeyGroupEntity> healed = new HashSet<>();
+ for (VersionableEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
+ healed.add((LicenseKeyGroupEntity) VendorLicenseArtifactsServiceImpl.healingService
+ .heal(licenseKeyGroupEntity, user));
+ }
+
+ return healed;
+ }
+
+ public static Set<EntitlementPoolEntity> healEPs(String user,
+ Collection<? extends VersionableEntity> entitlementPoolEntities) {
+ Set<EntitlementPoolEntity> healed = new HashSet<>();
+ for (VersionableEntity entitlementPoolEntity : entitlementPoolEntities) {
+ healed.add((EntitlementPoolEntity) VendorLicenseArtifactsServiceImpl.healingService
+ .heal(entitlementPoolEntity, user));
+ }
+
+ return healed;
+ }
+
+ public static List<Version> getFinalVersionsForVlm(String vlmId) {
+ VersionInfo versionInfo =
+ VendorLicenseArtifactsServiceImpl.vendorLicenseFacade
+ .getVersionInfo(vlmId, VersionableEntityAction.Read, "");
+ return versionInfo.getFinalVersions();
+
+ }
+
+ public static String getVendorName(String vendorLicenseModelId, String user) {
+ return VendorLicenseArtifactsServiceImpl.vendorLicenseFacade
+ .getVendorLicenseModel(vendorLicenseModelId, null, user)
+ .getVendorLicenseModel().getVendorName();
+ }
+}
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/VersionableEntitySortByVlmMajorVersion.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/VersionableEntitySortByVlmMajorVersion.java
new file mode 100644
index 0000000000..1aee2dd97e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/util/VersionableEntitySortByVlmMajorVersion.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.licenseartifacts.impl.util;
+
+import org.openecomp.sdc.versioning.dao.types.VersionableEntity;
+
+import java.util.Comparator;
+
+/**
+ * @author katyr
+ * @since January 10, 2017
+ */
+
+public class VersionableEntitySortByVlmMajorVersion implements Comparator<VersionableEntity> {
+ @Override
+ public int compare(VersionableEntity o1, VersionableEntity o2) {
+ return Integer.compare(o1.getVersion().getMajor(), o2.getVersion().getMajor());
+
+ }
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/pom.xml b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/pom.xml
index b98a669207..80d6e04e4d 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/pom.xml
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/pom.xml
@@ -2,17 +2,17 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+ <name>openecomp-sdc-vendor-license-lib</name>
+ <artifactId>openecomp-sdc-vendor-license-lib</artifactId>
+
+ <packaging>pom</packaging>
<parent>
<artifactId>openecomp-sdc-lib</artifactId>
<groupId>org.openecomp.sdc</groupId>
<version>1.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
</parent>
- <name>openecomp-sdc-vendor-license-lib</name>
- <artifactId>openecomp-sdc-vendor-license-lib</artifactId>
-
- <packaging>pom</packaging>
-
<modules>
<module>openecomp-sdc-vendor-license-api</module>
<module>openecomp-sdc-vendor-license-core</module>
@@ -21,4 +21,4 @@
<dependencies>
</dependencies>
-</project> \ No newline at end of file
+</project>
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/pom.xml.versionsBackup
new file mode 100644
index 0000000000..0b6ebb62d8
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/pom.xml.versionsBackup
@@ -0,0 +1,23 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>openecomp-sdc-vendor-license-lib</name>
+ <artifactId>openecomp-sdc-vendor-license-lib</artifactId>
+
+ <packaging>pom</packaging>
+ <parent>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <groupId>org.openecomp.sdc</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <modules>
+ <module>openecomp-sdc-vendor-license-api</module>
+ <module>openecomp-sdc-vendor-license-core</module>
+ </modules>
+
+ <dependencies>
+
+ </dependencies>
+</project> \ No newline at end of file