Code refactoring catalog-model 59/71459/2
authorSindhuri.A <arcot.sindhuri@huawei.com>
Tue, 30 Oct 2018 13:37:39 +0000 (19:07 +0530)
committerTal Gitelman <tal.gitelman@att.com>
Thu, 1 Nov 2018 10:25:40 +0000 (10:25 +0000)
Code refactor : catalog-model classes

Issue-ID: SDC-1880

Change-Id: I75ef87ef25cc9d1da6d59f4ed5d3790a0fbb2c25
Signed-off-by: Sindhuri.A <arcot.sindhuri@huawei.com>
catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementLifecycleOperation.java

index d7ff072..afad869 100644 (file)
@@ -247,7 +247,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
     private boolean hasPreviousVersion(GraphVertex toscaElementVertex) {
         boolean hasPreviousVersion = true;
         String version = (String) toscaElementVertex.getMetadataProperty(GraphPropertyEnum.VERSION);
-        if (StringUtils.isEmpty(version) || version.equals("0.1"))
+        if (StringUtils.isEmpty(version) || "0.1".equals(version))
             hasPreviousVersion = false;
         return hasPreviousVersion;
     }
@@ -1293,7 +1293,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
 
         GraphVertex nextVersionToscaElementVertex = new GraphVertex();
         String uniqueId = IdBuilderUtils.generateUniqueId();
-        Map<GraphPropertyEnum, Object> metadataProperties = new HashMap<>(toscaElementVertex.getMetadataProperties());
+        Map<GraphPropertyEnum, Object> metadataProperties = new EnumMap<>(toscaElementVertex.getMetadataProperties());
         nextVersionToscaElementVertex.setMetadataProperties(metadataProperties);
         nextVersionToscaElementVertex.setUniqueId(uniqueId);
         nextVersionToscaElementVertex.setLabel(toscaElementVertex.getLabel());
@@ -1322,12 +1322,6 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
         return nextVersionToscaElementVertex;
     }
 
-    private ComponentParametersView buildComponentParametersViewAfterCheckin() {
-        ComponentParametersView componentParametersView = new ComponentParametersView();
-        componentParametersView.disableAll();
-        componentParametersView.setIgnoreUsers(false);
-        return componentParametersView;
-    }
 
     private Either<GraphVertex, StorageOperationStatus> checkinToscaELement(LifecycleStateEnum currState, GraphVertex toscaElementVertex, GraphVertex ownerVertex, GraphVertex modifierVertex, LifecycleStateEnum nextState) {
         Either<GraphVertex, StorageOperationStatus> updateRelationsRes;
@@ -1368,7 +1362,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
 
         if (currState == LifecycleStateEnum.READY_FOR_CERTIFICATION) {
             // In case of cancel "ready for certification" remove last state edge with "STATE" property equals to "NOT_CERTIFIED_CHECKIN"
-            Map<GraphPropertyEnum, Object> vertexProperties = new HashMap<>();
+            Map<GraphPropertyEnum, Object> vertexProperties = new EnumMap<>(GraphPropertyEnum.class);
             vertexProperties.put(GraphPropertyEnum.STATE, nextState);
             Either<Edge, TitanOperationStatus> deleteResult = titanDao.deleteBelongingEdgeByCriteria(toscaElementVertex, EdgeLabelEnum.LAST_STATE, vertexProperties);
             if (deleteResult.isRight()) {
@@ -1387,7 +1381,7 @@ public class ToscaElementLifecycleOperation extends BaseOperation {
         }
         if (result == null) {
             // Create CHECKIN relation
-            Map<EdgePropertyEnum, Object> edgeProperties = new HashMap<>();
+            Map<EdgePropertyEnum, Object> edgeProperties = new EnumMap<>(EdgePropertyEnum.class);
             edgeProperties.put(EdgePropertyEnum.STATE, nextState);
             TitanOperationStatus createEdgeRes = titanDao.createEdge(modifierVertex.getVertex(), toscaElementVertex.getVertex(), EdgeLabelEnum.STATE, edgeProperties);
             if (createEdgeRes != TitanOperationStatus.OK) {