summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
diff options
context:
space:
mode:
authormichaere <michaere@amdocs.com>2018-06-27 09:51:34 +0100
committermichaere <michaere@amdocs.com>2018-06-27 09:51:34 +0100
commitd10a218c76633374f083f7a2802c198e93a6abae (patch)
tree7c68c359600270f4f6eb1290bd34093c386d5d23 /src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
parent68cd3355674d66f8feee3d067960c081581a3911 (diff)
Apply multiplicity Rule upon Edge creation
Uses multiplicity type from dbedge rules json to validate whether to and from vertices meet the multiplicity constraint e.g. ONE2MANY. This validation is applied when creating or updating an edge. Issue-ID: AAI-1197 Change-Id: Id6e78635c5cbea66d8a35e6901b7e1b673125e4e Signed-off-by: michaere <michaere@amdocs.com>
Diffstat (limited to 'src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java')
-rw-r--r--src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java b/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
index 6b447a1..c2d2591 100644
--- a/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
+++ b/src/main/java/org/onap/crud/service/CrudAsyncGraphDataService.java
@@ -56,11 +56,13 @@ import org.onap.crud.event.envelope.GraphEventEnvelope;
import org.onap.crud.event.response.GraphEventResponseHandler;
import org.onap.crud.exception.CrudException;
import org.onap.crud.logging.CrudServiceMsgs;
+import org.onap.crud.parser.EdgePayload;
+import org.onap.crud.parser.VertexPayload;
import org.onap.crud.util.CrudProperties;
import org.onap.crud.util.CrudServiceConstants;
import org.onap.crud.util.etag.EtagGenerator;
-import org.onap.schema.OxmModelValidator;
-import org.onap.schema.RelationshipSchemaValidator;
+import org.onap.schema.validation.OxmModelValidator;
+import org.onap.schema.validation.RelationshipSchemaValidator;
public class CrudAsyncGraphDataService extends AbstractGraphDataService {
@@ -211,7 +213,7 @@ public class CrudAsyncGraphDataService extends AbstractGraphDataService {
throws CrudException {
// Validate the incoming payload
Vertex vertex = OxmModelValidator.validateIncomingUpsertPayload(null, version, type, payload.getProperties());
- vertex.getProperties().put(org.onap.schema.OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
+ vertex.getProperties().put(OxmModelValidator.Metadata.NODE_TYPE.propertyName(), type);
// Create graph request event
GraphEvent event = GraphEvent.builder(GraphEventOperation.CREATE)
.vertex(GraphEventVertex.fromVertex(vertex, version)).build();
@@ -233,6 +235,7 @@ public class CrudAsyncGraphDataService extends AbstractGraphDataService {
public ImmutablePair<EntityTag, String> addEdge(String version, String type, EdgePayload payload)
throws CrudException {
Edge edge = RelationshipSchemaValidator.validateIncomingAddPayload(version, type, payload);
+
// Create graph request event
GraphEvent event =
GraphEvent.builder(GraphEventOperation.CREATE).edge(GraphEventEdge.fromEdge(edge, version)).build();
@@ -320,6 +323,7 @@ public class CrudAsyncGraphDataService extends AbstractGraphDataService {
OperationResult operationResult = dao.getEdge(id, type, new HashMap<String, String>());
Edge edge = Edge.fromJson(operationResult.getResult());
Edge validatedEdge = RelationshipSchemaValidator.validateIncomingUpdatePayload(edge, version, payload);
+
GraphEvent event = GraphEvent.builder(GraphEventOperation.UPDATE)
.edge(GraphEventEdge.fromEdge(validatedEdge, version)).build();