Refactor Code catalog-model 49/71449/2
authorSindhuri.A <arcot.sindhuri@huawei.com>
Tue, 30 Oct 2018 12:13:59 +0000 (17:43 +0530)
committerTal Gitelman <tal.gitelman@att.com>
Thu, 1 Nov 2018 10:27:06 +0000 (10:27 +0000)
Code refactor : catalog-model classes

Issue-ID: SDC-1880

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

index f0dee30..f700c2e 100644 (file)
@@ -84,16 +84,17 @@ public abstract class ToscaElementOperation extends BaseOperation {
 
     private static final Gson gson = new Gson();
 
+    @Autowired
+    protected CategoryOperation categoryOperation;
+
     protected Gson getGson() {
         return gson;
     }
 
-    @Autowired
-    protected CategoryOperation categoryOperation;
 
     protected Either<GraphVertex, StorageOperationStatus> getComponentByLabelAndId(String uniqueId, ToscaElementTypeEnum nodeType, JsonParseFlagEnum parseFlag) {
 
-        Map<GraphPropertyEnum, Object> propertiesToMatch = new HashMap<>();
+        Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
         propertiesToMatch.put(GraphPropertyEnum.UNIQUE_ID, uniqueId);
 
         VertexTypeEnum vertexType = ToscaElementTypeEnum.getVertexTypeByToscaType(nodeType);
@@ -330,7 +331,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
                 updaterVertex = findUser.left().value();
             }
         }
-        Map<EdgePropertyEnum, Object> props = new HashMap<>();
+        Map<EdgePropertyEnum, Object> props = new EnumMap<>(EdgePropertyEnum.class);
         props.put(EdgePropertyEnum.STATE, (String) toscaElement.getMetadataValue(JsonPresentationFields.LIFECYCLE_STATE));
 
         TitanOperationStatus result = titanDao.createEdge(updaterVertex, nodeTypeVertex, EdgeLabelEnum.STATE, props);
@@ -672,7 +673,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
         Map<GraphPropertyEnum, Object> props = null;
 
         if (userId != null) {
-            props = new HashMap<>();
+            props = new EnumMap<>(GraphPropertyEnum.class);
             // for Designer retrieve specific user
             props.put(GraphPropertyEnum.USERID, userId);
         }
@@ -1235,8 +1236,8 @@ public abstract class ToscaElementOperation extends BaseOperation {
 
     public Either<List<GraphVertex>, TitanOperationStatus> getListOfHighestComponents(ComponentTypeEnum
                                                                                               componentType, List<ResourceTypeEnum> excludeTypes, JsonParseFlagEnum parseFlag) {
-        Map<GraphPropertyEnum, Object> propertiesToMatch = new HashMap<>();
-        Map<GraphPropertyEnum, Object> propertiesHasNotToMatch = new HashMap<>();
+        Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
+        Map<GraphPropertyEnum, Object> propertiesHasNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
         propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
         propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
 
@@ -1256,8 +1257,8 @@ public abstract class ToscaElementOperation extends BaseOperation {
         long startFetchAllStates = System.currentTimeMillis();
         Either<List<GraphVertex>, TitanOperationStatus> highestNodes = getListOfHighestComponents(componentType, excludeTypes, JsonParseFlagEnum.ParseMetadata);
 
-        Map<GraphPropertyEnum, Object> propertiesToMatchCertified = new HashMap<>();
-        Map<GraphPropertyEnum, Object> propertiesHasNotToMatchCertified = new HashMap<>();
+        Map<GraphPropertyEnum, Object> propertiesToMatchCertified = new EnumMap<>(GraphPropertyEnum.class);
+        Map<GraphPropertyEnum, Object> propertiesHasNotToMatchCertified = new EnumMap<>(GraphPropertyEnum.class);
         propertiesToMatchCertified.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
         propertiesToMatchCertified.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
         if (componentType == ComponentTypeEnum.RESOURCE) {
@@ -1293,7 +1294,7 @@ public abstract class ToscaElementOperation extends BaseOperation {
                                                                                                           componentType) {
 
         // get all components marked for delete
-        Map<GraphPropertyEnum, Object> props = new HashMap<>();
+        Map<GraphPropertyEnum, Object> props = new EnumMap<>(GraphPropertyEnum.class);
         props.put(GraphPropertyEnum.IS_DELETED, true);
         props.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
 
index a1d08a6..5c06e97 100644 (file)
@@ -25,7 +25,6 @@ import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
 import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
@@ -1270,10 +1269,10 @@ public class ToscaOperationFacade {
                 ComponentInstanceDataDefinition componentInstance = new ComponentInstanceDataDefinition(entry.getKey());
                 MapListCapabilityDataDefinition capMap = nodeTemplateOperation.prepareCalculatedCapabiltyForNodeType(mapToscaDataDefinition, componentInstance);
 
-                MapCapabilityProperty MapCapabilityProperty = ModelConverter.convertToMapOfMapCapabiltyProperties(caps, componentInstance.getUniqueId(), true);
+                MapCapabilityProperty mapCapabilityProperty = ModelConverter.convertToMapOfMapCapabiltyProperties(caps, componentInstance.getUniqueId(), true);
 
                 calcCapabilty.put(entry.getKey().getUniqueId(), capMap);
-                calculatedCapabilitiesProperties.put(entry.getKey().getUniqueId(), MapCapabilityProperty);
+                calculatedCapabilitiesProperties.put(entry.getKey().getUniqueId(), mapCapabilityProperty);
             }
         }