Merge "Fix certify VFC with Model" into 21.4
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java
index 4dad18a..5d4a89c 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperation.java
@@ -181,7 +181,10 @@
             }
         }
         if (result == null) {
-            result = createModelEdge(previousToscaElement, nextToscaElement, user, createdToscaElementVertex);
+            result =
+                VertexTypeEnum.TOPOLOGY_TEMPLATE.equals(previousToscaElement.getLabel())
+                    ? createModelEdge(previousToscaElement, nextToscaElement, user, createdToscaElementVertex, EdgeLabelEnum.MODEL)
+                    : createModelEdge(previousToscaElement, nextToscaElement, user, createdToscaElementVertex, EdgeLabelEnum.MODEL_ELEMENT);
         }
         if (result == null) {
             status = janusGraphDao.createEdge(user.getVertex(), createdToscaElementVertex.getVertex(), EdgeLabelEnum.LAST_MODIFIER, new HashMap<>());
@@ -244,20 +247,23 @@
      * @param nextToscaElement latest element version
      * @param user user
      * @param createdToscaElementVertex created tosca element
+     * @param edgeLabelEnum
      * @return
      */
     private Either<GraphVertex, StorageOperationStatus> createModelEdge(final GraphVertex previousToscaElement,
                                                                         final GraphVertex nextToscaElement, GraphVertex user,
-                                                                        final GraphVertex createdToscaElementVertex) {
+                                                                        final GraphVertex createdToscaElementVertex,
+                                                                        final EdgeLabelEnum edgeLabelEnum) {
         Either<GraphVertex, StorageOperationStatus> result = null;
         final Either<GraphVertex, JanusGraphOperationStatus> modelElementVertexResponse = janusGraphDao
-            .getParentVertex(previousToscaElement, EdgeLabelEnum.MODEL, JsonParseFlagEnum.NoParse);
+            .getParentVertex(previousToscaElement, edgeLabelEnum, JsonParseFlagEnum.NoParse);
         if (modelElementVertexResponse.isLeft()) {
             final JanusGraphOperationStatus status = janusGraphDao
-                .createEdge(modelElementVertexResponse.left().value().getVertex(), createdToscaElementVertex.getVertex(), EdgeLabelEnum.MODEL, new HashMap<>());
+                .createEdge(modelElementVertexResponse.left().value().getVertex(), createdToscaElementVertex.getVertex(), edgeLabelEnum,
+                    new HashMap<>());
             if (JanusGraphOperationStatus.OK != status) {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
-                    FAILED_TO_CREATE_EDGE_WITH_LABEL_FROM_USER_VERTEX_TO_TOSCA_ELEMENT_VERTEX_ON_GRAPH_STATUS_IS, EdgeLabelEnum.MODEL,
+                    FAILED_TO_CREATE_EDGE_WITH_LABEL_FROM_USER_VERTEX_TO_TOSCA_ELEMENT_VERTEX_ON_GRAPH_STATUS_IS, edgeLabelEnum,
                     user.getUniqueId(), nextToscaElement.getMetadataProperty(GraphPropertyEnum.NORMALIZED_NAME), status);
                 result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
             }