From dc48060d3bdbd51583d61544311a3db7e9438496 Mon Sep 17 00:00:00 2001 From: renealr Date: Wed, 28 Mar 2018 09:45:08 -0400 Subject: Add test cases to increase coverage added test cases to increase coverage deleted classes that are not being used to increase coverage re-added the logic to ensure suggestions are enabled using search data service updated rest client aai schema and logging services version in pom file Issue-ID: AAI-951 Change-Id: Ie35813bc633a9e249a29baec1df8beefef91b10c Signed-off-by: renealr --- .../search/AggregateSummaryProcessor.java | 84 +++++---- .../search/AggregateVnfSearchProvider.java | 155 ++++++++++------ .../aggregatevnf/search/VnfSearchQueryBuilder.java | 2 +- .../aai/sparky/search/SearchServiceAdapter.java | 34 ++-- .../config/TierSupportUiConstants.java | 98 ---------- .../aai/sparky/viewandinspect/entity/JsonNode.java | 203 --------------------- .../sparky/viewandinspect/entity/JsonNodeLink.java | 73 -------- 7 files changed, 169 insertions(+), 480 deletions(-) delete mode 100644 sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java delete mode 100644 sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java delete mode 100644 sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNodeLink.java (limited to 'sparkybe-onap-service/src/main/java/org') diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java index b58d91b..a2df3b5 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java @@ -43,29 +43,31 @@ import org.onap.aai.sparky.viewandinspect.config.SparkyConstants; public class AggregateSummaryProcessor { - private static final Logger LOG = LoggerFactory.getInstance().getLogger(AggregateSummaryProcessor.class); + private static final Logger LOG = + LoggerFactory.getInstance().getLogger(AggregateSummaryProcessor.class); private static final String KEY_FILTERS = "filters"; private ElasticSearchAdapter elasticSearchAdapter = null; - + private String vnfAggregationIndexName; private FiltersConfig filtersConfig; - - public AggregateSummaryProcessor(ElasticSearchAdapter elasticSearchAdapter, FiltersConfig filtersConfig) { + + public AggregateSummaryProcessor(ElasticSearchAdapter elasticSearchAdapter, + FiltersConfig filtersConfig) { this.elasticSearchAdapter = elasticSearchAdapter; this.filtersConfig = filtersConfig; } - + public void setVnfAggregationIndexName(String vnfAggregationIndexName) { this.vnfAggregationIndexName = vnfAggregationIndexName; } - + public void getFilteredAggregation(Exchange exchange) { HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class); ServletUtils.setUpMdcContext(exchange, request); - + try { String payload = exchange.getIn().getBody(String.class); @@ -86,29 +88,29 @@ public class AggregateSummaryProcessor { if (parameters.has(KEY_FILTERS)) { requestFilters = parameters.getJSONArray(KEY_FILTERS); } else { - + JSONObject zeroResponsePayload = new JSONObject(); zeroResponsePayload.put("count", 0); - //response.setStatus(Status.SUCCESS_OK); - //response.setEntity(zeroResponsePayload.toString(), MediaType.APPLICATION_JSON); + // response.setStatus(Status.SUCCESS_OK); + // response.setEntity(zeroResponsePayload.toString(), MediaType.APPLICATION_JSON); exchange.getOut().setBody(zeroResponsePayload.toString()); - + LOG.error(AaiUiMsgs.ERROR_FILTERS_NOT_FOUND); return; } - + if (requestFilters != null && requestFilters.length() > 0) { List filtersToQuery = new ArrayList(); - for(int i = 0; i < requestFilters.length(); i++) { + for (int i = 0; i < requestFilters.length(); i++) { JSONObject filterEntry = requestFilters.getJSONObject(i); filtersToQuery.add(filterEntry); } - + String jsonResponsePayload = getVnfFilterAggregations(filtersToQuery); exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 200); exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "application/json"); exchange.getOut().setBody(jsonResponsePayload); - + } else { String emptyResponse = getEmptyAggResponse(); exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 200); @@ -118,10 +120,11 @@ public class AggregateSummaryProcessor { } } } catch (Exception exc) { - LOG.error(AaiUiMsgs.ERROR_GENERIC, "FilterProcessor failed to get filter list due to error = " + exc.getMessage()); + LOG.error(AaiUiMsgs.ERROR_GENERIC, + "FilterProcessor failed to get filter list due to error = " + exc.getMessage()); } } - + private String getEmptyAggResponse() { JSONObject aggPayload = new JSONObject(); aggPayload.put("totalChartHits", 0); @@ -130,44 +133,45 @@ public class AggregateSummaryProcessor { payload.append("groupby_aggregation", aggPayload); return payload.toString(); - } - + } + private static final String FILTER_ID_KEY = "filterId"; private static final String FILTER_VALUE_KEY = "filterValue"; private static final int DEFAULT_SHOULD_MATCH_SCORE = 1; private static final String VNF_FILTER_AGGREGATION = "vnfFilterAggregation"; - + private String getVnfFilterAggregations(List filtersToQuery) throws IOException { - + List searchFilters = new ArrayList(); - for(JSONObject filterEntry : filtersToQuery) { - + for (JSONObject filterEntry : filtersToQuery) { + String filterId = filterEntry.getString(FILTER_ID_KEY); - if(filterId != null) { + if (filterId != null) { SearchFilter filter = new SearchFilter(); filter.setFilterId(filterId); - - if(filterEntry.has(FILTER_VALUE_KEY)) { + + if (filterEntry.has(FILTER_VALUE_KEY)) { String filterValue = filterEntry.getString(FILTER_VALUE_KEY); filter.addValue(filterValue); } - + searchFilters.add(filter); } } - + // Create query for summary by entity type - JsonObject vnfSearch = FilterQueryBuilder.createCombinedBoolAndAggQuery(filtersConfig, searchFilters, DEFAULT_SHOULD_MATCH_SCORE); + JsonObject vnfSearch = FilterQueryBuilder.createCombinedBoolAndAggQuery(filtersConfig, + searchFilters, DEFAULT_SHOULD_MATCH_SCORE); // Parse response for summary by entity type query OperationResult opResult = elasticSearchAdapter.doPost( elasticSearchAdapter.buildElasticSearchUrlForApi(vnfAggregationIndexName, SparkyConstants.ES_SEARCH_API), vnfSearch.toString(), javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE); - - if ( opResult.wasSuccessful()) { - return buildAggregateVnfResponseJson(opResult.getResult()); + + if (opResult.wasSuccessful()) { + return buildAggregateVnfResponseJson(opResult.getResult()); } else { return buildEmptyAggregateVnfResponseJson(); } @@ -178,27 +182,27 @@ public class AggregateSummaryProcessor { finalOutputToFe.put("total", 0); return finalOutputToFe.toString(); } - + private String buildAggregateVnfResponseJson(String responseJsonStr) { - + JSONObject finalOutputToFe = new JSONObject(); JSONObject responseJson = new JSONObject(responseJsonStr); - - + + JSONObject hits = responseJson.getJSONObject("hits"); int totalHits = hits.getInt("total"); finalOutputToFe.put("total", totalHits); - + JSONObject aggregations = responseJson.getJSONObject("aggregations"); String[] aggKeys = JSONObject.getNames(aggregations); JSONObject aggregationsList = new JSONObject(); - - for(String aggName : aggKeys) { + + for (String aggName : aggKeys) { JSONObject aggregation = aggregations.getJSONObject(aggName); JSONArray buckets = aggregation.getJSONArray("buckets"); aggregationsList.put(aggName, buckets); } - + finalOutputToFe.put("aggregations", aggregationsList); return finalOutputToFe.toString(); diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java index 252ff75..5fd0dc9 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java @@ -20,46 +20,55 @@ */ package org.onap.aai.sparky.aggregatevnf.search; +import java.io.IOException; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; -import javax.json.JsonObject; -import javax.ws.rs.core.MediaType; - -import org.json.JSONArray; -import org.json.JSONObject; import org.onap.aai.cl.api.Logger; import org.onap.aai.cl.eelf.LoggerFactory; import org.onap.aai.restclient.client.OperationResult; import org.onap.aai.sparky.common.search.CommonSearchSuggestion; -import org.onap.aai.sparky.dal.ElasticSearchAdapter; import org.onap.aai.sparky.logging.AaiUiMsgs; +import org.onap.aai.sparky.search.SearchServiceAdapter; import org.onap.aai.sparky.search.api.SearchProvider; import org.onap.aai.sparky.search.entity.QuerySearchEntity; import org.onap.aai.sparky.search.entity.SearchSuggestion; import org.onap.aai.sparky.search.filters.entity.UiFilterValueEntity; import org.onap.aai.sparky.util.NodeUtils; -import org.onap.aai.sparky.viewandinspect.config.SparkyConstants; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; public class AggregateVnfSearchProvider implements SearchProvider { - - private static final Logger LOG = LoggerFactory.getInstance().getLogger(AggregateVnfSearchProvider.class); + + private static final Logger LOG = + LoggerFactory.getInstance().getLogger(AggregateVnfSearchProvider.class); private ObjectMapper mapper; - private ElasticSearchAdapter elasticSearchAdapter = null; + private SearchServiceAdapter searchServiceAdapter = null; private String autoSuggestIndexName; private String vnfSearchSuggestionRoute; - public AggregateVnfSearchProvider(ElasticSearchAdapter elasticSearchAdapter, + private static final String AUTO_SUGGEST_TEMPLATE = "{ " + "\"results-size\": %d," + + "\"suggest-text\": \"%s\"," + "\"suggest-field\": \"%s\"" + "}"; + + private static final String KEY_SEARCH_RESULT = "searchResult"; + private static final String KEY_HITS = "hits"; + private static final String KEY_DOCUMENT = "document"; + private static final String KEY_CONTENT = "content"; + private static final String KEY_TEXT = "text"; + private static final String KEY_FILTER_LIST = "filterList"; + + public AggregateVnfSearchProvider(SearchServiceAdapter searchServiceAdapter, String autoSuggestIndexName, String vnfSearchSuggestionRoute) { mapper = new ObjectMapper(); - this.elasticSearchAdapter = elasticSearchAdapter; + this.searchServiceAdapter = searchServiceAdapter; this.autoSuggestIndexName = autoSuggestIndexName; this.vnfSearchSuggestionRoute = vnfSearchSuggestionRoute; } - + public void setAutoSuggestIndexName(String autoSuggestIndexName) { this.autoSuggestIndexName = autoSuggestIndexName; } @@ -68,58 +77,96 @@ public class AggregateVnfSearchProvider implements SearchProvider { public List search(QuerySearchEntity queryRequest) { List returnList = new ArrayList(); - try { - /* Create suggestions query */ - JsonObject vnfSearch = VnfSearchQueryBuilder.createSuggestionsQuery(String.valueOf(queryRequest.getMaxResults()), queryRequest.getQueryStr()); + final String fullUrlStr = + searchServiceAdapter.buildSuggestServiceQueryUrl(autoSuggestIndexName); + String postBody = + String.format(AUTO_SUGGEST_TEMPLATE, Integer.parseInt(queryRequest.getMaxResults()), + queryRequest.getQueryStr(), "entity_suggest"); + OperationResult opResult = + searchServiceAdapter.doPost(fullUrlStr, postBody, "application/json"); + if (opResult.getResultCode() == 200) { + returnList = generateSuggestionsForSearchResponse(opResult.getResult()); + } else { + LOG.error(AaiUiMsgs.ERROR_PARSING_JSON_PAYLOAD_VERBOSE, opResult.getResult()); + return returnList; + } + } catch (Exception exc) { + LOG.error(AaiUiMsgs.ERROR_GENERIC, "Search failed due to error = " + exc.getMessage()); + } - /* Parse suggestions response */ - OperationResult opResult = elasticSearchAdapter.doPost( - elasticSearchAdapter.buildElasticSearchUrlForApi(autoSuggestIndexName, - SparkyConstants.ES_SUGGEST_API), - vnfSearch.toString(), MediaType.APPLICATION_JSON_TYPE); + return returnList; + } - String result = opResult.getResult(); + private List generateSuggestionsForSearchResponse(String operationResult) { - if (!opResult.wasSuccessful()) { - LOG.error(AaiUiMsgs.ERROR_PARSING_JSON_PAYLOAD_VERBOSE, result); - return returnList; - } + if (operationResult == null || operationResult.length() == 0) { + return null; + } - JSONObject responseJson = new JSONObject(result); - String suggestionsKey = "vnfs"; - JSONArray suggestionsArray = new JSONArray(); - JSONArray suggestions = responseJson.getJSONArray(suggestionsKey); - if (suggestions.length() > 0) { - suggestionsArray = suggestions.getJSONObject(0).getJSONArray("options"); - for (int i = 0; i < suggestionsArray.length(); i++) { - JSONObject querySuggestion = suggestionsArray.getJSONObject(i); - if (querySuggestion != null) { - CommonSearchSuggestion responseSuggestion = new CommonSearchSuggestion(); - responseSuggestion.setText(querySuggestion.getString("text")); - responseSuggestion.setRoute(vnfSearchSuggestionRoute); - responseSuggestion.setHashId(NodeUtils.generateUniqueShaDigest(querySuggestion.getString("text"))); - - // Extract filter list from JSON and add to response suggestion - JSONObject payload = querySuggestion.getJSONObject("payload"); - if (payload.length() > 0) { - JSONArray filterList = payload.getJSONArray("filterList"); - for (int filter = 0; filter < filterList.length(); filter++) { - String filterValueString = filterList.getJSONObject(filter).toString(); - UiFilterValueEntity filterValue = mapper.readValue(filterValueString, UiFilterValueEntity.class); - responseSuggestion.getFilterValues().add(filterValue); - } + ObjectMapper mapper = new ObjectMapper(); + JsonNode rootNode = null; + List suggestionEntityList = new ArrayList(); + + try { + rootNode = mapper.readTree(operationResult); + JsonNode hitsNode = rootNode.get(KEY_SEARCH_RESULT); + // Check if there are hits that are coming back + if (hitsNode.has(KEY_HITS)) { + ArrayNode hitsArray = (ArrayNode) hitsNode.get(KEY_HITS); + + /* + * next we iterate over the values in the hit array elements + */ + Iterator nodeIterator = hitsArray.elements(); + JsonNode entityNode = null; + CommonSearchSuggestion responseSuggestion = null; + JsonNode sourceNode = null; + + while (nodeIterator.hasNext()) { + entityNode = nodeIterator.next(); + String responseText = getValueFromNode(entityNode, KEY_TEXT); + // do the point transformation as we build the response? + responseSuggestion = new CommonSearchSuggestion(); + responseSuggestion.setRoute(vnfSearchSuggestionRoute); + responseSuggestion.setText(responseText); + responseSuggestion.setHashId(NodeUtils.generateUniqueShaDigest(responseText)); + + sourceNode = entityNode.get(KEY_DOCUMENT).get(KEY_CONTENT); + if (sourceNode.has(KEY_FILTER_LIST)) { + ArrayNode filtersArray = (ArrayNode) sourceNode.get(KEY_FILTER_LIST); + for (int i = 0; i < filtersArray.size(); i++) { + String filterValueString = filtersArray.get(i).toString(); + UiFilterValueEntity filterValue = + mapper.readValue(filterValueString, UiFilterValueEntity.class); + responseSuggestion.getFilterValues().add(filterValue); } - returnList.add(responseSuggestion); } + suggestionEntityList.add(responseSuggestion); } } - } catch (Exception exc) { - LOG.error(AaiUiMsgs.ERROR_GENERIC, "Search failed due to error = " + exc.getMessage()); + } catch (IOException exc) { + LOG.warn(AaiUiMsgs.SEARCH_RESPONSE_BUILDING_EXCEPTION, exc.getLocalizedMessage()); } + return suggestionEntityList; - return returnList; } - + + private String getValueFromNode(JsonNode node, String fieldName) { + + if (node == null || fieldName == null) { + return null; + } + + JsonNode valueNode = node.get(fieldName); + + if (valueNode != null) { + return valueNode.asText(); + } + + return null; + + } + } diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java index 62d287e..c833bd3 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java @@ -34,7 +34,7 @@ import javax.json.JsonObjectBuilder; */ public class VnfSearchQueryBuilder { - + /** * Creates the suggestions query. diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java index 59de87c..614968e 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java @@ -42,7 +42,8 @@ import org.slf4j.MDC; public class SearchServiceAdapter { private static final String VALUE_QUERY = "query"; - + private static final String SUGGEST_QUERY = "suggest"; + private RestClient client; private RestEndpointConfig endpointConfig; private String serviceApiVersion; @@ -51,20 +52,22 @@ public class SearchServiceAdapter { /** * Instantiates a new search adapter. - * @throws Exception + * + * @throws Exception */ - public SearchServiceAdapter(RestEndpointConfig endpointConfig, String serviceApiVersion) throws Exception { + public SearchServiceAdapter(RestEndpointConfig endpointConfig, String serviceApiVersion) + throws Exception { client = RestClientFactory.buildClient(endpointConfig); commonHeaders = new HashMap>(); commonHeaders.put("Accept", Arrays.asList("application/json")); commonHeaders.put(Headers.FROM_APP_ID, Arrays.asList("AAI-UI")); - + this.serviceApiVersion = serviceApiVersion; this.endpointConfig = endpointConfig; } - + public String getServiceApiVersion() { return serviceApiVersion; } @@ -88,21 +91,19 @@ public class SearchServiceAdapter { } public OperationResult doGet(String url, String acceptContentType) { - OperationResult or = - client.get(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE); + OperationResult or = client.get(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE); return new OperationResult(or.getResultCode(), or.getResult()); } public OperationResult doPut(String url, String payload, String acceptContentType) { - OperationResult or = client.put(url, payload, getTxnHeader(), - MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE); + OperationResult or = client.put(url, payload, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE, + MediaType.APPLICATION_JSON_TYPE); return new OperationResult(or.getResultCode(), or.getResult()); } public OperationResult doDelete(String url, String acceptContentType) { - OperationResult or = - client.delete(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE); + OperationResult or = client.delete(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE); return new OperationResult(or.getResultCode(), or.getResult()); } @@ -125,6 +126,17 @@ public class SearchServiceAdapter { return buildSearchServiceUrlForApi(indexName, VALUE_QUERY); } + /** + * Get Full URL for search + * + * @param api the api + * @param indexName + * @return the full url + */ + public String buildSuggestServiceQueryUrl(String indexName) { + return buildSearchServiceUrlForApi(indexName, SUGGEST_QUERY); + } + public String buildSearchServiceUrlForApi(String indexName, String api) { return String.format("https://%s:%s/services/search-data-service/%s/search/indexes/%s/%s", endpointConfig.getEndpointIpAddress(), endpointConfig.getEndpointServerPort(), diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java deleted file mode 100644 index ba64db0..0000000 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.aai.sparky.viewandinspect.config; - -/** - * The Class TierSupportUiConstants. - */ -public class TierSupportUiConstants { - - public static String APP_NAME = "AAIUI"; - - /** Default to unix file separator if system property file.separator is null */ - public static final String FILESEP = - (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator"); - - public static String CONFIG_HOME = System.getProperty("CONFIG_HOME") + FILESEP; - public static String AJSC_HOME = System.getProperty("AJSC_HOME") + FILESEP; - public static String CONFIG_ROOT_LOCATION = - AJSC_HOME + "bundleconfig" + FILESEP + "etc" + FILESEP; - public static String STATIC_CONFIG_APP_LOCATION = CONFIG_ROOT_LOCATION + "appprops" + FILESEP; - public static String DYNAMIC_CONFIG_APP_LOCATION = CONFIG_HOME; - - public static String CONFIG_OXM_LOCATION = CONFIG_HOME + "model" + FILESEP; - public static String CONFIG_FILTERS_BASE_LOCATION = CONFIG_HOME + FILESEP; - public static String CONFIG_AUTH_LOCATION = CONFIG_HOME + "auth" + FILESEP; - - public static String HOST = "host"; - public static String IP_ADDRESS = "ipAddress"; - public static String PORT = "port"; - public static String HTTP_PORT = "httpPort"; - public static String RETRIES = "numRequestRetries"; - public static String RESOURCE_VERSION = "resource-version"; - public static String URI = "URI"; - - public static String AUTHORIZED_USERS_FILE_LOCATION = - DYNAMIC_CONFIG_APP_LOCATION + "authorized-users.config"; - public static String USERS_FILE_LOCATION = DYNAMIC_CONFIG_APP_LOCATION + "users.config"; - public static String ROLES_FILE_LOCATION = DYNAMIC_CONFIG_APP_LOCATION + "roles.config"; - public static String PORTAL_AUTHENTICATION_FILE_LOCATION = - DYNAMIC_CONFIG_APP_LOCATION + "portal" + FILESEP + "portal-authentication.properties"; - - // Related to data-router properties - public static String DR_URI_SUFFIX = "uriSuffix"; - public static String DR_CERT_NAME = "cert-name"; - public static String DR_KEYSTORE_PASSWORD = "keystore-password"; - public static String DR_KEYSTORE = "keystore"; - public static String DR_CONNECT_TIMEOUT = "connectTimeoutMs"; - public static String DR_READ_TIMEOUT = "readTimeoutMs"; - - public static final String ES_SUGGEST_API = "_suggest"; - public static final String ES_COUNT_API = "_count"; - public static final String ES_SEARCH_API = "_search"; - - public static final String UI_FILTER_VIEW_NAME_PARAMETER = "viewName"; - public static final String UI_FILTER_ID_LIST_PARAMETER = "filterIdList"; - - public static final String ENTITY_AUTO_SUGGEST_INDEX_NAME_DEFAULT = - "entityautosuggestindex-localhost"; - public static final String ENTITY_AUTO_SUGGEST_SETTINGS_FILE_DEFAULT = - "/etc/autoSuggestSettings.json"; - public static final String ENTITY_AUTO_SUGGEST_MAPPINGS_FILE_DEFAULT = - "/etc/autoSuggestMappings.json"; - public static final String ENTITY_DYNAMIC_MAPPINGS_FILE_DEFAULT = "/etc/dynamicMappings.json"; - public static final String FILTER_LIST_FILE_DEFAULT = - CONFIG_FILTERS_BASE_LOCATION + "filters" + FILESEP + "aaiui_filters.json"; - public static final String FILTER_MAPPING_FILE_DEFAULT = - CONFIG_FILTERS_BASE_LOCATION + "filters" + FILESEP + "aaiui_views.json"; - - public static final String SUGGESTION_TEXT_SEPARATOR = " -- "; - - // Injected Attributes - public static String URI_ATTR_NAME = "uri"; - - public static final String URI_VERSION_REGEX_PATTERN = "aai/v[\\d]+/"; - - public static final String getConfigPath(String configFile) { - return AJSC_HOME + FILESEP + configFile; - } - -} diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java deleted file mode 100644 index 67dd669..0000000 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java +++ /dev/null @@ -1,203 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.aai.sparky.viewandinspect.entity; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import org.apache.log4j.Logger; -import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs; - -import com.fasterxml.jackson.annotation.JsonIgnore; - -/* - * We can use annotations to differentiate between intermediate data we use to build the node, and - * the data that we actually want to appear in the exported JSON. - */ - -/* - * This is our current ( 14-June-2016 ) working schema that will remain organic until we get it just - * right. - * - * { "item-type": "customer", "item-name-key": "subscriber-name", “item-name-value” : - * “subscriber-name-123456789-aai847-data-01”, "item-properties": [{ "property-name": - * "subscriber-name", "property-value": "subscriber-name-123456789-aai847-data-01" }, { - * "property-name": "global-customer-id", "property-value": - * "global-customer-id-123456789-aai847-data-01" } ], "node-meta": { “color” : “#f2d2d2”, - * "isSearchTarget" : false, "nodeGroups" : "1,2,3,4" }, } - * - */ - - -/** - * The Class JsonNode. - */ -public class JsonNode { - - private String id; - private String itemType; - private String itemNameKey; - private String itemNameValue; - private Map itemProperties; - private NodeMeta nodeMeta; - - @JsonIgnore - private boolean isRootNode; - - - @JsonIgnore - private String resourceKey; - @JsonIgnore - private Collection inboundNeighbors; - - @JsonIgnore - private Collection outboundNeighbors; - - - @JsonIgnore - private static final Logger LOG = Logger.getLogger(JsonNode.class); - - private VisualizationConfigs visualizationConfigs; - - - /** - * Instantiates a new json node. - * - * @param ain the ain - */ - public JsonNode(ActiveInventoryNode ain, VisualizationConfigs visualizationConfigs) { - this.resourceKey = ain.getNodeId(); - this.itemProperties = ain.getProperties(); - this.setItemType(ain.getEntityType()); - this.setItemNameKey(ain.getPrimaryKeyName()); - this.setItemNameValue(ain.getPrimaryKeyValue()); - this.setId(ain.getNodeId()); - this.isRootNode = ain.isRootNode(); - this.visualizationConfigs = visualizationConfigs; - - if (LOG.isDebugEnabled()) { - LOG.debug("---"); - LOG.debug("JsonNode constructor using AIN = " + ain.dumpNodeTree(true)); - LOG.debug("---"); - } - - inboundNeighbors = ain.getInboundNeighbors(); - outboundNeighbors = ain.getOutboundNeighbors(); - - nodeMeta = new NodeMeta(this.visualizationConfigs); - - nodeMeta.setNodeIssue(ain.isNodeIssue()); - nodeMeta.setNodeValidated(ain.isNodeValidated()); - nodeMeta.setNodeDepth(ain.getNodeDepth()); - - nodeMeta.setNumInboundNeighbors(ain.getInboundNeighbors().size()); - nodeMeta.setNumOutboundNeighbors(ain.getOutboundNeighbors().size()); - - nodeMeta.setAtMaxDepth(ain.isAtMaxDepth()); - nodeMeta.setSelfLinkResolved(!ain.isSelflinkRetrievalFailure()); - nodeMeta.setProcessingErrorOccurred(ain.isProcessingErrorOccurred()); - nodeMeta.setHasNeighbors( - ain.getOutboundNeighbors().size() > 0 || ain.getInboundNeighbors().size() > 0); - nodeMeta.setProcessingState(ain.getState()); - - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getItemNameKey() { - return itemNameKey; - } - - public String getItemNameValue() { - return itemNameValue; - } - - public Map getItemProperties() { - return itemProperties; - } - - public String getItemType() { - return itemType; - } - - public String getResourceKey() { - return resourceKey; - } - - public void setItemNameKey(String itemNameKey) { - this.itemNameKey = itemNameKey; - } - - public void setItemNameValue(String itemNameValue) { - this.itemNameValue = itemNameValue; - } - - public void setItemProperties(HashMap itemProperties) { - this.itemProperties = itemProperties; - } - - public void setItemType(String itemType) { - this.itemType = itemType; - } - - public void setResourceKey(String resourceKey) { - this.resourceKey = resourceKey; - } - - public NodeMeta getNodeMeta() { - return nodeMeta; - } - - public void setNodeMeta(NodeMeta nodeMeta) { - this.nodeMeta = nodeMeta; - } - - public boolean isRootNode() { - return isRootNode; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "JsonNode [" + (id != null ? "id=" + id + ", " : "") - + (itemType != null ? "itemType=" + itemType + ", " : "") - + (itemNameKey != null ? "itemNameKey=" + itemNameKey + ", " : "") - + (itemNameValue != null ? "itemNameValue=" + itemNameValue + ", " : "") - + (itemProperties != null ? "itemProperties=" + itemProperties + ", " : "") - + (nodeMeta != null ? "nodeMeta=" + nodeMeta + ", " : "") - + (resourceKey != null ? "resourceKey=" + resourceKey + ", " : "") - + (inboundNeighbors != null ? "inboundNeighbors=" + inboundNeighbors + ", " : "") - + (outboundNeighbors != null ? "outboundNeighbors=" + outboundNeighbors : "") + "]"; - } - - -} diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNodeLink.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNodeLink.java deleted file mode 100644 index 05672f3..0000000 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNodeLink.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-2018 Amdocs - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.aai.sparky.viewandinspect.entity; - -/* - * Expected JSON Output: - * - * { JsonNodeLink : { id : , source : , target : } } - * - */ - -/** - * The Class JsonNodeLink. - */ -public class JsonNodeLink { - - protected String id; - protected String source; - protected String target; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } - - public String getTarget() { - return target; - } - - public void setTarget(String target) { - this.target = target; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "JsonNodeLink [id=" + id + ", source=" + source + ", target=" + target + "]"; - } - -} -- cgit 1.2.3-korg