diff options
author | 2018-06-11 12:28:33 +0300 | |
---|---|---|
committer | 2018-06-11 12:28:43 +0300 | |
commit | 4dc878ccce1219a78cd64c3bdaee78421c68d11d (patch) | |
tree | f03b35d0c3ed9ed87c38de66f2ed4ed459044ba9 /openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp | |
parent | 907753f90f876574efdc4c4153ef7516e0bcf8b3 (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-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp')
6 files changed, 10 insertions, 643 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDaoCassandraImpl.java deleted file mode 100644 index da852a62b4..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDaoCassandraImpl.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.vendorsoftwareproduct.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 org.openecomp.core.dao.impl.CassandraBaseDao; -import org.openecomp.core.nosqldb.api.NoSqlDb; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; -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 ComponentDaoCassandraImpl extends CassandraBaseDao<ComponentEntity> - implements ComponentDao { - - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper<ComponentEntity> mapper = - noSqlDb.getMappingManager().mapper(ComponentEntity.class); - private static final ComponentAccessor accessor = - noSqlDb.getMappingManager().createAccessor(ComponentAccessor.class); - private static final 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( - VendorSoftwareProductConstants.UniqueValues.COMPONENT_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<ComponentEntity> getMapper() { - return mapper; - } - - @Override - protected Object[] getKeys(ComponentEntity entity) { - return new Object[]{entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getId()}; - } - - @Override - public void update(ComponentEntity entity) { - accessor.updateCompositionData(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getId(), entity.getCompositionData()); - } - - @Override - public Collection<ComponentEntity> list(ComponentEntity entity) { - return accessor.list(entity.getVspId(), versionMapper.toUDT(entity.getVersion())).all(); - } - - @Override - public ComponentEntity getQuestionnaireData(String vspId, Version version, String componentId) { - return accessor.getQuestionnaireData(vspId, versionMapper.toUDT(version), componentId); - } - - @Override - public void updateQuestionnaireData(String vspId, Version version, String componentId, - String questionnaireData) { - accessor.updateQuestionnaireData(questionnaireData, vspId, versionMapper.toUDT(version), - componentId); - } - - @Override - public Collection<ComponentEntity> listQuestionnaires(String vspId, Version version) { - return accessor.listQuestionnaires(vspId, versionMapper.toUDT(version)).all(); - } - - @Override - public Collection<ComponentEntity> listCompositionAndQuestionnaire(String vspId, - Version version) { - return accessor.listCompositionAndQuestionnaire(vspId, versionMapper.toUDT(version)).all(); - } - - @Override - public void deleteAll(String vspId, Version version) { - accessor.deleteAll(vspId, version); - } - - @Accessor - interface ComponentAccessor { - - @Query( - "select vsp_id, version, component_id, composition_data from vsp_component" - + " where vsp_id=? and version=?") - Result<ComponentEntity> list(String vspId, UDTValue version); - - @Query( - "select vsp_id, version, component_id, composition_data, questionnaire_data from vsp_component" - + " where vsp_id=? and version=?") - Result<ComponentEntity> listCompositionAndQuestionnaire(String vspId, UDTValue version); - - @Query( - "select vsp_id, version, component_id, questionnaire_data from vsp_component" - + " where vsp_id=? and version=?") - Result<ComponentEntity> listQuestionnaires(String vspId, UDTValue version); - - @Query( - "select vsp_id, version, component_id, questionnaire_data from vsp_component" - + " where vsp_id=? and version=? and component_id=?") - ComponentEntity getQuestionnaireData(String vspId, UDTValue version, String id); - - @Query( - "insert into vsp_component (vsp_id, version, component_id, composition_data)" - + " values (?,?,?,?)") - ResultSet updateCompositionData(String vspId, UDTValue version, String id, - String compositionData); - - @Query( - "update vsp_component set questionnaire_data=? where vsp_id=? and version=?" - + " and component_id=?") - ResultSet updateQuestionnaireData(String questionnaireData, String vspId, UDTValue version, - String id); - - @Query("delete from vsp_component where vsp_id=? and version=?") - ResultSet deleteAll(String vspId, Version version); - } -} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java deleted file mode 100644 index 11524ed05f..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComponentDependencyModelDaoCassandraImpl.java +++ /dev/null @@ -1,94 +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.vendorsoftwareproduct.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 org.openecomp.core.dao.impl.CassandraBaseDao; -import org.openecomp.core.nosqldb.api.NoSqlDb; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; -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 ComponentDependencyModelDaoCassandraImpl extends - CassandraBaseDao<ComponentDependencyModelEntity> implements ComponentDependencyModelDao { - - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper<ComponentDependencyModelEntity> mapper = - noSqlDb.getMappingManager().mapper(ComponentDependencyModelEntity.class); - private static final ComponentDependencyModelDaoCassandraImpl.ComponentDependencyModelAccessor - accessor = noSqlDb.getMappingManager().createAccessor( - ComponentDependencyModelDaoCassandraImpl.ComponentDependencyModelAccessor.class); - private static final UDTMapper<Version> versionMapper = - noSqlDb.getMappingManager().udtMapper(Version.class); - - @Override - protected Mapper<ComponentDependencyModelEntity> getMapper() { - return mapper; - } - - @Override - protected Object[] getKeys(ComponentDependencyModelEntity entity) { - return new Object[]{entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getId()}; - } - - @Override - public Collection<ComponentDependencyModelEntity> list(ComponentDependencyModelEntity entity) { - return accessor - .list(entity.getVspId(), versionMapper.toUDT(entity.getVersion())).all(); - } - - @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( - VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, - Arrays.asList("vsp_id", "version", "component_id", "name")))); - - ActionVersioningManagerFactory.getInstance().createInterface() - .register(versionableEntityType, metadata); - - } - - @Accessor - interface ComponentDependencyModelAccessor { - @Query("delete from vsp_component_dependency_model where vsp_id=? and version=?") - ResultSet deleteAll(String vspId, UDTValue version); - - @Query( - "select * from vsp_component_dependency_model where vsp_id=? and version=?") - Result<ComponentDependencyModelEntity> list(String vspId, UDTValue version); - } -} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComputeDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComputeDaoCassandraImpl.java deleted file mode 100644 index 4e85ff61c3..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ComputeDaoCassandraImpl.java +++ /dev/null @@ -1,135 +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.vendorsoftwareproduct.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 org.openecomp.core.dao.impl.CassandraBaseDao; -import org.openecomp.core.nosqldb.api.NoSqlDb; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; -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 ComputeDaoCassandraImpl extends CassandraBaseDao<ComputeEntity> implements - ComputeDao { - - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper<ComputeEntity> mapper = - noSqlDb.getMappingManager().mapper(ComputeEntity.class); - private static final ComputeAccessor accessor = - noSqlDb.getMappingManager().createAccessor(ComputeDaoCassandraImpl.ComputeAccessor.class); - private static final 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( - VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, - Arrays.asList("vsp_id", "version", "component_id", "name")))); - - ActionVersioningManagerFactory.getInstance().createInterface() - .register(versionableEntityType, metadata); - } - - @Override - public Collection<ComputeEntity> list(ComputeEntity entity) { - return accessor.listByComponentId(entity.getVspId(), - versionMapper.toUDT(entity.getVersion()), entity.getComponentId()).all(); - } - - @Override - protected Mapper<ComputeEntity> getMapper() { - return mapper; - } - - @Override - protected Object[] getKeys(ComputeEntity entity) { - return new Object[]{entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId(), entity.getId()}; - } - - @Override - public Collection<ComputeEntity> listByVsp(String vspId, Version version) { - return accessor.listByVspId(vspId, versionMapper.toUDT(version)).all(); - } - - @Override - public void update(ComputeEntity entity) { - accessor.updateCompositionData(entity.getCompositionData(), entity.getVspId(), versionMapper - .toUDT(entity.getVersion()), entity.getComponentId(), entity.getId()); - } - - @Override - public void updateQuestionnaireData(String vspId, Version version, String componentId, - String computeId, String questionnaireData) { - accessor.updateQuestionnaireData(questionnaireData, vspId, versionMapper.toUDT(version), - componentId, computeId); - } - - @Override - public void deleteAll(String vspId, Version version) { - accessor.deleteAll(vspId, version); - } - - @Override - public ComputeEntity getQuestionnaireData(String vspId, Version version, String componentId, - String computeId) { - return null; - } - - @Accessor - interface ComputeAccessor { - - @Query("select * from vsp_component_compute where vsp_id=? and version=? and component_id=?") - Result<ComputeEntity> listByComponentId(String vspId, UDTValue version, String componentId); - - @Query("select * from vsp_component_compute where vsp_id=? and version=?") - Result<ComputeEntity> listByVspId(String vspId, UDTValue version); - - @Query("update vsp_component_compute set composition_data=? where vsp_id=? and version=?" - + " and component_id=? and compute_id=?") - ResultSet updateCompositionData(String compositionData, String vspId, UDTValue version, - String componentId, String computeId); - - @Query("update vsp_component_compute set questionnaire_data=? where vsp_id=? and version=?" - + " and component_id=? and compute_id=?") - ResultSet updateQuestionnaireData(String questionnaireData, String vspId, UDTValue version, - String componentId, String computeId); - - @Query("delete from vsp_component_compute where vsp_id=? and version=?") - ResultSet deleteAll(String vspId, Version version); - } -} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/DeploymentFlavorDaoCassandraImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/DeploymentFlavorDaoCassandraImpl.java deleted file mode 100644 index 2a19082005..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/DeploymentFlavorDaoCassandraImpl.java +++ /dev/null @@ -1,111 +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.vendorsoftwareproduct.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 org.openecomp.core.dao.impl.CassandraBaseDao; -import org.openecomp.core.nosqldb.api.NoSqlDb; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; -import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; -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 DeploymentFlavorDaoCassandraImpl extends CassandraBaseDao<DeploymentFlavorEntity> - implements DeploymentFlavorDao { - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper<DeploymentFlavorEntity> mapper = - noSqlDb.getMappingManager().mapper(DeploymentFlavorEntity.class); - private static final DeploymentFlavorAccessor accessor = - noSqlDb.getMappingManager().createAccessor(DeploymentFlavorAccessor.class); - private static final UDTMapper<Version> versionMapper = - noSqlDb.getMappingManager().udtMapper(Version.class); - - @Override - protected Mapper<DeploymentFlavorEntity> getMapper() { - return mapper; - } - - @Override - protected Object[] getKeys(DeploymentFlavorEntity entity) { - return new Object[]{entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getId()}; - } - - @Override - public Collection<DeploymentFlavorEntity> list(DeploymentFlavorEntity entity) { - return accessor.list(entity.getVspId(), versionMapper.toUDT(entity.getVersion())).all(); - } - - @Override - public void update(DeploymentFlavorEntity entity) { - accessor.updateCompositionData(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getId(), entity.getCompositionData()); - } - - @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( - VendorSoftwareProductConstants.UniqueValues.DEPLOYMENT_FLAVOR_NAME, - Arrays.asList(mapper.getTableMetadata().getPartitionKey().get(0).getName(), - mapper.getTableMetadata().getPartitionKey().get(1).getName(), "name")))); - - ActionVersioningManagerFactory.getInstance().createInterface() - .register(versionableEntityType, metadata); - } - - @Override - public void deleteAll(String vspId, Version version) { - accessor.deleteAll(vspId, version); - } - - @Accessor - interface DeploymentFlavorAccessor { - @Query( - "select vsp_id, version, deployment_flavor_id, composition_data from vsp_deployment_flavor where vsp_id=?" - + " and version=?") - Result<DeploymentFlavorEntity> list(String vspId, UDTValue version); - - @Query( - "insert into vsp_deployment_flavor (vsp_id, version, deployment_flavor_id, composition_data) values (?,?,?,?)") - ResultSet updateCompositionData(String vspId, UDTValue version, String id, - String compositionData); - - @Query("delete from vsp_deployment_flavor where vsp_id=? and version=?") - ResultSet deleteAll(String vspId, Version version); - - } -} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ImageDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ImageDaoImpl.java deleted file mode 100644 index 441f8fbbf9..0000000000 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/ImageDaoImpl.java +++ /dev/null @@ -1,144 +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.vendorsoftwareproduct.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 org.openecomp.core.dao.impl.CassandraBaseDao; -import org.openecomp.core.nosqldb.api.NoSqlDb; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; -import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; -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 ImageDaoImpl extends CassandraBaseDao<ImageEntity> implements ImageDao { - - private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static final Mapper<ImageEntity> mapper = - noSqlDb.getMappingManager().mapper(ImageEntity.class); - private static final ImageAccessor accessor = - noSqlDb.getMappingManager().createAccessor(ImageAccessor.class); - private static final 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( - VendorSoftwareProductConstants.UniqueValues.IMAGE_NAME, - Arrays.asList("vsp_id", "version", "component_id", "name")))); - - ActionVersioningManagerFactory.getInstance().createInterface() - .register(versionableEntityType, metadata); - } - - @Override - protected Mapper<ImageEntity> getMapper() { - return mapper; - } - - @Override - protected Object[] getKeys(ImageEntity entity) { - return new Object[]{entity.getVspId(), - versionMapper.toUDT(entity.getVersion()), entity.getComponentId(), entity.getId() }; - } - - @Override - public Collection<ImageEntity> list(ImageEntity entity) { - return accessor.list(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId()).all(); - } - - @Override - public void update(ImageEntity entity) { - accessor.updateCompositionData(entity.getVspId(), versionMapper.toUDT(entity.getVersion()), - entity.getComponentId(), entity.getId(), entity.getCompositionData()); - } - - @Override - public void updateQuestionnaireData(String vspId, Version version, String componentId, - String imageId, String questionnaireData) { - accessor.updateQuestionnaireData(questionnaireData, vspId, versionMapper.toUDT(version), - componentId, imageId); - } - - @Override - public void delete(ImageEntity entity) { - super.delete(entity); - } - - @Override - public void deleteByVspId(String vspId, Version version) { - accessor.deleteByVspId(vspId, versionMapper.toUDT(version)); - } - - @Override - public Collection<ImageEntity> listByVsp(String vspId, Version version) { - return accessor.listByVspId(vspId, versionMapper.toUDT(version)).all(); - } - - @Override - public ImageEntity getQuestionnaireData(String vspId, Version version, String componentId, - String computeId) { - return null; - } - - @Accessor - interface ImageAccessor { - - @Query("select vsp_id, version, component_id, image_id, composition_data from " - + "vsp_component_image where vsp_id=? and version=? and component_id=?") - Result<ImageEntity> list(String vspId, UDTValue version, String componentId); - - @Query( - "insert into vsp_component_image (vsp_id, version, component_id, image_id, " - + "composition_data) values (?,?,?,?,?)") - ResultSet updateCompositionData(String vspId, UDTValue version, String componentId, String id, - String compositionData); - - @Query("update vsp_component_image set questionnaire_data=? where vsp_id=? and version=?" - + " and component_id=? and image_id=?") - ResultSet updateQuestionnaireData(String questionnaireData, String vspId, UDTValue version, - String componentId, String computeId); - - @Query("delete from vsp_component_image where vsp_id=? and version=?") - ResultSet deleteByVspId(String vspId, UDTValue version); - - @Query("select * from vsp_component_image where vsp_id=? and version=?") - Result<ImageEntity> listByVspId(String vspId, UDTValue version); - - } - -} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java index 3516263fbc..786a2c4ba8 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/VspMergeDaoImpl.java @@ -8,6 +8,8 @@ import com.amdocs.zusammen.datatypes.item.ElementContext; import com.amdocs.zusammen.datatypes.item.Resolution; import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Row; +import com.datastax.driver.extras.codecs.enums.EnumNameCodec; +import com.datastax.driver.mapping.MappingManager; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; @@ -27,9 +29,14 @@ public class VspMergeDaoImpl implements VspMergeDao { private static final String VSP_MODEL_NOT_EXIST = "Vsp model does not exist for Vsp %s, version %s."; - private static VspMergeHintAccessor accessor = - NoSqlDbFactory.getInstance().createInterface() - .getMappingManager().createAccessor(VspMergeHintAccessor.class); + private static final VspMergeHintAccessor accessor; + + static { + MappingManager mappingManager = NoSqlDbFactory.getInstance().createInterface().getMappingManager(); + mappingManager.getSession().getCluster().getConfiguration().getCodecRegistry() + .register(new EnumNameCodec<>(Resolution.class)); + accessor = mappingManager.createAccessor(VspMergeHintAccessor.class); + } private ZusammenAdaptor zusammenAdaptor; |