summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/crud/service/AaiResourceService.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/AaiResourceService.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/AaiResourceService.java')
-rw-r--r--src/main/java/org/onap/crud/service/AaiResourceService.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/main/java/org/onap/crud/service/AaiResourceService.java b/src/main/java/org/onap/crud/service/AaiResourceService.java
index afabe7e..c0375b4 100644
--- a/src/main/java/org/onap/crud/service/AaiResourceService.java
+++ b/src/main/java/org/onap/crud/service/AaiResourceService.java
@@ -54,10 +54,11 @@ import org.onap.aaiauth.auth.Auth;
import org.onap.crud.exception.CrudException;
import org.onap.crud.logging.CrudServiceMsgs;
import org.onap.crud.logging.LoggingUtil;
+import org.onap.crud.parser.EdgePayload;
+import org.onap.crud.parser.util.EdgePayloadUtil;
import org.onap.crud.service.CrudRestService.Action;
import org.onap.crud.util.CrudServiceConstants;
import org.onap.schema.EdgeRulesLoader;
-import org.onap.schema.RelationshipSchemaValidator;
import org.slf4j.MDC;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
@@ -397,16 +398,15 @@ public class AaiResourceService {
public EdgePayload applyEdgeRulesToPayload(EdgePayload payload) throws CrudException {
// Extract the types for both the source and target vertices.
- String srcType = RelationshipSchemaValidator.vertexTypeFromUri(payload.getSource());
- String tgtType = RelationshipSchemaValidator.vertexTypeFromUri(payload.getTarget());
+ String srcType = EdgePayloadUtil.getVertexNodeType(payload.getSource());
+ String tgtType = EdgePayloadUtil.getVertexNodeType(payload.getTarget());
- // Now, get the default properties for this edge based on the edge rules definition...
- Map<EdgeProperty, String> props = getEdgeRuleProperties(srcType, tgtType);
-
- // ...and merge them with any custom properties provided in the request.
- JsonElement mergedProperties = mergeProperties(payload.getProperties(), props);
- payload.setProperties(mergedProperties);
+ // Now, get the default properties for this edge based on the edge rules definition...
+ Map<EdgeProperty, String> props = getEdgeRuleProperties(srcType, tgtType);
+ // ...and merge them with any custom properties provided in the request.
+ JsonElement mergedProperties = mergeProperties(payload.getProperties(), props);
+ payload.setProperties(mergedProperties);
if(logger.isDebugEnabled()) {
logger.debug("Edge properties after applying rules for '" + srcType + " -> " + tgtType + "': " + mergedProperties);
@@ -430,6 +430,7 @@ public class AaiResourceService {
*
* @throws CrudException
*/
+ @SuppressWarnings("unchecked")
public JsonElement mergeProperties(JsonElement propertiesFromRequest, Map<EdgeProperty, String> propertyDefaults) throws CrudException {
// Convert the properties from the edge payload into something we can