aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-license-lib
diff options
context:
space:
mode:
authortalig <talig@amdocs.com>2018-06-11 12:28:33 +0300
committertalig <talig@amdocs.com>2018-06-11 12:28:43 +0300
commit4dc878ccce1219a78cd64c3bdaee78421c68d11d (patch)
treef03b35d0c3ed9ed87c38de66f2ed4ed459044ba9 /openecomp-be/lib/openecomp-sdc-vendor-license-lib
parent907753f90f876574efdc4c4153ef7516e0bcf8b3 (diff)
Upgrade datastax cassandra driver to 3.4.0
Upgrage zusammen to 1.0.0 which uses datastax cassandra driver 3.4.0 Change-Id: Ie7217986b67cd95de015daedd0f7106c2d0a972d Issue-ID: SDC-1416 Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-license-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java2
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/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/FeatureGroupCassandraDaoImpl.java202
-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.java156
-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/VendorLicenseModelCassandraDaoImpl.java77
7 files changed, 0 insertions, 717 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java
index d76b434f29..660f46ee0a 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/EntitlementPoolEntity.java
@@ -22,7 +22,6 @@ package org.openecomp.sdc.vendorlicense.dao.types;
import com.datastax.driver.mapping.annotations.ClusteringColumn;
import com.datastax.driver.mapping.annotations.Column;
-import com.datastax.driver.mapping.annotations.Enumerated;
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
@@ -62,7 +61,6 @@ public class EntitlementPoolEntity implements VersionableEntity {
private Integer thresholdValue;
@Column(name = "threshold_unit")
- @Enumerated
private ThresholdUnit thresholdUnit;
private String increments;
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java
index 3f51a2eeca..06c691293c 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-api/src/main/java/org/openecomp/sdc/vendorlicense/dao/types/LicenseKeyGroupEntity.java
@@ -22,7 +22,6 @@ package org.openecomp.sdc.vendorlicense.dao.types;
import com.datastax.driver.mapping.annotations.ClusteringColumn;
import com.datastax.driver.mapping.annotations.Column;
-import com.datastax.driver.mapping.annotations.Enumerated;
import com.datastax.driver.mapping.annotations.Frozen;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
@@ -56,7 +55,6 @@ public class LicenseKeyGroupEntity implements VersionableEntity {
private String id;
private String name;
private String description;
- @Enumerated
private LicenseKeyType type;
@Column(name = "operational_scope")
@Frozen
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
deleted file mode 100644
index ac43ed19fe..0000000000
--- 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
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright © 2016-2018 European Support Limited
- *
- * 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.
- */
-
-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 java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-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.ActionVersioningManagerFactory;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.UniqueValueMetadata;
-import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
-
-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"))));
-
- ActionVersioningManagerFactory.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 String getManufacturerReferenceNumber(EntitlementPoolEntity entitlementPoolEntity) {
- return null;
- }
-
- @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/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
deleted file mode 100644
index 3c804f3bfe..0000000000
--- 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
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Copyright © 2016-2018 European Support Limited
- *
- * 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.
- */
-
-package org.openecomp.sdc.vendorlicense.dao.impl;
-
-import static org.openecomp.core.utilities.CommonMethods.toSingleElementSet;
-
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.UDTValue;
-import com.datastax.driver.mapping.Mapper;
-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 java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-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.ActionVersioningManagerFactory;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.UniqueValueMetadata;
-import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
-
-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"))));
-
- ActionVersioningManagerFactory.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 deleteAll(FeatureGroupEntity entity) {
- accessor.deleteByVlmVersion(entity.getVendorLicenseModelId(),
- versionMapper.toUDT(entity.getVersion())).all();
- }
-
- @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 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(toSingleElementSet(entitlementPoolId),
- entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()), entity.getId());
- }
-
- @Override
- public void removeLicenseKeyGroup(FeatureGroupEntity entity, String licenseKeyGroupId) {
- accessor.removeLicenseKeyGroup(toSingleElementSet(licenseKeyGroupId),
- entity.getVendorLicenseModelId(), versionMapper.toUDT(entity.getVersion()), entity.getId());
- }
-
- @Override
- public Collection<FeatureGroupEntity> list(FeatureGroupEntity entity) {
- return accessor.listByVlmVersion(entity.getVendorLicenseModelId(),
- versionMapper.toUDT(entity.getVersion())).all();
- }
-
- @Accessor
- interface FeatureGroupAccessor {
-
- @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/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
deleted file mode 100644
index 0ba9ca3899..0000000000
--- 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
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright © 2016-2018 European Support Limited
- *
- * 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.
- */
-
-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 java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-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.ActionVersioningManagerFactory;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.UniqueValueMetadata;
-import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
-
-
-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"))));
-
- ActionVersioningManagerFactory.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/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
deleted file mode 100644
index fdd5716472..0000000000
--- 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
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright © 2016-2018 European Support Limited
- *
- * 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.
- */
-
-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 java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-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.ActionVersioningManagerFactory;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.UniqueValueMetadata;
-import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
-
-
-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"))));
-
- ActionVersioningManagerFactory.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 long count(LicenseKeyGroupEntity licenseKeyGroup) {
- return 0;
- }
-
- @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/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
deleted file mode 100644
index 9574dac3d5..0000000000
--- 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
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright © 2016-2018 European Support Limited
- *
- * 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.
- */
-
-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 java.util.Collection;
-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.ActionVersioningManagerFactory;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionableEntityMetadata;
-
-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) {
- ActionVersioningManagerFactory.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();
- }
-
- @Accessor
- interface VendorLicenseModelAccessor {
-
- @Query("SELECT * FROM vendor_license_model")
- Result<VendorLicenseModelEntity> getAll();
-
- }
-}