summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authormichaere <michaere@amdocs.com>2018-08-01 17:41:00 +0100
committermichaere <michaere@amdocs.com>2018-08-01 17:41:00 +0100
commitd8bd36e376d17c8d1fc13cc8b5ba00708c3b6673 (patch)
tree9ad542c02279016635aeea1f491c40cdacab228c /src/main/java/org
parent3bc6a702f2d3d8710c7aaa94cdc8c0ccf3deb759 (diff)
Re-enable vertex edges retrieval for bulk
Following changes to champ to retrieve edges in context of transaction for bulk. This issue was caused as a result of multiplicity rules check. Issue-ID: AAI-1439 Change-Id: If68efa4b531644bf4297b08f566b18b5bd21c2b8 Signed-off-by: michaere <michaere@amdocs.com>
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/onap/crud/service/AbstractGraphDataService.java31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/main/java/org/onap/crud/service/AbstractGraphDataService.java b/src/main/java/org/onap/crud/service/AbstractGraphDataService.java
index 59046ab..db4c4d8 100644
--- a/src/main/java/org/onap/crud/service/AbstractGraphDataService.java
+++ b/src/main/java/org/onap/crud/service/AbstractGraphDataService.java
@@ -236,41 +236,26 @@ public abstract class AbstractGraphDataService {
if (edgePayload.getType() == null || edgePayload.getType().isEmpty()) {
edgePayload.setType(CrudServiceUtil.determineEdgeType(edgePayload, version));
}
-
- // TODO: Champ needs to support getting an object's relationships within the context of an existing transaction.
- // Currently it doesn't. Disabling multiplicity check until this happens.
-
- List<Edge> sourceVertexEdges = new ArrayList<Edge>();
- List<Edge> targetVertexEdges = new ArrayList<Edge>();
-
- /*
+
List<Edge> sourceVertexEdges =
EdgePayloadUtil.filterEdgesByRelatedVertexAndType(EdgePayloadUtil.getVertexNodeType(edgePayload.getSource()), edgePayload.getType(),
dao.getVertexEdges(EdgePayloadUtil.getVertexNodeId(edgePayload.getSource()), null, txId));
-
+
List<Edge> targetVertexEdges =
EdgePayloadUtil.filterEdgesByRelatedVertexAndType(EdgePayloadUtil.getVertexNodeType(edgePayload.getTarget()), edgePayload.getType(),
dao.getVertexEdges(EdgePayloadUtil.getVertexNodeId(edgePayload.getTarget()), null, txId));
- */
-
+
validatedEdge = RelationshipSchemaValidator.validateIncomingAddPayload(version, edgePayload.getType(), edgePayload, sourceVertexEdges,
targetVertexEdges);
persistedEdge = addBulkEdge(validatedEdge, version, txId);
} else if (opr.getValue().getAsString().equalsIgnoreCase("modify")) {
Edge edge = dao.getEdge(edgePayload.getId(), txId);
-
+
// If the type isn't set, resolve it based on on the sourece and target vertex types
if (edgePayload.getType() == null || edgePayload.getType().isEmpty()) {
edgePayload.setType(edge.getType());
}
- // TODO: Champ needs to support getting an object's relationships within the context of an existing transaction.
- // Currently it doesn't. Disabling multiplicity check until this happens.
-
- List<Edge> sourceVertexEdges = new ArrayList<Edge>();
- List<Edge> targetVertexEdges = new ArrayList<Edge>();
-
- /*
// load source and target vertex relationships for validation
List<Edge> sourceVertexEdges =
EdgePayloadUtil.filterEdgesByRelatedVertexAndType(EdgePayloadUtil.getVertexNodeType(edgePayload.getSource()), edgePayload.getType(),
@@ -279,8 +264,8 @@ public abstract class AbstractGraphDataService {
List<Edge> targetVertexEdges =
EdgePayloadUtil.filterEdgesByRelatedVertexAndType(EdgePayloadUtil.getVertexNodeType(edgePayload.getTarget()), edgePayload.getType(),
dao.getVertexEdges(EdgePayloadUtil.getVertexNodeId(edgePayload.getTarget()), null, txId));
- */
-
+
+
validatedEdge = RelationshipSchemaValidator.validateIncomingUpdatePayload(edge, version, edgePayload, edgePayload.getType(), sourceVertexEdges, targetVertexEdges);
persistedEdge = updateBulkEdge(validatedEdge, version, txId);
} else {
@@ -288,12 +273,12 @@ public abstract class AbstractGraphDataService {
throw new CrudException("id must be specified for patch request", Status.BAD_REQUEST);
}
Edge existingEdge = dao.getEdge(edgePayload.getId(), txId);
-
+
// If the type isn't set, resolve it based on on the sourece and target vertex types
if (edgePayload.getType() == null || edgePayload.getType().isEmpty()) {
edgePayload.setType(existingEdge.getType());
}
-
+
Edge patchedEdge = RelationshipSchemaValidator.validateIncomingPatchPayload(existingEdge, version, edgePayload);
persistedEdge = updateBulkEdge(patchedEdge, version, txId);
}