aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
committerMichael Lando <ml636r@att.com>2017-02-19 12:35:04 +0200
commitf5f13c4f6b6fe3b4d98e349dfd7db59339803436 (patch)
tree72caffc93fab394ffa3b761505775331f1c559b9 /openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core
parent451a3400b76511393c62a444f588a4ed15f4a549 (diff)
push addional code
Change-Id: Ia427bb3460cda3a896f8faced2de69eaf3807b74 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml48
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/SimpleHealingServiceServiceFactoryImpl.java34
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseArtifactServiceFactoryImpl.java34
-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.java148
-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.java33
-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.java206
-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.java33
-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.java160
-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.java33
-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.java130
-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.java33
-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.java91
-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.java34
-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/VendorLicenseFacadeFactoryImpl.java33
-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.java478
-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.java63
-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.java200
-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/FeatureGroupForArtifact.java60
-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/VendorLicenseArtifact.java80
-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.java97
-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.java54
-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.java100
-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.java100
-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/MixinFeatureGroupEntity.java62
-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.java61
-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.java72
-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.java74
27 files changed, 2551 insertions, 0 deletions
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
new file mode 100644
index 0000000000..7b66b2a505
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/pom.xml
@@ -0,0 +1,48 @@
+<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.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>RELEASE</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/SimpleHealingServiceServiceFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/SimpleHealingServiceServiceFactoryImpl.java
new file mode 100644
index 0000000000..79973bb888
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/SimpleHealingServiceServiceFactoryImpl.java
@@ -0,0 +1,34 @@
+/*-
+ * ============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;
+
+import org.openecomp.sdc.vendorlicense.healing.HealingService;
+import org.openecomp.sdc.vendorlicense.healing.impl.SimpleHealingServiceImpl;
+
+public class SimpleHealingServiceServiceFactoryImpl extends HealingServiceFactory {
+ private static HealingService INSTANCE = new SimpleHealingServiceImpl();
+
+ @Override
+ public HealingService createInterface() {
+ return INSTANCE;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseArtifactServiceFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseArtifactServiceFactoryImpl.java
new file mode 100644
index 0000000000..582b0e2094
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/VendorLicenseArtifactServiceFactoryImpl.java
@@ -0,0 +1,34 @@
+/*-
+ * ============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;
+
+import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
+import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.VendorLicenseArtifactsServiceImpl;
+
+public class VendorLicenseArtifactServiceFactoryImpl extends VendorLicenseArtifactServiceFactory {
+ private static VendorLicenseArtifactsService INSTANCE = new VendorLicenseArtifactsServiceImpl();
+
+ @Override
+ public VendorLicenseArtifactsService createInterface() {
+ return INSTANCE;
+ }
+
+}
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
new file mode 100644
index 0000000000..1722f8f8de
--- /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/EntitlementPoolCassandraDaoImpl.java
@@ -0,0 +1,148 @@
+/*-
+ * ============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;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.UDTValue;
+import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.UDTMapper;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.dao.impl.CassandraBaseDao;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
+import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.UniqueValueMetadata;
+import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+
+public class EntitlementPoolCassandraDaoImpl extends CassandraBaseDao<EntitlementPoolEntity>
+ implements EntitlementPoolDao {
+
+ private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static Mapper<EntitlementPoolEntity> mapper =
+ noSqlDb.getMappingManager().mapper(EntitlementPoolEntity.class);
+ private static EntitlementPoolAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(EntitlementPoolAccessor.class);
+ private static UDTMapper<Version> versionMapper =
+ noSqlDb.getMappingManager().udtMapper(Version.class);
+
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ VersionableEntityMetadata metadata = new VersionableEntityMetadata(
+ mapper.getTableMetadata().getName(),
+ mapper.getTableMetadata().getPartitionKey().get(0).getName(),
+ mapper.getTableMetadata().getPartitionKey().get(1).getName());
+
+ metadata.setUniqueValuesMetadata(Collections.singletonList(
+ new UniqueValueMetadata(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
+ Arrays.asList(mapper.getTableMetadata().getPartitionKey().get(0).getName(),
+ mapper.getTableMetadata().getPartitionKey().get(1).getName(), "name"))));
+
+ VersioningManagerFactory.getInstance().createInterface()
+ .register(versionableEntityType, metadata);
+ }
+
+ @Override
+ protected Mapper<EntitlementPoolEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(EntitlementPoolEntity entity) {
+ return new Object[]{entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getId()};
+ }
+
+ @Override
+ public Collection<EntitlementPoolEntity> list(EntitlementPoolEntity entity) {
+ return accessor.listByVlmVersion(entity.getVendorLicenseModelId(),
+ versionMapper.toUDT(entity.getVersion())).all();
+ }
+
+ @Override
+ public long count(EntitlementPoolEntity entity) {
+ return accessor.countByVlmVersion(entity.getVendorLicenseModelId(),
+ versionMapper.toUDT(entity.getVersion())).one().getLong("count");
+ }
+
+ @Override
+ public void deleteAll(EntitlementPoolEntity entity) {
+ accessor.deleteByVlmVersion(entity.getVendorLicenseModelId(),
+ versionMapper.toUDT(entity.getVersion())).all();
+ }
+
+ @Override
+ public void addReferencingFeatureGroup(EntitlementPoolEntity entity,
+ String referencingFeatureGroupId) {
+ accessor
+ .addReferencingFeatureGroups(CommonMethods.toSingleElementSet(referencingFeatureGroupId),
+ entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getId());
+ }
+
+ @Override
+ public void removeReferencingFeatureGroup(EntitlementPoolEntity entity,
+ String referencingFeatureGroupId) {
+ accessor
+ .removeReferencingFeatureGroups(CommonMethods.toSingleElementSet(referencingFeatureGroupId),
+ entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getId());
+ }
+
+ @Accessor
+ interface EntitlementPoolAccessor {
+
+ @Query("select * from entitlement_pool where vlm_id=? AND version=?")
+ Result<EntitlementPoolEntity> listByVlmVersion(String vendorLicenseModelId,
+ UDTValue vendorLicenseModelVersion);
+
+ @Query("delete from entitlement_pool where vlm_id=? AND version=?")
+ ResultSet deleteByVlmVersion(String vendorLicenseModelId, UDTValue vendorLicenseModelVersion);
+
+ @Query("select count(1) from entitlement_pool where vlm_id=? AND version=?")
+ ResultSet countByVlmVersion(String vendorLicenseModelId, UDTValue vendorLicenseModelVersion);
+
+ @Query(
+ "UPDATE entitlement_pool SET ref_fg_ids = ref_fg_ids + ? WHERE vlm_id=? AND version=? "
+ + "AND ep_id=?")
+ ResultSet addReferencingFeatureGroups(Set<String> referencingFeatureGroups,
+ String vendorLicenseModelId,
+ UDTValue vendorLicenseModelVersion, String id);
+
+ @Query(
+ "UPDATE entitlement_pool SET ref_fg_ids = ref_fg_ids - ? WHERE vlm_id=? AND version=? "
+ + "AND ep_id=?")
+ ResultSet removeReferencingFeatureGroups(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
new file mode 100644
index 0000000000..c1046f79cd
--- /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/EntitlementPoolDaoFactoryImpl.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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;
+
+import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
+import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
+
+public class EntitlementPoolDaoFactoryImpl extends EntitlementPoolDaoFactory {
+ private static EntitlementPoolDao INSTANCE = new EntitlementPoolCassandraDaoImpl();
+
+ @Override
+ public EntitlementPoolDao createInterface() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000000..86957a02c7
--- /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/FeatureGroupCassandraDaoImpl.java
@@ -0,0 +1,206 @@
+/*-
+ * ============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;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.UDTValue;
+import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.UDTMapper;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.dao.impl.CassandraBaseDao;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.UniqueValueMetadata;
+import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+
+public class FeatureGroupCassandraDaoImpl extends CassandraBaseDao<FeatureGroupEntity>
+ implements FeatureGroupDao {
+
+ private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static Mapper<FeatureGroupEntity> mapper =
+ noSqlDb.getMappingManager().mapper(FeatureGroupEntity.class);
+ private static FeatureGroupAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(FeatureGroupAccessor.class);
+ private static UDTMapper<Version> versionMapper =
+ noSqlDb.getMappingManager().udtMapper(Version.class);
+
+ private static Set<String> emptyIfNull(Set<String> set) {
+ return set == null ? new HashSet<>() : set;
+ }
+
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ VersionableEntityMetadata metadata = new VersionableEntityMetadata(
+ mapper.getTableMetadata().getName(),
+ mapper.getTableMetadata().getPartitionKey().get(0).getName(),
+ mapper.getTableMetadata().getPartitionKey().get(1).getName());
+
+ metadata.setUniqueValuesMetadata(Collections.singletonList(
+ new UniqueValueMetadata(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
+ Arrays.asList(mapper.getTableMetadata().getPartitionKey().get(0).getName(),
+ mapper.getTableMetadata().getPartitionKey().get(1).getName(), "name"))));
+
+ VersioningManagerFactory.getInstance().createInterface()
+ .register(versionableEntityType, metadata);
+ }
+
+ @Override
+ protected Mapper<FeatureGroupEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(FeatureGroupEntity entity) {
+ return new Object[]{entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getId()};
+ }
+
+ @Override
+ public long count(FeatureGroupEntity entity) {
+ return accessor.countByVlmVersion(entity.getVendorLicenseModelId(),
+ versionMapper.toUDT(entity.getVersion())).one().getLong("count");
+ }
+
+ @Override
+ public void updateFeatureGroup(FeatureGroupEntity entity,
+ Set<String> addedEntitlementPools,
+ Set<String> removedEntitlementPools,
+ Set<String> addedLicenseKeyGroups,
+ Set<String> removedLicenseKeyGroups) {
+ accessor.updateColumnsAndDeltaFeatureGroupIds(
+ entity.getName(),
+ entity.getDescription(),
+ entity.getPartNumber(),
+ emptyIfNull(addedEntitlementPools),
+ emptyIfNull(removedEntitlementPools),
+ emptyIfNull(addedLicenseKeyGroups),
+ emptyIfNull(removedLicenseKeyGroups),
+ 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();
+ }
+
+ @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());
+ }
+
+ @Override
+ public void removeReferencingLicenseAgreement(FeatureGroupEntity entity,
+ String licenseAgreementId) {
+ accessor
+ .removeReferencingLicenseAgreements(CommonMethods.toSingleElementSet(licenseAgreementId),
+ entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getId());
+ }
+
+ @Override
+ public void removeEntitlementPool(FeatureGroupEntity entity, String entitlementPoolId) {
+ accessor.removeEntitlementPools(CommonMethods.toSingleElementSet(entitlementPoolId),
+ entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()), entity.getId());
+ }
+
+ @Override
+ public void removeLicenseKeyGroup(FeatureGroupEntity entity, String licenseKeyGroupId) {
+ accessor.removeLicenseKeyGroup(CommonMethods.toSingleElementSet(licenseKeyGroupId),
+ entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()), entity.getId());
+ }
+
+ @Accessor
+ interface FeatureGroupAccessor {
+
+ @Query("select * from feature_group where vlm_id=? AND version=?")
+ Result<FeatureGroupEntity> listByVlmVersion(String vendorLicenseModelId, UDTValue version);
+
+ @Query("select count(1) from feature_group where vlm_id=? AND version=?")
+ ResultSet countByVlmVersion(String vendorLicenseModelId, UDTValue vendorLicenseModelVersion);
+
+ @Query("delete from feature_group where vlm_id=? AND version=?")
+ ResultSet deleteByVlmVersion(String vendorLicenseModelId, UDTValue vendorLicenseModelVersion);
+
+ @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=?")
+ ResultSet updateColumnsAndDeltaFeatureGroupIds(String name, String description,
+ String partNumber,
+ Set<String> addedEntitlementPools,
+ Set<String> removedEntitlementPools,
+ Set<String> addedLicenseKeyGroups,
+ Set<String> removedLicenseKeyGroups,
+ 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=?")
+ 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=?")
+ ResultSet removeReferencingLicenseAgreements(Set<String> licenseAgreementIds,
+ String vendorLicenseModelId, UDTValue version,
+ String id);
+
+ @Query("UPDATE feature_group SET ep_ids = ep_ids - ? WHERE vlm_id=? AND version=? AND fg_id=?")
+ ResultSet removeEntitlementPools(Set<String> entitlementPoolIds, String vendorLicenseModelId,
+ UDTValue version, String id);
+
+ @Query(
+ "UPDATE feature_group SET lkg_ids = lkg_ids - ? WHERE vlm_id=? AND version=? AND fg_id=?")
+ ResultSet removeLicenseKeyGroup(Set<String> licenseKeyGroupIds, 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
new file mode 100644
index 0000000000..941b2b5ecc
--- /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/FeatureGroupDaoFactoryImpl.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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;
+
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory;
+
+public class FeatureGroupDaoFactoryImpl extends FeatureGroupDaoFactory {
+ private static FeatureGroupDao INSTANCE = new FeatureGroupCassandraDaoImpl();
+
+ @Override
+ public FeatureGroupDao createInterface() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000000..6a7cc2aa60
--- /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/LicenseAgreementCassandraDaoImpl.java
@@ -0,0 +1,160 @@
+/*-
+ * ============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;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.UDTValue;
+import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.UDTMapper;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.dao.impl.CassandraBaseDao;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
+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.versioning.VersioningManagerFactory;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.UniqueValueMetadata;
+import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
+
+import java.util.Arrays;
+import java.util.Collection;
+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();
+ private static Mapper<LicenseAgreementEntity> mapper =
+ noSqlDb.getMappingManager().mapper(LicenseAgreementEntity.class);
+ private static LicenseAgreementAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(LicenseAgreementAccessor.class);
+ private static UDTMapper<ChoiceOrOther> choiceOrOtherMapper =
+ noSqlDb.getMappingManager().udtMapper(ChoiceOrOther.class);
+ private static UDTMapper<Version> versionMapper =
+ noSqlDb.getMappingManager().udtMapper(Version.class);
+
+ private static Set<String> emptyIfNull(Set<String> set) {
+ return set == null ? new HashSet<>() : set;
+ }
+
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ VersionableEntityMetadata metadata = new VersionableEntityMetadata(
+ mapper.getTableMetadata().getName(),
+ mapper.getTableMetadata().getPartitionKey().get(0).getName(),
+ mapper.getTableMetadata().getPartitionKey().get(1).getName());
+
+ metadata.setUniqueValuesMetadata(Collections.singletonList(
+ new UniqueValueMetadata(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
+ Arrays.asList(mapper.getTableMetadata().getPartitionKey().get(0).getName(),
+ mapper.getTableMetadata().getPartitionKey().get(1).getName(), "name"))));
+
+ VersioningManagerFactory.getInstance().createInterface()
+ .register(versionableEntityType, metadata);
+ }
+
+ @Override
+ protected Mapper<LicenseAgreementEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(LicenseAgreementEntity entity) {
+ return new Object[]{entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getId()};
+ }
+
+ @Override
+ public Collection<LicenseAgreementEntity> list(LicenseAgreementEntity entity) {
+ return accessor.listByVlmVersion(entity.getVendorLicenseModelId(),
+ versionMapper.toUDT(entity.getVersion())).all();
+ }
+
+ @Override
+ public long count(LicenseAgreementEntity entity) {
+ return accessor.countByVlmVersion(entity.getVendorLicenseModelId(),
+ versionMapper.toUDT(entity.getVersion())).one().getLong("count");
+ }
+
+ @Override
+ public void deleteAll(LicenseAgreementEntity entity) {
+ accessor.deleteByVlmVersion(entity.getVendorLicenseModelId(),
+ versionMapper.toUDT(entity.getVersion())).all();
+ }
+
+ @Override
+ public void removeFeatureGroup(LicenseAgreementEntity licenseAgreement, String featureGroupId) {
+ accessor.removeFeatureGroup(CommonMethods.toSingleElementSet(featureGroupId),
+ licenseAgreement.getVendorLicenseModelId(),
+ versionMapper.toUDT(licenseAgreement.getVersion()), licenseAgreement.getId());
+ }
+
+ @Override
+ public void updateColumnsAndDeltaFeatureGroupIds(LicenseAgreementEntity licenseAgreement,
+ Set<String> addedFeatureGroupIds,
+ Set<String> removedFeatureGroupIds) {
+ accessor.updateColumnsAndDeltaFeatureGroupIds(licenseAgreement.getName(),
+ licenseAgreement.getDescription(),
+ licenseAgreement.getLicenseTerm() == null ? null
+ : choiceOrOtherMapper.toUDT(licenseAgreement.getLicenseTerm()),
+ licenseAgreement.getRequirementsAndConstrains(),
+ emptyIfNull(addedFeatureGroupIds),
+ emptyIfNull(removedFeatureGroupIds),
+ licenseAgreement.getVendorLicenseModelId(),
+ versionMapper.toUDT(licenseAgreement.getVersion()),
+ licenseAgreement.getId());
+
+ }
+
+ @Accessor
+ interface LicenseAgreementAccessor {
+
+ @Query("SELECT * FROM license_agreement WHERE vlm_id=? and version=?")
+ Result<LicenseAgreementEntity> listByVlmVersion(String vendorLicenseModelId, UDTValue version);
+
+ @Query("select count(1) from license_agreement where vlm_id=? AND version=?")
+ ResultSet countByVlmVersion(String vendorLicenseModelId, UDTValue vendorLicenseModelVersion);
+
+ @Query("delete from license_agreement where vlm_id=? AND version=?")
+ ResultSet deleteByVlmVersion(String vendorLicenseModelId, UDTValue vendorLicenseModelVersion);
+
+ @Query(
+ "UPDATE license_agreement SET name=?, description=?, lic_term=?, req_const=?, "
+ + "fg_ids=fg_ids+?, fg_ids=fg_ids-? WHERE vlm_id=? AND version=? AND la_id=?")
+ ResultSet updateColumnsAndDeltaFeatureGroupIds(String name, String description,
+ UDTValue licenseTerm, String reqAndConst,
+ Set<String> addedFeatureGroupIds,
+ Set<String> removedFeatureGroupIds,
+ String vendorLicenseModelId, UDTValue version,
+ String id);
+
+ @Query("UPDATE license_agreement SET fg_ids=fg_ids-? WHERE vlm_id=? AND version=? AND la_id=?")
+ ResultSet removeFeatureGroup(Set<String> featureGroupIds, 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/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
new file mode 100644
index 0000000000..d92e2562e9
--- /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/LicenseAgreementDaoFactoryImpl.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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;
+
+import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
+import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory;
+
+public class LicenseAgreementDaoFactoryImpl extends LicenseAgreementDaoFactory {
+ private static LicenseAgreementDao INSTANCE = new LicenseAgreementCassandraDaoImpl();
+
+ @Override
+ public LicenseAgreementDao createInterface() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000000..c6952c8d03
--- /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/LicenseKeyGroupCassandraDaoImpl.java
@@ -0,0 +1,130 @@
+/*-
+ * ============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;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.UDTValue;
+import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.UDTMapper;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.dao.impl.CassandraBaseDao;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
+import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.UniqueValueMetadata;
+import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+
+
+public class LicenseKeyGroupCassandraDaoImpl extends CassandraBaseDao<LicenseKeyGroupEntity>
+ implements LicenseKeyGroupDao {
+ private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static Mapper<LicenseKeyGroupEntity> mapper =
+ noSqlDb.getMappingManager().mapper(LicenseKeyGroupEntity.class);
+ private static LicenseKeyGroupAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(LicenseKeyGroupAccessor.class);
+ private static UDTMapper<Version> versionMapper =
+ noSqlDb.getMappingManager().udtMapper(Version.class);
+
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ VersionableEntityMetadata metadata = new VersionableEntityMetadata(
+ mapper.getTableMetadata().getName(),
+ mapper.getTableMetadata().getPartitionKey().get(0).getName(),
+ mapper.getTableMetadata().getPartitionKey().get(1).getName());
+
+ metadata.setUniqueValuesMetadata(Collections.singletonList(
+ new UniqueValueMetadata(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
+ Arrays.asList(mapper.getTableMetadata().getPartitionKey().get(0).getName(),
+ mapper.getTableMetadata().getPartitionKey().get(1).getName(), "name"))));
+
+ VersioningManagerFactory.getInstance().createInterface()
+ .register(versionableEntityType, metadata);
+ }
+
+ @Override
+ protected Mapper<LicenseKeyGroupEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(LicenseKeyGroupEntity entity) {
+ return new Object[]{entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()),
+ entity.getId()};
+ }
+
+ @Override
+ public Collection<LicenseKeyGroupEntity> list(LicenseKeyGroupEntity entity) {
+ return accessor.listByVlmVersion(entity.getVendorLicenseModelId(),
+ versionMapper.toUDT(entity.getVersion())).all();
+ }
+
+ @Override
+ public void deleteAll(LicenseKeyGroupEntity entity) {
+ accessor.deleteByVlmVersion(entity.getVendorLicenseModelId(),
+ versionMapper.toUDT(entity.getVersion())).all();
+ }
+
+ @Override
+ public void addReferencingFeatureGroup(LicenseKeyGroupEntity entity, String featureGroupId) {
+ accessor.addReferencingFeatureGroups(CommonMethods.toSingleElementSet(featureGroupId),
+ entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()), entity.getId());
+ }
+
+ @Override
+ public void removeReferencingFeatureGroup(LicenseKeyGroupEntity entity, String featureGroupId) {
+ accessor.removeReferencingFeatureGroups(CommonMethods.toSingleElementSet(featureGroupId),
+ entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()), entity.getId());
+ }
+
+ @Accessor
+ interface LicenseKeyGroupAccessor {
+ @Query("select * from license_key_group where vlm_id=? and version=?")
+ Result<LicenseKeyGroupEntity> listByVlmVersion(String vendorLicenseModelId, UDTValue version);
+
+ @Query("delete from license_key_group where vlm_id=? and version=?")
+ 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=?")
+ ResultSet addReferencingFeatureGroups(Set<String> referencingFeatureGroups,
+ String vendorLicenseModelId, UDTValue version, String id);
+
+ @Query(
+ "UPDATE license_key_group SET ref_fg_ids = ref_fg_ids - ? WHERE vlm_id=? AND version=? "
+ + "AND lkg_id=?")
+ ResultSet removeReferencingFeatureGroups(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
new file mode 100644
index 0000000000..16d1fd2a3e
--- /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/LicenseKeyGroupDaoFactoryImpl.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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;
+
+import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory;
+
+public class LicenseKeyGroupDaoFactoryImpl extends LicenseKeyGroupDaoFactory {
+ private static LicenseKeyGroupDao INSTANCE = new LicenseKeyGroupCassandraDaoImpl();
+
+ @Override
+ public LicenseKeyGroupDao createInterface() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000000..4d08d98bd7
--- /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/VendorLicenseModelCassandraDaoImpl.java
@@ -0,0 +1,91 @@
+/*-
+ * ============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;
+
+import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.UDTMapper;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.dao.impl.CassandraBaseDao;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+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 java.util.Collection;
+
+public class VendorLicenseModelCassandraDaoImpl extends CassandraBaseDao<VendorLicenseModelEntity>
+ implements VendorLicenseModelDao {
+
+ private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static Mapper<VendorLicenseModelEntity> mapper =
+ noSqlDb.getMappingManager().mapper(VendorLicenseModelEntity.class);
+ private static VendorLicenseModelAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(VendorLicenseModelAccessor.class);
+ private static UDTMapper<Version> versionMapper =
+ noSqlDb.getMappingManager().udtMapper(Version.class);
+
+ @Override
+ public void registerVersioning(String versionableEntityType) {
+ VersioningManagerFactory.getInstance().createInterface()
+ .register(versionableEntityType, new VersionableEntityMetadata(
+ mapper.getTableMetadata().getName(),
+ mapper.getTableMetadata().getPartitionKey().get(0).getName(),
+ mapper.getTableMetadata().getPartitionKey().get(1).getName()));
+ }
+
+ @Override
+ protected Mapper<VendorLicenseModelEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(VendorLicenseModelEntity entity) {
+ return new Object[]{entity.getId(), versionMapper.toUDT(entity.getVersion())};
+ }
+
+ @Override
+ public Collection<VendorLicenseModelEntity> list(VendorLicenseModelEntity vendorLicenseModel) {
+ 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
new file mode 100644
index 0000000000..d218ca4907
--- /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/VendorLicenseModelDaoFactoryImpl.java
@@ -0,0 +1,34 @@
+/*-
+ * ============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;
+
+import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
+import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory;
+
+public class VendorLicenseModelDaoFactoryImpl extends VendorLicenseModelDaoFactory {
+
+ private static VendorLicenseModelDao INSTANCE = new VendorLicenseModelCassandraDaoImpl();
+
+ @Override
+ public VendorLicenseModelDao createInterface() {
+ return INSTANCE;
+ }
+}
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/VendorLicenseFacadeFactoryImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeFactoryImpl.java
new file mode 100644
index 0000000000..3cf6d0b806
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeFactoryImpl.java
@@ -0,0 +1,33 @@
+/*-
+ * ============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.facade.impl;
+
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
+
+public class VendorLicenseFacadeFactoryImpl extends VendorLicenseFacadeFactory {
+ private static VendorLicenseFacade INSTANCE = new VendorLicenseFacadeImpl();
+
+ @Override
+ public VendorLicenseFacade createInterface() {
+ return INSTANCE;
+ }
+}
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
new file mode 100644
index 0000000000..678a53583c
--- /dev/null
+++ 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
@@ -0,0 +1,478 @@
+/*-
+ * ============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.facade.impl;
+
+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.vendorlicense.VendorLicenseConstants;
+import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
+import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
+import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
+import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
+import org.openecomp.sdc.vendorlicense.errors.SubmitUncompletedLicenseModelErrorBuilder;
+import org.openecomp.sdc.vendorlicense.errors.VendorLicenseModelNotFoundErrorBuilder;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
+import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
+import org.openecomp.sdc.versioning.VersioningUtil;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.errors.RequestedVersionInvalidErrorBuilder;
+import org.openecomp.sdc.versioning.errors.VersionableSubEntityNotFoundErrorBuilder;
+import org.openecomp.sdc.versioning.types.VersionInfo;
+import org.openecomp.sdc.versioning.types.VersionableEntityAction;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+
+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 FeatureGroupDao featureGroupDao =
+ FeatureGroupDaoFactory.getInstance().createInterface();
+ private static final EntitlementPoolDao entitlementPoolDao =
+ EntitlementPoolDaoFactory.getInstance().createInterface();
+ private static final LicenseKeyGroupDao licenseKeyGroupDao =
+ LicenseKeyGroupDaoFactory.getInstance().createInterface();
+
+ /**
+ * 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);
+ }
+
+ @Override
+ public void checkin(String vendorLicenseModelId, String user) {
+ Version newVersion = versioningManager
+ .checkin(VendorLicenseConstants
+ .VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE,
+ vendorLicenseModelId, user, null);
+ updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
+ }
+
+ @Override
+ public void submit(String vendorLicenseModelId, String user) {
+ validateCompletedVendorLicenseModel(vendorLicenseModelId, user);
+ Version newVersion = versioningManager
+ .submit(VendorLicenseConstants
+ .VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE,
+ vendorLicenseModelId, user, null);
+ updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
+ }
+
+ @Override
+ public FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup, String user) {
+ Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
+ getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Read, user));
+ featureGroup.setVersion(version);
+ return getFeatureGroup(featureGroup);
+ }
+
+ private FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup) {
+ FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
+ VersioningUtil
+ .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ return retrieved;
+ }
+
+ @Override
+ public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user) {
+ FeatureGroupEntity retrieved = getFeatureGroup(featureGroup, user);
+
+ FeatureGroupModel featureGroupModel = new FeatureGroupModel();
+ featureGroupModel.setFeatureGroup(retrieved);
+
+ for (String licenseKeyGroupId : retrieved.getLicenseKeyGroupIds()) {
+ featureGroupModel.getLicenseKeyGroups().add(licenseKeyGroupDao.get(
+ new LicenseKeyGroupEntity(retrieved.getVendorLicenseModelId(), retrieved.getVersion(),
+ licenseKeyGroupId)));
+ }
+ for (String entitlementPoolId : retrieved.getEntitlementPoolIds()) {
+ featureGroupModel.getEntitlementPools().add(entitlementPoolDao.get(
+ new EntitlementPoolEntity(retrieved.getVendorLicenseModelId(), retrieved.getVersion(),
+ entitlementPoolId)));
+ }
+
+ return featureGroupModel;
+ }
+
+ @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 =
+ getLicenseAgreement(vlmId, version, licenseAgreementId, user);
+
+ LicenseAgreementModel licenseAgreementModel = new LicenseAgreementModel();
+ licenseAgreementModel.setLicenseAgreement(retrieved);
+
+ for (String featureGroupId : retrieved.getFeatureGroupIds()) {
+ licenseAgreementModel.getFeatureGroups().add(featureGroupDao
+ .get(new FeatureGroupEntity(vlmId, retrieved.getVersion(), featureGroupId)));
+ }
+
+ return licenseAgreementModel;
+ }
+
+ @Override
+ public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool,
+ String user) {
+ entitlementPool.setVersion(
+ getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
+ user).getActiveVersion());
+ entitlementPool.setId(CommonMethods.nextUuId());
+ entitlementPool.setVersionUuId(CommonMethods.nextUuId());
+ UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
+ entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion().toString(),
+ entitlementPool.getName());
+ entitlementPoolDao.create(entitlementPool);
+ updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion());
+ return entitlementPool;
+ }
+
+ @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(
+ getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
+ user).getActiveVersion());
+ EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
+ VersioningUtil
+ .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
+
+ UniqueValueUtil.updateUniqueValue(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
+ retrieved.getName(), entitlementPool.getName(), entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion().toString());
+ entitlementPool.setVersionUuId(CommonMethods.nextUuId());
+ entitlementPoolDao.update(entitlementPool);
+
+ updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(),
+ entitlementPool.getVersion());
+
+ }
+
+ @Override
+ public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
+ String user) {
+ return licenseKeyGroupDao.list(new LicenseKeyGroupEntity(vlmId, VersioningUtil
+ .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user)), 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));
+ }
+
+ @Override
+ public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
+ licenseKeyGroup.setVersion(
+ getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
+ user).getActiveVersion());
+ LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
+ licenseKeyGroup.setVersionUuId((CommonMethods.nextUuId()));
+ VersioningUtil
+ .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
+ UniqueValueUtil.updateUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
+ retrieved.getName(), licenseKeyGroup.getName(), licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion().toString());
+ licenseKeyGroupDao.update(licenseKeyGroup);
+
+ updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
+ licenseKeyGroup.getVersion());
+ }
+
+
+ @Override
+ public VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action,
+ String user) {
+ return versioningManager
+ .getEntityVersionInfo(VendorLicenseConstants
+ .VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE,
+ vendorLicenseModelId, user,
+ action);
+ }
+
+ @Override
+ public VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version,
+ String user) {
+ VersionInfo versionInfo = getVersionInfo(vlmId, VersionableEntityAction.Read, user);
+
+ VendorLicenseModelEntity vendorLicenseModel = vendorLicenseModelDao.get(
+ new VendorLicenseModelEntity(vlmId, VersioningUtil.resolveVersion(version, versionInfo)));
+ if (vendorLicenseModel == null) {
+ throw new CoreException(new VendorLicenseModelNotFoundErrorBuilder(vlmId).build());
+ }
+
+ 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);
+
+ // vendorLicenseModelEntity.setLastModificationTime(new Date());
+
+ vendorLicenseModelDao.create(vendorLicenseModelEntity);
+ UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME,
+ vendorLicenseModelEntity.getVendorName());
+
+ return vendorLicenseModelEntity;
+ }
+
+ @Override
+ public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
+ String user) {
+ Version activeVersion =
+ getVersionInfo(licenseAgreement.getVendorLicenseModelId(), VersionableEntityAction.Write,
+ user).getActiveVersion();
+ licenseAgreement.setVersion(activeVersion);
+ licenseAgreement.setId(CommonMethods.nextUuId());
+ VersioningUtil.validateEntitiesExistence(licenseAgreement.getFeatureGroupIds(),
+ new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), activeVersion, null),
+ featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
+ UniqueValueUtil.validateUniqueValue(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,
+ 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());
+
+ return licenseAgreement;
+ }
+
+ @Override
+ public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user) {
+ Version activeVersion =
+ getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write, user)
+ .getActiveVersion();
+ featureGroup.setId(CommonMethods.nextUuId());
+ featureGroup.setVersion(activeVersion);
+ VersioningUtil.validateEntitiesExistence(featureGroup.getLicenseKeyGroupIds(),
+ new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), activeVersion, null),
+ licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
+ VersioningUtil.validateEntitiesExistence(featureGroup.getEntitlementPoolIds(),
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), activeVersion, null),
+ entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
+ UniqueValueUtil.validateUniqueValue(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());
+ }
+ }
+
+ if (featureGroup.getEntitlementPoolIds() != null) {
+ for (String addedEpId : featureGroup.getEntitlementPoolIds()) {
+ entitlementPoolDao.addReferencingFeatureGroup(
+ new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), activeVersion,
+ 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,
+ Collection<String> featureGroupIds) {
+ try {
+ VersionInfo versionInfo = getVersionInfo(vlmId, VersionableEntityAction.Read, "");
+ if (version == null || !version.isFinal()
+ || !versionInfo.getViewableVersions().contains(version)) {
+ return Collections.singletonList(new RequestedVersionInvalidErrorBuilder().build());
+ }
+ } catch (CoreException coreException) {
+ return Collections.singletonList(coreException.code());
+ }
+
+ List<ErrorCode> errorMessages = new ArrayList<>();
+
+ try {
+ getLicenseAgreement(vlmId, licenseAgreementId, version);
+ } catch (CoreException coreException) {
+ errorMessages.add(coreException.code());
+ }
+
+ for (String featureGroupId : featureGroupIds) {
+ try {
+ FeatureGroupEntity featureGroup =
+ getFeatureGroup(new FeatureGroupEntity(vlmId, version, featureGroupId));
+ if (!featureGroup.getReferencingLicenseAgreements().contains(licenseAgreementId)) {
+ errorMessages.add(new VersionableSubEntityNotFoundErrorBuilder(
+ featureGroup.getEntityType(),
+ featureGroupId,
+ LicenseAgreementEntity.ENTITY_TYPE,
+ licenseAgreementId,
+ version).build());
+ }
+ } catch (CoreException coreException) {
+ errorMessages.add(coreException.code());
+ }
+ }
+
+ return errorMessages;
+ }
+
+ @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);
+ }
+
+ private void validateCompletedVendorLicenseModel(String vendorLicenseModelId, String user) {
+ Version activeVersion =
+ getVersionInfo(vendorLicenseModelId, VersionableEntityAction.Read, user).getActiveVersion();
+ Collection<LicenseAgreementEntity> licenseAgreements = licenseAgreementDao
+ .list(new LicenseAgreementEntity(vendorLicenseModelId, activeVersion, null));
+
+ if (licenseAgreements == null || licenseAgreements.isEmpty()) {
+ throw new CoreException(
+ new SubmitUncompletedLicenseModelErrorBuilder(vendorLicenseModelId).build());
+ }
+
+ for (LicenseAgreementEntity licenseAgreement : licenseAgreements) {
+ if (licenseAgreement.getFeatureGroupIds() == null
+ || licenseAgreement.getFeatureGroupIds().isEmpty()) {
+ throw new CoreException(
+ new SubmitUncompletedLicenseModelErrorBuilder(vendorLicenseModelId).build());
+ }
+ }
+
+ Collection<FeatureGroupEntity> featureGroupEntities = featureGroupDao
+ .list(new FeatureGroupEntity(vendorLicenseModelId, activeVersion, null));
+ for (FeatureGroupEntity featureGroupEntity : featureGroupEntities) {
+ if (featureGroupEntity.getEntitlementPoolIds() == null
+ || featureGroupEntity.getEntitlementPoolIds().isEmpty()) {
+ throw new CoreException(
+ new SubmitUncompletedLicenseModelErrorBuilder(vendorLicenseModelId).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
new file mode 100644
index 0000000000..8f8f34e471
--- /dev/null
+++ 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
@@ -0,0 +1,63 @@
+/*-
+ * ============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.healing.impl;
+
+import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
+import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory;
+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.versioning.dao.types.VersionableEntity;
+
+public class SimpleHealingServiceImpl implements HealingService {
+ private static final EntitlementPoolDao entitlementPoolDao =
+ EntitlementPoolDaoFactory.getInstance().createInterface();
+ private static final LicenseKeyGroupDao licenseKeyGroupDao =
+ LicenseKeyGroupDaoFactory.getInstance().createInterface();
+
+ @Override
+ public VersionableEntity heal(VersionableEntity toHeal, String user) {
+ return handleMissingVersionId(toHeal, user);
+ }
+
+ private VersionableEntity handleMissingVersionId(VersionableEntity toHeal, String user) {
+ if (toHeal.getVersionUuId() != null) {
+ return toHeal;
+ }
+
+
+ if (toHeal instanceof EntitlementPoolEntity) {
+ toHeal.setVersionUuId(toHeal.getId());
+ entitlementPoolDao.update((EntitlementPoolEntity) toHeal);
+ } else if (toHeal instanceof LicenseKeyGroupEntity) {
+ toHeal.setVersionUuId(toHeal.getId());
+ licenseKeyGroupDao.update((LicenseKeyGroupEntity) toHeal);
+ } else {
+ throw new UnsupportedOperationException(
+ "Unsupported operation for 1610 release/1607->1610 migration.");
+ //todo maybe errorbuilder?
+ }
+ 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
new file mode 100644
index 0000000000..2f11b75a98
--- /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/VendorLicenseArtifactsServiceImpl.java
@@ -0,0 +1,200 @@
+/*-
+ * ============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;
+
+import org.apache.commons.collections4.MultiValuedMap;
+import org.apache.commons.collections4.multimap.ArrayListValuedHashMap;
+import org.openecomp.core.utilities.file.FileContentHandler;
+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;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
+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.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;
+
+public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifactsService {
+
+ private static final VendorLicenseFacade vendorLicenseFacade = VendorLicenseFacadeFactory
+ .getInstance().createInterface();
+ private static final HealingService healingService = HealingServiceFactory
+ .getInstance().createInterface();
+
+ /**
+ * 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));
+
+ return artifacts;
+ }
+
+ static byte[] createVnfArtifact(
+ String vspId, String vlmId, Version vlmVersion,
+ String vendorName, List<String> featureGroups,
+ String user) {
+ VnfLicenseArtifact artifact = new VnfLicenseArtifact();
+
+ artifact.setVspId(vspId);
+ artifact.setVendorName(vendorName);
+ for (String featureGroupId : featureGroups) {
+ 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()));
+ artifact.getFeatureGroups().add(featureGroupModel);
+ }
+
+ return artifact.toXml().getBytes();
+ }
+
+
+ static byte[] createVendorLicenseArtifact(String vlmId, String vendorName, String user) {
+ VendorLicenseArtifact vendorLicenseArtifact = new VendorLicenseArtifact();
+ vendorLicenseArtifact.setVendorName(vendorName);
+ Set<EntitlementPoolEntity> entitlementPoolEntities = new HashSet<>();
+ Set<LicenseKeyGroupEntity> licenseKeyGroupEntities = new HashSet<>();
+
+ List<Version> finalVersions = getFinalVersionsForVlm(vlmId);
+ for (Version finalVersion : finalVersions) {
+ entitlementPoolEntities.addAll(
+ vendorLicenseFacade.listEntitlementPools(vlmId, finalVersion, user));
+ licenseKeyGroupEntities.addAll(
+ vendorLicenseFacade.listLicenseKeyGroups(vlmId, finalVersion, user));
+ }
+
+
+ entitlementPoolEntities = healEPs(user, filterChangedEntities(entitlementPoolEntities));
+ licenseKeyGroupEntities = healLkgs(user, 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;
+ }
+
+
+ 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;
+ }
+
+ 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;
+ }
+
+ private static List<Version> getFinalVersionsForVlm(String vlmId) {
+ VersionInfo versionInfo = vendorLicenseFacade
+ .getVersionInfo(vlmId, VersionableEntityAction.Read, "");
+ return versionInfo.getFinalVersions();
+
+ }
+
+
+ private static String getVendorName(String vendorLicenseModelId, String user) {
+ return 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/types/FeatureGroupForArtifact.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/FeatureGroupForArtifact.java
new file mode 100644
index 0000000000..6dddb9ac69
--- /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/types/FeatureGroupForArtifact.java
@@ -0,0 +1,60 @@
+/*-
+ * ============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.types;
+
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class FeatureGroupForArtifact {
+ Collection<EntitlementPoolEntity> entitlementPoolEntities = new ArrayList<>();
+ Collection<LicenseKeyGroupEntity> licenseKeyGroupEntities = new ArrayList<>();
+ private String name;
+ private String description;
+ private String partNumber;
+ private String id;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getPartNumber() {
+ return partNumber;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public Collection<EntitlementPoolEntity> getEntitlementPoolEntities() {
+ return entitlementPoolEntities;
+ }
+
+ public Collection<LicenseKeyGroupEntity> getLicenseKeyGroupEntities() {
+ return licenseKeyGroupEntities;
+ }
+}
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/VendorLicenseArtifact.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/VendorLicenseArtifact.java
new file mode 100644
index 0000000000..589b7fa668
--- /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/types/VendorLicenseArtifact.java
@@ -0,0 +1,80 @@
+/*-
+ * ============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.types;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinEntitlementPoolEntityForVendorLicenseArtifact;
+import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLicenseKeyGroupEntityForVendorLicenseArtifact;
+
+import java.util.Collection;
+
+@JacksonXmlRootElement(localName = "vendor-license-model",
+ namespace = "http://xmlns.openecomp.org/asdc/license-model/1.0")
+public class VendorLicenseArtifact extends XmlArtifact {
+ @JsonProperty(value = "vendor-name")
+ String vendorName;
+
+ Collection<EntitlementPoolEntity> entitlementPoolEntities;
+ Collection<LicenseKeyGroupEntity> licenseKeyGroupEntities;
+
+ public String getVendorName() {
+ return vendorName;
+ }
+
+ public void setVendorName(String vendorName) {
+ this.vendorName = vendorName;
+ }
+
+ @JacksonXmlProperty(isAttribute = false, localName = "entitlement-pool")
+ @JacksonXmlElementWrapper(localName = "entitlement-pool-list")
+ public Collection<EntitlementPoolEntity> getEntitlementPoolEntities() {
+ return entitlementPoolEntities;
+ }
+
+ public void setEntitlementPoolEntities(
+ Collection<EntitlementPoolEntity> entitlementPoolEntities) {
+ this.entitlementPoolEntities = entitlementPoolEntities;
+ }
+
+ @JacksonXmlProperty(isAttribute = false, localName = "license-key-group")
+ @JacksonXmlElementWrapper(localName = "license-key-group-list")
+ public Collection<LicenseKeyGroupEntity> getLicenseKeyGroupEntities() {
+ return licenseKeyGroupEntities;
+ }
+
+ public void setLicenseKeyGroupEntities(
+ Collection<LicenseKeyGroupEntity> licenseKeyGroupEntities) {
+ this.licenseKeyGroupEntities = licenseKeyGroupEntities;
+ }
+
+ @Override
+ void initMapper() {
+ xmlMapper.addMixIn(EntitlementPoolEntity.class,
+ MixinEntitlementPoolEntityForVendorLicenseArtifact.class);
+ xmlMapper.addMixIn(LicenseKeyGroupEntity.class,
+ MixinLicenseKeyGroupEntityForVendorLicenseArtifact.class);
+ }
+}
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
new file mode 100644
index 0000000000..1f8607765a
--- /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/types/VnfLicenseArtifact.java
@@ -0,0 +1,97 @@
+/*-
+ * ============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.types;
+
+import com.ctc.wstx.api.WstxInputProperties;
+import com.ctc.wstx.stax.WstxInputFactory;
+import com.ctc.wstx.stax.WstxOutputFactory;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.XmlFactory;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinEntitlementPoolEntityForVnfArtifact;
+import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinFeatureGroupModel;
+import org.openecomp.sdc.vendorlicense.licenseartifacts.impl.types.mixins.MixinLicenseKeyGroupEntityForVnfArtifact;
+
+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")
+public class VnfLicenseArtifact extends XmlArtifact {
+ @JsonProperty(value = "vendor-name")
+ String vendorName;
+ @JsonProperty(value = "vf-id")
+ String vspId;
+ List<FeatureGroupModel> featureGroups = new ArrayList<>();
+
+ public String getVspId() {
+ return vspId;
+ }
+
+ public void setVspId(String vspId) {
+ this.vspId = vspId;
+ }
+
+ public String getVendorName() {
+ return vendorName;
+ }
+
+ public void setVendorName(String vendorName) {
+ this.vendorName = vendorName;
+ }
+
+ @JacksonXmlProperty(isAttribute = false, localName = "feature-group")
+ @JacksonXmlElementWrapper(localName = "feature-group-list")
+ public List<FeatureGroupModel> getFeatureGroups() {
+ return featureGroups;
+ }
+
+ public void setFeatureGroups(List<FeatureGroupModel> featureGroups) {
+ this.featureGroups = featureGroups;
+ }
+
+ void initMapper() {
+ WstxOutputFactory wstxOutputFactory = new WstxOutputFactory() {
+ @Override
+ public XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException {
+ mConfig.setProperty(WstxInputProperties.P_RETURN_NULL_FOR_DEFAULT_NAMESPACE, true);
+ return super.createXMLStreamWriter(writer);
+ }
+ };
+ XmlFactory factory = new XmlFactory(new WstxInputFactory(), wstxOutputFactory);
+
+ xmlMapper = new XmlMapper(factory);
+
+
+ xmlMapper.addMixIn(EntitlementPoolEntity.class, MixinEntitlementPoolEntityForVnfArtifact.class);
+ xmlMapper.addMixIn(LicenseKeyGroupEntity.class, MixinLicenseKeyGroupEntityForVnfArtifact.class);
+ xmlMapper.addMixIn(FeatureGroupModel.class, MixinFeatureGroupModel.class);
+ }
+}
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
new file mode 100644
index 0000000000..78d5e22412
--- /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/types/XmlArtifact.java
@@ -0,0 +1,54 @@
+/*-
+ * ============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.types;
+
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
+import org.openecomp.sdc.vendorlicense.errors.JsonErrorBuilder;
+
+public abstract class XmlArtifact {
+
+ XmlMapper xmlMapper = new XmlMapper();
+
+ abstract void initMapper();
+
+ /**
+ * To xml string.
+ *
+ * @return the string
+ */
+ public String toXml() {
+ initMapper();
+ String xml = "";
+
+ try {
+ xml = xmlMapper.writeValueAsString(this);
+ } catch (com.fasterxml.jackson.core.JsonProcessingException jsonProcessingException) {
+ throw new CoreException(new JsonErrorBuilder(jsonProcessingException.getMessage()).build());
+
+ }
+
+ return xml.replaceAll(VendorLicenseConstants.VENDOR_LICENSE_MODEL_ARTIFACT_REGEX_REMOVE, "");
+ }
+
+
+}
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
new file mode 100644
index 0000000000..1458fa80a7
--- /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/types/mixins/MixinEntitlementPoolEntityForVendorLicenseArtifact.java
@@ -0,0 +1,100 @@
+/*-
+ * ============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.types.mixins;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+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.xml.AggregationFunctionForXml;
+import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementMetricForXml;
+import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementTimeForXml;
+import org.openecomp.sdc.vendorlicense.dao.types.xml.ThresholdForXml;
+
+import java.util.Set;
+
+public abstract class MixinEntitlementPoolEntityForVendorLicenseArtifact {
+ @JsonProperty(value = "threshold-value")
+ abstract ThresholdForXml getThresholdForArtifact();
+
+ @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
+ abstract String getId();
+
+ @JsonIgnore
+ abstract String getVersion();
+
+ @JsonIgnore
+ abstract String getVendorLicenseModelId();
+
+ @JsonIgnore
+ abstract String getThresholdUnit();
+
+ @JsonIgnore
+ abstract float getThresholdValue();
+
+ @JsonIgnore
+ abstract ChoiceOrOther<EntitlementMetric> getEntitlementMetric();
+
+ @JsonIgnore
+ abstract ChoiceOrOther<EntitlementTime> getTime();
+
+ @JsonIgnore
+ abstract ChoiceOrOther<AggregationFunction> getAggregationFunction();
+
+ @JsonIgnore
+ abstract String getEntityType();
+
+ @JacksonXmlProperty(isAttribute = false, localName = "value")
+ @JacksonXmlElementWrapper(localName = "operational-scope")
+ abstract String getOperationalScopeForArtifact();
+
+ @JsonIgnore
+ abstract ChoiceOrOther<OperationalScope> getOperationalScope();
+
+
+ @JsonProperty(value = "entitlement-metric")
+ abstract EntitlementMetricForXml getEntitlementMetricForArtifact();
+
+ @JsonProperty(value = "time")
+ abstract EntitlementTimeForXml getTimeForArtifact();
+
+
+ @JsonProperty(value = "aggregation-function")
+ abstract AggregationFunctionForXml getAggregationFunctionForArtifact();
+
+}
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
new file mode 100644
index 0000000000..c4f2b4d4bd
--- /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/types/mixins/MixinEntitlementPoolEntityForVnfArtifact.java
@@ -0,0 +1,100 @@
+/*-
+ * ============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.types.mixins;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+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.xml.AggregationFunctionForXml;
+import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementMetricForXml;
+import org.openecomp.sdc.vendorlicense.dao.types.xml.EntitlementTimeForXml;
+import org.openecomp.sdc.vendorlicense.dao.types.xml.ThresholdForXml;
+
+import java.util.Set;
+
+public abstract class MixinEntitlementPoolEntityForVnfArtifact {
+ @JsonProperty(value = "threshold-value")
+ abstract ThresholdForXml getThresholdForArtifact();
+
+ @JsonIgnore
+ abstract String getId();
+
+ @JsonProperty(value = "manufacturer-reference-number")
+ abstract String getManufacturerReferenceNumber();
+
+ @JsonIgnore
+ abstract Set<String> getReferencingFeatureGroups();
+
+ @JsonIgnore
+ abstract String getFirstClassCitizenId();
+
+ @JsonProperty(value = "entitlement-pool-uuid")
+ abstract String getVersionUuId();
+
+ @JsonIgnore
+ abstract String getVersion();
+
+ @JsonIgnore
+ abstract String getVendorLicenseModelId();
+
+ @JsonIgnore
+ abstract String getThresholdUnit();
+
+ @JsonIgnore
+ abstract float getThresholdValue();
+
+ @JsonIgnore
+ abstract ChoiceOrOther<EntitlementMetric> getEntitlementMetric();
+
+ @JsonIgnore
+ abstract ChoiceOrOther<EntitlementTime> getTime();
+
+ @JsonIgnore
+ abstract ChoiceOrOther<AggregationFunction> getAggregationFunction();
+
+ @JsonIgnore
+ abstract String getEntityType();
+
+ @JacksonXmlProperty(isAttribute = false, localName = "value")
+ @JacksonXmlElementWrapper(localName = "operational-scope")
+ abstract String getOperationalScopeForArtifact();
+
+ @JsonIgnore
+ abstract ChoiceOrOther<OperationalScope> getOperationalScope();
+
+
+ @JsonProperty(value = "entitlement-metric")
+ abstract EntitlementMetricForXml getEntitlementMetricForArtifact();
+
+ @JsonProperty(value = "time")
+ abstract EntitlementTimeForXml getTimeForArtifact();
+
+
+ @JsonProperty(value = "aggregation-function")
+ abstract AggregationFunctionForXml getAggregationFunctionForArtifact();
+
+}
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/MixinFeatureGroupEntity.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/MixinFeatureGroupEntity.java
new file mode 100644
index 0000000000..be6bd61357
--- /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/types/mixins/MixinFeatureGroupEntity.java
@@ -0,0 +1,62 @@
+/*-
+ * ============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.types.mixins;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Set;
+
+public abstract class MixinFeatureGroupEntity {
+
+ @JsonIgnore
+ abstract String getVendorLicenseModelId();
+
+ @JsonIgnore
+ abstract String getEntityType();
+
+
+ @JsonIgnore
+ abstract Version getVersion();
+
+ @JsonIgnore
+ abstract String getId();
+
+ @JsonIgnore
+ abstract String getName();
+
+ @JsonIgnore
+ abstract String getDescription();
+
+ @JsonIgnore
+ abstract String getPartNumber();
+
+ @JsonIgnore
+ abstract Set<String> getLicenseKeyGroupIds();
+
+ @JsonIgnore
+ abstract Set<String> getEntitlementPoolIds();
+
+
+ @JsonIgnore
+ abstract Set<String> getReferencingLicenseAgreements();
+
+}
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
new file mode 100644
index 0000000000..1e76a74f4c
--- /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/types/mixins/MixinFeatureGroupModel.java
@@ -0,0 +1,61 @@
+/*-
+ * ============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.types.mixins;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+
+import java.util.Set;
+
+public abstract class MixinFeatureGroupModel {
+ @JacksonXmlProperty(isAttribute = false, localName = "entitlement-pool")
+ @JacksonXmlElementWrapper(localName = "entitlement-pool-list")
+ abstract Set<EntitlementPoolEntity> getEntitlementPools();
+
+ @JacksonXmlProperty(isAttribute = false, localName = "license-key-group")
+ @JacksonXmlElementWrapper(localName = "license-key-group-list")
+ abstract Set<LicenseKeyGroupEntity> getLicenseKeyGroups();
+
+ @JacksonXmlProperty(isAttribute = false, localName = "internal-part-number")
+ abstract String getEntityPartNumber();
+
+ @JacksonXmlProperty(isAttribute = false, localName = "feature-group-uuid")
+ abstract String getEntityId();
+
+ @JacksonXmlProperty(isAttribute = false, localName = "description")
+ abstract String getEntityDesc();
+
+ @JacksonXmlProperty(isAttribute = false, localName = "name")
+ abstract String getEntityName();
+
+
+ @JsonIgnore
+ abstract FeatureGroupEntity getFeatureGroup();
+
+ @JsonIgnore
+ abstract String getEntityType();
+
+
+}
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
new file mode 100644
index 0000000000..ed3083afe3
--- /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/types/mixins/MixinLicenseKeyGroupEntityForVendorLicenseArtifact.java
@@ -0,0 +1,72 @@
+/*-
+ * ============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.types.mixins;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
+import org.openecomp.sdc.vendorlicense.dao.types.xml.LicenseKeyTypeForXml;
+
+import java.util.Set;
+
+public abstract class MixinLicenseKeyGroupEntityForVendorLicenseArtifact {
+ @JsonProperty(value = "license-key-group-uuid")
+ abstract String getVersionUuId();
+
+ @JsonIgnore
+ abstract Set<String> getReferencingFeatureGroups();
+
+ @JsonIgnore
+ abstract String getVersion();
+
+ @JsonIgnore
+ abstract String getVendorLicenseModelId();
+
+
+ @JsonIgnore
+ abstract String getEntityType();
+
+ @JsonIgnore
+ abstract String getFirstClassCitizenId();
+
+ @JsonIgnore
+ abstract String getId();
+
+
+ @JsonIgnore
+ abstract ChoiceOrOther<OperationalScope> getOperationalScope();
+
+ @JacksonXmlProperty(isAttribute = false, localName = "value")
+ @JacksonXmlElementWrapper(localName = "operational-scope")
+ abstract String getOperationalScopeForArtifact();
+
+
+ @JsonIgnore
+ abstract LicenseKeyTypeForXml getTypeForArtifact();
+
+ @JsonIgnore
+ abstract String getVersionableId();
+
+
+}
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
new file mode 100644
index 0000000000..6281c44830
--- /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/types/mixins/MixinLicenseKeyGroupEntityForVnfArtifact.java
@@ -0,0 +1,74 @@
+/*-
+ * ============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.types.mixins;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther;
+import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope;
+import org.openecomp.sdc.vendorlicense.dao.types.xml.LicenseKeyTypeForXml;
+
+import java.util.Set;
+
+public abstract class MixinLicenseKeyGroupEntityForVnfArtifact {
+ @JsonIgnore
+ abstract String getId();
+
+ @JsonIgnore
+ abstract Set<String> getReferencingFeatureGroups();
+
+ @JsonIgnore
+ abstract String getVersion();
+
+ @JsonIgnore
+ abstract String getVendorLicenseModelId();
+
+
+ @JsonIgnore
+ abstract String getEntityType();
+
+ @JsonProperty(value = "license-key-group-uuid")
+ abstract String getVersionUuId();
+
+ @JsonIgnore
+ abstract String getFirstClassCitizenId();
+
+
+
+ @JsonIgnore
+ abstract ChoiceOrOther<OperationalScope> getOperationalScope();
+
+ @JacksonXmlProperty(isAttribute = false, localName = "value")
+ @JacksonXmlElementWrapper(localName = "operational-scope")
+ abstract String getOperationalScopeForArtifact();
+
+
+ @JsonIgnore
+ abstract LicenseKeyTypeForXml getTypeForArtifact();
+
+ @JsonIgnore
+ abstract String getVersionableId();
+
+
+}
+