From: Sindhuri.A Date: Tue, 30 Oct 2018 12:13:59 +0000 (+0530) Subject: Refactor Code catalog-model X-Git-Tag: 1.3.2~6 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=63b4f6532cd9cadef8d6c53a210f66142158d601;p=sdc.git Refactor Code catalog-model Code refactor : catalog-model classes Issue-ID: SDC-1880 Change-Id: I8f9e0f87eed6f9db8885572dce159eedc7845173 Signed-off-by: Sindhuri.A --- diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java index f0dee3016b..f700c2eb69 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaElementOperation.java @@ -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 getComponentByLabelAndId(String uniqueId, ToscaElementTypeEnum nodeType, JsonParseFlagEnum parseFlag) { - Map propertiesToMatch = new HashMap<>(); + Map 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 props = new HashMap<>(); + Map 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 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, TitanOperationStatus> getListOfHighestComponents(ComponentTypeEnum componentType, List excludeTypes, JsonParseFlagEnum parseFlag) { - Map propertiesToMatch = new HashMap<>(); - Map propertiesHasNotToMatch = new HashMap<>(); + Map propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class); + Map 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, TitanOperationStatus> highestNodes = getListOfHighestComponents(componentType, excludeTypes, JsonParseFlagEnum.ParseMetadata); - Map propertiesToMatchCertified = new HashMap<>(); - Map propertiesHasNotToMatchCertified = new HashMap<>(); + Map propertiesToMatchCertified = new EnumMap<>(GraphPropertyEnum.class); + Map 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 props = new HashMap<>(); + Map props = new EnumMap<>(GraphPropertyEnum.class); props.put(GraphPropertyEnum.IS_DELETED, true); props.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name()); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java index a1d08a6eed..5c06e97bf3 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java @@ -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); } }