import org.onap.crud.exception.CrudException;\r
import org.onap.crud.logging.CrudServiceMsgs;\r
import org.onap.crud.logging.LoggingUtil;\r
+import org.onap.crud.parser.EdgePayload;\r
+import org.onap.crud.parser.util.EdgePayloadUtil;\r
import org.onap.crud.service.CrudRestService.Action;\r
import org.onap.crud.util.CrudServiceConstants;\r
import org.onap.schema.EdgeRulesLoader;\r
-import org.onap.schema.RelationshipSchemaValidator;\r
import org.slf4j.MDC;\r
import com.google.gson.Gson;\r
import com.google.gson.JsonElement;\r
public EdgePayload applyEdgeRulesToPayload(EdgePayload payload) throws CrudException {\r
\r
// Extract the types for both the source and target vertices.\r
- String srcType = RelationshipSchemaValidator.vertexTypeFromUri(payload.getSource());\r
- String tgtType = RelationshipSchemaValidator.vertexTypeFromUri(payload.getTarget());\r
+ String srcType = EdgePayloadUtil.getVertexNodeType(payload.getSource());\r
+ String tgtType = EdgePayloadUtil.getVertexNodeType(payload.getTarget());\r
\r
- // Now, get the default properties for this edge based on the edge rules definition...\r
- Map<EdgeProperty, String> props = getEdgeRuleProperties(srcType, tgtType);\r
-\r
- // ...and merge them with any custom properties provided in the request.\r
- JsonElement mergedProperties = mergeProperties(payload.getProperties(), props);\r
- payload.setProperties(mergedProperties);\r
+ // Now, get the default properties for this edge based on the edge rules definition...\r
+ Map<EdgeProperty, String> props = getEdgeRuleProperties(srcType, tgtType);\r
\r
+ // ...and merge them with any custom properties provided in the request.\r
+ JsonElement mergedProperties = mergeProperties(payload.getProperties(), props);\r
+ payload.setProperties(mergedProperties);\r
\r
if(logger.isDebugEnabled()) {\r
logger.debug("Edge properties after applying rules for '" + srcType + " -> " + tgtType + "': " + mergedProperties);\r
*\r
* @throws CrudException\r
*/\r
+ @SuppressWarnings("unchecked")\r
public JsonElement mergeProperties(JsonElement propertiesFromRequest, Map<EdgeProperty, String> propertyDefaults) throws CrudException {\r
\r
// Convert the properties from the edge payload into something we can\r