diff options
Diffstat (limited to 'openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store')
13 files changed, 237 insertions, 332 deletions
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementCassandraLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementCassandraLoader.java index d7f2ba63d6..faf2528a50 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementCassandraLoader.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementCassandraLoader.java @@ -1,75 +1,61 @@ /* -* 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. -*/ - - + * 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.core.tools.store; import com.datastax.driver.mapping.Result; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; import com.datastax.driver.mapping.annotations.QueryParameters; +import java.nio.ByteBuffer; +import java.util.Set; import org.openecomp.core.nosqldb.api.NoSqlDb; import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.core.tools.store.zusammen.datatypes.ElementEntity; -import java.nio.ByteBuffer; -import java.util.Set; - public class ElementCassandraLoader { private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); private static ElementAccessor accessor = noSqlDb.getMappingManager().createAccessor(ElementAccessor.class); public void createEntity(ElementEntity elementEntity) { - accessor.insertElement(elementEntity.getSpace(), - elementEntity.getItemId(), - elementEntity.getVersionId(), - elementEntity.getElementId(), - elementEntity.getData(), - elementEntity.getInfo(), - elementEntity.getNamespace(), - elementEntity.getParentId(), - elementEntity.getRelations(), - elementEntity.getSearchableData(), - elementEntity.getSubElementIds()); + accessor.insertElement(elementEntity.getSpace(), elementEntity.getItemId(), elementEntity.getVersionId(), elementEntity.getElementId(), + elementEntity.getData(), elementEntity.getInfo(), elementEntity.getNamespace(), elementEntity.getParentId(), elementEntity.getRelations(), + elementEntity.getSearchableData(), elementEntity.getSubElementIds()); } public Result<ElementEntity> list() { return accessor.getAll(); } - public Result<ElementEntity> getByPK(String space, String itemId, String versionId, String elementId, - String revisionId) { + + public Result<ElementEntity> getByPK(String space, String itemId, String versionId, String elementId, String revisionId) { return accessor.getByPK(space, itemId, versionId, elementId, revisionId); } + @Accessor interface ElementAccessor { - @Query("insert into zusammen_dox.element (space,item_id,version_id,element_id,data,info," + - "namespace,parent_id,relations,searchable_data,sub_element_ids) values (?,?,?,?,?,?,?,?,?,?,?)") - void insertElement(String space, String itemId, String versionId, String elementId, ByteBuffer data, - String info, String namespaceStr, String parentId, String relations, ByteBuffer searchable, - Set<String> subElementsIds); - + @Query("insert into zusammen_dox.element (space,item_id,version_id,element_id,data,info, namespace,parent_id,relations,searchable_data,sub_element_ids) values (?,?,?,?,?,?,?,?,?,?,?)") + void insertElement(String space, String itemId, String versionId, String elementId, ByteBuffer data, String info, String namespaceStr, + String parentId, String relations, ByteBuffer searchable, Set<String> subElementsIds); @Query("select * from zusammen_dox.element ") @QueryParameters(fetchSize = 100) Result<ElementEntity> getAll(); - @Query("select * from zusammen_dox.element where space = ? and item_id = ? and version_id = ? and " + - "element_id = ? and revision_id = ?") - Result<ElementEntity> getByPK(String space, String itemId, String versionId, String elementId, - String revisionId); + + @Query("select * from zusammen_dox.element where space = ? and item_id = ? and version_id = ? and element_id = ? and revision_id = ?") + Result<ElementEntity> getByPK(String space, String itemId, String versionId, String elementId, String revisionId); } } diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementNamespaceHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementNamespaceHandler.java index c8ceaabf82..fe19ecfe03 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementNamespaceHandler.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementNamespaceHandler.java @@ -7,9 +7,9 @@ * 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. @@ -17,10 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.core.tools.store; - import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Param; import com.datastax.driver.mapping.annotations.Query; @@ -30,18 +28,17 @@ import org.openecomp.core.tools.store.zusammen.datatypes.ElementEntity; public class ElementNamespaceHandler { - private static NoSqlDb nnoSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static ElementNamespaceAccessor accessor = nnoSqlDb.getMappingManager().createAccessor(ElementNamespaceAccessor.class); + private static NoSqlDb nnoSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static ElementNamespaceAccessor accessor = nnoSqlDb.getMappingManager().createAccessor(ElementNamespaceAccessor.class); public void createElementNamespace(ElementEntity elementEntity) { - accessor.create(elementEntity.getSpace(),elementEntity.getItemId(),elementEntity.getElementId(),elementEntity.getNamespace()); + accessor.create(elementEntity.getSpace(), elementEntity.getItemId(), elementEntity.getElementId(), elementEntity.getNamespace()); } @Accessor interface ElementNamespaceAccessor { + @Query("UPDATE zusammen_dox.element_namespace SET namespace=:ns WHERE space=:space AND item_id=:item AND element_id=:id ") void create(@Param("space") String space, @Param("item") String item, @Param("id") String id, @Param("ns") String ns); } - - } diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/HealingHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/HealingHandler.java index e5c541216c..2d0a5b5d5a 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/HealingHandler.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/HealingHandler.java @@ -7,9 +7,9 @@ * 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. @@ -17,58 +17,49 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.core.tools.store; import com.datastax.driver.core.ResultSet; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; +import java.util.List; import org.openecomp.core.nosqldb.api.NoSqlDb; import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.core.tools.store.zusammen.datatypes.HealingEntity; -import java.util.List; - /** * Created by ayalaben on 10/15/2017 */ public class HealingHandler { - private static NoSqlDb nnoSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static HealingAccessor accessor = - nnoSqlDb.getMappingManager().createAccessor(HealingAccessor.class); - - - public void populateHealingTable(List<HealingEntity> healingEntities) { - healingEntities.forEach(healingEntity -> { - if (isHealingRecordExist(healingEntity)) { - accessor.updateFlag(healingEntity.isHealingFlag(), healingEntity.getSpace(), - healingEntity.getItemId(), healingEntity.getVersionId()); - } else { - accessor.create(healingEntity.getSpace(), healingEntity.getItemId(), - healingEntity.getVersionId(), healingEntity.isHealingFlag(), - healingEntity.getOldVersion()); - } - }); - } + private static NoSqlDb nnoSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static HealingAccessor accessor = nnoSqlDb.getMappingManager().createAccessor(HealingAccessor.class); - private boolean isHealingRecordExist(HealingEntity healingEntity) { - return accessor.getFlag(healingEntity.getSpace(), healingEntity.getItemId(), - healingEntity.getVersionId()).getAvailableWithoutFetching() == 1; - } + public void populateHealingTable(List<HealingEntity> healingEntities) { + healingEntities.forEach(healingEntity -> { + if (isHealingRecordExist(healingEntity)) { + accessor.updateFlag(healingEntity.isHealingFlag(), healingEntity.getSpace(), healingEntity.getItemId(), healingEntity.getVersionId()); + } else { + accessor.create(healingEntity.getSpace(), healingEntity.getItemId(), healingEntity.getVersionId(), healingEntity.isHealingFlag(), + healingEntity.getOldVersion()); + } + }); + } - @Accessor - interface HealingAccessor { + private boolean isHealingRecordExist(HealingEntity healingEntity) { + return accessor.getFlag(healingEntity.getSpace(), healingEntity.getItemId(), healingEntity.getVersionId()).getAvailableWithoutFetching() == 1; + } - @Query("SELECT healing_needed FROM healing WHERE space=? AND item_id=? AND version_id=?") - ResultSet getFlag(String space, String itemId, String versionId); + @Accessor + interface HealingAccessor { - @Query("Insert into healing (space, item_id, version_id, healing_needed, old_version) " + - "values (?,?,?,?,?)") - void create(String space, String itemId, String versionId, boolean flag, String oldVersion); + @Query("SELECT healing_needed FROM healing WHERE space=? AND item_id=? AND version_id=?") + ResultSet getFlag(String space, String itemId, String versionId); - @Query("UPDATE healing SET healing_needed=? WHERE space=? AND item_id=? AND version_id=?") - void updateFlag(boolean flag, String space, String itemId, String versionId); - } + @Query("Insert into healing (space, item_id, version_id, healing_needed, old_version) " + "values (?,?,?,?,?)") + void create(String space, String itemId, String versionId, boolean flag, String oldVersion); + @Query("UPDATE healing SET healing_needed=? WHERE space=? AND item_id=? AND version_id=?") + void updateFlag(boolean flag, String space, String itemId, String versionId); + } } diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ItemHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ItemHandler.java index 8260d0c09b..67d0ba717f 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ItemHandler.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ItemHandler.java @@ -7,9 +7,9 @@ * 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. @@ -17,36 +17,32 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.core.tools.store; import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Row; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; - import java.util.Collections; import java.util.List; import java.util.stream.Collectors; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; public class ItemHandler { - public List<String> getItemList() { - ResultSet resultSet = NoSqlDbFactory.getInstance().createInterface() - .getMappingManager().createAccessor(ItemAccessor.class).list(); - List<Row> rows = resultSet.all(); - - if (rows != null) { - return rows.stream().map(row -> row.getString("item_id")).collect(Collectors.toList()); + public List<String> getItemList() { + ResultSet resultSet = NoSqlDbFactory.getInstance().createInterface().getMappingManager().createAccessor(ItemAccessor.class).list(); + List<Row> rows = resultSet.all(); + if (rows != null) { + return rows.stream().map(row -> row.getString("item_id")).collect(Collectors.toList()); + } + return Collections.emptyList(); } - return Collections.emptyList(); - } - @Accessor - interface ItemAccessor { - @Query("SELECT item_id FROM zusammen_dox.item") - ResultSet list(); - } + @Accessor + interface ItemAccessor { + @Query("SELECT item_id FROM zusammen_dox.item") + ResultSet list(); + } } diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/NotificationHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/NotificationHandler.java index 6b3bcb6a3a..9dd111cd73 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/NotificationHandler.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/NotificationHandler.java @@ -7,9 +7,9 @@ * 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. @@ -17,32 +17,27 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.core.tools.store; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; - import java.util.HashSet; import java.util.Set; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; public class NotificationHandler { - public void registerNotificationForUserOnEntity(String user, String entityId) { - - Set<String> userSet = new HashSet<>(); - userSet.add(user); - NoSqlDbFactory.getInstance().createInterface().getMappingManager() - .createAccessor(NotificationAccessor.class) - .updateNotificationSubscription(userSet, entityId); - } + public void registerNotificationForUserOnEntity(String user, String entityId) { + Set<String> userSet = new HashSet<>(); + userSet.add(user); + NoSqlDbFactory.getInstance().createInterface().getMappingManager().createAccessor(NotificationAccessor.class) + .updateNotificationSubscription(userSet, entityId); + } - @Accessor - interface NotificationAccessor { + @Accessor + interface NotificationAccessor { - @Query("UPDATE dox.notification_subscribers SET subscribers = subscribers + ? where " + - "entity_id = ?") - void updateNotificationSubscription(Set<String> users, String entityId); - } + @Query("UPDATE dox.notification_subscribers SET subscribers = subscribers + ? where " + "entity_id = ?") + void updateNotificationSubscription(Set<String> users, String entityId); + } } diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/PermissionHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/PermissionHandler.java index 1a339e80f3..d3e31b12e0 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/PermissionHandler.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/PermissionHandler.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.core.tools.store; import com.datastax.driver.core.ResultSet; @@ -25,62 +24,54 @@ import com.datastax.driver.core.Row; import com.datastax.driver.mapping.Result; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; -import org.openecomp.core.nosqldb.api.NoSqlDb; -import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; -import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity; - import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.Set; +import org.openecomp.core.nosqldb.api.NoSqlDb; +import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; +import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity; public class PermissionHandler { - private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static PermissionAccessor accessor = - noSqlDb.getMappingManager().createAccessor(PermissionAccessor.class); - - - public Optional<String> getItemUserPermission(String itemId, String user) { - ResultSet resultSet = accessor.getItemUserPermission(itemId, user); - Row row = resultSet.one(); - - if (Objects.nonNull(row)) { - return Optional.of(row.getString("permission")); - } else { - return Optional.empty(); + private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); + private static PermissionAccessor accessor = noSqlDb.getMappingManager().createAccessor(PermissionAccessor.class); + + public Optional<String> getItemUserPermission(String itemId, String user) { + ResultSet resultSet = accessor.getItemUserPermission(itemId, user); + Row row = resultSet.one(); + if (Objects.nonNull(row)) { + return Optional.of(row.getString("permission")); + } else { + return Optional.empty(); + } } - } - - public void setItemUserPermission(String itemId, String user, String permission) { - accessor.setItemUserPermission(itemId, user, permission); - } - - public void addItem(Set<String> items, String userId, String permission){ - accessor.addItem(items,userId,permission); - } - - public List<ItemPermissionsEntity> getAll(){ - return accessor.getAll().all(); - } - - @Accessor - interface PermissionAccessor { + public void setItemUserPermission(String itemId, String user, String permission) { + accessor.setItemUserPermission(itemId, user, permission); + } + public void addItem(Set<String> items, String userId, String permission) { + accessor.addItem(items, userId, permission); + } - @Query("INSERT into dox.item_permissions (item_id,user_id,permission) VALUES (?,?,?)") - void setItemUserPermission(String permission, String itemId, String userId); + public List<ItemPermissionsEntity> getAll() { + return accessor.getAll().all(); + } + @Accessor + interface PermissionAccessor { - @Query("SELECT permission FROM dox.item_permissions WHERE item_id=? AND user_id=?") - ResultSet getItemUserPermission(String itemId, String userId); + @Query("INSERT into dox.item_permissions (item_id,user_id,permission) VALUES (?,?,?)") + void setItemUserPermission(String permission, String itemId, String userId); - @Query("SELECT * from dox.item_permissions") - Result<ItemPermissionsEntity> getAll(); + @Query("SELECT permission FROM dox.item_permissions WHERE item_id=? AND user_id=?") + ResultSet getItemUserPermission(String itemId, String userId); - @Query("update dox.user_permission_items set item_list=item_list+? WHERE user_id = ? AND permission = ?") - void addItem(Set<String> items, String userId, String permission); - } + @Query("SELECT * from dox.item_permissions") + Result<ItemPermissionsEntity> getAll(); + @Query("update dox.user_permission_items set item_list=item_list+? WHERE user_id = ? AND permission = ?") + void addItem(Set<String> items, String userId, String permission); + } } diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionCassandraLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionCassandraLoader.java index 38bb21ccf1..10d3099cfa 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionCassandraLoader.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionCassandraLoader.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.core.tools.store; import com.datastax.driver.core.ResultSet; @@ -27,14 +26,13 @@ import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; import com.datastax.driver.mapping.annotations.QueryParameters; import com.google.common.collect.Sets; +import java.util.Date; +import java.util.Set; import org.openecomp.core.nosqldb.api.NoSqlDb; import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.core.tools.store.zusammen.datatypes.ElementEntity; import org.openecomp.core.tools.store.zusammen.datatypes.VersionEntity; -import java.util.Date; -import java.util.Set; - public class VersionCassandraLoader { private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); @@ -42,37 +40,32 @@ public class VersionCassandraLoader { private static VersionAccessor accessor = noSqlDb.getMappingManager().createAccessor(VersionAccessor.class); public void insertElementToVersion(ElementEntity elementEntity) { - accessor.addElements(Sets.newHashSet(elementEntity.getElementId()), elementEntity.getSpace(), elementEntity.getItemId(), elementEntity.getVersionId()); + accessor.addElements(Sets.newHashSet(elementEntity.getElementId()), elementEntity.getSpace(), elementEntity.getItemId(), + elementEntity.getVersionId()); } public void insertVersion(VersionEntity versionEntity) { - accessor.insertVersion( versionEntity.getSpace(), - versionEntity.getItemId(), - versionEntity.getVersionId(), - versionEntity.getBaseVersionId(), - versionEntity.getCreationTime(), - versionEntity.getInfo(), - versionEntity.getModificationTime(), - versionEntity.getRelations()); + accessor.insertVersion(versionEntity.getSpace(), versionEntity.getItemId(), versionEntity.getVersionId(), versionEntity.getBaseVersionId(), + versionEntity.getCreationTime(), versionEntity.getInfo(), versionEntity.getModificationTime(), versionEntity.getRelations()); } - public Result<VersionEntity> list() { return accessor.getAll(); } - public ResultSet listItemVersion() { return accessor.getAllItemVersion();} + public ResultSet listItemVersion() { + return accessor.getAllItemVersion(); + } @Accessor interface VersionAccessor { - @Query("UPDATE zusammen_dox.version_elements SET element_ids=element_ids+? " + - "WHERE space=? AND item_id=? AND version_id=?") + @Query("UPDATE zusammen_dox.version_elements SET element_ids=element_ids+? " + "WHERE space=? AND item_id=? AND version_id=?") void addElements(Set<String> elementIds, String space, String itemId, String versionId); @Query("insert into zusammen_dox.version (space,item_id,version_id,base_version_id,creation_time,info,modification_time,relations) values (?,?,?,?,?,?,?,?)") - void insertVersion(String space, String itemId, String versionId, String baseVersionId, Date createTime, String info, Date modificationTime, String relations); - + void insertVersion(String space, String itemId, String versionId, String baseVersionId, Date createTime, String info, Date modificationTime, + String relations); @Query("select * from zusammen_dox.version ") @QueryParameters(fetchSize = 400) diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionElementsCassandraLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionElementsCassandraLoader.java index 5c02af408f..17b6730258 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionElementsCassandraLoader.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionElementsCassandraLoader.java @@ -1,19 +1,18 @@ /* -* 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. -*/ - + * 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.core.tools.store; import com.datastax.driver.mapping.Result; @@ -25,9 +24,9 @@ import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.core.tools.store.zusammen.datatypes.VersionElementsEntity; public class VersionElementsCassandraLoader { + private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static VersionElementsAccessor accessor = noSqlDb.getMappingManager(). - createAccessor(VersionElementsAccessor.class); + private static VersionElementsAccessor accessor = noSqlDb.getMappingManager().createAccessor(VersionElementsAccessor.class); public Result<VersionElementsEntity> listVersionElementsByPK(String space, String itemId, String versionId) { return accessor.getByPK(space, itemId, versionId); @@ -36,9 +35,7 @@ public class VersionElementsCassandraLoader { @Accessor interface VersionElementsAccessor { - @Query("SELECT space, item_id, version_id, revision_id, element_ids " + - "FROM zusammen_dox.version_elements WHERE space=? and item_id=? and version_id=?") - + @Query("SELECT space, item_id, version_id, revision_id, element_ids FROM zusammen_dox.version_elements WHERE space=? and item_id=? and version_id=?") @QueryParameters(fetchSize = 400) Result<VersionElementsEntity> getByPK(String space, String itemId, String versionId); } diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionInfoCassandraLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionInfoCassandraLoader.java index 1d66aa32bf..7a2dd79869 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionInfoCassandraLoader.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VersionInfoCassandraLoader.java @@ -7,9 +7,9 @@ * 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. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.core.tools.store; import com.datastax.driver.mapping.Mapper; @@ -25,23 +24,19 @@ import com.datastax.driver.mapping.Result; import com.datastax.driver.mapping.annotations.Accessor; import com.datastax.driver.mapping.annotations.Query; import com.datastax.driver.mapping.annotations.QueryParameters; +import java.util.Collection; import org.openecomp.core.nosqldb.api.NoSqlDb; import org.openecomp.core.nosqldb.factory.NoSqlDbFactory; import org.openecomp.sdc.versioning.dao.VersionInfoDao; import org.openecomp.sdc.versioning.dao.VersionInfoDaoFactory; import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity; -import java.util.Collection; - public class VersionInfoCassandraLoader { private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface(); - private static Mapper<VersionInfoEntity> mapper = - noSqlDb.getMappingManager().mapper(VersionInfoEntity.class); - private static VersionInfoAccessor accessor = - noSqlDb.getMappingManager().createAccessor(VersionInfoAccessor.class); - private static VersionInfoDao versionInfoDao = - VersionInfoDaoFactory.getInstance().createInterface(); + private static Mapper<VersionInfoEntity> mapper = noSqlDb.getMappingManager().mapper(VersionInfoEntity.class); + private static VersionInfoAccessor accessor = noSqlDb.getMappingManager().createAccessor(VersionInfoAccessor.class); + private static VersionInfoDao versionInfoDao = VersionInfoDaoFactory.getInstance().createInterface(); public void insertVersionInfo(VersionInfoEntity versionInfoEntity) { versionInfoDao.create(versionInfoEntity); @@ -53,10 +48,9 @@ public class VersionInfoCassandraLoader { @Accessor interface VersionInfoAccessor { + @Query("select * from dox.version_info ") @QueryParameters(fetchSize = 400) Result<VersionInfoEntity> getAll(); } - - } diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/ElementEntity.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/ElementEntity.java index d1fd93dd71..d88f36b8dd 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/ElementEntity.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/ElementEntity.java @@ -1,25 +1,23 @@ /* -* 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. -*/ - + * 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.core.tools.store.zusammen.datatypes; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; - import java.nio.ByteBuffer; import java.util.Set; @@ -40,49 +38,35 @@ import java.util.Set; * PRIMARY KEY ((space, item_id, version_id, element_id)) * ) */ -@Table( - keyspace = "zusammen_dox", - name = "element" -) +@Table(keyspace = "zusammen_dox", name = "element") public class ElementEntity { - @Column( name = "space" ) + + @Column(name = "space") @PartitionKey(0) private String space; - - @Column( name = "item_id" ) + @Column(name = "item_id") @PartitionKey(1) private String itemId; - - @Column( name = "version_id" ) + @Column(name = "version_id") @PartitionKey(2) private String versionId; - @Column(name = "element_id") @PartitionKey(3) private String elementId; - @Column(name = "data") private ByteBuffer data; - @Column(name = "info") private String info; - @Column(name = "namespace") private String namespace; - @Column(name = "parent_id") private String parentId; - @Column(name = "relations") private String relations; - @Column(name = "searchable_data") private ByteBuffer searchableData; - @Column(name = "sub_element_ids") private Set<String> subElementIds; - - @Column(name = "visualization") private ByteBuffer visualization; diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/HealingEntity.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/HealingEntity.java index 155c8e2215..bde7855c9c 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/HealingEntity.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/HealingEntity.java @@ -33,21 +33,17 @@ import lombok.Setter; @Table(keyspace = "dox", name = "healing") public class HealingEntity { - @Column(name = "space") - @PartitionKey(0) - private String space; - - @Column(name = "item_id") - @PartitionKey(1) - private String itemId; - - @Column(name = "version_id") - @PartitionKey(2) - private String versionId; - - @Column(name = "healing_needed") - private boolean healingFlag; - - @Column(name = "old_version") - private String oldVersion; + @Column(name = "space") + @PartitionKey(0) + private String space; + @Column(name = "item_id") + @PartitionKey(1) + private String itemId; + @Column(name = "version_id") + @PartitionKey(2) + private String versionId; + @Column(name = "healing_needed") + private boolean healingFlag; + @Column(name = "old_version") + private String oldVersion; } diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/VersionElementsEntity.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/VersionElementsEntity.java index 936d7198c8..41649d2b48 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/VersionElementsEntity.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/VersionElementsEntity.java @@ -1,26 +1,24 @@ /* -* 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. -*/ - + * 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.core.tools.store.zusammen.datatypes; import com.datastax.driver.mapping.annotations.ClusteringColumn; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; - import java.util.Map; /** @@ -39,63 +37,61 @@ import java.util.Map; * PRIMARY KEY ((space, item_id, version_id), revision_id)) * WITH CLUSTERING ORDER BY (revision_id ASC) */ - -@Table( - keyspace = "zusammen_dox", - name = "version_elements" -) +@Table(keyspace = "zusammen_dox", name = "version_elements") public class VersionElementsEntity { - @Column( name = "space" ) + + @Column(name = "space") @PartitionKey(0) private String space; - - @Column( name = "item_id" ) + @Column(name = "item_id") @PartitionKey(1) private String itemId; - - @Column( name = "version_id" ) + @Column(name = "version_id") @PartitionKey(2) private String versionId; - @Column(name = "revision_id") @ClusteringColumn private String revisionId; - @Column(name = "element_ids") - private Map<String,String> elementIds; + private Map<String, String> elementIds; - public void setSpace(String space) { - this.space = space; - } public String getSpace() { return space; } - public void setItemId(String itemId) { - this.itemId = itemId; + public void setSpace(String space) { + this.space = space; } + public String getItemId() { return itemId; } - public void setVersionId(String versionId) { - this.versionId = versionId; + public void setItemId(String itemId) { + this.itemId = itemId; } + public String getVersionId() { return versionId; } - public void setRevisionId(String revisionId) { - this.revisionId = revisionId; + public void setVersionId(String versionId) { + this.versionId = versionId; } + public String getRevisionId() { return revisionId; } - public void setElementIds(Map<String,String> elementIds) { - this.elementIds = elementIds; + public void setRevisionId(String revisionId) { + this.revisionId = revisionId; } - public Map<String,String> getElementIds() { + + public Map<String, String> getElementIds() { return elementIds; } + + public void setElementIds(Map<String, String> elementIds) { + this.elementIds = elementIds; + } } diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/VersionEntity.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/VersionEntity.java index e9f7d51038..652565d35b 100644 --- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/VersionEntity.java +++ b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/zusammen/datatypes/VersionEntity.java @@ -7,9 +7,9 @@ * 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. @@ -17,13 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.core.tools.store.zusammen.datatypes; import com.datastax.driver.mapping.annotations.Column; import com.datastax.driver.mapping.annotations.PartitionKey; import com.datastax.driver.mapping.annotations.Table; - import java.util.Date; /** @@ -52,35 +50,26 @@ import java.util.Date; * AND read_repair_chance = 0.0 * AND speculative_retry = '99.0PERCENTILE'; */ -@Table( - keyspace = "zusammen_dox", - name = "version" -) +@Table(keyspace = "zusammen_dox", name = "version") public class VersionEntity { + @Column(name = "space") @PartitionKey(0) private String space; - @Column(name = "item_id") @PartitionKey(1) private String itemId; - @Column(name = "version_id") @PartitionKey(2) private String versionId; - @Column(name = "base_version_id") private String baseVersionId; - @Column(name = "creation_time") private Date creationTime; - @Column(name = "info") private String info; - @Column(name = "modification_time") private Date modificationTime; - @Column(name = "relations") private String relations; |