summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuli Shlosberg <ys9693@att.com>2017-10-22 14:27:51 +0300
committerYuli Shlosberg <ys9693@att.com>2017-10-23 07:55:42 +0000
commit30ca09d02fb6d8a2489b1e1fb7ae3a0c998628f4 (patch)
tree007743842ba110c1270c7d511e89cb83cd191424
parenta112d87d3d839a2230921a6aff9b9ce3f78bef96 (diff)
remove neo4j classes
Change-Id: I7a9b781c30d4eb269c19dfdaa5d230807a97f08b Issue-Id: SDC-487 Signed-off-by: Yuli Shlosberg <ys9693@att.com> (cherry picked from commit 00fca27997c4a4a473823c4dc0123c074dac7b50)
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminManagerTest.java91
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/BasicDao.java183
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IBasicDAO.java65
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IPropertyDAO.java28
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IResourceDAO.java57
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jElementDAO.java112
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jPropertyDAO.java52
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jResourceDAO.java229
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jUsersDAO.java169
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/BatchBuilder.java83
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTemplates.java52
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTranslator.java251
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphNeighbourTable.java64
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jClient.java1003
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jEdge.java69
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jGraphBatchBuilder.java189
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jOperationStatus.java77
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/NodeRelation.java65
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilter.java51
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilter.java81
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilter.java68
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilter.java56
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilterTest.java50
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilterTest.java93
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilterTest.java83
-rw-r--r--catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilterTest.java40
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverter.java78
27 files changed, 0 insertions, 3439 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminManagerTest.java
deleted file mode 100644
index 4b01b4fd61..0000000000
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/user/UserAdminManagerTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.user;
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.when;
-
-import org.junit.Before;
-import org.mockito.Mockito;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.api.IUsersDAO;
-import org.openecomp.sdc.be.dao.impl.Neo4jUsersDAO;
-import org.openecomp.sdc.be.resources.data.UserData;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-
-import fj.data.Either;
-
-public class UserAdminManagerTest {
-
- final IUsersDAO usersDao = Mockito.mock(Neo4jUsersDAO.class);
- Gson gson;
-
- @Before
- public void setup() {
- Either<UserData, ActionStatus> eitherOk = Either.right(ActionStatus.OK);
- gson = new GsonBuilder().setPrettyPrinting().create();
- when(usersDao.getUserData(anyString())).thenReturn(eitherOk);
- when(usersDao.saveUserData((UserData) anyObject())).thenReturn(ActionStatus.OK);
- when(usersDao.updateUserData((UserData) anyObject())).thenReturn(ActionStatus.OK);
- when(usersDao.deleteUserData(anyString())).thenReturn(ActionStatus.OK);
- }
-
- // @Test
- // public void testCreateUser() {
- // String json = "{\"firstName\": \"James\",\"lastName\":
- // \"Brown\",\"userId\": \"jb1234u\",\"email\":
- // \"jb1234u@sdc.com\",\"role\": \"ADMIN\"}";
- // UserData user = gson.fromJson(json, UserData.class);
- // Either<UserData,ActionStatus> either =
- // UserAdminManager.getInstance().createUser(user);
- // assertTrue(either.isRight());
- // assertEquals(ActionStatus.OK, either.right().value());
- // }
- //
- //
- // @Test
- // public void testCreateUserInvalidEmail() {
- // String json = "{\"firstName\": \"James\",\"lastName\":
- // \"Brown\",\"userId\": \"jb1234u\",\"email\": \"@sdc.com\",\"role\":
- // \"ADMIN\"}";
- // UserData user = gson.fromJson(json, UserData.class);
- // Either<UserData,ActionStatus> either =
- // UserAdminManager.getInstance().createUser(user);
- // assertTrue(either.isRight());
- // assertEquals(ActionStatus.INVALID_EMAIL_ADDRESS, either.right().value());
- // }
- //
- // @Test
- // public void testCreateUserInvalidRole() {
- // String json = "{\"firstName\": \"James\",\"lastName\":
- // \"Brown\",\"userId\": \"jb1234u\",\"email\":
- // \"jb1234u@sdc.com\",\"role\": \"MIN\"}";
- // UserData user = gson.fromJson(json, UserData.class);
- // Either<UserData,ActionStatus> either =
- // UserAdminManager.getInstance().createUser(user);
- // assertTrue(either.isRight());
- // assertEquals(ActionStatus.INVALID_EMAIL_ADDRESS, either.right().value());
- // }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/BasicDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/BasicDao.java
deleted file mode 100644
index 3e6e7706cb..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/BasicDao.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.api;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.impl.Neo4jResourceDAO;
-import org.openecomp.sdc.be.dao.neo4j.BatchBuilder;
-import org.openecomp.sdc.be.dao.neo4j.GraphNeighbourTable;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jClient;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jGraphBatchBuilder;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import fj.data.Either;
-
-public abstract class BasicDao implements IBasicDAO {
-
- Neo4jGraphBatchBuilder graphBatchBuilder = new Neo4jGraphBatchBuilder();
-
- Neo4jClient neo4jClient;
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jResourceDAO.class.getName());
-
- public <T extends GraphNode> Either<T, Neo4jOperationStatus> create(GraphNeighbourTable graphNeighbourTable,
- Class<T> clazz, NodeTypeEnum nodeType) {
-
- if (graphNeighbourTable != null) {
-
- Either<BatchBuilder, Neo4jOperationStatus> bbResult = graphBatchBuilder
- .buildBatchBuilderFromTable(graphNeighbourTable);
-
- if (bbResult.isLeft()) {
-
- BatchBuilder batchBuilder = bbResult.left().value();
- // Neo4jOperationStatus neo4jOperationStatus =
- // neo4jClient.execute(batchBuilder);
- Either<List<List<GraphElement>>, Neo4jOperationStatus> executeResult = neo4jClient
- .execute(batchBuilder);
-
- if (executeResult.isRight()) {
- return Either.right(executeResult.right().value());
- }
-
- T result = null;
- List<List<GraphElement>> listOfResults = executeResult.left().value();
- if (listOfResults != null) {
- for (List<GraphElement> listOfElements : listOfResults) {
- if (listOfElements != null && false == listOfElements.isEmpty()) {
- for (GraphElement element : listOfElements) {
- logger.debug("element {} was returned after running batch operation {}",
- element, batchBuilder);
- if (element instanceof GraphNode) {
- GraphNode neo4jNode = (GraphNode) element;
- if (NodeTypeEnum.getByName(neo4jNode.getLabel()) == nodeType) {
- result = clazz.cast(neo4jNode);
- }
- }
- }
- }
- }
- }
-
- return Either.left(result);
-
- } else {
- return Either.right(bbResult.right().value());
- }
-
- } else {
- logger.error("The table sent in order to create resource is empty.");
- return Either.right(Neo4jOperationStatus.BAD_REQUEST);
- }
-
- }
-
- @Override
- public <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(String uniqueid, Class<T> clazz,
- NodeTypeEnum nodeTypeEnum) {
-
- MatchFilter filter = new MatchFilter();
- filter.addToMatch(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), uniqueid);
-
- return getNodeData(filter, clazz, nodeTypeEnum);
-
- }
-
- @Override
- public <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(String keyName, String uniqueid,
- Class<T> clazz, NodeTypeEnum nodeTypeEnum) {
-
- MatchFilter filter = new MatchFilter();
- filter.addToMatch(keyName, uniqueid);
-
- return getNodeData(filter, clazz, nodeTypeEnum);
-
- }
-
- private <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(MatchFilter filter, Class<T> clazz,
- NodeTypeEnum nodeTypeEnum) {
-
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- nodeTypeEnum.getName(), filter);
-
- if (status.isRight()) {
- return Either.right(status.right().value());
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null || value.isEmpty()) {
- return Either.right(Neo4jOperationStatus.NOT_FOUND);
- } else {
- return Either.left(clazz.cast(value.get(0)));
- }
- }
- }
-
- @Override
- public <T extends GraphNode> Either<List<T>, Neo4jOperationStatus> getNodesData(
- Map<String, Object> propertiesToMatch, Class<T> clazz, NodeTypeEnum nodeTypeEnum) {
-
- MatchFilter filter = new MatchFilter();
- if (propertiesToMatch != null) {
- for (Entry<String, Object> property : propertiesToMatch.entrySet()) {
- filter.addToMatch(property.getKey(), property.getValue());
- }
- }
-
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- nodeTypeEnum.getName(), filter);
-
- if (status.isRight()) {
- return Either.right(status.right().value());
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null || value.isEmpty()) {
- return Either.right(Neo4jOperationStatus.NOT_FOUND);
- } else {
- List<T> list = new ArrayList<T>();
- for (GraphElement element : value) {
- list.add(clazz.cast(element));
- }
- return Either.left(list);
- }
- }
- }
-
- public Neo4jClient getNeo4jClient() {
- return neo4jClient;
- }
-
- public void setNeo4jClient(Neo4jClient neo4jClient) {
- this.neo4jClient = neo4jClient;
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IBasicDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IBasicDAO.java
deleted file mode 100644
index 3a2bfb34e8..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IBasicDAO.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.api;
-
-import java.util.List;
-import java.util.Map;
-
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.neo4j.GraphNeighbourTable;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
-import fj.data.Either;
-
-public interface IBasicDAO {
-
- /**
- * add the content of the graph neighbour table to the graph.
- *
- * @param graphNeighbourTable
- * @param clazz
- * - the type of the object to be returned
- * @param nodeType
- * - label of the node
- * @return Neo4jNode implementation
- */
- public <T extends GraphNode> Either<T, Neo4jOperationStatus> create(GraphNeighbourTable graphNeighbourTable,
- Class<T> clazz, NodeTypeEnum nodeType);
-
- /**
- * return the node data by unique id.
- *
- * @param id
- * - unique id of the node
- * @param clazz
- * @param nodeType
- * @return
- */
- public <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(String id, Class<T> clazz,
- NodeTypeEnum nodeType);
-
- public <T extends GraphNode> Either<T, Neo4jOperationStatus> getNodeData(String keyName, String id, Class<T> clazz,
- NodeTypeEnum nodeType);
-
- public <T extends GraphNode> Either<List<T>, Neo4jOperationStatus> getNodesData(
- Map<String, Object> propertiesToMatch, Class<T> clazz, NodeTypeEnum nodeTypeEnum);
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IPropertyDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IPropertyDAO.java
deleted file mode 100644
index 17bded535c..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IPropertyDAO.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.api;
-
-public interface IPropertyDAO extends IBasicDAO {
-
- // Either<PropertyData, Neo4jOperationStatus>
- // createPropertyData(GraphNeighbourTable graphNeighbourTable);
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IResourceDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IResourceDAO.java
deleted file mode 100644
index 47bbcbcb11..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/IResourceDAO.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.api;
-
-import java.util.List;
-import java.util.Map;
-
-import org.openecomp.sdc.be.dao.neo4j.Neo4jClient;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-
-import fj.data.Either;
-
-public interface IResourceDAO extends IBasicDAO {
-
- Either<ResourceMetadataData, Neo4jOperationStatus> getResourceData(String id);
-
- // Either<ResourceData, Neo4jOperationStatus>
- // createResourceData(GraphNeighbourTable graphNeighbourTable);
-
- /**
- * the method retrieves all the resources according to the supplied
- * properties, if none or null is supplied all the resources will be
- * returned.
- *
- * @param propertiesToMatch
- * a map of properties to match.
- * @return
- */
- Either<List<ResourceMetadataData>, Neo4jOperationStatus> getAllResourcesData(Map<String, Object> propertiesToMatch);
-
- // ActionStatus updateUserData(UserData userData);
- //
- // ActionStatus deleteUserData(String id);
-
- void setNeo4jClient(Neo4jClient client);
-
- Either<Integer, Neo4jOperationStatus> getNumberOfResourcesByName(String name);
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jElementDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jElementDAO.java
deleted file mode 100644
index d6b8d2eed8..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jElementDAO.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.impl;
-
-import java.util.List;
-
-import javax.annotation.Resource;
-
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.api.IElementDAO;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jClient;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import fj.data.Either;
-
-//@Component("elements-dao")
-public class Neo4jElementDAO implements IElementDAO {
-
- // @Resource
- Neo4jClient neo4jClient;
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jElementDAO.class.getName());
-
- @Override
- public Either<List<GraphElement>, ActionStatus> getAllCategories() {
- MatchFilter filter = new MatchFilter();
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- NodeTypeEnum.ResourceCategory.getName(), filter);
- if (status.isRight()) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null || value.isEmpty()) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- return Either.left(value);
- }
- }
- }
-
- @Override
- public Either<List<GraphElement>, ActionStatus> getAllTags() {
- MatchFilter filter = new MatchFilter();
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- NodeTypeEnum.Tag.getName(), filter);
- if (status.isRight()) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- return Either.left(value);
- }
- }
- }
-
- @Override
- public Either<GraphElement, ActionStatus> getCategory(String name) {
- MatchFilter filter = new MatchFilter();
- filter.addToMatch(GraphPropertiesDictionary.NAME.getProperty(), name);
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- NodeTypeEnum.ResourceCategory.getName(), filter);
- if (status.isRight()) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- return Either.left(value.get(0));
- }
- }
-
- }
-
- /**
- * FOR TEST ONLY
- *
- * @param neo4jClient
- */
- public void setNeo4jClient(Neo4jClient neo4jClient) {
- this.neo4jClient = neo4jClient;
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jPropertyDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jPropertyDAO.java
deleted file mode 100644
index c9fcbab0de..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jPropertyDAO.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.impl;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-
-import org.openecomp.sdc.be.dao.api.BasicDao;
-import org.openecomp.sdc.be.dao.api.IPropertyDAO;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jClient;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jGraphBatchBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-//@Component("neo4j-property-dao")
-public class Neo4jPropertyDAO extends BasicDao implements IPropertyDAO {
-
- // @Resource
- Neo4jClient neo4jClient;
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jPropertyDAO.class.getName());
-
- Neo4jGraphBatchBuilder graphBatchBuilder = new Neo4jGraphBatchBuilder();
-
- public Neo4jPropertyDAO() {
-
- }
-
- @PostConstruct
- public void init() {
- setNeo4jClient(neo4jClient);
- }
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jResourceDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jResourceDAO.java
deleted file mode 100644
index 8d961b10ec..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jResourceDAO.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.impl;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.PostConstruct;
-
-import org.openecomp.sdc.be.dao.api.BasicDao;
-import org.openecomp.sdc.be.dao.api.IResourceDAO;
-import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
-import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint;
-import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jClient;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jGraphBatchBuilder;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter;
-import org.openecomp.sdc.be.dao.neo4j.filters.RecursiveFilter;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import fj.data.Either;
-
-//@Component("neo4j-resource-dao")
-public class Neo4jResourceDAO extends BasicDao implements IResourceDAO {
-
- // @Resource
- Neo4jClient neo4jClient;
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jResourceDAO.class.getName());
-
- Neo4jGraphBatchBuilder graphBatchBuilder = new Neo4jGraphBatchBuilder();
-
- public Neo4jResourceDAO() {
-
- }
-
- @PostConstruct
- public void init() {
- super.setNeo4jClient(neo4jClient);
- }
-
- private String findResourceDataIdFromNodes(List<GraphNode> nodes) {
-
- if (nodes != null) {
-
- for (GraphNode neo4jNode : nodes) {
- String label = neo4jNode.getLabel();
- if (label.equals(NodeTypeEnum.Resource.getName())) {
- return neo4jNode.getUniqueId().toString();
- }
- }
- }
-
- return null;
- }
-
- private GraphRelation addStateRelation(RelationEndPoint from, RelationEndPoint to, GraphEdgeLabels edgeLabel,
- String value) {
-
- GraphRelation relationState = new GraphRelation();
- relationState.setFrom(from);
- relationState.setTo(to);
- relationState.setType(edgeLabel.name());
- relationState.setAction(ActionEnum.Create);
- return relationState;
- }
-
- // private ActionStatus convertNeo4jOperationStatusToActionStatus(
- // Neo4jOperationStatus value) {
- //
- // if (value == null) {
- // return ActionStatus.GENERAL_ERROR;
- // }
- //
- // switch (value) {
- // case NOT_FOUND:
- // return ActionStatus.RESOURCE_NOT_FOUND;
- // case ERROR:
- // return ActionStatus.GENERAL_ERROR;
- // case NOT_SUPPORTED:
- // return ActionStatus.INVALID_CONTENT;
- // case WRONG_INPUT:
- // return ActionStatus.INVALID_CONTENT;
- // case OK:
- // return ActionStatus.OK;
- // default:
- // return ActionStatus.GENERAL_ERROR;
- // }
- //
- // }
-
- @Override
- public Either<ResourceMetadataData, Neo4jOperationStatus> getResourceData(String id) {
-
- MatchFilter filter = new MatchFilter();
- filter.addToMatch(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), id);
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- NodeTypeEnum.Resource.getName(), filter);
-
- if (status.isRight()) {
- return Either.right(status.right().value());
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null || value.isEmpty()) {
- return Either.right(Neo4jOperationStatus.NOT_FOUND);
- } else {
- return Either.left((ResourceMetadataData) value.get(0));
- }
- }
- }
-
- @Override
- public Either<Integer, Neo4jOperationStatus> getNumberOfResourcesByName(String name) {
-
- MatchFilter filter = new MatchFilter();
- filter.addToMatch(GraphPropertiesDictionary.NAME.getProperty(), name);
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- NodeTypeEnum.Resource.getName(), filter);
-
- if (status.isRight() || (status.left().value() == null)) {
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- } else {
- List<GraphElement> value = status.left().value();
- return Either.left(value.size());
- }
- }
-
- @Override
- public void setNeo4jClient(Neo4jClient client) {
- this.neo4jClient = client;
- super.setNeo4jClient(client);
- }
-
- @Override
- public Either<List<ResourceMetadataData>, Neo4jOperationStatus> getAllResourcesData(
- Map<String, Object> propertiesToMatch) {
-
- RecursiveFilter filter = new RecursiveFilter(NodeTypeEnum.Resource);
- // filter.addRelationType("typeof").addRelationType("belong").setProperties(propertiesToMatch);
-
- Either<List<List<GraphElement>>, Neo4jOperationStatus> ret = neo4jClient.executeGet(filter);
- if (ret.isRight()) {
- return Either.right(ret.right().value());
- }
- List<List<GraphElement>> listOfListOfNeo4jElement = ret.left().value();
-
- for (List<GraphElement> row : listOfListOfNeo4jElement) {
-
- for (GraphElement elem : row) {
-
- }
- }
- return Either.right(null);
-
- /*
- * MatchFilter filter = new MatchFilter(); if(propertiesToMatch !=
- * null){ for (Entry<String,Object> propertie :
- * propertiesToMatch.entrySet()){ filter.addToMatch(propertie.getKey(),
- * propertie.getValue()); } } Either<List<GraphElement>,
- * Neo4jOperationStatus> status =
- * neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- * NodeTypeEnum.Resource.getName(), filter); if (status.isRight()) {
- * return Either.right(status.right().value()); } else {
- * List<GraphElement> value = status.left().value(); if (value == null
- * || value.isEmpty()) { return
- * Either.right(Neo4jOperationStatus.NOT_FOUND); } else {
- * List<ResourceData> result=new ArrayList<>(); for(GraphElement element
- * : value ){ result.add((ResourceData)element); } return
- * Either.left(result); } }
- */
- }
-
- // @Override
- // public ActionStatus updateUserData(UserData userData) {
- // UpdateFilter filter = new UpdateFilter();
- // filter.addToMatch("userId", userData.getUserId());
- // filter.setToUpdate(userData.toMap());
- // Neo4jOperationStatus status =
- // neo4jClient.updateElement(Neo4JElementTypeEnum.Node,
- // NodeTypeEnum.User.getName(), filter);
- // if (status.equals(Neo4jOperationStatus.OK)) {
- // return ActionStatus.OK;
- // } else {
- // return ActionStatus.GENERAL_ERROR;
- // }
- // }
- //
- // @Override
- // public ActionStatus deleteUserData(String id) {
- // MatchFilter filter = new MatchFilter();
- // filter.addToMatch("userId", id);
- // Neo4jOperationStatus status =
- // neo4jClient.deleteElement(Neo4JElementTypeEnum.Node,
- // NodeTypeEnum.User.getName(), filter);
- // if (status.equals(Neo4jOperationStatus.OK)) {
- // return ActionStatus.OK;
- // } else {
- // return ActionStatus.GENERAL_ERROR;
- // }
- // }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jUsersDAO.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jUsersDAO.java
deleted file mode 100644
index 14489ef04b..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/Neo4jUsersDAO.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.api.IUsersDAO;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jClient;
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter;
-import org.openecomp.sdc.be.dao.neo4j.filters.UpdateFilter;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.resources.data.UserData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import fj.data.Either;
-
-//@Component("users-dao")
-public class Neo4jUsersDAO implements IUsersDAO {
-
- // @Resource
- Neo4jClient neo4jClient;
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jUsersDAO.class.getName());
-
- public Neo4jUsersDAO() {
-
- }
-
- @PostConstruct
- public void init() {
- }
-
- private void createIndexesAndConstraints() {
- Either<Map<String, List<String>>, Neo4jOperationStatus> statusInd = neo4jClient
- .getIndexes(NodeTypeEnum.User.getName());
- if (statusInd.isRight()) {
- logger.error("Failed to get indexes from Neo4j graph");
- throw new RuntimeException("Failed to initialize Neo4jUsersDAO - Failed to get indexes from Neo4j graph");
- }
- Map<String, List<String>> indexes = statusInd.left().value();
- if (indexes == null || indexes.isEmpty()) {
- logger.info("Define users indexes in Neo4j");
- List<String> propertyNames = new ArrayList<String>();
- propertyNames.add("firstName");
- propertyNames.add("lastName");
- propertyNames.add("email");
- propertyNames.add("role");
- logger.info("Start create Users indexes in Neo4jGraph");
- Neo4jOperationStatus createIndexStatus = neo4jClient.createIndex(NodeTypeEnum.User.getName(),
- propertyNames);
- if (createIndexStatus.equals(Neo4jOperationStatus.OK)) {
- logger.info("Users indexes created in Neo4j");
- List<String> propertyUnique = new ArrayList<String>();
- propertyUnique.add("userId");
-
- logger.info("Start create Users constraints in Neo4jGraph");
- Neo4jOperationStatus createUniquenessStatus = neo4jClient
- .createUniquenessConstraints(NodeTypeEnum.User.getName(), propertyUnique);
- if (createUniquenessStatus.equals(Neo4jOperationStatus.OK)) {
- logger.info("Users constraints creatyed in Neo4j");
- } else {
- logger.error("Failed to create constraints in Neo4j graph [{}]", createUniquenessStatus);
- throw new RuntimeException(
- "Failed to initialize Neo4jUsersDAO - Failed to create constraints in Neo4j graph");
- }
- } else {
- logger.error("Failed to create indexes in Neo4j graph [{}]", createIndexStatus);
- throw new RuntimeException(
- "Failed to initialize Neo4jUsersDAO - Failed to create indexes in Neo4j graph");
- }
- } else {
- logger.info("Users indexes already defined in Neo4j");
- }
- }
-
- @Override
- public Either<UserData, ActionStatus> getUserData(String id) {
- MatchFilter filter = new MatchFilter();
- filter.addToMatch("userId", id);
- Either<List<GraphElement>, Neo4jOperationStatus> status = neo4jClient.getByFilter(GraphElementTypeEnum.Node,
- NodeTypeEnum.User.getName(), filter);
- if (status.isRight()) {
- return Either.right(ActionStatus.GENERAL_ERROR);
- } else {
- List<GraphElement> value = status.left().value();
- if (value == null || value.isEmpty()) {
- return Either.right(ActionStatus.USER_NOT_FOUND);
- } else {
- return Either.left((UserData) value.get(0));
- }
- }
- }
-
- @Override
- public ActionStatus saveUserData(UserData userData) {
- Neo4jOperationStatus status = neo4jClient.createElement(userData);
- if (status.equals(Neo4jOperationStatus.OK)) {
- return ActionStatus.OK;
- } else {
- return ActionStatus.GENERAL_ERROR;
- }
- }
-
- @Override
- public ActionStatus updateUserData(UserData userData) {
- UpdateFilter filter = new UpdateFilter();
- filter.addToMatch("userId", userData.getUserId());
- filter.setToUpdate(userData.toGraphMap());
- Neo4jOperationStatus status = neo4jClient.updateElement(GraphElementTypeEnum.Node, NodeTypeEnum.User.getName(),
- filter);
- if (status.equals(Neo4jOperationStatus.OK)) {
- return ActionStatus.OK;
- } else {
- return ActionStatus.GENERAL_ERROR;
- }
- }
-
- @Override
- public ActionStatus deleteUserData(String id) {
- MatchFilter filter = new MatchFilter();
- filter.addToMatch("userId", id);
- Neo4jOperationStatus status = neo4jClient.deleteElement(GraphElementTypeEnum.Node, NodeTypeEnum.User.getName(),
- filter);
- if (status.equals(Neo4jOperationStatus.OK)) {
- return ActionStatus.OK;
- } else {
- return ActionStatus.GENERAL_ERROR;
- }
- }
-
- public Neo4jClient getNeo4jClient() {
- return neo4jClient;
- }
-
- public void setNeo4jClient(Neo4jClient neo4jClient) {
- this.neo4jClient = neo4jClient;
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/BatchBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/BatchBuilder.java
deleted file mode 100644
index 0177d0bd70..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/BatchBuilder.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
-
-public class BatchBuilder {
- // private Map<String, List<Neo4jNode>> nodes;
- // private List<Neo4jRelation> relations;
- //
- private List<GraphElement> elements;
-
- // TODO add filter
-
- protected BatchBuilder() {
- // nodes = new HashMap<String, List<Neo4jNode>>();
- // relations = new ArrayList<Neo4jRelation>();
- elements = new ArrayList<GraphElement>();
- }
-
- public static BatchBuilder getBuilder() {
- return new BatchBuilder();
- }
-
- public BatchBuilder add(GraphElement element) {
- elements.add(element);
- return this;
- }
-
- public List<GraphElement> getElements() {
- return elements;
- }
-
- // public BatchBuilder add( Neo4jNode element ){
- // String label = element.getLabel();
- // List<Neo4jNode> list = nodes.get(label);
- // if ( list == null ){
- // list = new ArrayList<Neo4jNode>();
- // }
- // list.add(element);
- // nodes.put(label, list);
-
- // return this;
- // }
- // public BatchBuilder add( Neo4jRelation relation ){
- // relations.add(relation);
- // return this;
- // }
- //
- // public Map<String, List<Neo4jNode>> getNodes() {
- // return nodes;
- // }
- //
- // public List<Neo4jRelation> getRelations() {
- // return relations;
- // }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTemplates.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTemplates.java
deleted file mode 100644
index b0b2cc20bb..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTemplates.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-public interface CypherTemplates {
-
- public static final String CypherUrlTemplate = "http://$host$:$port$/db/data/transaction/commit";
- public static final String batchTemplate = "http://$host$:$port$/db/data/batch";
- public static final String getAllIndexsTemplate = "http://$host$:$port$/db/data/schema/index";
-
- public static final String CypherCreateNodeTemplate = "{\n\"statements\" : [ {\n \"statement\" : \"CREATE (n:$label$ { props } ) RETURN n\",\n \"parameters\" : { \n \"props\" : $props$ \n } } ] }";
-
- public static final String CypherMatchTemplate = "{\"statements\": [{\"statement\": \"MATCH (n:$label$ {$filter$}) RETURN ($type$) \" }]}";
-
- public static final String CypherUpdateTemplate = "{\"statements\": [{\"statement\": \"MATCH (n:$label$ {$filter$}) SET n += {props} RETURN ($type$) \",\"parameters\" : {\"props\" : {$props$}}}]}";
- public static final String CypherDeleteNodeTemplate = "{\"statements\": [{\"statement\": \"MATCH ( n:$label$ {$filter$} ) DELETE n \" }]}";
-
- public static final String BatchTemplate = "{ \"statements\" : [ $statementList$ ] }";
-
- public static final String RegularStatementTemplate = "{ \"statement\" : $statement$ }";
-
- public static final String CreateSingleNodeTemplate = " \"CREATE (n:$label$ { props } ) RETURN n, labels(n)\", \"parameters\" : { \"props\" : $props$ }";
-
- public static final String CreateRelationTemplate = "\"MATCH (a:$labelFrom$),(b:$labelTo$) WHERE a.$idNameFrom$ = '$idValueFrom$' AND b.$idNameTo$ = '$idvalueTo$' CREATE (a)-[r:$type$ { props } ]->(b) RETURN a, labels(a), b, labels(b), r, type(r)\", \"parameters\": {\"props\": $props$ } ";
-
- public static final String CreateRelationTemplateNoProps = "\"MATCH (a:$labelFrom$),(b:$labelTo$) WHERE a.$idNameFrom$ = '$idValueFrom$' AND b.$idNameTo$ = '$idvalueTo$' CREATE (a)-[r:$type$ ]->(b) RETURN a,labels(a), b, labels(b), r, type(r)\"";
-
- public static final String UpdateNodeStatementTemplate = "\"MATCH (n:$label$ {$filter$}) SET n += {props} \",\"parameters\" : {\"props\" : $props$}";
-
- public static final String GetNodeRecursiveTemplate = "\"MATCH (m:$label$ {$filter$} )-[f$typesList$]->l RETURN m, labels(m), l, labels(l),f, type(f)\"";
-
- public static final String GetByRelationNodeRecursiveTemplate = "\"MATCH (n:$labelNode$ ($propsNode$} )-[r:$type$ {$propsRel$}]->(m:$labelSrc$)-[f$typesList$]->l RETURN n, labels(n), r, type(r), m, labels(m), l, labels(l),f, type(f)\"";
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTranslator.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTranslator.java
deleted file mode 100644
index e1409b3bb1..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/CypherTranslator.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
-import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint;
-import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter;
-import org.openecomp.sdc.be.dao.neo4j.filters.RecursiveByRelationFilter;
-import org.openecomp.sdc.be.dao.neo4j.filters.RecursiveFilter;
-import org.openecomp.sdc.be.dao.utils.DaoUtils;
-
-public class CypherTranslator {
-
- public String translate(BatchBuilder builder) {
- String json = null;
- StringBuilder statementList = new StringBuilder();
-
- List<GraphElement> elements = builder.getElements();
- int statementCounter = 0;
- for (GraphElement element : elements) {
- String singleStatementBody = null;
- switch (element.getElementType()) {
- case Node:
- singleStatementBody = prepareNodeStatement(element);
- break;
- case Relationship:
- singleStatementBody = prepareRelationStatement(element);
- break;
- }
- if (singleStatementBody != null && !singleStatementBody.isEmpty()) {
-
- String singleStatement = CypherTemplates.RegularStatementTemplate.replace("$statement$",
- singleStatementBody);
-
- statementList.append(singleStatement);
- }
- ++statementCounter;
- if (statementCounter < elements.size() && singleStatementBody != null) {
- statementList.append(",");
- }
-
- }
- json = CypherTemplates.BatchTemplate.replace("$statementList$", statementList.toString());
- return json;
- }
-
- private String prepareNodeStatement(GraphElement element) {
- if (element instanceof GraphNode) {
- GraphNode node = (GraphNode) element;
-
- switch (node.getAction()) {
- case Create:
- return createNodeStatement(node);
- case Update:
- return updateNodeStatement(node);
- case Delete:
- // TODO
- break;
- default:
- break;
- }
- }
- return null;
- }
-
- private String updateNodeStatement(GraphNode node) {
- String singleStatement = CypherTemplates.UpdateNodeStatementTemplate.replace("$label$", node.getLabel());
- String filter = prepareKeyValueFilter(node);
-
- singleStatement = singleStatement.replace("$filter$", filter);
-
- singleStatement = singleStatement.replace("$props$", DaoUtils.convertToJson(node.toGraphMap()));
-
- return singleStatement;
- }
-
- private String createNodeStatement(GraphNode node) {
- String singleStatement = CypherTemplates.CreateSingleNodeTemplate.replace("$label$", node.getLabel());
-
- singleStatement = singleStatement.replace("$props$", DaoUtils.convertToJson(node.toGraphMap()));
- return singleStatement;
- }
-
- private String prepareRelationStatement(GraphElement element) {
- if (element instanceof GraphRelation) {
-
- GraphRelation relation = (GraphRelation) element;
-
- switch (relation.getAction()) {
- case Create:
- return createRelationStatement(relation);
- case Update:
- return updateRelationStatement(relation);
- case Delete:
- // TODO
- break;
- default:
- break;
- }
- }
- return null;
- }
-
- private String createRelationStatement(GraphRelation relation) {
- RelationEndPoint from = relation.getFrom();
- String singleStatement;
-
- Map<String, Object> props = relation.toGraphMap();
- if (props == null || props.isEmpty()) {
- singleStatement = CypherTemplates.CreateRelationTemplateNoProps.replace("$labelFrom$",
- from.getLabel().getName());
- } else {
- singleStatement = CypherTemplates.CreateRelationTemplate.replace("$labelFrom$", from.getLabel().getName());
- singleStatement = singleStatement.replace("$props$", DaoUtils.convertToJson(props));
- }
-
- singleStatement = singleStatement.replace("$idNameFrom$", from.getIdName());
- singleStatement = singleStatement.replace("$idValueFrom$", from.getIdValue().toString());
-
- RelationEndPoint to = relation.getTo();
- singleStatement = singleStatement.replace("$labelTo$", to.getLabel().getName());
- singleStatement = singleStatement.replace("$idNameTo$", to.getIdName());
- singleStatement = singleStatement.replace("$idvalueTo$", to.getIdValue().toString());
-
- singleStatement = singleStatement.replace("$type$", relation.getType());
- return singleStatement;
- }
-
- private String updateRelationStatement(GraphRelation relation) {
- // TODO
- return null;
- }
-
- private String prepareKeyValueFilter(GraphNode node) {
- StringBuilder sb = new StringBuilder();
-
- ImmutablePair<String, Object> keyValueId = node.getKeyValueId();
-
- sb.append(keyValueId.getKey()).append(":");
- if (keyValueId.getValue() instanceof String) {
- sb.append("'");
- }
- sb.append(keyValueId.getValue());
-
- if (keyValueId.getValue() instanceof String) {
- sb.append("'");
- }
-
- return sb.toString();
- }
-
- public String translateGet(RecursiveFilter filter) {
- String requestJson = null;
- String statement;
-
- if (filter instanceof RecursiveByRelationFilter) {
- RecursiveByRelationFilter byRelationFilter = (RecursiveByRelationFilter) filter;
-
- statement = CypherTemplates.GetByRelationNodeRecursiveTemplate.replace("$labelNode$",
- byRelationFilter.getNode().getLabel());
- String keyValueId = prepareKeyValueFilter(byRelationFilter.getNode());
-
- statement = statement.replace("$propsNode$", keyValueId);
-
- statement = statement.replace("$type$", byRelationFilter.getRelationType());
-
- String relationProps = prepareFilterBody(filter);
- statement = statement.replace("$propsRel$", relationProps);
- statement = statement.replace("$labelSrc$", filter.getNodeType().getName());
-
- } else {
-
- statement = CypherTemplates.GetNodeRecursiveTemplate.replace("$label$", filter.getNodeType().getName());
-
- // replace filter
- if (filter.getProperties().isEmpty()) {
- // get all records by label
- statement = statement.replace("{$filter$}", "");
- } else {
- String filterStr = prepareFilterBody(filter);
- statement = statement.replace("$filter$", filterStr);
- }
- }
-
- if (filter.getChildRelationTypes() == null || filter.getChildRelationTypes().isEmpty()) {
- statement = statement.replace("$typesList$", "");
-
- } else {
- StringBuilder typesList = new StringBuilder();
- int count = 0;
- for (String type : filter.getChildRelationTypes()) {
- typesList.append(":").append(type);
- ++count;
- if (count < filter.getChildRelationTypes().size()) {
- typesList.append("|");
- }
- }
- statement = statement.replace("$typesList$", typesList.toString());
- }
- String singleStatement = CypherTemplates.RegularStatementTemplate.replace("$statement$", statement);
- requestJson = CypherTemplates.BatchTemplate.replace("$statementList$", singleStatement);
-
- return requestJson;
- }
-
- public static String prepareFilterBody(MatchFilter filter) {
- StringBuilder sb = new StringBuilder();
- int count = 0;
- int size = filter.getProperties().entrySet().size();
- for (Map.Entry<String, Object> entry : filter.getProperties().entrySet()) {
- sb.append(entry.getKey()).append(":");
- if (entry.getValue() instanceof String) {
- sb.append("'");
- }
- sb.append(entry.getValue());
- if (entry.getValue() instanceof String) {
- sb.append("'");
- }
- ++count;
- if (count < size) {
- sb.append(",");
- }
- }
- return sb.toString();
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphNeighbourTable.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphNeighbourTable.java
deleted file mode 100644
index ccfb57b145..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/GraphNeighbourTable.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-
-public class GraphNeighbourTable {
-
- List<GraphNode> nodes = new ArrayList<GraphNode>();
-
- List<NodeRelation> directedEdges = new ArrayList<NodeRelation>();
-
- public List<GraphNode> getNodes() {
- return nodes;
- }
-
- public void setNodes(List<GraphNode> nodes) {
- this.nodes = nodes;
- }
-
- public List<NodeRelation> getDirectedEdges() {
- return directedEdges;
- }
-
- public void setDirectedEdges(List<NodeRelation> directedEdges) {
- this.directedEdges = directedEdges;
- }
-
- public int addNode(GraphNode node) {
- this.nodes.add(node);
- return this.nodes.size() - 1;
- }
-
- public void addEdge(NodeRelation directedEdge) {
- this.directedEdges.add(directedEdge);
- }
-
- @Override
- public String toString() {
- return "GraphNeighbourTable [nodes=" + nodes + ", directedEdges=" + directedEdges + "]";
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jClient.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jClient.java
deleted file mode 100644
index eb279cda3d..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jClient.java
+++ /dev/null
@@ -1,1003 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.AuthCache;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.HttpResponseException;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.impl.client.BasicAuthCache;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.BasicResponseHandler;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.util.EntityUtils;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-import org.json.simple.parser.ParseException;
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.dao.graph.GraphElementFactory;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.neo4j.filters.MatchFilter;
-import org.openecomp.sdc.be.dao.neo4j.filters.RecursiveFilter;
-import org.openecomp.sdc.be.dao.neo4j.filters.UpdateFilter;
-import org.openecomp.sdc.be.dao.utils.DaoUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-
-import fj.data.Either;
-
-//@Component("neo4j-client")
-public class Neo4jClient {
- private CloseableHttpClient httpClient;
- private JSONParser jsonParser;
-
- private CypherTranslator cypherTranslator;
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jClient.class.getName());
-
- private static final String getServiceRoot = "http://$host$:$port$/db/data/";
- // Error's Classification templates
- private static final String ClientError = "ClientError";
- private static final String DatabaseError = "DatabaseError";
- private static final String TransientError = "TransientError";
-
- // Error's Category templates
- private static final String General = "General";
- private static final String LegacyIndex = "LegacyIndex";
- private static final String Request = "Request";
- private static final String Schema = "Schema";
- private static final String Security = "Security";
- private static final String Statement = "Statement";
- private static final String Transaction = "Transaction";
-
- // Error's Title templates
- private static final String EntityNotFound = "EntityNotFound";
- private static final String ConstraintViolation = "ConstraintViolation";
-
- @PostConstruct
- public void init() {
-
- PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
- connectionManager.setMaxTotal(100);
- connectionManager.setDefaultMaxPerRoute(20);
- connectionManager.setValidateAfterInactivity(15000);
- this.httpClient = HttpClients.custom().setConnectionManager(connectionManager).build();
- jsonParser = new JSONParser();
- cypherTranslator = new CypherTranslator();
-
- }
-
- @PreDestroy
- public void shutdown() {
- try {
- httpClient.close();
- logger.debug("Http client to Neo4j Graph closed");
- } catch (Exception e) {
- logger.info("Failed to close http client", e);
- }
- }
-
- /**
- *
- * @param builder
- * @return
- */
- public Either<List<List<GraphElement>>, Neo4jOperationStatus> execute(BatchBuilder builder) {
-
- String json = cypherTranslator.translate(builder);
- logger.debug("Try to execute cypher request [{}]", json);
-
- Either<String, Neo4jOperationStatus> result = sendPostCypher(json);
- if (result.isRight()) {
- return Either.right(result.right().value());
- }
- List<List<GraphElement>> batchResult;
- try {
- batchResult = parseResult(result.left().value(), false);
- } catch (ParseException e) {
- logger.error("Failed to parse batchresponse", e);
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
-
- return Either.left(batchResult);
- }
-
- public Either<List<List<GraphElement>>, Neo4jOperationStatus> executeGet(RecursiveFilter filter) {
- String json = cypherTranslator.translateGet(filter);
- logger.debug("Try to execute cypher request [{}]", json);
-
- Either<String, Neo4jOperationStatus> result = sendPostCypher(json);
- if (result.isRight()) {
- return Either.right(result.right().value());
- }
- List<List<GraphElement>> batchResult;
- try {
- batchResult = parseResult(result.left().value(), true);
- } catch (ParseException e) {
- logger.error("Failed to parse batchresponse", e);
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
-
- return Either.left(batchResult);
-
- }
-
- /**
- *
- * @param element
- * @param ip
- * @param user
- * @param password
- * @return
- */
- public Neo4jOperationStatus createElement(GraphElement element) {
- Neo4jOperationStatus result = Neo4jOperationStatus.OK;
- switch (element.getElementType()) {
- case Node:
- Either<String, Neo4jOperationStatus> status = createNode(element);
- if (status.isRight()) {
- result = status.right().value();
- }
- break;
- case Relationship:
- // TODO
- break;
-
- default:
- break;
- }
-
- return result;
- }
-
- public Either<GraphElement, Neo4jOperationStatus> createSingleElement(GraphElement element) {
- switch (element.getElementType()) {
- case Node:
- Either<String, Neo4jOperationStatus> status = createNode(element);
- if (status.isRight()) {
- return Either.right(status.right().value());
- }
- // parse response
- String response = status.left().value();
- try {
- List<GraphElement> listElements = parseGetResponse(element.getElementType(),
- ((GraphNode) element).getLabel(), response);
- if (listElements == null || listElements.isEmpty()) {
- return Either.right(Neo4jOperationStatus.NOT_FOUND);
- } else {
- return Either.left(listElements.get(0));
- }
- } catch (Exception e) {
- logger.error("Failed to parse fetched data from graph", e);
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
- case Relationship:
- // TODO
- break;
-
- default:
- break;
- }
-
- return Either.right(Neo4jOperationStatus.NOT_SUPPORTED);
- }
-
- /**
- *
- * @param type
- * @param label
- * @param filter
- * @param ip
- * @param user
- * @param password
- * @return
- */
- public Either<List<GraphElement>, Neo4jOperationStatus> getByFilter(GraphElementTypeEnum type, String label,
- MatchFilter filter) {
-
- List<GraphElement> result = null;
-
- String requestJson;
- // replace return type
- if (type.equals(GraphElementTypeEnum.Node)) {
- requestJson = CypherTemplates.CypherMatchTemplate.replace("$type$", "n");
- } else {
- requestJson = CypherTemplates.CypherMatchTemplate.replace("$type$", "r");
- }
- // replace label
- if (label != null && !label.isEmpty()) {
- requestJson = requestJson.replace("$label$", label);
- } else {
- requestJson = requestJson.replace("$label$", "");
- }
-
- // replace filter
- if (filter.getProperties().isEmpty()) {
- // get all records by label
- requestJson = requestJson.replace("{$filter$}", "");
- } else {
- String filterStr = CypherTranslator.prepareFilterBody(filter);
- requestJson = requestJson.replace("$filter$", filterStr);
- }
- logger.debug("Try to perform request []", requestJson);
-
- Either<String, Neo4jOperationStatus> status = sendPostCypher(requestJson);
- if (status.isRight()) {
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
- // parse response
- String response = status.left().value();
- try {
- result = parseGetResponse(type, label, response);
- } catch (Exception e) {
- logger.error("Failed to parse fetched data from graph", e);
- Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
-
- return Either.left(result);
- }
-
- /**
- *
- * @param type
- * @param label
- * @param toMatch
- * @param toUpdate
- * @param ip
- * @param user
- * @param password
- * @return
- */
- public Neo4jOperationStatus updateElement(GraphElementTypeEnum type, String label, UpdateFilter toUpdate) {
-
- String requestJson;
- // replace return type
- if (type.equals(GraphElementTypeEnum.Node)) {
- requestJson = CypherTemplates.CypherUpdateTemplate.replace("$type$", "n");
- } else {
- requestJson = CypherTemplates.CypherUpdateTemplate.replace("$type$", "r");
- }
- // replace label
- if (label != null && !label.isEmpty()) {
- requestJson = requestJson.replace("$label$", label);
- } else {
- requestJson = requestJson.replace("$label$", "");
- }
-
- // replace filter
- if (toUpdate.getProperties().isEmpty()) {
- // get all records by label
- requestJson = requestJson.replace("{$filter$}", "");
- } else {
- String filterStr = CypherTranslator.prepareFilterBody(toUpdate);
- requestJson = requestJson.replace("$filter$", filterStr);
- }
- String props = preparePropertiesInStatement(toUpdate.getToUpdate());
- requestJson = requestJson.replace("$props$", props);
-
- logger.debug("Try to perform request [{}]", requestJson);
-
- Either<String, Neo4jOperationStatus> result = sendPostCypher(requestJson);
- if (result.isRight()) {
- return Neo4jOperationStatus.GENERAL_ERROR;
- }
- return Neo4jOperationStatus.OK;
- }
-
- /**
- *
- * @param type
- * @param label
- * @param response
- * @return
- * @throws ParseException
- */
-
- private List<GraphElement> parseGetResponse(GraphElementTypeEnum type, String label, String response)
- throws ParseException {
- List<GraphElement> result = new ArrayList<GraphElement>();
- JSONObject responseData = (JSONObject) jsonParser.parse(response);
- JSONArray results = (JSONArray) responseData.get("results");
- Iterator<JSONObject> iteratorResults = results.iterator();
- while (iteratorResults.hasNext()) {
- JSONObject elementResult = iteratorResults.next();
- // JSONArray data = (JSONArray) elementResult.get("row");
- JSONArray data = (JSONArray) elementResult.get("data");
-
- Iterator<JSONObject> iterator = data.iterator();
- JSONObject element;
- while (iterator.hasNext()) {
- element = (JSONObject) iterator.next();
- JSONArray row = (JSONArray) element.get("row");
-
- Iterator<JSONObject> iteratorRow = row.iterator();
- while (iteratorRow.hasNext()) {
- JSONObject rowElement = iteratorRow.next();
-
- Map<String, Object> props = new HashMap<String, Object>();
-
- for (Map.Entry<String, Object> entry : (Set<Map.Entry<String, Object>>) rowElement.entrySet()) {
- // props.put(entry.getKey(),
- // rowElement.get(entry.getValue()));
- props.put(entry.getKey(), entry.getValue());
- }
- GraphElement newElement = GraphElementFactory.createElement(label, type, props);
- result.add(newElement);
- }
- }
- }
- return result;
- }
-
- private List<List<GraphElement>> parseResult(String response, boolean storeRelationNode) throws ParseException {
-
- List<List<GraphElement>> batchList = new ArrayList<List<GraphElement>>();
-
- JSONObject responseData = (JSONObject) jsonParser.parse(response);
- JSONArray results = (JSONArray) responseData.get("results");
- Iterator<JSONObject> iteratorResults = results.iterator();
-
- while (iteratorResults.hasNext()) {
- JSONObject elementResult = iteratorResults.next();
- JSONArray data = (JSONArray) elementResult.get("data");
- JSONArray columns = (JSONArray) elementResult.get("columns");
- Iterator<JSONObject> iteratorData = data.iterator();
- List<GraphElement> singleDataList = new ArrayList<GraphElement>();
- while (iteratorData.hasNext()) {
-
- JSONObject singleData = iteratorData.next();
- JSONArray row = (JSONArray) singleData.get("row");
- if (columns.size() == 2) {
- // node
- JSONArray labelArray = (JSONArray) row.get(1);
- JSONObject node = (JSONObject) row.get(0);
-
- Map<String, Object> props = jsonObjectToMap(node);
- // get only first label on node. Now single label supported
- GraphElement newElement = GraphElementFactory.createElement((String) labelArray.get(0),
- GraphElementTypeEnum.Node, props);
- singleDataList.add(newElement);
- }
- if (columns.size() == 10) {
- // relation
- JSONObject startNode = (JSONObject) row.get(0);
- JSONArray startNodeArray = (JSONArray) row.get(1);
-
- JSONObject relationFromStart = (JSONObject) row.get(2);
- String relationFromStartType = (String) row.get(3);
-
- JSONObject nodeFrom = (JSONObject) row.get(4);
- JSONArray labelFromArray = (JSONArray) row.get(5);
-
- JSONObject nodeTo = (JSONObject) row.get(6);
- JSONArray labelToArray = (JSONArray) row.get(7);
-
- JSONObject relation = (JSONObject) row.get(8);
- String type = (String) row.get(9);
-
- Map<String, Object> propsStartNode = jsonObjectToMap(startNode);
- Map<String, Object> propsRelationStartNode = jsonObjectToMap(relationFromStart);
-
- Map<String, Object> propsFrom = jsonObjectToMap(nodeFrom);
- Map<String, Object> propsTo = jsonObjectToMap(nodeTo);
- Map<String, Object> propsRelation = jsonObjectToMap(relation);
-
- GraphNode startN = (GraphNode) GraphElementFactory.createElement((String) startNodeArray.get(0),
- GraphElementTypeEnum.Node, propsStartNode);
-
- GraphNode from = (GraphNode) GraphElementFactory.createElement((String) labelFromArray.get(0),
- GraphElementTypeEnum.Node, propsFrom);
- GraphNode to = (GraphNode) GraphElementFactory.createElement((String) labelToArray.get(0),
- GraphElementTypeEnum.Node, propsTo);
-
- singleDataList.add(startN);
-
- GraphElement relationFromStartNode = GraphElementFactory.createRelation(type,
- propsRelationStartNode, startN, from);
- singleDataList.add(relationFromStartNode);
-
- singleDataList.add(from);
- singleDataList.add(to);
- // get only first type on relationship. Now single type
- // supported
- GraphElement newElement = GraphElementFactory.createRelation(type, propsRelation, from, to);
- singleDataList.add(newElement);
- }
- if (columns.size() == 8) {
-
- }
- }
- batchList.add(singleDataList);
- }
- return batchList;
- }
-
- private Map<String, Object> jsonObjectToMap(JSONObject node) {
- Map<String, Object> props = new HashMap<String, Object>();
-
- for (Map.Entry<String, Object> entry : (Set<Map.Entry<String, Object>>) node.entrySet()) {
- props.put(entry.getKey(), entry.getValue());
- }
- return props;
- }
-
- private String preparePropertiesInStatement(Map<String, Object> properties) {
- StringBuilder sb = new StringBuilder();
- int count = 0;
- int size = properties.entrySet().size();
- for (Map.Entry<String, Object> entry : properties.entrySet()) {
- sb.append("\"").append(entry.getKey()).append("\"").append(":");
- if (entry.getValue() instanceof String) {
- sb.append("\"");
- }
- sb.append(entry.getValue());
- if (entry.getValue() instanceof String) {
- sb.append("\"");
- }
- ++count;
- if (count < size) {
- sb.append(",");
- }
- }
- return sb.toString();
- }
-
- private Either<String, Neo4jOperationStatus> createNode(GraphElement element) {
- Either<String, Neo4jOperationStatus> status;
- if (element instanceof GraphNode) {
- GraphNode node = (GraphNode) element;
- String json = prepareCreateNodeBody(node);
-
- logger.debug("Try to save Node [{}] on graph", json);
-
- status = sendPostCypher(json);
-
- return status;
-
- } else {
- return Either.right(Neo4jOperationStatus.WRONG_INPUT);
- }
- }
-
- private Either<String, Neo4jOperationStatus> sendPostCypher(String json) {
- Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration().getNeo4j();
- String host = (String) neo4jParams.get("host");
- Integer port = (Integer) neo4jParams.get("port");
- String user = (String) neo4jParams.get("user");
- String password = (String) neo4jParams.get("password");
-
- String uri = CypherTemplates.CypherUrlTemplate.replace("$host$", host);
- uri = uri.replace("$port$", port.toString());
-
- HttpClientContext context = creatClientContext(host, user, password);
- CloseableHttpResponse response = null;
-
- HttpPost post = new HttpPost(uri);
- try {
- StringEntity input = new StringEntity(json);
- input.setContentType("application/json");
- post.setEntity(input);
-
- response = httpClient.execute(post, context);
-
- int status = response.getStatusLine().getStatusCode();
- String responseString;
- responseString = new BasicResponseHandler().handleResponse(response);
- logger.debug("response [{}]", responseString);
-
- if (status == 200 || status == 201) {
- logger.debug("cypher request [{}] was succeeded", json);
- Neo4jOperationStatus responseStatus = checkResponse(responseString);
- if (Neo4jOperationStatus.OK.equals(responseStatus)) {
- return Either.left(responseString);
- } else {
- return Either.right(responseStatus);
- }
- } else {
- logger.debug("cypher request [{}] was failed : [{}]", json, responseString);
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
-
- } catch (HttpResponseException e) {
- logger.debug("failed to perform cypher request [{}]", json, e);
- if (e.getStatusCode() == 401) {
- return Either.right(Neo4jOperationStatus.NOT_AUTHORIZED);
- } else {
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- }
- } catch (ClientProtocolException e) {
- logger.debug("failed to perform cypher request [{}]", json, e);
- return Either.right(Neo4jOperationStatus.HTTP_PROTOCOL_ERROR);
- } catch (IOException e) {
- logger.debug("failed to perform cypher request [{}]", json, e);
- return Either.right(Neo4jOperationStatus.NOT_CONNECTED);
- } finally {
- releaseResource(response);
- }
- }
-
- private Neo4jOperationStatus checkResponse(String responseString) {
- try {
- JSONObject response = (JSONObject) jsonParser.parse(responseString);
- JSONArray errors = (JSONArray) response.get("errors");
- if (errors.size() == 0) {
- return Neo4jOperationStatus.OK;
- } else {
- Iterator<JSONObject> iterator = errors.iterator();
- JSONObject error;
- while (iterator.hasNext()) {
- error = (JSONObject) iterator.next();
- String code = (String) error.get("code");
- String message = (String) error.get("message");
-
- Neo4jOperationStatus neoError = mapToNeoError(code, message);
- return neoError;
- }
- return Neo4jOperationStatus.GENERAL_ERROR;
- }
- } catch (ParseException e) {
- logger.error("Failed to parse response", e);
- return Neo4jOperationStatus.GENERAL_ERROR;
- }
- }
-
- private Neo4jOperationStatus mapToNeoError(String code, String message) {
- Neo4jOperationStatus error;
-
- String[] errorCode = code.split("\\.");
- if (errorCode.length < 4) {
- error = Neo4jOperationStatus.GENERAL_ERROR;
- } else {
- // by Classification
- switch (errorCode[1]) {
- case ClientError:
- // by Category
- switch (errorCode[2]) {
- case General:
- error = Neo4jOperationStatus.DB_READ_ONLY;
- break;
- case LegacyIndex:
- error = Neo4jOperationStatus.LEGACY_INDEX_ERROR;
- break;
- case Request:
- error = Neo4jOperationStatus.BAD_REQUEST;
- break;
- case Schema:
- if (errorCode[3].equals(ConstraintViolation)) {
- error = Neo4jOperationStatus.ENTITY_ALREADY_EXIST;
- } else {
- error = Neo4jOperationStatus.SCHEMA_ERROR;
- }
- break;
- case Security:
- error = Neo4jOperationStatus.NOT_AUTHORIZED;
- break;
- case Statement:
- // by Title
- if (errorCode[3].equals(EntityNotFound)) {
- error = Neo4jOperationStatus.NOT_FOUND;
- } else {
- if (errorCode[3].equals(ConstraintViolation)) {
- error = Neo4jOperationStatus.ENTITY_ALREADY_EXIST;
- } else {
- error = Neo4jOperationStatus.BAD_REQUEST;
- }
- }
- break;
- case Transaction:
- error = Neo4jOperationStatus.TRANSACTION_ERROR;
- break;
- default:
- error = Neo4jOperationStatus.GENERAL_ERROR;
- break;
- }
- break;
- case DatabaseError:
- // by Category
- switch (errorCode[2]) {
- case General:
- error = Neo4jOperationStatus.GENERAL_ERROR;
- break;
- case Schema:
- error = Neo4jOperationStatus.SCHEMA_ERROR;
- break;
- case Statement:
- error = Neo4jOperationStatus.EXECUTION_FAILED;
- break;
- case Transaction:
- error = Neo4jOperationStatus.TRANSACTION_ERROR;
- break;
- default:
- error = Neo4jOperationStatus.GENERAL_ERROR;
- break;
- }
- break;
- case TransientError:
- error = Neo4jOperationStatus.DB_NOT_AVAILABLE;
- break;
- default:
- error = Neo4jOperationStatus.GENERAL_ERROR;
- break;
- }
- error.setOriginError(code).setMessage(message);
- String errorFromCfg = code.replace(".", "_");
- String helpMessage = ConfigurationManager.getConfigurationManager().getNeo4jErrorsConfiguration()
- .getErrorMessage(errorFromCfg);
- if (helpMessage != null && !helpMessage.isEmpty()) {
- error.setHelpErrorMsg(helpMessage);
- }
- }
- return error;
- }
-
- private String prepareCreateNodeBody(GraphNode node) {
-
- String body = CypherTemplates.CypherCreateNodeTemplate.replace("$label$", node.getLabel());
-
- body = body.replace("$props$", DaoUtils.convertToJson(node.toGraphMap()));
-
- return body;
- }
-
- /**
- * the method returns all the indexes for the given label if no label is
- * supplied ( null or "") all indexes will be returned
- *
- * @param label
- * the name of the label
- * @param ip
- * @param user
- * @param password
- * @return a map of labels and there properties
- */
- public Either<Map<String, List<String>>, Neo4jOperationStatus> getIndexes(String label) {
- Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration().getNeo4j();
- String host = (String) neo4jParams.get("host");
- Integer port = (Integer) neo4jParams.get("port");
- String user = (String) neo4jParams.get("user");
- String password = (String) neo4jParams.get("password");
-
- String uri = null;
- if (label == null || "".equals(label)) {
- uri = CypherTemplates.getAllIndexsTemplate.replace("$host$", host);
- } else {
- uri = CypherTemplates.getAllIndexsTemplate.replace("$host$", host) + "/" + label;
- }
- uri = uri.replace("$port$", port.toString());
-
- HttpClientContext context = creatClientContext(host, user, password);
- CloseableHttpResponse response = null;
-
- HttpGet get = new HttpGet(uri);
- get.setHeader("Content-Type", "application/json");
- get.setHeader("Accept", "application/json; charset=UTF-8");
-
- try {
-
- response = httpClient.execute(get, context);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != 200) {
- logger.error("failed to get indexes requeste returned {}", statusCode);
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- } else {
- Map<String, List<String>> labels = getLeablesFromJson(response);
- return Either.left(labels);
- }
- } catch (Exception e) {
- logger.debug("failed to get indexes ", e);
- return Either.right(Neo4jOperationStatus.GENERAL_ERROR);
- } finally {
- releaseResource(response);
-
- }
-
- }
-
- private Map<String, List<String>> getLeablesFromJson(CloseableHttpResponse response)
- throws HttpResponseException, IOException, ParseException {
- Map<String, List<String>> labels = new HashMap<>();
- String responseString = new BasicResponseHandler().handleResponse(response);
- JSONArray results = (JSONArray) jsonParser.parse(responseString);
- Iterator<JSONObject> iteratorResults = results.iterator();
- while (iteratorResults.hasNext()) {
- JSONObject elementResult = iteratorResults.next();
- String label = (String) elementResult.get("label");
- List<String> props = labels.get(label);
- if (props == null) {
- props = new ArrayList<>();
- labels.put(label, props);
- }
- JSONArray properties = (JSONArray) elementResult.get("property_keys");
- Iterator<String> iterator = properties.iterator();
- while (iterator.hasNext()) {
- props.add(iterator.next());
- }
- }
- return labels;
- }
-
- public Neo4jOperationStatus createIndex(String label, List<String> propertyNames) {
-
- Neo4jOperationStatus result = Neo4jOperationStatus.OK;
- if (propertyNames != null && !propertyNames.isEmpty()) {
-
- Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getNeo4j();
- String host = (String) neo4jParams.get("host");
- Integer port = (Integer) neo4jParams.get("port");
- String user = (String) neo4jParams.get("user");
- String password = (String) neo4jParams.get("password");
-
- String uri = CypherTemplates.batchTemplate.replace("$host$", host);
- uri = uri.replace("$port$", port.toString());
-
- String opertionUri = "/schema/index/" + label;
-
- HttpClientContext context = creatClientContext(host, user, password);
-
- CloseableHttpResponse response = null;
-
- HttpPost post = new HttpPost(uri);
-
- String json = createBatchJson(HttpMethod.POST, opertionUri, propertyNames);
-
- try {
- StringEntity input = new StringEntity(json);
- input.setContentType("application/json");
- post.setEntity(input);
- response = httpClient.execute(post, context);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != 200) {
- logger.error("failed to create index for label [{}] with properties:{} requeste returned {}",label,propertyNames,statusCode);
- result = Neo4jOperationStatus.GENERAL_ERROR;
- } else {
- logger.debug("index for label [{}] with properties: {} created", label, propertyNames);
- }
- } catch (Exception e) {
- logger.debug("failed to create index for label [{}] with properties: {}", label, propertyNames);
- result = Neo4jOperationStatus.GENERAL_ERROR;
- } finally {
-
- releaseResource(response);
-
- }
-
- }
-
- else {
- logger.debug("no index was created for label :{} the recived propertyNames list: {} is invalide",label,propertyNames);
- return Neo4jOperationStatus.WRONG_INPUT;
- }
-
- return result;
- }
-
- public Neo4jOperationStatus createUniquenessConstraints(String label, List<String> propertyNames) {
- Neo4jOperationStatus result = Neo4jOperationStatus.OK;
- if (propertyNames != null && !propertyNames.isEmpty()) {
-
- Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getNeo4j();
- String host = (String) neo4jParams.get("host");
- Integer port = (Integer) neo4jParams.get("port");
- String user = (String) neo4jParams.get("user");
- String password = (String) neo4jParams.get("password");
-
- String uri = CypherTemplates.batchTemplate.replace("$host$", host);
- uri = uri.replace("$port$", port.toString());
-
- String opertionUri = "/schema/constraint/" + label + "/uniqueness/";
-
- HttpClientContext context = creatClientContext(host, user, password);
-
- CloseableHttpResponse response = null;
-
- HttpPost post = new HttpPost(uri);
-
- String json = createBatchJson(HttpMethod.POST, opertionUri, propertyNames);
-
- try {
- StringEntity input = new StringEntity(json);
- input.setContentType("application/json");
- post.setEntity(input);
- response = httpClient.execute(post, context);
-
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != 200) {
- logger.error("failed to create uniqueness constraint for label [{}] on properties:{}. request returned ",
- label,propertyNames,statusCode);
- result = Neo4jOperationStatus.GENERAL_ERROR;
- } else {
- logger.debug("uniqueness constraint for label [{}] on properties:{} created",label,propertyNames);
- }
- } catch (Exception e) {
- logger.error("failed to create uniqueness constraint [{}] with properties:{}",label,propertyNames,e);
- result = Neo4jOperationStatus.GENERAL_ERROR;
- } finally {
- releaseResource(response);
- }
-
- }
-
- else {
- logger.debug("no index was created for label :{} the recived propertyNames list: {} is invalide",label,propertyNames);
- return Neo4jOperationStatus.WRONG_INPUT;
- }
-
- return result;
- }
-
- public Neo4jOperationStatus deleteElement(GraphElementTypeEnum type, String label, MatchFilter filter) {
-
- String requestJson;
- // replace return type
- if (type.equals(GraphElementTypeEnum.Node)) {
- logger.debug("removing node label: {}", label);
- requestJson = createDeleteNodeStatment(label, filter);
-
- } else {
- logger.error(" delete on type {} is not yet supported", type);
- throw new RuntimeException(" delete on type " + type + " is not yet supported");
- }
-
- logger.debug("Try to perform request [{}]", requestJson);
-
- Either<String, Neo4jOperationStatus> status = sendPostCypher(requestJson);
- if (status.isRight()) {
- logger.error(" delete request failed with: {}", status.right());
- return Neo4jOperationStatus.GENERAL_ERROR;
- } else {
- return Neo4jOperationStatus.OK;
- }
- }
-
- public String getNeo4jVersion() throws Exception {
- Map<String, Object> neo4jParams = ConfigurationManager.getConfigurationManager().getConfiguration().getNeo4j();
- String host = (String) neo4jParams.get("host");
- Integer port = (Integer) neo4jParams.get("port");
- String user = (String) neo4jParams.get("user");
- String password = (String) neo4jParams.get("password");
-
- String uri = getServiceRoot.replace("$host$", host).replace("$port$", port.toString());
-
- HttpClientContext context = creatClientContext(host, user, password);
- CloseableHttpResponse response = null;
- String result = null;
-
- HttpGet get = new HttpGet(uri);
- get.setHeader("Content-Type", "application/json");
- get.setHeader("Accept", "application/json; charset=UTF-8");
-
- try {
- response = httpClient.execute(get, context);
- int statusCode = response.getStatusLine().getStatusCode();
- if (statusCode != 200) {
- throw new Exception("Couldn't get Neo4j service root, HTTP status " + statusCode);
- } else {
- // Parse response
- String responseString = new BasicResponseHandler().handleResponse(response);
- JSONObject responseData = (JSONObject) jsonParser.parse(responseString);
- Object obj = responseData.get("neo4j_version");
- if (obj != null) {
- result = (String) obj;
- }
- return result;
- }
- } finally {
- releaseResource(response);
- }
- }
-
- private String createDeleteNodeStatment(String label, MatchFilter filter) {
- String requestJson;
- requestJson = CypherTemplates.CypherDeleteNodeTemplate;
-
- if (label != null && !label.isEmpty()) {
- requestJson = requestJson.replace("$label$", label);
- } else {
- requestJson = requestJson.replace("$label$", "");
- }
-
- // replace filter
- if (filter.getProperties().isEmpty()) {
- // get all records by label
- requestJson = requestJson.replace("{$filter$}", "");
- } else {
- String filterStr = CypherTranslator.prepareFilterBody(filter);
- requestJson = requestJson.replace("$filter$", filterStr);
- }
- return requestJson;
- }
-
- /*
- * removed do to fortify scan CredentialsProvider cp = new
- * BasicCredentialsProvider(); cp.setCredentials(AuthScope.ANY, new
- * UsernamePasswordCredentials(user, password)); AuthCache authCache = new
- * BasicAuthCache(); BasicScheme basicAuth = new BasicScheme();
- * authCache.put(new HttpHost(ip, 7474, "http"), basicAuth);
- * context.setAuthCache(authCache); context.setCredentialsProvider(cp);
- *
- */
- private HttpClientContext creatClientContext(String ip, String user, String password) {
- HttpClientContext context = HttpClientContext.create();
-
- return context;
- }
-
- private void releaseResource(CloseableHttpResponse response) {
- if (response != null) {
- try {
- HttpEntity entity = response.getEntity();
- EntityUtils.consume(entity);
- response.close();
- } catch (Exception e) {
- logger.error("failed to close connection exception", e);
- }
- }
- }
-
- private String createBatchJson(HttpMethod method, String opertionUri, List<String> propertyNames) {
- StringBuilder sb = new StringBuilder();
- sb.append("[ ");
- for (int i = 0; i < propertyNames.size(); i++) {
- sb.append("{ \"method\" : \"" + method + "\" , \"to\" : \"" + opertionUri
- + "\" , \"body\" : { \"property_keys\" : [ \"" + propertyNames.get(i) + "\" ] } }");
- if (i + 1 < propertyNames.size()) {
- sb.append(",");
- }
- }
- sb.append(" ]");
- String json = sb.toString();
- return json;
- }
-
- enum HttpMethod {
- GET, PUT, POST, DELETE
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jEdge.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jEdge.java
deleted file mode 100644
index e8278a9a3e..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jEdge.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-import java.util.Map;
-
-import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum;
-
-public class Neo4jEdge {
-
- private GraphEdgeLabels edgeType;
- private Map<String, Object> properties;
- private ActionEnum action;
-
- public Neo4jEdge(GraphEdgeLabels edgeType, Map<String, Object> properties, ActionEnum actionEnum) {
- super();
- this.edgeType = edgeType;
- this.properties = properties;
- this.action = actionEnum;
- }
-
- public GraphEdgeLabels getEdgeType() {
- return edgeType;
- }
-
- public void setEdgeType(GraphEdgeLabels edgeType) {
- this.edgeType = edgeType;
- }
-
- public Map<String, Object> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, Object> properties) {
- this.properties = properties;
- }
-
- public ActionEnum getAction() {
- return action;
- }
-
- public void setAction(ActionEnum action) {
- this.action = action;
- }
-
- @Override
- public String toString() {
- return "Neo4jEdge [edgeType=" + edgeType + ", properties=" + properties + ", action=" + action + "]";
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jGraphBatchBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jGraphBatchBuilder.java
deleted file mode 100644
index 5a6a8fdade..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jGraphBatchBuilder.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.openecomp.sdc.be.dao.graph.datatype.ActionEnum;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
-import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import fj.data.Either;
-
-public class Neo4jGraphBatchBuilder {
-
- private static Logger logger = LoggerFactory.getLogger(Neo4jGraphBatchBuilder.class.getName());
-
- public Either<BatchBuilder, Neo4jOperationStatus> buildBatchBuilderFromTable(
- GraphNeighbourTable graphNeighbourTable) {
-
- logger.debug("The table sent in order to build BatchBuilder is {}", graphNeighbourTable);
-
- List<GraphNode> nodes = graphNeighbourTable.getNodes();
- if (nodes != null && nodes.size() > 0) {
- List<NodeRelation> directedEdges = graphNeighbourTable.getDirectedEdges();
-
- List<RelationEndPoint> relationEndPoints = new ArrayList<RelationEndPoint>(nodes.size());
- Set<Integer> nodesInRelations = findDistinctNodesIndex(directedEdges);
-
- buildRelationEndPoints(nodes, nodesInRelations, relationEndPoints);
-
- BatchBuilder batchBuilder = BatchBuilder.getBuilder();
-
- for (GraphElement neo4jElement : nodes) {
- if (neo4jElement.getAction() != ActionEnum.Delete) {
- logger.debug("Goint to add node {} to batch builder.", neo4jElement);
- batchBuilder.add(neo4jElement);
- }
- }
-
- if (directedEdges != null) {
- for (NodeRelation nodeRelation : directedEdges) {
- GraphRelation relation = buildNeo4jRelation(relationEndPoints, nodeRelation);
- logger.debug("Goint to add relation {} to batch builder.", relation);
- batchBuilder.add(relation);
- }
- }
-
- for (GraphElement neo4jElement : nodes) {
- if (neo4jElement.getAction() == ActionEnum.Delete) {
- logger.debug("Goint to add node {} to batch builder.", neo4jElement);
- batchBuilder.add(neo4jElement);
- }
- }
-
- return Either.left(batchBuilder);
-
- } else {
- logger.error("No node was sent in order to create the resource.");
- return Either.right(Neo4jOperationStatus.BAD_REQUEST);
- }
- }
-
- private Pair<String, String> getUniqueIdKeyValue(GraphNode neo4jNode) {
-
- // String label = neo4jNode.getLabel();
- // NodeTypeEnum nodeTypeEnum = NodeTypeEnum.getByName(label);
- //
- return Pair.createPair(neo4jNode.getUniqueIdKey(), neo4jNode.getUniqueId().toString());
- }
-
- private Set<Integer> findDistinctNodesIndex(List<NodeRelation> directedEdges) {
-
- HashSet<Integer> nodesIndex = new HashSet<Integer>();
-
- if (directedEdges != null) {
- for (NodeRelation nodeRelation : directedEdges) {
- nodesIndex.add(nodeRelation.getFromIndex());
- nodesIndex.add(nodeRelation.getToIndex());
- }
- }
-
- return nodesIndex;
- }
-
- private String findResourceDataIdFromNodes(List<GraphNode> nodes) {
-
- if (nodes != null) {
-
- for (GraphNode neo4jNode : nodes) {
- String label = neo4jNode.getLabel();
- if (label.equals(NodeTypeEnum.Resource.getName())) {
- return neo4jNode.getUniqueId().toString();
- }
- }
- }
-
- return null;
- }
-
- private GraphRelation buildNeo4jRelation(List<RelationEndPoint> relationEndPoints, NodeRelation nodeRelation) {
- GraphRelation relation = new GraphRelation();
- int fromIndex = nodeRelation.getFromIndex();
- int toIndex = nodeRelation.getToIndex();
- Neo4jEdge neo4jEdge = nodeRelation.getEdge();
- relation.setFrom(relationEndPoints.get(fromIndex));
- relation.setTo(relationEndPoints.get(toIndex));
- relation.setType(neo4jEdge.getEdgeType().getProperty());
-
- // TODO: fix it after change
- Map<String, Object> edgeProps = neo4jEdge.getProperties();
- if (edgeProps != null && false == edgeProps.isEmpty()) {
- relation.addPropertis(edgeProps);
- }
-
- relation.setAction(neo4jEdge.getAction());
- return relation;
- }
-
- private void buildRelationEndPoints(List<GraphNode> nodes, Set<Integer> nodesInRelations,
- List<RelationEndPoint> relationEndPoints) {
-
- if (nodesInRelations != null) {
- for (Integer nodeIndex : nodesInRelations) {
-
- GraphElement neo4jElement = nodes.get(nodeIndex);
- GraphNode neo4jNode = (GraphNode) neo4jElement;
- String label = neo4jNode.getLabel();
- Pair<String, String> uniqueKeyValue = getUniqueIdKeyValue(neo4jNode);
-
- RelationEndPoint endPoint = new RelationEndPoint(NodeTypeEnum.getByName(label), uniqueKeyValue.getKey(),
- uniqueKeyValue.getValue());
- relationEndPoints.add(nodeIndex, endPoint);
-
- }
- }
-
- }
-
- public static class Pair<K, V> {
-
- private final K key;
- private final V value;
-
- public static <K, V> Pair<K, V> createPair(K key, V value) {
- return new Pair<K, V>(key, value);
- }
-
- public Pair(K key, V value) {
- this.key = key;
- this.value = value;
- }
-
- public K getKey() {
- return key;
- }
-
- public V getValue() {
- return value;
- }
-
- }
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jOperationStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jOperationStatus.java
deleted file mode 100644
index 154449b521..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/Neo4jOperationStatus.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-public enum Neo4jOperationStatus {
-
- OK, NOT_CONNECTED, NOT_AUTHORIZED, HTTP_PROTOCOL_ERROR, DB_NOT_AVAILABLE, DB_READ_ONLY, BAD_REQUEST, LEGACY_INDEX_ERROR, SCHEMA_ERROR, TRANSACTION_ERROR, EXECUTION_FAILED, ENTITY_ALREADY_EXIST,
-
- WRONG_INPUT, GENERAL_ERROR, NOT_SUPPORTED, NOT_FOUND;
-
- private String originError;
- private String message;
- private String helpErrorMsg;
-
- private static final String NA = "NA";
-
- Neo4jOperationStatus() {
- originError = NA;
- message = NA;
- helpErrorMsg = NA;
- }
-
- public Neo4jOperationStatus setOriginError(String originError) {
- this.originError = originError;
- return this;
- }
-
- public Neo4jOperationStatus setMessage(String message) {
- if (message != null && !message.isEmpty()) {
- this.message = message;
- }
- return this;
- }
-
- public Neo4jOperationStatus setHelpErrorMsg(String helpErrorMsg) {
- this.helpErrorMsg = helpErrorMsg;
- return this;
- }
-
- public String getOriginError() {
- return originError;
- }
-
- public String getMessage() {
- return message;
- }
-
- public String getHelpErrorMsg() {
- return helpErrorMsg;
- }
-
- public String printError() {
- StringBuilder sb = new StringBuilder();
- sb.append("[").append(toString()).append("-").append(originError).append("-").append(helpErrorMsg).append("-")
- .append(message).append("]");
- return sb.toString();
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/NodeRelation.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/NodeRelation.java
deleted file mode 100644
index c1402f402f..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/NodeRelation.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j;
-
-public class NodeRelation {
-
- private int fromIndex;
- private int toIndex;
- private Neo4jEdge edge;
-
- public NodeRelation(int fromIndex, int toIndex, Neo4jEdge edge) {
- super();
- this.fromIndex = fromIndex;
- this.toIndex = toIndex;
- this.edge = edge;
- }
-
- public int getFromIndex() {
- return fromIndex;
- }
-
- public void setFromIndex(int fromIndex) {
- this.fromIndex = fromIndex;
- }
-
- public int getToIndex() {
- return toIndex;
- }
-
- public void setToIndex(int toIndex) {
- this.toIndex = toIndex;
- }
-
- public Neo4jEdge getEdge() {
- return edge;
- }
-
- public void setEdge(Neo4jEdge edge) {
- this.edge = edge;
- }
-
- @Override
- public String toString() {
- return "NodeRelation [fromIndex=" + fromIndex + ", toIndex=" + toIndex + ", edge=" + edge + "]";
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilter.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilter.java
deleted file mode 100644
index 10e93c1f56..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class MatchFilter {
- private Map<String, Object> toMatchProperties;
-
- public MatchFilter() {
- toMatchProperties = new HashMap<String, Object>();
- }
-
- public MatchFilter(Map<String, Object> toMatchProperties) {
- super();
- this.toMatchProperties = toMatchProperties;
- }
-
- public Map<String, Object> getProperties() {
- return toMatchProperties;
- }
-
- public void setProperties(Map<String, Object> properties) {
- this.toMatchProperties = properties;
- }
-
- public MatchFilter addToMatch(String propName, Object value) {
- toMatchProperties.put(propName, value);
- return this;
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilter.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilter.java
deleted file mode 100644
index 698077d45b..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
-public class RecursiveByRelationFilter extends RecursiveFilter {
-
- private GraphNode node;
- private String relationType;
-
- public RecursiveByRelationFilter() {
- super();
- }
-
- public RecursiveByRelationFilter(NodeTypeEnum nodeType, GraphNode node) {
- super(nodeType);
- this.node = node;
- }
-
- public RecursiveByRelationFilter(NodeTypeEnum nodeType) {
- super(nodeType);
- }
-
- public RecursiveByRelationFilter(NodeTypeEnum nodeType, GraphNode node, String relationType) {
- super(nodeType);
- this.node = node;
- this.relationType = relationType;
- }
-
- public RecursiveByRelationFilter addNode(GraphNode node) {
- this.node = node;
- return this;
- }
-
- public RecursiveByRelationFilter addRelation(String relationType) {
- this.relationType = relationType;
- return this;
- }
-
- public GraphNode getNode() {
- return node;
- }
-
- public void setNode(GraphNode node) {
- this.node = node;
- }
-
- public String getRelationType() {
- return relationType;
- }
-
- public void setRelationType(String relationType) {
- this.relationType = relationType;
- }
-
- @Override
- public String toString() {
- return "RecursiveByRelationFilter [node=" + node + ", relationType=" + relationType + "]";
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilter.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilter.java
deleted file mode 100644
index fa78539f8f..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
-public class RecursiveFilter extends MatchFilter {
-
- private List<String> childRelationTypes;
- NodeTypeEnum nodeType;
-
- public RecursiveFilter() {
- childRelationTypes = new ArrayList<String>();
- }
-
- public RecursiveFilter(NodeTypeEnum nodeType) {
- childRelationTypes = new ArrayList<String>();
- this.nodeType = nodeType;
- }
-
- public RecursiveFilter addChildRelationType(String type) {
- childRelationTypes.add(type);
- return this;
- }
-
- public List<String> getChildRelationTypes() {
- return childRelationTypes;
- }
-
- public void setChildRelationTypes(List<String> childRelationTypes) {
- this.childRelationTypes = childRelationTypes;
- }
-
- public NodeTypeEnum getNodeType() {
- return nodeType;
- }
-
- public void setNodeType(NodeTypeEnum nodeType) {
- this.nodeType = nodeType;
- }
-
- @Override
- public String toString() {
- return "RecursiveFilter [childRelationTypes=" + childRelationTypes + ", nodeType=" + nodeType + "]";
- }
-
-}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilter.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilter.java
deleted file mode 100644
index 3abfdeb70e..0000000000
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class UpdateFilter extends MatchFilter {
-
- private Map<String, Object> toUpdate;
-
- public UpdateFilter(Map<String, Object> toUpdate) {
- super();
- this.toUpdate = toUpdate;
- }
-
- public UpdateFilter() {
- super();
- toUpdate = new HashMap<String, Object>();
- }
-
- public UpdateFilter(Map<String, Object> toMatch, Map<String, Object> toUpdate) {
- super(toMatch);
- this.toUpdate = toUpdate;
- }
-
- public Map<String, Object> getToUpdate() {
- return toUpdate;
- }
-
- public void setToUpdate(Map<String, Object> toUpdate) {
- this.toUpdate = toUpdate;
- }
-
- public void addToUpdate(String property, Object value) {
- toUpdate.put(property, value);
- }
-}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilterTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilterTest.java
deleted file mode 100644
index 529f642fb2..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/MatchFilterTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import java.util.Map;
-
-import javax.annotation.Generated;
-
-import org.junit.Test;
-
-
-public class MatchFilterTest {
-
- private MatchFilter createTestSubject() {
- return new MatchFilter();
- }
-
-
- @Test
- public void testGetProperties() throws Exception {
- MatchFilter testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getProperties();
- }
-
-
- @Test
- public void testSetProperties() throws Exception {
- MatchFilter testSubject;
- Map<String, Object> properties = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setProperties(properties);
- }
-
-
- @Test
- public void testAddToMatch() throws Exception {
- MatchFilter testSubject;
- String propName = "";
- Object value = null;
- MatchFilter result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addToMatch(propName, value);
- }
-} \ No newline at end of file
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilterTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilterTest.java
deleted file mode 100644
index 76b36d2a97..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveByRelationFilterTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import javax.annotation.Generated;
-
-import org.junit.Test;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-
-
-public class RecursiveByRelationFilterTest {
-
- private RecursiveByRelationFilter createTestSubject() {
- return new RecursiveByRelationFilter();
- }
-
-
- @Test
- public void testAddNode() throws Exception {
- RecursiveByRelationFilter testSubject;
- GraphNode node = null;
- RecursiveByRelationFilter result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addNode(node);
- }
-
-
- @Test
- public void testAddRelation() throws Exception {
- RecursiveByRelationFilter testSubject;
- String relationType = "";
- RecursiveByRelationFilter result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addRelation(relationType);
- }
-
-
- @Test
- public void testGetNode() throws Exception {
- RecursiveByRelationFilter testSubject;
- GraphNode result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getNode();
- }
-
-
- @Test
- public void testSetNode() throws Exception {
- RecursiveByRelationFilter testSubject;
- GraphNode node = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setNode(node);
- }
-
-
- @Test
- public void testGetRelationType() throws Exception {
- RecursiveByRelationFilter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getRelationType();
- }
-
-
- @Test
- public void testSetRelationType() throws Exception {
- RecursiveByRelationFilter testSubject;
- String relationType = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setRelationType(relationType);
- }
-
-
- @Test
- public void testToString() throws Exception {
- RecursiveByRelationFilter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
-} \ No newline at end of file
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilterTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilterTest.java
deleted file mode 100644
index 990a2b4972..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/RecursiveFilterTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import java.util.List;
-
-import javax.annotation.Generated;
-
-import org.junit.Test;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
-
-public class RecursiveFilterTest {
-
- private RecursiveFilter createTestSubject() {
- return new RecursiveFilter();
- }
-
-
- @Test
- public void testAddChildRelationType() throws Exception {
- RecursiveFilter testSubject;
- String type = "";
- RecursiveFilter result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.addChildRelationType(type);
- }
-
-
- @Test
- public void testGetChildRelationTypes() throws Exception {
- RecursiveFilter testSubject;
- List<String> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getChildRelationTypes();
- }
-
-
- @Test
- public void testSetChildRelationTypes() throws Exception {
- RecursiveFilter testSubject;
- List<String> childRelationTypes = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setChildRelationTypes(childRelationTypes);
- }
-
-
- @Test
- public void testGetNodeType() throws Exception {
- RecursiveFilter testSubject;
- NodeTypeEnum result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getNodeType();
- }
-
-
- @Test
- public void testSetNodeType() throws Exception {
- RecursiveFilter testSubject;
- NodeTypeEnum nodeType = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setNodeType(nodeType);
- }
-
-
- @Test
- public void testToString() throws Exception {
- RecursiveFilter testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.toString();
- }
-} \ No newline at end of file
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilterTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilterTest.java
deleted file mode 100644
index 55a9255d31..0000000000
--- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/neo4j/filters/UpdateFilterTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.openecomp.sdc.be.dao.neo4j.filters;
-
-import java.util.Map;
-
-import javax.annotation.Generated;
-
-import org.junit.Test;
-
-
-public class UpdateFilterTest {
-
- private UpdateFilter createTestSubject() {
- return new UpdateFilter(null);
- }
-
-
- @Test
- public void testGetToUpdate() throws Exception {
- UpdateFilter testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getToUpdate();
- }
-
-
- @Test
- public void testSetToUpdate() throws Exception {
- UpdateFilter testSubject;
- Map<String, Object> toUpdate = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setToUpdate(toUpdate);
- }
-
-
-
-} \ No newline at end of file
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverter.java
deleted file mode 100644
index 55531fec79..0000000000
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverter.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.model.operations.impl;
-
-import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-
-public class Neo4jStatusConverter {
-
- public static StorageOperationStatus convertNeo4jStatusToStorageStatus(Neo4jOperationStatus neo4jStatus) {
-
- if (neo4jStatus == null) {
- return StorageOperationStatus.GENERAL_ERROR;
- }
-
- switch (neo4jStatus) {
-
- case OK:
- return StorageOperationStatus.OK;
-
- case NOT_CONNECTED:
- return StorageOperationStatus.CONNECTION_FAILURE;
-
- case NOT_AUTHORIZED:
- return StorageOperationStatus.PERMISSION_ERROR;
-
- case HTTP_PROTOCOL_ERROR:
- return StorageOperationStatus.HTTP_PROTOCOL_ERROR;
- case DB_NOT_AVAILABLE:
- return StorageOperationStatus.STORAGE_NOT_AVAILABLE;
- case DB_READ_ONLY:
- return StorageOperationStatus.READ_ONLY_STORAGE;
- case BAD_REQUEST:
- return StorageOperationStatus.BAD_REQUEST;
- case LEGACY_INDEX_ERROR:
- return StorageOperationStatus.STORAGE_LEGACY_INDEX_ERROR;
- case SCHEMA_ERROR:
- return StorageOperationStatus.SCHEMA_ERROR;
- case TRANSACTION_ERROR:
- return StorageOperationStatus.TRANSACTION_ERROR;
- case EXECUTION_FAILED:
- return StorageOperationStatus.EXEUCTION_FAILED;
- case ENTITY_ALREADY_EXIST:
- return StorageOperationStatus.ENTITY_ALREADY_EXISTS;
- case WRONG_INPUT:
- return StorageOperationStatus.BAD_REQUEST;
- case GENERAL_ERROR:
- return StorageOperationStatus.GENERAL_ERROR;
- case NOT_SUPPORTED:
- return StorageOperationStatus.OPERATION_NOT_SUPPORTED;
- case NOT_FOUND:
- return StorageOperationStatus.NOT_FOUND;
-
- default:
- return StorageOperationStatus.GENERAL_ERROR;
- }
-
- }
-
-}