diff options
Diffstat (limited to 'src/main/java/org')
4 files changed, 31 insertions, 26 deletions
diff --git a/src/main/java/org/onap/aai/datarouter/entity/AaiEventEntity.java b/src/main/java/org/onap/aai/datarouter/entity/AaiEventEntity.java index c32cd6f..0391ae3 100644 --- a/src/main/java/org/onap/aai/datarouter/entity/AaiEventEntity.java +++ b/src/main/java/org/onap/aai/datarouter/entity/AaiEventEntity.java @@ -72,9 +72,9 @@ public class AaiEventEntity implements DocumentStoreDataEntity, Serializable { protected String entityType; protected String entityPrimaryKeyName; protected String entityPrimaryKeyValue; - protected ArrayList<String> searchTagCollection = new ArrayList<String>(); - protected ArrayList<String> searchTagIdCollection = new ArrayList<String>(); - protected ArrayList<String> crossEntityReferenceCollection = new ArrayList<String>(); + protected ArrayList<String> searchTagCollection = new ArrayList<>(); + protected ArrayList<String> searchTagIdCollection = new ArrayList<>(); + protected ArrayList<String> crossEntityReferenceCollection = new ArrayList<>(); protected String lastmodTimestamp; protected String link; @@ -95,7 +95,7 @@ public class AaiEventEntity implements DocumentStoreDataEntity, Serializable { private static String convertBytesToHexString(byte[] bytesToConvert) { - StringBuffer hexString = new StringBuffer(); + StringBuilder hexString = new StringBuilder(); for (int i = 0; i < bytesToConvert.length; i++) { hexString.append(Integer.toHexString(0xFF & bytesToConvert[i])); } @@ -104,13 +104,12 @@ public class AaiEventEntity implements DocumentStoreDataEntity, Serializable { private static String concatArray(List<String> list, char delimiter) { - if (list == null || list.size() == 0) { + if (list == null || list.isEmpty()) { return ""; } StringBuilder result = new StringBuilder(64); - int listSize = list.size(); boolean firstValue = true; for (String item : list) { diff --git a/src/main/java/org/onap/aai/datarouter/entity/AggregationEntity.java b/src/main/java/org/onap/aai/datarouter/entity/AggregationEntity.java index 44927eb..56ef6fd 100644 --- a/src/main/java/org/onap/aai/datarouter/entity/AggregationEntity.java +++ b/src/main/java/org/onap/aai/datarouter/entity/AggregationEntity.java @@ -49,6 +49,8 @@ public class AggregationEntity implements DocumentStoreDataEntity, Serializable public void setLink(String link) { this.link = link; } + + @Override public String getId() { // make sure that deliveFields() is called before getting the id return id; @@ -66,7 +68,7 @@ public class AggregationEntity implements DocumentStoreDataEntity, Serializable } - Map<String, String> attributes = new HashMap<String, String>(); + Map<String, String> attributes = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); /** @@ -86,20 +88,22 @@ public class AggregationEntity implements DocumentStoreDataEntity, Serializable while (nodes.hasNext()) { Map.Entry<String, JsonNode> entry = (Map.Entry<String, JsonNode>) nodes.next(); - if (!entry.getKey().equalsIgnoreCase("relationship-list")){ + if (!"relationship-list".equalsIgnoreCase(entry.getKey())){ attributes.put(entry.getKey(), entry.getValue().asText()); } } } public void copyAttributeKeyValuePair(Map<String, Object> map){ - for(String key: map.keySet()){ - if (!key.equalsIgnoreCase("relationship-list")){ // ignore relationship data which is not required in aggregation - this.attributes.put(key, map.get(key).toString()); // not sure if entity attribute can contain an object as value + for(Map.Entry<String, Object> entry: map.entrySet()){ + String key = entry.getKey(); + Object value = entry.getValue(); + if (!"relationship-list".equalsIgnoreCase(key)){ // ignore relationship data which is not required in aggregation + this.attributes.put(key, value.toString()); // not sure if entity attribute can contain an object as value } } } - + public void addAttributeKeyValuePair(String key, String value){ this.attributes.put(key, value); } @@ -108,8 +112,10 @@ public class AggregationEntity implements DocumentStoreDataEntity, Serializable ObjectNode rootNode = mapper.createObjectNode(); rootNode.put("link", this.getLink()); rootNode.put("lastmodTimestamp", lastmodTimestamp); - for (String key: this.attributes.keySet()){ - rootNode.put(key, this.attributes.get(key)); + for (Map.Entry<String, String> entry: this.attributes.entrySet()){ + String key = entry.getKey(); + String value = entry.getValue(); + rootNode.put(key, value); } return rootNode.toString(); } diff --git a/src/main/java/org/onap/aai/datarouter/entity/SuggestionSearchEntity.java b/src/main/java/org/onap/aai/datarouter/entity/SuggestionSearchEntity.java index a41487e..bd3c5b7 100644 --- a/src/main/java/org/onap/aai/datarouter/entity/SuggestionSearchEntity.java +++ b/src/main/java/org/onap/aai/datarouter/entity/SuggestionSearchEntity.java @@ -57,7 +57,7 @@ public class SuggestionSearchEntity implements DocumentStoreDataEntity, Serializ private Map<String, String> inputOutputData = new HashMap<>(); private Map<String, UiFilterConfig> filters = new HashMap<>(); private JSONObject filterPayload = new JSONObject(); - private StringBuffer searchSuggestionDisplayString = new StringBuffer(); + private StringBuilder searchSuggestionDisplayString = new StringBuilder(); private JSONArray payloadFilters = new JSONArray(); private UiFiltersSchemaUtility filtersSchemaUtility = new UiFiltersSchemaUtility(); @@ -124,7 +124,7 @@ public class SuggestionSearchEntity implements DocumentStoreDataEntity, Serializ } } - ArrayList<String> listOfSearchSuggestionPermutations = new ArrayList<String>(); + ArrayList<String> listOfSearchSuggestionPermutations = new ArrayList<>(); ArrayList<String> listToPermutate = new ArrayList<>(this.getInputOutputData().values()); @@ -152,7 +152,7 @@ public class SuggestionSearchEntity implements DocumentStoreDataEntity, Serializ JSONObject rootNode = new JSONObject(); JSONArray inputArray = new JSONArray(); JSONObject payloadNode = new JSONObject(); - StringBuffer outputString = new StringBuffer(); + StringBuilder outputString = new StringBuilder(); int payloadEntryCounter = 1; @@ -240,10 +240,10 @@ public class SuggestionSearchEntity implements DocumentStoreDataEntity, Serializ inputOutputData.put(attribute, entityFromUebEvent.get(attribute).asText()); if(filterConfig != null) { - JSONObject filterPayload = new JSONObject(); - filterPayload.put(FILTER_ID, filterConfig.getFilterId()); - filterPayload.put(FILTER_VALUE, entityFromUebEvent.get(attribute).asText()); - this.payloadFilters.put(filterPayload); + JSONObject jsonFilterPayload = new JSONObject(); + jsonFilterPayload.put(FILTER_ID, filterConfig.getFilterId()); + jsonFilterPayload.put(FILTER_VALUE, entityFromUebEvent.get(attribute).asText()); + this.payloadFilters.put(jsonFilterPayload); } else { this.filterPayload.put(attribute, entityFromUebEvent.get(attribute).asText()); } @@ -292,7 +292,7 @@ public class SuggestionSearchEntity implements DocumentStoreDataEntity, Serializ return id; } - public StringBuffer getSearchSuggestionDisplayString() { + public StringBuilder getSearchSuggestionDisplayString() { return searchSuggestionDisplayString; } @@ -324,7 +324,7 @@ public class SuggestionSearchEntity implements DocumentStoreDataEntity, Serializ return inputOutputData; } - public void setSearchSuggestionDisplayString(StringBuffer searchSuggestionDisplayString) { + public void setSearchSuggestionDisplayString(StringBuilder searchSuggestionDisplayString) { this.searchSuggestionDisplayString = searchSuggestionDisplayString; } diff --git a/src/main/java/org/onap/aai/datarouter/entity/TopographicalEntity.java b/src/main/java/org/onap/aai/datarouter/entity/TopographicalEntity.java index fa25a56..1f81573 100644 --- a/src/main/java/org/onap/aai/datarouter/entity/TopographicalEntity.java +++ b/src/main/java/org/onap/aai/datarouter/entity/TopographicalEntity.java @@ -46,7 +46,7 @@ public class TopographicalEntity implements DocumentStoreDataEntity, Serializabl protected String id; private static String convertBytesToHexString(byte[] bytesToConvert) { - StringBuffer hexString = new StringBuffer(); + StringBuilder hexString = new StringBuilder(); for (int i = 0; i < bytesToConvert.length; i++) { hexString.append(Integer.toHexString(0xFF & bytesToConvert[i])); } @@ -55,13 +55,12 @@ public class TopographicalEntity implements DocumentStoreDataEntity, Serializabl private static String concatArray(List<String> list, char delimiter) { - if (list == null || list.size() == 0) { + if (list == null || list.isEmpty()) { return ""; } StringBuilder result = new StringBuilder(64); - int listSize = list.size(); boolean firstValue = true; for (String item : list) { @@ -103,6 +102,7 @@ public class TopographicalEntity implements DocumentStoreDataEntity, Serializabl * * @see org.onap.aai.datarouter.entity.TopographicalEntity#getAsJson() */ + @Override public String getAsJson() throws IOException { JsonObject obj = |