aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/tools/zusammen-tools/src/main
diff options
context:
space:
mode:
authorshalomb <shalomb@amdocs.com>2018-01-02 13:48:40 +0200
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2018-01-02 14:00:34 +0000
commitb38f18bb99a603012ec406053531c45fb4643d62 (patch)
treecbf8d7faacc50103737c84c76fdb3ee8ce1de7f3 /openecomp-be/tools/zusammen-tools/src/main
parentbadc6daeca01c3c6dda5d2d5d1d7bacec2c24f48 (diff)
Remove Zusammen cassandra plugin
Remove Zusammen cassandra plugin Change dependency Modify imports Change-Id: Ice66fdd9f3970961723df476c8d1e38040504189 Issue-ID: SDC-862 Signed-off-by: shalomb <shalomb@amdocs.com>
Diffstat (limited to 'openecomp-be/tools/zusammen-tools/src/main')
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java171
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/CassandraElementRepository.java272
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java26
-rw-r--r--openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java149
4 files changed, 0 insertions, 618 deletions
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java
deleted file mode 100644
index eb9a9ee408..0000000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/Commands/ResetOldVersion.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright © 2016-2017 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.Commands;
-
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.impl.VersionCassandraDao;
-import com.google.common.collect.Sets;
-import org.apache.commons.lang3.StringUtils;
-import org.openecomp.core.tools.store.ElementHandler;
-import org.openecomp.core.tools.store.VersionInfoCassandraLoader;
-import org.openecomp.core.tools.store.VspGeneralLoader;
-import org.openecomp.core.zusammen.impl.CassandraConnectionInitializer;
-import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionInfoEntity;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-
-import static org.openecomp.core.tools.store.VspGeneralLoader.buildKey;
-
-public class ResetOldVersion {
-
-
- private static final String OLD_VERSION = "oldVersion";
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ResetOldVersion.class);
- private static final String CASSANDRA_DOX_KEYSTORE = "cassandra.dox.keystore";
- private static int count = 0;
-
- private ResetOldVersion() {
- }
-
- public static void reset(SessionContext context, String oldVersion, String emptyOldVersion) {
- Map<String, List<String>> itemVersionMap = new HashMap<>();
- Map<String, List<String>> itemChangeRefMap = new HashMap<>();
-
- CassandraConnectionInitializer.setCassandraConnectionPropertiesToSystem();
-
- loadItemVersionInfo(context, itemChangeRefMap, itemVersionMap);
-
- Map<String, ElementEntity> generalElementMap =
- VspGeneralLoader.load(context, itemVersionMap, itemChangeRefMap);
-
- generalElementMap.values().forEach(elementEntity -> updateOldVersionFlag(elementEntity,
- oldVersion, Boolean.TRUE.toString().equals(emptyOldVersion)));
-
-
- itemVersionMap.entrySet().forEach(entry -> updateElements(context, generalElementMap, entry));
-
- itemChangeRefMap.entrySet().forEach(entry -> updateElements(context, generalElementMap, entry));
- LOGGER.info("number of element updated:" + count);
- }
-
- private static void updateElements(SessionContext context, Map<String,
- ElementEntity> generalElementMap, Map.Entry<String, List<String>> entry) {
-
- entry.getValue().stream()
- .filter(changeRef -> generalElementMap.containsKey(buildKey(context, entry, changeRef)))
- .forEach(changeref -> ElementHandler.update(context, entry.getKey(), changeref, changeref,
- generalElementMap.get(buildKey(context, entry, changeref))));
-
- }
-
- private static void updateOldVersionFlag(ElementEntity elementEntity, String oldVersion,
- boolean emptyOldVersion) {
-
- if (!emptyOldVersion
- || StringUtils.isBlank(elementEntity.getInfo().getProperty(OLD_VERSION))) {
- elementEntity.getInfo().addProperty(OLD_VERSION, oldVersion);
- count++;
- }
- }
-
- private static void loadItemVersionInfo(SessionContext context,
- Map<String, List<String>> itemChangeRefMap,
- Map<String, List<String>> itemVersionMap) {
-
- List<String> items = new ArrayList<>();
- System.setProperty(CASSANDRA_DOX_KEYSTORE, "dox");
- VersionInfoCassandraLoader versionInfoCassandraLoader = new VersionInfoCassandraLoader();
- Collection<VersionInfoEntity> versions = versionInfoCassandraLoader.list();
-
- versions.stream().filter(versionInfoEntity -> versionInfoEntity.getEntityType()
- .equals(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE))
- .forEach(versionInfoEntity -> handleVersionInfoEntity(items, versionInfoEntity,
- itemChangeRefMap));
-
- System.setProperty(CASSANDRA_DOX_KEYSTORE, "zusammen_dox");
- VersionCassandraDao versionCassandraDao = new VersionCassandraDao();
-
- items.forEach(itemId -> versionCassandraDao.list(context, context.getUser().getUserName(),
- new Id(itemId)).forEach(itemVersion -> addItemVersion(itemId, itemVersion.getId(),
- itemVersionMap)));
-
- }
-
- private static void handleVersionInfoEntity(List<String> items,
- VersionInfoEntity versionInfoEntity,
- Map<String, List<String>> itemChangeRefMap) {
- items.add(versionInfoEntity.getEntityId());
- Set<Version> viewableVersions;
- if (versionInfoEntity.getViewableVersions() != null
- && !versionInfoEntity.getViewableVersions().isEmpty()) {
- viewableVersions = versionInfoEntity.getViewableVersions();
- } else {
- viewableVersions = Sets.newHashSet(versionInfoEntity.getActiveVersion());
- }
- addItemChangeRef(versionInfoEntity.getEntityId(), maxChangeRef(viewableVersions),
- itemChangeRefMap);
- }
-
- private static Id maxChangeRef(Set<Version> viewableVersions) {
- Optional<Version> maxVersion = viewableVersions.stream()
- .max(ResetOldVersion::evaluateMaxVersion);
-
- return maxVersion.map(version -> new Id(version.toString())).orElse(null);
- }
-
- private static int evaluateMaxVersion(Version version1, Version version2) {
- if (version1.getMajor() > version2.getMajor()) {
- return 1;
- } else if (version1.getMajor() == version2.getMajor()) {
- return Integer.compare(version1.getMinor(), version2.getMinor());
- } else {
- return -1;
- }
- }
-
- private static void addItemChangeRef(String itemId, Id changeRef,
- Map<String, List<String>> itemChangeRefMap) {
- addItemVersion(itemChangeRefMap, itemId, changeRef);
- }
-
- private static void addItemVersion(String itemId, Id versionId,
- Map<String, List<String>> itemVersionMap) {
- addItemVersion(itemVersionMap, itemId, versionId);
- }
-
- private static void addItemVersion(Map<String, List<String>> itemVersions, String itemId, Id id) {
-
- if (!itemVersions.containsKey(itemId)) {
- itemVersions.put(itemId, new ArrayList<>());
- }
-
- itemVersions.get(itemId).add(id.getValue());
- }
-} \ No newline at end of file
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/CassandraElementRepository.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/CassandraElementRepository.java
deleted file mode 100644
index fcc67e11d0..0000000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/CassandraElementRepository.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright © 2016-2017 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.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.Namespace;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.datatypes.item.Relation;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import com.amdocs.zusammen.utils.fileutils.json.JsonUtil;
-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.Param;
-import com.datastax.driver.mapping.annotations.Query;
-import com.google.gson.reflect.TypeToken;
-import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
-import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
-
-import java.lang.reflect.Type;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-public class CassandraElementRepository {
-
-
- public Collection<ElementEntity> list(SessionContext context,
- ElementEntityContext elementContext) {
- Set<String> elementIds = getVersionElementIds(context, elementContext);
-
- return elementIds.stream()
- .map(elementId -> get(context, elementContext, new ElementEntity(new Id(elementId))).get())
- .filter(Objects::nonNull)
- .collect(Collectors.toList());
- }
-
-
- public void update(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
- updateElement(context, elementContext, element);
- }
-
-
- public Optional<ElementEntity> get(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
- Row row = getElementAccessor(context).get(
- elementContext.getSpace(),
- elementContext.getItemId().getValue(),
- getVersionId(elementContext),
- element.getId().getValue()).one();
-
- return row == null ? Optional.empty() : Optional.of(getElementEntity(element, row));
- }
-
-
- private String getVersionId(ElementEntityContext elementContext) {
- return elementContext.getRevisionId() == null
- ? elementContext.getVersionId().getValue()
- : elementContext.getRevisionId().getValue();
- }
-
-
- private ElementAccessor getElementAccessor(SessionContext context) {
- return NoSqlDbFactory.getInstance().createInterface().getMappingManager().createAccessor
- (ElementAccessor.class);
-
- }
-
- private VersionElementsAccessor getVersionElementsAccessor() {
- return NoSqlDbFactory.getInstance().createInterface().getMappingManager().createAccessor
- (VersionElementsAccessor.class);
-
- }
-
-
- private void updateElement(SessionContext context, ElementEntityContext elementContext,
- ElementEntity element) {
-
- if (elementContext.getRevisionId() == null) {
-
- getElementAccessor(context).update(
- JsonUtil.object2Json(element.getInfo()),
- JsonUtil.object2Json(element.getRelations()),
- element.getData(),
- element.getSearchableData(),
- element.getVisualization(),
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- elementContext.getVersionId().toString(),
- element.getId().toString());
- } else {
- getElementAccessor(context).update(
- JsonUtil.object2Json(element.getInfo()),
- JsonUtil.object2Json(element.getRelations()),
- element.getData(),
- element.getSearchableData(),
- element.getVisualization(),
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- elementContext.getRevisionId().getValue(),
- element.getId().toString());
- }
- }
-
-
- private ElementEntity getElementEntity(ElementEntity element, Row row) {
- element.setNamespace(getNamespace(row.getString(ElementField.NAMESPACE)));
- element.setParentId(new Id(row.getString(ElementField.PARENT_ID)));
- element.setInfo(json2Object(row.getString(ElementField.INFO), Info.class));
- element.setRelations(
- json2Object(row.getString(ElementField.RELATIONS), new TypeToken<ArrayList<Relation>>() {
- }.getType()));
- element.setData(row.getBytes(ElementField.DATA));
- element.setSearchableData(row.getBytes(ElementField.SEARCHABLE_DATA));
- element.setVisualization(row.getBytes(ElementField.VISUALIZATION));
- element.setSubElementIds(row.getSet(ElementField.SUB_ELEMENT_IDS, String.class)
- .stream().map(Id::new).collect(Collectors.toSet()));
- return element;
- }
-
- private Namespace getNamespace(String namespaceStr) {
- Namespace namespace = new Namespace();
- if (namespaceStr != null) {
- namespace.setValue(namespaceStr);
- }
- return namespace;
- }
-
- private static <T> T json2Object(String json, Type typeOfT) {
- return json == null ? null : JsonUtil.json2Object(json, typeOfT);
- }
-
- private Set<String> getVersionElementIds(SessionContext context,
- ElementEntityContext elementContext) {
- Row row = getVersionElementsAccessor().get(
- elementContext.getSpace(),
- elementContext.getItemId().toString(),
- getVersionId(elementContext)).one();
- return row == null
- ? new HashSet<>()
- : row.getSet(VersionElementsField.ELEMENT_IDS, String.class);
- }
-
- /*
-CREATE TABLE IF NOT EXISTS element_namespace (
- space text,
- item_id text,
- element_id text,
- namespace text,
- PRIMARY KEY (( space, item_id, element_id ))
-);
- */
- @Accessor
- interface ElementNamespaceAccessor {
- @Query(
- "UPDATE 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 itemId,
- @Param("id") String elementId,
- @Param("ns") String namespace);
- }
-
- /*
-CREATE TABLE IF NOT EXISTS element (
- space text,
- item_id text,
- version_id text,
- element_id text,
- parent_id text,
- namespace text,
- info text,
- relations text,
- data blob,
- searchable_data blob,
- visualization blob,
- sub_element_ids set<text>,
- PRIMARY KEY (( space, item_id, version_id, element_id ))
-);
- */
- @Accessor
- interface ElementAccessor {
- @Query(
- "UPDATE zusammen_dox.element SET parent_id=:parentId, namespace=:ns, info=:info, " +
- "relations=:rels, " +
- "data=:data, searchable_data=:searchableData, visualization=:visualization, " +
- "sub_element_ids=sub_element_ids+:subs " +
- "WHERE space=:space AND item_id=:item AND version_id=:ver AND element_id=:id ")
- void create(@Param("space") String space,
- @Param("item") String itemId,
- @Param("ver") String versionId,
- @Param("id") String elementId,
- @Param("parentId") String parentElementId,
- @Param("ns") String namespace,
- @Param("info") String info,
- @Param("rels") String relations,
- @Param("data") ByteBuffer data,
- @Param("searchableData") ByteBuffer searchableData,
- @Param("visualization") ByteBuffer visualization,
- @Param("subs") Set<String> subElementIds);
-
- @Query("UPDATE zusammen_dox.element SET info=?, relations=?, data=?, searchable_data=?, " +
- "visualization=?" +
- " WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
- void update(String info, String relations, ByteBuffer data, ByteBuffer searchableData,
- ByteBuffer visualization, String space, String itemId, String versionId,
- String elementId);
-
-
- @Query("SELECT parent_id, namespace, info, relations, data, searchable_data, visualization, " +
- "sub_element_ids FROM zusammen_dox.element " +
- "WHERE space=? AND item_id=? AND version_id=? AND element_id=? ")
- ResultSet get(String space, String itemId, String versionId, String elementId);
-
-
- }
-
- private static final class ElementField {
- private static final String NAMESPACE = "namespace";
- private static final String PARENT_ID = "parent_id";
- private static final String INFO = "info";
- private static final String RELATIONS = "relations";
- private static final String DATA = "data";
- private static final String SEARCHABLE_DATA = "searchable_data";
- private static final String VISUALIZATION = "visualization";
- private static final String SUB_ELEMENT_IDS = "sub_element_ids";
- }
-
- /*
- CREATE TABLE IF NOT EXISTS version_elements (
- space text,
- item_id text,
- version_id text,
- element_ids set<text>,
- PRIMARY KEY (( space, item_id, version_id ))
- );
- */
- @Accessor
- interface VersionElementsAccessor {
-
-
- @Query("SELECT element_ids FROM zusammen_dox.version_elements WHERE space=? AND item_id=? AND version_id=?")
- ResultSet get(String space, String itemId, String versionId);
-
-
- }
-
- private static final class VersionElementsField {
- private static final String ELEMENT_IDS = "element_ids";
- }
-}
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java
deleted file mode 100644
index d8929ea720..0000000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/ElementHandler.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.openecomp.core.tools.store;
-
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
-
-public class ElementHandler {
-
- private static final String GLOBAL_USER = "GLOBAL_USER";
-
- public static void update(SessionContext context,
- String itemId, String versionId, String revisionId,
- ElementEntity elementEntity) {
-
- ElementEntityContext elementContext;
- CassandraElementRepository cassandraElementRepository = new CassandraElementRepository();
- if (revisionId == null) {
-
- elementContext = new ElementEntityContext(GLOBAL_USER, new Id(itemId),
- new Id(versionId));
-
- }
- }
-}
-
diff --git a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java b/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java
deleted file mode 100644
index b8620b8283..0000000000
--- a/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/VspGeneralLoader.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package org.openecomp.core.tools.store;
-
-import com.amdocs.zusammen.datatypes.Id;
-import com.amdocs.zusammen.datatypes.SessionContext;
-import com.amdocs.zusammen.datatypes.item.Info;
-import com.amdocs.zusammen.plugin.statestore.cassandra.dao.types.ElementEntityContext;
-import org.openecomp.core.zusammen.plugin.dao.types.ElementEntity;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-public class VspGeneralLoader {
-
- public static final String NAME = "name";
- public static final String GENERAL = "General";
-
- private static CassandraElementRepository cassandraElementRepository =
- new CassandraElementRepository();
-
- public static Map<String, ElementEntity> load(SessionContext context,
- Map<String, List<String>> vspItemVersionsMap,
- Map<String, List<String>> vspItemChangeRefssMap) {
- Map<String, ElementEntity> elementEntityMap = new HashMap<>();
- System.setProperty("cassandra.dox.keystore", "zusammen_dox");
-
- Id entityId;
- Id itemId;
- Id changeRefId;
- for (Map.Entry<String, List<String>> entry : vspItemVersionsMap.entrySet()) {
-
- for (String version : entry.getValue()) {
-
-
- itemId = new Id(entry.getKey());
- changeRefId = new Id(version);
- entityId = getEntityIdByInfoNameValue(context, itemId, changeRefId, null, null, NAME,
- GENERAL);
- if (entityId != null) {
- Optional<ElementEntity> result =
- cassandraElementRepository.get(context, new ElementEntityContext(
- context.getUser().getUserName(),
- itemId,
- changeRefId),
- new ElementEntity(entityId));
- if (result.isPresent()) {
- elementEntityMap.put(buildKey(context, entry, version), result.get());
- }
- }
- }
- }
-
-
- for (Map.Entry<String, List<String>> entry : vspItemChangeRefssMap.entrySet()) {
-
- for (String revisionId : entry.getValue()) {
-
-
- itemId = new Id(entry.getKey());
-
- entityId = getEntityIdByInfoNameValue(context, itemId, null, revisionId,null, NAME,
- GENERAL);
- if (entityId != null) {
- ElementEntityContext elementContext = new ElementEntityContext(
- context.getUser().getUserName(),
- itemId,
- null);
- elementContext.setRevisionId(new Id(revisionId));
- Optional<ElementEntity> result =
- cassandraElementRepository.get(context, elementContext,
- new ElementEntity(entityId));
- if (result.isPresent()) {
- elementEntityMap.put(buildKey(context, entry, revisionId), result.get());
- }
- }
- }
- }
-
-
- return elementEntityMap;
- }
-
- public static String buildKey(SessionContext context, Map.Entry<String, List<String>> entry, String version) {
- return String.format("%s_%s_%s", context.getUser().getUserName(), entry.getKey(), version);
- }
-
- private static Id getEntityIdByInfoNameValue(SessionContext context,
- Id itemId,
- Id versionId,
- String revisionId,
- Id elementId,
- String name,
- String value) {
-
-
- ElementEntityContext elementContext = new ElementEntityContext(
- context.getUser().getUserName(),
- itemId,
- versionId);
- if (revisionId != null) {
- elementContext.setRevisionId(new Id(revisionId));
- }
- Optional<ElementEntity> result =
- cassandraElementRepository.get(context, elementContext,
- new ElementEntity(Id.ZERO));
- if (result.isPresent()) {
- ElementEntity elementEntity = result.get();
- return elementEntity.getSubElementIds().stream().filter(subelementId -> {
- ElementEntityContext subElementContext = new ElementEntityContext(
- context.getUser().getUserName(),
- itemId,
- versionId);
- if(revisionId!= null){
- subElementContext.setRevisionId(new Id(revisionId));
- }
- Optional<ElementEntity> subElementEntityOptional =
- cassandraElementRepository.get(context, subElementContext,
- new ElementEntity(subelementId));
- if (subElementEntityOptional.isPresent()) {
- Info info = subElementEntityOptional.get().getInfo();
- if (isValid(name, info)) {
- return false;
- }
- if (NAME.equals(name)) {
- if (value.equals(info.getName())) {
- return true;
- }
- }
- if (value.equals(info.getProperty(name))) {
- return true;
- }
- }
- return false;
-
- }).findFirst().orElse(null);
- }
- return null;
-
-
- }
-
- private static boolean isValid(String name, Info info) {
- return Objects.isNull(info)|| Objects.isNull(info.getProperty(name));
- }
-
-
-}