summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/crud/service
diff options
context:
space:
mode:
authorGurjeet Bedi <gurjeetb@amdocs.com>2018-01-31 15:05:30 -0500
committerGurjeet Bedi <gurjeetb@amdocs.com>2018-01-31 15:19:18 -0500
commit74879a7b7a5607c89aef5fa9d64aca5ddea8e3b7 (patch)
tree051004369efcf083980116201116de438a938567 /src/main/java/org/onap/crud/service
parent1bb61ff3e013bcd41beffc5d9f01964f422f8a9e (diff)
Config to be able to route GET through datarouter
Option to route GET through data router Issue-ID: AAI-482 Change-Id: I6b9a3621d5e3a5ec83d69a948917865941ede833 Signed-off-by: Gurjeet Bedi <gurjeetb@amdocs.com>
Diffstat (limited to 'src/main/java/org/onap/crud/service')
-rw-r--r--src/main/java/org/onap/crud/service/AbstractGraphDataService.java18
-rw-r--r--src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java12
-rw-r--r--src/main/java/org/onap/crud/service/CrudGraphDataService.java17
3 files changed, 30 insertions, 17 deletions
diff --git a/src/main/java/org/onap/crud/service/AbstractGraphDataService.java b/src/main/java/org/onap/crud/service/AbstractGraphDataService.java
index 1163623..5ad4b7d 100644
--- a/src/main/java/org/onap/crud/service/AbstractGraphDataService.java
+++ b/src/main/java/org/onap/crud/service/AbstractGraphDataService.java
@@ -44,45 +44,44 @@ import org.onap.schema.RelationshipSchemaValidator;
import com.google.gson.JsonElement;
public abstract class AbstractGraphDataService {
+ protected GraphDao daoForGet;
protected GraphDao dao;
- public AbstractGraphDataService(GraphDao dao) throws CrudException {
- this.dao = dao;
-
+ public AbstractGraphDataService() throws CrudException {
CrudServiceUtil.loadModels();
}
public String getEdge(String version, String id, String type) throws CrudException {
RelationshipSchemaValidator.validateType(version, type);
- Edge edge = dao.getEdge(id, type);
+ Edge edge = daoForGet.getEdge(id, type);
return CrudResponseBuilder.buildGetEdgeResponse(RelationshipSchemaValidator.validateOutgoingPayload(version, edge), version);
}
public String getEdges(String version, String type, Map<String, String> filter) throws CrudException {
RelationshipSchemaValidator.validateType(version, type);
- List<Edge> items = dao.getEdges(type, RelationshipSchemaValidator.resolveCollectionfilter(version, type, filter));
+ List<Edge> items = daoForGet.getEdges(type, RelationshipSchemaValidator.resolveCollectionfilter(version, type, filter));
return CrudResponseBuilder.buildGetEdgesResponse(items, version);
}
public String getVertex(String version, String id, String type) throws CrudException {
type = OxmModelValidator.resolveCollectionType(version, type);
- Vertex vertex = dao.getVertex(id, type, version);
- List<Edge> edges = dao.getVertexEdges(id);
+ Vertex vertex = daoForGet.getVertex(id, type, version);
+ List<Edge> edges = daoForGet.getVertexEdges(id);
return CrudResponseBuilder.buildGetVertexResponse(OxmModelValidator.validateOutgoingPayload(version, vertex), edges,
version);
}
public String getVertices(String version, String type, Map<String, String> filter, HashSet<String> properties) throws CrudException {
type = OxmModelValidator.resolveCollectionType(version, type);
- List<Vertex> items = dao.getVertices(type, OxmModelValidator.resolveCollectionfilter(version, type, filter), properties);
+ List<Vertex> items = daoForGet.getVertices(type, OxmModelValidator.resolveCollectionfilter(version, type, filter), properties);
return CrudResponseBuilder.buildGetVerticesResponse(items, version);
}
public String addBulk(String version, BulkPayload payload, HttpHeaders headers) throws CrudException {
HashMap<String, Vertex> vertices = new HashMap<String, Vertex>();
HashMap<String, Edge> edges = new HashMap<String, Edge>();
-
+
String txId = dao.openTransaction();
try {
@@ -269,4 +268,5 @@ public abstract class AbstractGraphDataService {
protected abstract Edge addBulkEdge(Edge edge, String version, String dbTransId) throws CrudException;
protected abstract Edge updateBulkEdge(Edge edge, String version, String dbTransId) throws CrudException;
protected abstract void deleteBulkEdge(String id, String version, String type, String dbTransId) throws CrudException;
+
}
diff --git a/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java b/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
index b3e7551..5e264b5 100644
--- a/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
+++ b/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
@@ -84,12 +84,21 @@ public class CrudAsyncGraphDataService extends AbstractGraphDataService {
public static Integer getRequestTimeOut() {
return requestTimeOut;
}
+
+ public CrudAsyncGraphDataService(GraphDao dao,
+ EventPublisher asyncRequestPublisher,
+ EventConsumer asyncResponseConsumer) throws CrudException {
+ this(dao,dao,asyncRequestPublisher,asyncResponseConsumer);
+ }
public CrudAsyncGraphDataService(GraphDao dao,
+ GraphDao daoForGet,
EventPublisher asyncRequestPublisher,
EventConsumer asyncResponseConsumer) throws CrudException {
- super(dao);
+ super();
+ this.dao = dao;
+ this.daoForGet = daoForGet;
requestTimeOut = DEFAULT_REQUEST_TIMEOUT;
try {
@@ -443,5 +452,4 @@ public class CrudAsyncGraphDataService extends AbstractGraphDataService {
+ " , operation: " + event.getOperation().toString() + " , result: "
+ response.getResult() + " , error: " + response.getErrorMessage());
}
-
} \ No newline at end of file
diff --git a/src/main/java/org/onap/crud/service/CrudGraphDataService.java b/src/main/java/org/onap/crud/service/CrudGraphDataService.java
index 61550b2..3eeac3f 100644
--- a/src/main/java/org/onap/crud/service/CrudGraphDataService.java
+++ b/src/main/java/org/onap/crud/service/CrudGraphDataService.java
@@ -35,9 +35,18 @@ import org.onap.schema.RelationshipSchemaValidator;
public class CrudGraphDataService extends AbstractGraphDataService {
-
+
+
public CrudGraphDataService(GraphDao dao) throws CrudException {
- super(dao);
+ super();
+ this.dao = dao;
+ this.daoForGet = dao;
+ }
+
+ public CrudGraphDataService(GraphDao dao, GraphDao daoForGet) throws CrudException {
+ super();
+ this.dao = dao;
+ this.daoForGet = daoForGet;
}
public String addVertex(String version, String type, VertexPayload payload) throws CrudException {
@@ -112,10 +121,6 @@ public class CrudGraphDataService extends AbstractGraphDataService {
}
- public Vertex getVertex(String id, String version) throws CrudException {
- return dao.getVertex(id, version);
- }
-
@Override
protected Vertex addBulkVertex(Vertex vertex, String version, String dbTransId) throws CrudException {
return dao.addVertex(vertex.getType(), vertex.getProperties(), version, dbTransId);