summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShawn Severin <shawn.severin@amdocs.com>2017-12-08 08:57:17 -0500
committerShawn Severin <shawn.severin@amdocs.com>2017-12-08 08:57:29 -0500
commit27da2e3395b009702c9032f9fa184f253747c8a7 (patch)
tree1cb71ce58b3e063ef4f2ee6290b8260d4d28b2c1 /src
parent7d63a5118b745cc5ed6d8fd87210e74c0b3ac354 (diff)
Adding back-end support for UI filters
Issue-ID: AAI-543 Change-Id: I15b7ef1a9d4091981444019b5cceac08c4045c51 Signed-off-by: Shawn Severin <shawn.severin@amdocs.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/routes/sparky-core-unifiedFilterRequest.route4
-rw-r--r--src/main/java/org/onap/aai/sparky/logging/AaiUiMsgs.java6
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/FilterElasticSearchAdapter.java137
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/FilterProcessor.java142
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/FilterQueryBuilder.java220
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/FilteredSearchHelper.java156
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/UiFiltersEntityConverter.java178
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/config/FiltersConfig.java157
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/config/FiltersDetailsConfig.java55
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/config/FiltersForViewsConfig.java55
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterConfig.java186
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterDataSourceConfig.java97
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterListItemConfig.java69
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterOptionsValuesConfig.java66
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/config/UiViewListItemConfig.java66
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/entity/AggregationEntity.java78
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilder.java121
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/entity/FilteredAggregationQueryBuilder.java63
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntity.java75
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/entity/SearchFilter.java86
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntity.java178
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntity.java78
-rw-r--r--src/main/java/org/onap/aai/sparky/search/filters/entity/UiFiltersEntity.java51
-rw-r--r--src/main/java/org/onap/aai/sparky/security/portal/PortalRestAPIServiceImpl.java8
-rw-r--r--src/main/java/org/onap/aai/sparky/synchronizer/config/NetworkStatisticsConfig.java237
-rw-r--r--src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java26
-rw-r--r--src/test/java/org/onap/aai/sparky/search/filters/FilterProcessorTest.java373
-rw-r--r--src/test/java/org/onap/aai/sparky/search/filters/FilteredSearchHelperTest.java69
-rw-r--r--src/test/java/org/onap/aai/sparky/search/filters/entity/DiscoverFiltersRequest.java40
-rw-r--r--src/test/java/org/onap/aai/sparky/search/filters/entity/ViewConfiguration.java68
-rw-r--r--src/test/java/org/onap/aai/sparky/search/filters/entity/ViewFilter.java57
-rw-r--r--src/test/resources/filters/AggregationSuggestionEntity_getIndexDocumentJson_expected.json1
-rw-r--r--src/test/resources/filters/aaiui_filters.json88
-rw-r--r--src/test/resources/filters/aaiui_views.json38
-rw-r--r--src/test/resources/filters/filterAggregationEndpoint_emptyRequestBody_expectedResponse.json1
-rw-r--r--src/test/resources/filters/filterAggregationEndpoint_emptyRequestFilterArray_expectedResponse.json1
-rw-r--r--src/test/resources/filters/filterAggregationEndpoint_emptyRequestFilterArray_requestBody.json3
-rw-r--r--src/test/resources/filters/filterAggregationEndpoint_successPath_expectedResponse.json1
-rw-r--r--src/test/resources/filters/filterAggregationEndpoint_successPath_operationResult.json1
-rw-r--r--src/test/resources/filters/filterAggregationEndpoint_successPath_requestBody.json11
40 files changed, 3338 insertions, 9 deletions
diff --git a/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/routes/sparky-core-unifiedFilterRequest.route b/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/routes/sparky-core-unifiedFilterRequest.route
new file mode 100644
index 0000000..36cf518
--- /dev/null
+++ b/src/main/ajsc/inventory-ui-service_v1/inventory-ui-service/v1/routes/sparky-core-unifiedFilterRequest.route
@@ -0,0 +1,4 @@
+<route xmlns="http://camel.apache.org/schema/spring" trace="true">
+ <from uri="restlet:/search/unifiedFilterRequest?restletMethods=get,post" />
+ <to uri="bean:filterProcessor?method=getFiltersWithValues"/>
+</route> \ No newline at end of file
diff --git a/src/main/java/org/onap/aai/sparky/logging/AaiUiMsgs.java b/src/main/java/org/onap/aai/sparky/logging/AaiUiMsgs.java
index 12e53b5..4555b70 100644
--- a/src/main/java/org/onap/aai/sparky/logging/AaiUiMsgs.java
+++ b/src/main/java/org/onap/aai/sparky/logging/AaiUiMsgs.java
@@ -412,6 +412,12 @@ public enum AaiUiMsgs implements LogMessageEnum {
ERROR_AAI_QUERY_WITH_RETRY,
/** Arguments: Error extracting resource path from self-link. Error = {0} */
ERROR_EXTRACTING_RESOURCE_PATH_FROM_LINK,
+ /** Arguments: {0} = Schema file location */
+ ERROR_READING_JSON_SCHEMA,
+ /** Arguments: {0} = UI view name */
+ VIEW_NAME_NOT_SUPPORTED,
+ /** Arguments: {0} = response code, {1} = filter name */
+ ERROR_FETCHING_FILTER_VALUES,
/** Arguments: {0} = URI */
RESOURCE_NOT_FOUND;
/**
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/FilterElasticSearchAdapter.java b/src/main/java/org/onap/aai/sparky/search/filters/FilterElasticSearchAdapter.java
new file mode 100644
index 0000000..2fe8a0a
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/FilterElasticSearchAdapter.java
@@ -0,0 +1,137 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.json.JsonObject;
+
+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.dal.elasticsearch.SearchAdapter;
+import org.onap.aai.sparky.dal.elasticsearch.config.ElasticSearchConfig;
+import org.onap.aai.sparky.logging.AaiUiMsgs;
+import org.onap.aai.sparky.search.filters.config.UiFilterDataSourceConfig;
+import org.onap.aai.sparky.search.filters.entity.UiFilterEntity;
+import org.onap.aai.sparky.viewandinspect.config.TierSupportUiConstants;
+
+
+/**
+ * Performs all Elasticsearch related queries for filters related to
+ * the Sparky-FE.
+ */
+public class FilterElasticSearchAdapter {
+
+ private static ElasticSearchConfig esConfig = null;
+ private static SearchAdapter search = null;
+ private static final String ES_SEARCH_API = TierSupportUiConstants.ES_SEARCH_API;
+ private static final String APP_JSON = "application/json";
+ private static final Logger LOG = LoggerFactory.getInstance().getLogger(FilterElasticSearchAdapter.class);
+ private static final String AGGS = "aggregations";
+ private static final String CONTAINER = "default";
+ private static final String BUCKETS = "buckets";
+ private static final String FILTER_VALUE_KEY = "key";
+
+
+ public FilterElasticSearchAdapter() {
+ try {
+ if (esConfig == null) {
+ esConfig = ElasticSearchConfig.getConfig();
+ }
+ if (search == null) {
+ search = new SearchAdapter();
+ }
+ } catch (Exception exc) {
+ LOG.error(AaiUiMsgs.CONFIGURATION_ERROR, "Search");
+ }
+ }
+
+ /**
+ * Get Full URL for search using elastic search configuration.
+ *
+ * @param api the api
+ * @return the full url
+ */
+ private String getFullUrl(String indexName, String api) {
+ final String host = esConfig.getIpAddress();
+ final String port = esConfig.getHttpPort();
+ return String.format("http://%s:%s/%s/%s", host, port, indexName, api);
+ }
+
+ /**
+ * For a given UiFilterEntity, will attempt to contact an Elasticsearch instance
+ * and fetch all possible values for filter's field name.
+ *
+ * @param filter - Filter object against which the search will take place.
+ * @param sourceData - If present, contains the index name and field value to search against.
+ * @return - A List of strings if results were found, else empty list.
+ */
+ public List<String> fetchValuesForFilter(UiFilterEntity filter, UiFilterDataSourceConfig dataSourceConfig) {
+ ArrayList<String> filterValues = new ArrayList<String>();
+
+ if(dataSourceConfig != null) {
+ JsonObject filterValueQuery = null;
+ if(dataSourceConfig.getPathToField() != null) {
+ filterValueQuery = FilterQueryBuilder.createNestedFilterValueQueryObject(dataSourceConfig.getFieldName(), dataSourceConfig.getPathToField());
+ } else {
+ filterValueQuery = FilterQueryBuilder.createFilterValueQueryObject(dataSourceConfig.getFieldName());
+ }
+
+ org.onap.aai.sparky.dal.rest.OperationResult opResult = search.doPost(getFullUrl(dataSourceConfig.getIndexName(), ES_SEARCH_API), filterValueQuery.toString(), APP_JSON);
+
+ String result = opResult.getResult();
+ if(opResult.wasSuccessful() && result != null) {
+ JSONObject responseJson = new JSONObject(result);
+ JSONObject aggJson = responseJson.getJSONObject(AGGS);
+
+ JSONObject containerJson = null;
+ if(dataSourceConfig.getPathToField() != null) {
+ JSONObject nestedContainer = aggJson.getJSONObject(dataSourceConfig.getPathToField());
+ containerJson = nestedContainer.getJSONObject(dataSourceConfig.getFieldName());
+ } else {
+ containerJson = aggJson.getJSONObject(CONTAINER);
+ }
+
+ JSONArray buckets = containerJson.getJSONArray(BUCKETS);
+
+ int bucketLength = buckets.length();
+ for(int i = 0; i < bucketLength; i++) {
+ JSONObject filterBucket = buckets.getJSONObject(i);
+
+ String filterValue = filterBucket.getString(FILTER_VALUE_KEY);
+ if(filterValue != null && !filterValue.isEmpty()) {
+ filterValues.add(filterValue);
+ }
+ }
+ } else {
+ LOG.error(AaiUiMsgs.ERROR_FETCHING_FILTER_VALUES, String.valueOf(opResult.getResultCode()), filter.getFilterName());
+ }
+ }
+ filterValues.sort(String::compareToIgnoreCase);
+ return filterValues;
+ }
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/FilterProcessor.java b/src/main/java/org/onap/aai/sparky/search/filters/FilterProcessor.java
new file mode 100644
index 0000000..100257b
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/FilterProcessor.java
@@ -0,0 +1,142 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.json.JsonObject;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.restlet.RestletConstants;
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
+import org.onap.aai.sparky.logging.AaiUiMsgs;
+import org.onap.aai.sparky.search.filters.FilteredSearchHelper;
+import org.onap.aai.sparky.search.filters.entity.UiFilterEntity;
+import org.onap.aai.sparky.search.filters.entity.UiFiltersEntity;
+import org.onap.aai.sparky.viewandinspect.config.TierSupportUiConstants;
+import org.restlet.Request;
+import org.restlet.Response;
+import org.restlet.data.MediaType;
+import org.restlet.data.Status;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class FilterProcessor {
+
+ private static final Logger LOG = LoggerFactory.getInstance().getLogger(FilterProcessor.class);
+
+ private ObjectMapper mapper;
+ private FilteredSearchHelper filteredSearchHelper;
+
+ public FilterProcessor() {
+ this.mapper = new ObjectMapper();
+ }
+
+ public FilterProcessor(FilteredSearchHelper filteredSearchHelper) {
+ this.mapper = new ObjectMapper();
+ this.filteredSearchHelper = filteredSearchHelper;
+ }
+
+ public ObjectMapper getMapper() {
+ return mapper;
+ }
+
+ public FilteredSearchHelper getFilteredSearchHelper() {
+ return filteredSearchHelper;
+ }
+
+ public void setFilteredSearchHelper(FilteredSearchHelper filteredSearchHelper) {
+ this.filteredSearchHelper = filteredSearchHelper;
+ }
+
+ public void getFiltersWithValues(Exchange exchange) {
+ Response response = exchange.getIn().getHeader(RestletConstants.RESTLET_RESPONSE, Response.class);
+
+ Request request = exchange.getIn().getHeader(RestletConstants.RESTLET_REQUEST, Request.class);
+
+ /* Disables automatic Apache Camel Restlet component logging which prints out an undesirable log entry
+ which includes client (e.g. browser) information */
+ request.setLoggable(false);
+
+ UiFiltersEntity viewFiltersList = null;
+ boolean wasErrorDuringFilterDiscovery = false;
+
+ try {
+ String payload = exchange.getIn().getBody(String.class);
+
+ if (payload == null || payload.isEmpty()) {
+ /* Don't throw back an error, just return an empty set */
+ LOG.error(AaiUiMsgs.SEARCH_SERVLET_ERROR, "Request Payload is empty");
+ wasErrorDuringFilterDiscovery = true;
+ } else {
+ String viewName = mapper.readValue(payload, JsonNode.class).get(TierSupportUiConstants.UI_FILTER_VIEW_NAME_PARAMETER).asText();
+
+ if (viewName == null || viewName.isEmpty()) {
+ wasErrorDuringFilterDiscovery = true;
+ } else {
+ viewFiltersList = filteredSearchHelper.doFilterDiscovery(viewName);
+ }
+ }
+ } catch(Exception exc) {
+ LOG.error(AaiUiMsgs.ERROR_GENERIC, "FilterProcessor failed to get filter list due to error = " + exc.getMessage());
+ wasErrorDuringFilterDiscovery = true;
+ }
+
+ boolean wasErrorDuringValueSearch = false;
+ if(!wasErrorDuringFilterDiscovery) {
+ try {
+ if(!viewFiltersList.getFilters().isEmpty()) {
+ List<String> filterIds = new ArrayList<String>();
+
+ for(UiFilterEntity filterEntity : viewFiltersList.getFilters()) {
+ filterIds.add(filterEntity.getFilterId());
+ }
+
+ UiFiltersEntity responseFiltersList = filteredSearchHelper.doFilterEnumeration(filterIds);
+
+ JsonObject finalResponse = UiFiltersEntityConverter.convertUiFiltersEntityToUnifiedFilterResponse(responseFiltersList);
+
+ response.setStatus(Status.SUCCESS_OK);
+ response.setEntity(finalResponse.toString(), MediaType.APPLICATION_JSON);
+ exchange.getOut().setBody(response);
+ } else {
+ wasErrorDuringValueSearch = true;
+ }
+ } catch(Exception exc) {
+ LOG.error(AaiUiMsgs.ERROR_GENERIC, "FilterProcessor failed to generate valid unifiedFilterRequest response due to error, " + exc.getMessage());
+ response.setStatus(Status.SERVER_ERROR_INTERNAL);
+ }
+ }
+
+ // In the case of an error we want to respond with a valid empty response
+ if(wasErrorDuringFilterDiscovery || wasErrorDuringValueSearch) {
+ response.setStatus(Status.SUCCESS_OK);
+ response.setEntity(UiFiltersEntityConverter.generateEmptyResponse().toString(), MediaType.APPLICATION_JSON);
+ exchange.getOut().setBody(response);
+ }
+ }
+
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/FilterQueryBuilder.java b/src/main/java/org/onap/aai/sparky/search/filters/FilterQueryBuilder.java
new file mode 100644
index 0000000..23f0dce
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/FilterQueryBuilder.java
@@ -0,0 +1,220 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.json.Json;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+
+import org.onap.aai.sparky.search.filters.config.FiltersConfig;
+import org.onap.aai.sparky.search.filters.config.UiFilterConfig;
+import org.onap.aai.sparky.search.filters.entity.AggregationEntity;
+import org.onap.aai.sparky.search.filters.entity.BoolQueryBuilder;
+import org.onap.aai.sparky.search.filters.entity.FilteredAggregationQueryBuilder;
+import org.onap.aai.sparky.search.filters.entity.MatchFilterCriteriaEntity;
+import org.onap.aai.sparky.search.filters.entity.SearchFilter;
+
+/**
+ * Used to generate queries against Elasticsearch for filter related queries.
+ */
+public class FilterQueryBuilder {
+
+ private static final int EXISTING_FILTERS_LIMIT = 0;
+ private static final int SHOULD_BRANCH_LIMIT = 2;
+
+ public static JsonObject createFilteredBoolQueryObject(List<SearchFilter> searchFilters, int minShouldMatch, List<String> fields) {
+
+ if (searchFilters == null || searchFilters.size() == 0) {
+ return null;
+ }
+
+ int searchFilterValueSize = 0;
+
+ BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder();
+
+ FiltersConfig filters = FiltersConfig.getInstance();
+
+ for (SearchFilter searchFilter : searchFilters) {
+
+ searchFilterValueSize = searchFilter.getValues().size();
+
+ /*
+ * translate the filter-id into the filter-name from the oxm data model/config file
+ */
+ UiFilterConfig filter = filters.getFilterById(searchFilter.getFilterId());
+
+ if (filter == null || filter.getFilterName() == null) {
+ // log error and continue
+ } else {
+
+ String fieldName = filter.getDataSource().getFieldName();
+ if(!fields.contains(fieldName)) {
+ fields.add(fieldName);
+ }
+
+ if (searchFilterValueSize >= SHOULD_BRANCH_LIMIT) {
+ // Add should branches
+ for (String filterValue : searchFilter.getValues()) {
+ boolQueryBuilder.addShouldFilter(new MatchFilterCriteriaEntity(fieldName, filterValue));
+ }
+
+ } else if (searchFilterValueSize > EXISTING_FILTERS_LIMIT) {
+ // Add must branch
+ for (String filterValue : searchFilter.getValues()) {
+ boolQueryBuilder.addMustFilter(new MatchFilterCriteriaEntity(fieldName, filterValue));
+ }
+ }
+ }
+ }
+
+ boolQueryBuilder.setMinShouldMatch(minShouldMatch);
+
+ return boolQueryBuilder.getJsonObject();
+ }
+
+ public static JsonObject createAggregationQueryArray(List<SearchFilter> searchFilters) {
+
+ if (searchFilters == null || searchFilters.size() == 0) {
+ // log error
+ return null;
+ }
+
+ FilteredAggregationQueryBuilder aggQueryBuilder = new FilteredAggregationQueryBuilder();
+
+ FiltersConfig filters = FiltersConfig.getInstance();
+
+ for (SearchFilter searchFilter : searchFilters) {
+
+ /*
+ * translate the filter-id into the filter-name from the oxm data model/config file
+ */
+ UiFilterConfig filter = filters.getFilterById(searchFilter.getFilterId());
+
+ if (filter == null || filter.getFilterName() == null) {
+ // log error and continue
+ } else {
+ String fieldName = filter.getDataSource().getFieldName();
+ aggQueryBuilder.addAggregationEntity(new AggregationEntity(fieldName, fieldName, 0));
+ }
+
+ }
+
+ return aggQueryBuilder.getJsonObject();
+ }
+
+ public static JsonObject createCombinedBoolAndAggQuery(List<SearchFilter> searchFilters, int minShouldMatch) {
+ JsonObjectBuilder wrappedQueryBuilder = Json.createObjectBuilder();
+ if(searchFilters != null) {
+ List<String> fields = new ArrayList<String>();
+ JsonObject boolQuery = createFilteredBoolQueryObject(searchFilters, minShouldMatch, fields);
+ JsonObject aggQuery = createAggregationQueryArray(searchFilters);
+
+ if (boolQuery != null) {
+ wrappedQueryBuilder.add("size", 0);
+
+ JsonArrayBuilder filedsArrayBuilder = Json.createBuilderFactory(null).createArrayBuilder(); // TODO -> Should we use a class instance factory?
+ for(String field : fields) {
+ filedsArrayBuilder.add(field);
+ }
+ wrappedQueryBuilder.add("fields", filedsArrayBuilder.build());
+
+ wrappedQueryBuilder.add("query", boolQuery);
+ }
+
+ if (aggQuery != null) {
+ wrappedQueryBuilder.add("aggs", aggQuery);
+ }
+ }
+ return wrappedQueryBuilder.build();
+ }
+
+ public static JsonObject createFilterValueQueryObject(String fieldValue) {
+ JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
+ jsonBuilder.add("size", "0"); // avoid source data
+ buildZeroTermSummaryQuery(jsonBuilder, fieldValue);
+
+ return jsonBuilder.build();
+ }
+
+ public static JsonObject createNestedFilterValueQueryObject(String fieldValue,
+ String pathToField) {
+ JsonObjectBuilder jsonBuilder = Json.createObjectBuilder();
+ jsonBuilder.add("size", "0"); // avoid source data
+ generateNestedAggregations(jsonBuilder, fieldValue, pathToField);
+
+ return jsonBuilder.build();
+ }
+
+ public static void buildZeroTermSummaryQuery(JsonObjectBuilder jsonBuilder, String fieldValue) {
+ JsonObjectBuilder aggsBlobBuilder = Json.createObjectBuilder();
+ getSummaryAggsBlob(aggsBlobBuilder, fieldValue, 0);
+ jsonBuilder.add("aggs", aggsBlobBuilder.build());
+ }
+
+ public static void getSummaryAggsBlob(JsonObjectBuilder aggsBlobBuilder, String fieldValue,
+ int resultSize) {
+ JsonObjectBuilder fieldBuilder =
+ Json.createObjectBuilder().add("field", fieldValue).add("size", resultSize);
+ JsonObject aggsFieldBlob = fieldBuilder.build();
+ JsonObjectBuilder defaultBlobBuilder = Json.createObjectBuilder().add("terms", aggsFieldBlob);
+ JsonObject defaultBlob = defaultBlobBuilder.build();
+ aggsBlobBuilder.add("default", defaultBlob);
+ }
+
+ public static void addNestedSummaryAggsBlob(JsonObjectBuilder nestedAggsBuilder,
+ String containerValue, String fieldValue, int resultSize) {
+ JsonObjectBuilder fieldBuilder = Json.createObjectBuilder()
+ .add("field", containerValue + "." + fieldValue).add("size", resultSize);
+ JsonObject aggsFieldObject = fieldBuilder.build();
+
+ JsonObjectBuilder termBuilder = Json.createObjectBuilder().add("terms", aggsFieldObject);
+ JsonObject termObject = termBuilder.build();
+
+ JsonObjectBuilder namedAggsBuilder = Json.createObjectBuilder().add(fieldValue, termObject);
+ JsonObject namedAggsObject = namedAggsBuilder.build();
+
+ nestedAggsBuilder.add("aggs", namedAggsObject);
+ }
+
+ public static void generateNestedAggregations(JsonObjectBuilder jsonBuilder, String fieldValue,
+ String pathToField) {
+ JsonObjectBuilder nestedAggsBuilder = Json.createObjectBuilder();
+
+ JsonObjectBuilder pathObjectBuilder = Json.createObjectBuilder().add("path", pathToField);
+ JsonObject nestedPathObject = pathObjectBuilder.build();
+
+ JsonObjectBuilder nestedObjectBuilder =
+ Json.createObjectBuilder().add("nested", nestedPathObject);
+
+ addNestedSummaryAggsBlob(nestedObjectBuilder, pathToField, fieldValue, 0);
+
+ JsonObject nestedObject = nestedObjectBuilder.build();
+ nestedAggsBuilder.add(pathToField, nestedObject);
+
+ jsonBuilder.add("aggs", nestedAggsBuilder.build());
+ }
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/FilteredSearchHelper.java b/src/main/java/org/onap/aai/sparky/search/filters/FilteredSearchHelper.java
new file mode 100644
index 0000000..825dc5e
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/FilteredSearchHelper.java
@@ -0,0 +1,156 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
+import org.onap.aai.sparky.logging.AaiUiMsgs;
+import org.onap.aai.sparky.search.filters.config.FiltersConfig;
+import org.onap.aai.sparky.search.filters.config.FiltersDetailsConfig;
+import org.onap.aai.sparky.search.filters.config.UiFilterConfig;
+import org.onap.aai.sparky.search.filters.config.UiFilterDataSourceConfig;
+import org.onap.aai.sparky.search.filters.config.UiFilterListItemConfig;
+import org.onap.aai.sparky.search.filters.config.UiViewListItemConfig;
+import org.onap.aai.sparky.search.filters.entity.UiFilterEntity;
+import org.onap.aai.sparky.search.filters.entity.UiFilterValueEntity;
+import org.onap.aai.sparky.search.filters.entity.UiFiltersEntity;
+
+public class FilteredSearchHelper {
+ private static final Logger LOG = LoggerFactory.getInstance().getLogger(FilteredSearchHelper.class);
+
+ private FiltersConfig filtersConfig;
+ private Map<String, UiFilterConfig> filtersMap = null;
+ private FilterElasticSearchAdapter filterSearchAdapter = null;
+
+ public FilteredSearchHelper(FiltersConfig filterConfig) {
+ this.filtersConfig = filterConfig;
+
+ if (filtersMap == null) {
+ filtersMap = new HashMap<>();
+
+ final FiltersDetailsConfig uiFiltersConfig = filterConfig.getFiltersConfig();
+
+ if (uiFiltersConfig != null) {
+ for (UiFilterConfig filter : uiFiltersConfig.getFilters()) {
+ filtersMap.put(filter.getFilterId(), filter);
+ }
+ }
+ }
+
+ filterSearchAdapter = new FilterElasticSearchAdapter();
+ }
+
+ public FiltersConfig getFiltersConfig() {
+ return filtersConfig;
+ }
+
+ public void setFiltersConfig(FiltersConfig filterConfig) {
+ this.filtersConfig = filterConfig;
+ }
+
+ public UiFiltersEntity doFilterDiscovery(String viewName) {
+ List<UiViewListItemConfig> views = filtersConfig.getViewsConfig().getViews();
+ List<UiFilterListItemConfig> filters = null;
+ UiFiltersEntity viewFiltersList = new UiFiltersEntity();
+
+ if(viewName != null) {
+ for (UiViewListItemConfig view: views) {
+ if (viewName.equalsIgnoreCase(view.getViewName())) {
+ filters = view.getFilters();
+ break;
+ }
+ }
+
+ if (filters == null) {
+ LOG.error(AaiUiMsgs.VIEW_NAME_NOT_SUPPORTED, viewName);
+ } else {
+ for (UiFilterListItemConfig filter : filters) {
+ FiltersDetailsConfig filtersDetailsConfig = filtersConfig.getFiltersConfig();
+
+ for (UiFilterConfig filterConfig: filtersDetailsConfig.getFilters()) {
+ if (filterConfig.getFilterId().equals(filter.getFilterId())) {
+ UiFilterEntity filterEntity = new UiFilterEntity(filterConfig);
+ if(filter.getDefaultValue() != null) {
+ filterEntity.setDefaultValue(filter.getDefaultValue());
+ }
+ viewFiltersList.addFilter(filterEntity);
+ }
+ }
+ }
+ }
+ }
+ return viewFiltersList;
+ }
+
+ public UiFiltersEntity doFilterEnumeration(List<String> requestedFilterIds) {
+ UiFiltersEntity viewFiltersList = new UiFiltersEntity();
+
+ for (String requestedFilterId : requestedFilterIds) {
+ if (null == filtersMap.get(requestedFilterId)) {
+ String errorMessage = "Requested filter ID '" + requestedFilterId + "' does not exist.";
+ LOG.error(AaiUiMsgs.SEARCH_SERVLET_ERROR, errorMessage);
+ } else {
+ UiFilterConfig sourceData = filtersMap.get(requestedFilterId);
+ UiFilterEntity filterEntity = new UiFilterEntity(sourceData);
+ this.getFilterEnumeration(filterEntity, sourceData);
+ viewFiltersList.addFilter(filterEntity);
+ }
+ }
+
+ return viewFiltersList;
+ }
+
+ public void getFilterEnumeration(UiFilterEntity filter, UiFilterConfig sourceData) {
+ List<String> filterValues = filterSearchAdapter.fetchValuesForFilter(filter, sourceData.getDataSource());
+
+ for(String value : filterValues) {
+ UiFilterValueEntity valueEntity = new UiFilterValueEntity();
+ valueEntity.setDisplayName(value);
+ valueEntity.setFilterValue(value);
+ filter.addFilterValue(valueEntity);
+ }
+ }
+
+ public Map<String, UiFilterConfig> getFiltersMap() {
+ return filtersMap;
+ }
+
+ public void setFiltersMap(Map<String, UiFilterConfig> filtersMap) {
+ this.filtersMap = filtersMap;
+ }
+
+ public UiFilterDataSourceConfig getFilterDataSource(String filterId) {
+ UiFilterConfig filterConfig = filtersMap.get(filterId);
+ UiFilterDataSourceConfig returnValue = null;
+
+ if(filterConfig != null) {
+ returnValue = filterConfig.getDataSource();
+ }
+
+ return returnValue;
+ }
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/UiFiltersEntityConverter.java b/src/main/java/org/onap/aai/sparky/search/filters/UiFiltersEntityConverter.java
new file mode 100644
index 0000000..24851f7
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/UiFiltersEntityConverter.java
@@ -0,0 +1,178 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters;
+
+import java.util.List;
+
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+
+import org.onap.aai.sparky.search.filters.config.UiFilterOptionsValuesConfig;
+import org.onap.aai.sparky.search.filters.entity.UiFilterEntity;
+import org.onap.aai.sparky.search.filters.entity.UiFilterValueEntity;
+import org.onap.aai.sparky.search.filters.entity.UiFiltersEntity;
+
+public class UiFiltersEntityConverter {
+
+ private static final String KEY_TYPE = "type";
+ private static final String KEY_MULTISELECT = "multiSelect";
+ private static final String KEY_WATERMARK = "watermark";
+ private static final String KEY_CONTROLS = "controls";
+ private static final String KEY_LABEL = "label";
+ private static final String KEY_FILTERS = "filters";
+ private static final String KEY_DECODE = "decode";
+ private static final String KEY_CODE = "code";
+ private static final String KEY_DEFAULT_VALUE = "defaultValue";
+
+ /**
+ * Converts a UiFiltersEntity into a JSON object to satisfy a new (as of 23 Oct 2017)
+ * filter library being used in the FE.
+ *
+ * @param entityToConvert - The UiFiltersEntity to be converted into a JSON response.
+ * @return A JsonObject representing the passed in UiFiltersEntity.
+ */
+ public static JsonObject convertUiFiltersEntityToUnifiedFilterResponse(UiFiltersEntity entityToConvert) {
+ JsonObjectBuilder filterBuilder = Json.createObjectBuilder();
+
+ if(entityToConvert != null) {
+ List<UiFilterEntity> filterEntities = entityToConvert.getFilters();
+ if(filterEntities != null) {
+ for(UiFilterEntity entity : filterEntities) {
+ filterBuilder.add(entity.getFilterId(), generateFilterObject(entity));
+ }
+ }
+ }
+
+ JsonObjectBuilder finalObject = Json.createObjectBuilder();
+ finalObject.add(KEY_FILTERS, filterBuilder.build());
+ return finalObject.build();
+ }
+
+ /**
+ * Generates the core body of the a single filter within the JSON body.
+ *
+ * @param entity - The filter entity (loaded from config and populated from data store).
+ * @return A JsonObject representing the core data of a filter.
+ */
+ private static JsonObject generateFilterObject(UiFilterEntity entity) {
+ JsonObjectBuilder filterBuilder = Json.createObjectBuilder();
+
+ filterBuilder.add(KEY_LABEL, entity.getDisplayName());
+ filterBuilder.add(KEY_CONTROLS, generateControlObject(entity, entity.getFilterValueList()));
+
+ return filterBuilder.build();
+ }
+
+ /**
+ * Generates the "controls" object within the filter JSON.
+ *
+ * @param filterEntity - The filter entity on which this filter will be based.
+ * @param filterValues - The list of values associated with the filter
+ * from data store queries.
+ * @return A JsonObject representing the "controls" object of the filter JSON.
+ */
+ private static JsonObject generateControlObject(UiFilterEntity filterEntity, List<UiFilterValueEntity> filterValues) {
+ JsonObjectBuilder controls = Json.createObjectBuilder();
+ JsonObjectBuilder subControl = Json.createObjectBuilder();
+
+ subControl.add(KEY_TYPE, filterEntity.getDataType());
+ subControl.add(KEY_MULTISELECT, filterEntity.getMultiSelect());
+ subControl.add(KEY_WATERMARK, filterEntity.getWatermark());
+
+ if(filterEntity.getDefaultValue() != null && !filterEntity.getDefaultValue().getCode().isEmpty() && !filterEntity.getDefaultValue().getDecode().isEmpty()) {
+ JsonObjectBuilder defaultValueBuilder = Json.createObjectBuilder();
+
+ defaultValueBuilder.add(KEY_DECODE, filterEntity.getDefaultValue().getDecode());
+ defaultValueBuilder.add(KEY_CODE, filterEntity.getDefaultValue().getCode());
+
+ subControl.add(KEY_DEFAULT_VALUE, defaultValueBuilder.build());
+ }
+
+ if(filterEntity.getOptionsValues() == null || filterEntity.getOptionsValues().isEmpty()) {
+ subControl.add(filterEntity.getOptionsType(), generateOptionsObject(filterValues));
+ } else {
+ subControl.add(filterEntity.getOptionsType(), generateOptionsValuesObject(filterEntity.getOptionsValues()));
+ }
+
+ controls.add(filterEntity.getFilterName(), subControl.build());
+
+ return controls.build();
+ }
+
+ /**
+ * Creates a JsonArray representing the list of options for a filter.
+ * Similar to function generateOptionsObject, except using different arguments.
+ *
+ * @param optionsValues - Values that are loaded from config.
+ * @return JsonArray of options for a filter.
+ */
+ private static JsonArray generateOptionsValuesObject(List<UiFilterOptionsValuesConfig> optionsValues) {
+ JsonArrayBuilder optionsBuilder = Json.createArrayBuilder();
+
+ if(optionsValues != null && !optionsValues.isEmpty()) {
+ for(UiFilterOptionsValuesConfig optionValue : optionsValues) {
+ JsonObjectBuilder option = Json.createObjectBuilder();
+
+ option.add(KEY_DECODE, optionValue.getDecode());
+ option.add(KEY_CODE, optionValue.getCode());
+
+ optionsBuilder.add(option.build());
+ }
+ }
+
+ return optionsBuilder.build();
+ }
+
+ /**
+ * Creates a JsonArray representing the list of options for a filter.
+ *
+ * @param filterValues - The list of values associates with a filter (likely from a data store query).
+ * @return JsonArray of options for a filter.
+ */
+ private static JsonArray generateOptionsObject(List<UiFilterValueEntity> filterValues) {
+ JsonArrayBuilder optionsBuilder = Json.createArrayBuilder();
+
+ if(filterValues != null && !filterValues.isEmpty()) {
+ for(UiFilterValueEntity valueEntity : filterValues) {
+ JsonObjectBuilder option = Json.createObjectBuilder();
+
+ option.add(KEY_DECODE, valueEntity.getDisplayName());
+ option.add(KEY_CODE, valueEntity.getFilterValue());
+
+ optionsBuilder.add(option.build());
+ }
+ }
+
+ return optionsBuilder.build();
+ }
+
+ public static JsonObject generateEmptyResponse() {
+ JsonObjectBuilder filterBuilder = Json.createObjectBuilder();
+ JsonObjectBuilder finalObject = Json.createObjectBuilder();
+ finalObject.add(KEY_FILTERS, filterBuilder.build());
+ return finalObject.build();
+ }
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/config/FiltersConfig.java b/src/main/java/org/onap/aai/sparky/search/filters/config/FiltersConfig.java
new file mode 100644
index 0000000..b1b503c
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/config/FiltersConfig.java
@@ -0,0 +1,157 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.config;
+
+import java.io.File;
+
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
+import org.onap.aai.sparky.logging.AaiUiMsgs;
+import org.onap.aai.sparky.synchronizer.config.NetworkStatisticsConfig;
+import org.onap.aai.sparky.viewandinspect.config.TierSupportUiConstants;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class FiltersConfig {
+
+ private static final Logger LOG = LoggerFactory.getInstance().getLogger(FiltersConfig.class);
+
+ private static FiltersConfig instance;
+
+ private String filtersFileName;
+
+ private String filterMappingsFileName;
+
+ private FiltersForViewsConfig viewsConfig;
+
+ private FiltersDetailsConfig filtersConfig;
+
+ private NetworkStatisticsConfig processorConfig;
+
+ public NetworkStatisticsConfig getProcessorConfig() {
+ return processorConfig;
+ }
+
+ public void setProcessorConfig(NetworkStatisticsConfig processorConfig) {
+ this.processorConfig = processorConfig;
+ }
+
+ public static FiltersConfig getInstance() {
+ if (instance == null) {
+ instance = new FiltersConfig();
+ instance.initializeFilters();
+ }
+
+ return instance;
+ }
+
+ public static void setConfig(FiltersConfig config) {
+ FiltersConfig.instance = config;
+ }
+
+ /**
+ * Instantiates a new UiViewFilterConfig.
+ */
+ private FiltersConfig() {}
+
+ /**
+ * Initialize config.
+ */
+ private void initializeFilters() {
+ filtersFileName = TierSupportUiConstants.FILTER_LIST_FILE_DEFAULT;
+ filterMappingsFileName = TierSupportUiConstants.FILTER_MAPPING_FILE_DEFAULT;
+
+ viewsConfig = this.readUiViewsConfig();
+ filtersConfig = this.readUiFiltersConfig();
+ }
+
+ public String getFilterMappingsFileName() {
+ return filterMappingsFileName;
+ }
+
+ public void setFilterMappingsFileName(String filterMappingsFileName) {
+ this.filterMappingsFileName = filterMappingsFileName;
+ }
+
+ public String getFiltersFileName() {
+ return filtersFileName;
+ }
+
+ public void setFiltersFileName(String filtersFileName) {
+ this.filtersFileName = filtersFileName;
+ }
+
+ public FiltersForViewsConfig getViewsConfig() {
+ return viewsConfig;
+ }
+
+ public void setViewsConfig(FiltersForViewsConfig filtersMapEntity) {
+ this.viewsConfig = filtersMapEntity;
+ }
+
+ public FiltersDetailsConfig getFiltersConfig() {
+ return filtersConfig;
+ }
+
+ public UiFilterConfig getFilterById(String filterId) {
+ for ( UiFilterConfig filter : filtersConfig.getFilters()) {
+ if ( filter.getFilterId().equals(filterId)) {
+ return filter;
+ }
+ }
+
+ return null;
+ }
+
+ public void setFiltersConfig(FiltersDetailsConfig filtersConfig) {
+ this.filtersConfig = filtersConfig;
+ }
+
+ public FiltersDetailsConfig readUiFiltersConfig(){
+ ObjectMapper mapper = new ObjectMapper();
+ FiltersDetailsConfig filtersConfig = null;
+ try{
+ filtersConfig = mapper.readValue(new File(this.getFiltersFileName()), FiltersDetailsConfig.class);
+ System.out.println(String.valueOf(filtersConfig));
+ } catch (Exception e){
+ LOG.error(AaiUiMsgs.ERROR_READING_JSON_SCHEMA, TierSupportUiConstants.getConfigPath(this.getFiltersFileName()));
+ }
+
+ return filtersConfig;
+ }
+
+ public FiltersForViewsConfig readUiViewsConfig(){
+ ObjectMapper mapper = new ObjectMapper();
+ FiltersForViewsConfig viewsConfig = null;
+
+ try {
+ viewsConfig = mapper.readValue(new File(this.getFilterMappingsFileName()), FiltersForViewsConfig.class);
+ System.out.println(String.valueOf(viewsConfig));
+ } catch (Exception e){
+ LOG.error(AaiUiMsgs.ERROR_READING_JSON_SCHEMA, TierSupportUiConstants.getConfigPath(this.getFilterMappingsFileName()));
+ }
+
+ return viewsConfig;
+ }
+}
+
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/config/FiltersDetailsConfig.java b/src/main/java/org/onap/aai/sparky/search/filters/config/FiltersDetailsConfig.java
new file mode 100644
index 0000000..09eec02
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/config/FiltersDetailsConfig.java
@@ -0,0 +1,55 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.att.aft.dme2.internal.jackson.annotate.JsonCreator;
+import com.att.aft.dme2.internal.jackson.annotate.JsonProperty;
+
+public class FiltersDetailsConfig {
+ @JsonProperty("filters")
+ private List<UiFilterConfig> filters = new ArrayList<UiFilterConfig>();
+
+ public FiltersDetailsConfig(){}
+
+ @JsonCreator
+ public FiltersDetailsConfig(@JsonProperty("filters") final List<UiFilterConfig> filters) {
+ this.filters = filters;
+ }
+
+ public List<UiFilterConfig> getFilters() {
+ return filters;
+ }
+
+ public void setFilters(List<UiFilterConfig> filters) {
+ this.filters = filters;
+ }
+
+ @Override
+ public String toString() {
+ return "UiFiltersConfig [filters=" + filters + "]";
+ }
+
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/config/FiltersForViewsConfig.java b/src/main/java/org/onap/aai/sparky/search/filters/config/FiltersForViewsConfig.java
new file mode 100644
index 0000000..7340758
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/config/FiltersForViewsConfig.java
@@ -0,0 +1,55 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.att.aft.dme2.internal.jackson.annotate.JsonCreator;
+import com.att.aft.dme2.internal.jackson.annotate.JsonProperty;
+
+public class FiltersForViewsConfig {
+
+ private List<UiViewListItemConfig> views = new ArrayList<UiViewListItemConfig>();
+
+ public FiltersForViewsConfig(){}
+
+ @JsonCreator
+ public FiltersForViewsConfig(@JsonProperty("views") final List<UiViewListItemConfig> views) {
+ this.views = views;
+ }
+
+ @JsonProperty("views")
+ public List<UiViewListItemConfig> getViews() {
+ return views;
+ }
+
+ public void setViews(List<UiViewListItemConfig> views) {
+ this.views = views;
+ }
+
+ @Override
+ public String toString() {
+ return "UiViewToFilterMappingEntity [allUiViews=" + views + "]";
+ }
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterConfig.java b/src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterConfig.java
new file mode 100644
index 0000000..c566565
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterConfig.java
@@ -0,0 +1,186 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.config;
+
+import java.util.List;
+
+import com.att.aft.dme2.internal.jackson.annotate.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonInclude(Include.NON_NULL)
+public class UiFilterConfig {
+
+ @JsonProperty("filterId")
+ private String filterId;
+
+ @JsonProperty("filterName")
+ private String filterName;
+
+ @JsonProperty("displayName")
+ private String displayName;
+
+ @JsonProperty("dataType")
+ private String dataType;
+
+ @JsonProperty("multiSelect")
+ private String multiSelect;
+
+ @JsonProperty("watermark")
+ private String watermark;
+
+ @JsonProperty("defaultValue")
+ private UiFilterOptionsValuesConfig defaultValue;
+
+ @JsonProperty("optionsType")
+ private String optionsType;
+
+ @JsonProperty("optionsValues")
+ private List<UiFilterOptionsValuesConfig> optionsValues;
+
+ @JsonProperty("dataSource")
+ private UiFilterDataSourceConfig dataSource = new UiFilterDataSourceConfig();
+
+ @JsonCreator
+ public UiFilterConfig(@JsonProperty("filterId") final String filterId,
+ @JsonProperty("filterName") final String filterName,
+ @JsonProperty("displayName") final String displayName,
+ @JsonProperty("dataType") final String dataType,
+ @JsonProperty("multiSelect") final String multiSelect,
+ @JsonProperty("watermark") final String watermark,
+ @JsonProperty("defaultValue") final UiFilterOptionsValuesConfig defaultValue,
+ @JsonProperty("optionsType") final String optionsType,
+ @JsonProperty("optionsValues") final List<UiFilterOptionsValuesConfig> optionsValues,
+ @JsonProperty("dataSource") final UiFilterDataSourceConfig dataSource
+ ) {
+ this.filterId = filterId;
+ this.filterName = filterName;
+ this.displayName = displayName;
+ this.dataType = dataType;
+ this.multiSelect = multiSelect;
+ this.watermark = watermark;
+ this.defaultValue = defaultValue;
+ this.optionsType = optionsType;
+ this.optionsValues = optionsValues;
+ this.dataSource = dataSource;
+ }
+
+ @JsonProperty("filterId")
+ public String getFilterId() {
+ return filterId;
+ }
+
+ public void setFilterId(String filterId) {
+ this.filterId = filterId;
+ }
+
+ @JsonProperty("filterName")
+ public String getFilterName() {
+ return filterName;
+ }
+
+ public void setFilterName(String filterName) {
+ this.filterName = filterName;
+ }
+
+ @JsonProperty("displayName")
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ @JsonProperty("dataType")
+ public String getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(String dataType) {
+ this.dataType = dataType;
+ }
+
+ @JsonProperty("multiSelect")
+ public String getMultiSelect() {
+ return multiSelect;
+ }
+
+ public void setMultiSelect(String multiSelect) {
+ this.multiSelect = multiSelect;
+ }
+
+ @JsonProperty("watermark")
+ public String getWatermark() {
+ return watermark;
+ }
+
+ public void setWatermark(String watermark) {
+ this.watermark = watermark;
+ }
+
+ @JsonProperty("defaultValue")
+ public UiFilterOptionsValuesConfig getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(UiFilterOptionsValuesConfig defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ @JsonProperty("optionsType")
+ public String getOptionsType() {
+ return optionsType;
+ }
+
+ public void setOptionsType(String optionsType) {
+ this.optionsType = optionsType;
+ }
+ @JsonProperty("optionsValues")
+ public List<UiFilterOptionsValuesConfig> getOptionsValues() {
+ return optionsValues;
+ }
+
+ public void setOptionsValues(List<UiFilterOptionsValuesConfig> optionsValues) {
+ this.optionsValues = optionsValues;
+ }
+
+ @JsonProperty("dataSource")
+ public UiFilterDataSourceConfig getDataSource() {
+ return dataSource;
+ }
+
+ public void setDataSource(UiFilterDataSourceConfig dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ @Override
+ public String toString() {
+ return "UiFilterConfig [filterId=" + filterId + ", filterName=" + filterName + ", displayName="
+ + displayName + ", dataType=" + dataType + ", multiSelect=" + multiSelect + ", watermark="
+ + watermark + ", optionsType=" + optionsType + ", optionsValues=" + optionsValues
+ + ", dataSource=" + dataSource + "]";
+ }
+}
+
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterDataSourceConfig.java b/src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterDataSourceConfig.java
new file mode 100644
index 0000000..be0603b
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterDataSourceConfig.java
@@ -0,0 +1,97 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.config;
+
+import com.att.aft.dme2.internal.jackson.annotate.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonInclude(Include.NON_NULL)
+public class UiFilterDataSourceConfig {
+
+ @JsonProperty("indexName")
+ private String indexName;
+
+ @JsonProperty("docType")
+ private String docType;
+
+ @JsonProperty("fieldName")
+ private String fieldName;
+
+ @JsonProperty("pathToField")
+ private String pathToField;
+
+ public UiFilterDataSourceConfig(){}
+
+ @JsonCreator
+ public UiFilterDataSourceConfig(@JsonProperty("indexName") final String indexName, @JsonProperty("docType") final String docType, @JsonProperty("fieldName") final String fieldName, @JsonProperty("pathToField") final String pathToField) {
+ this.indexName = indexName;
+ this.docType = docType;
+ this.fieldName = fieldName;
+ this.pathToField = pathToField;
+ }
+
+ @JsonProperty("indexName")
+ public String getIndexName() {
+ return indexName;
+ }
+
+ public void setIndexName(String indexName) {
+ this.indexName = indexName;
+ }
+
+ @JsonProperty("docType")
+ public String getDocType() {
+ return docType;
+ }
+
+ public void setDocType(String docType) {
+ this.docType = docType;
+ }
+
+ @JsonProperty("fieldName")
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ public void setFieldName(String fieldName) {
+ this.fieldName = fieldName;
+ }
+
+ @JsonProperty("pathToField")
+ public String getPathToField() {
+ return pathToField;
+ }
+
+ public void setPathToField(String pathToField) {
+ this.pathToField = pathToField;
+ }
+
+ @Override
+ public String toString() {
+ return "UiFilterDataSourceConfig [indexName=" + indexName + ", docType=" + docType
+ + ", fieldName=" + fieldName + ", pathToField=" + pathToField + "]";
+ }
+}
+
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterListItemConfig.java b/src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterListItemConfig.java
new file mode 100644
index 0000000..c1ee089
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterListItemConfig.java
@@ -0,0 +1,69 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.config;
+
+import com.att.aft.dme2.internal.jackson.annotate.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonInclude(Include.NON_NULL)
+public class UiFilterListItemConfig {
+ @JsonProperty("filterId")
+ private String filterId;
+
+ @JsonProperty("defaultValue")
+ private UiFilterOptionsValuesConfig defaultValue;
+
+
+ @JsonCreator
+ public UiFilterListItemConfig(@JsonProperty("filterId") final String filterId, @JsonProperty("defaultValue") final UiFilterOptionsValuesConfig defaultValue) {
+ this.filterId = filterId;
+ this.defaultValue = defaultValue;
+ }
+
+ @JsonProperty("filterId")
+ public String getFilterId() {
+ return filterId;
+ }
+
+ public void setFilterId(String filterId) {
+ this.filterId = filterId;
+ }
+
+ @JsonProperty("defaultValue")
+ public UiFilterOptionsValuesConfig getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(UiFilterOptionsValuesConfig defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ @Override
+ public String toString() {
+ return "FilterListItemEntity [filterId=" + filterId + ", defaultValue=" + defaultValue + "]";
+ }
+
+
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterOptionsValuesConfig.java b/src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterOptionsValuesConfig.java
new file mode 100644
index 0000000..2abdfdd
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/config/UiFilterOptionsValuesConfig.java
@@ -0,0 +1,66 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.config;
+
+import com.att.aft.dme2.internal.jackson.annotate.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonInclude(Include.NON_NULL)
+public class UiFilterOptionsValuesConfig {
+ @JsonProperty("decode")
+ private String decode;
+
+ @JsonProperty("code")
+ private String code;
+
+ @JsonCreator
+ public UiFilterOptionsValuesConfig(@JsonProperty("decode") final String decode, @JsonProperty("code") final String code) {
+ this.decode = decode;
+ this.code = code;
+ }
+
+ @JsonProperty("decode")
+ public String getDecode() {
+ return decode;
+ }
+
+ public void setDecode(String decode) {
+ this.decode = decode;
+ }
+
+ @JsonProperty("code")
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ @Override
+ public String toString() {
+ return "UiFilterOptionsValuesConfig [decode=" + decode + ", code=" + code + "]";
+ }
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/config/UiViewListItemConfig.java b/src/main/java/org/onap/aai/sparky/search/filters/config/UiViewListItemConfig.java
new file mode 100644
index 0000000..3707417
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/config/UiViewListItemConfig.java
@@ -0,0 +1,66 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.att.aft.dme2.internal.jackson.annotate.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class UiViewListItemConfig {
+ @JsonProperty("viewName")
+ private String viewName;
+
+ private List<UiFilterListItemConfig> filters = new ArrayList<UiFilterListItemConfig>();
+
+ @JsonCreator
+ public UiViewListItemConfig(@JsonProperty("viewName") final String viewName, @JsonProperty("filters") final List<UiFilterListItemConfig> filters) {
+ this.viewName = viewName;
+ this.filters = filters;
+ }
+
+ @JsonProperty("viewName")
+ public String getViewName() {
+ return viewName;
+ }
+
+ public void setViewName(String viewName) {
+ this.viewName = viewName;
+ }
+
+ @JsonProperty("filters")
+ public List<UiFilterListItemConfig> getFilters() {
+ return filters;
+ }
+
+ public void setListOfFilters(List<UiFilterListItemConfig> filters) {
+ this.filters = filters;
+ }
+
+ @Override
+ public String toString() {
+ return "UiViewEntity [viewName=" + viewName + ", filters=" + filters + "]";
+ }
+
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/entity/AggregationEntity.java b/src/main/java/org/onap/aai/sparky/search/filters/entity/AggregationEntity.java
new file mode 100644
index 0000000..bf901e2
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/entity/AggregationEntity.java
@@ -0,0 +1,78 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.entity;
+
+import javax.json.Json;
+import javax.json.JsonBuilderFactory;
+import javax.json.JsonObject;
+
+public class AggregationEntity {
+
+ private String aggregationName;
+ private String aggregationFieldName;
+ private int size;
+
+ public AggregationEntity(String aggName, String fieldName, int size) {
+
+ this.aggregationName = aggName;
+ this.aggregationFieldName = fieldName;
+ this.size = size;
+ }
+
+ public String getAggregationName() {
+ return aggregationName;
+ }
+
+ public void setAggregationName(String aggregationName) {
+ this.aggregationName = aggregationName;
+ }
+
+ public String getAggregationFieldName() {
+ return aggregationFieldName;
+ }
+
+ public void setAggregationFieldName(String aggregationFieldName) {
+ this.aggregationFieldName = aggregationFieldName;
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public void setSize(int size) {
+ this.size = size;
+ }
+
+ public JsonObject getJsonObject() {
+
+ JsonBuilderFactory factory = Json.createBuilderFactory(null);
+
+ return factory.createObjectBuilder()
+ .add("terms", factory.createObjectBuilder()
+ .add("field", aggregationFieldName)
+ .add("size", size))
+ .build();
+ }
+
+
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilder.java b/src/main/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilder.java
new file mode 100644
index 0000000..dabe061
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilder.java
@@ -0,0 +1,121 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonArrayBuilder;
+import javax.json.JsonBuilderFactory;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+
+public class BoolQueryBuilder {
+
+ private List<MatchFilterCriteriaEntity> mustFilters;
+ private List<MatchFilterCriteriaEntity> shouldFilters;
+
+ private int minShouldMatch;
+
+ public BoolQueryBuilder() {
+
+ mustFilters = new ArrayList<MatchFilterCriteriaEntity>();
+ shouldFilters = new ArrayList<MatchFilterCriteriaEntity>();
+ minShouldMatch = -1;
+
+ }
+
+ public void addMustFilter(MatchFilterCriteriaEntity filter) {
+
+ if (!mustFilters.contains(filter)) {
+ mustFilters.add(filter);
+ }
+
+ }
+
+ public void addShouldFilter(MatchFilterCriteriaEntity filter) {
+
+ if (!shouldFilters.contains(filter)) {
+ shouldFilters.add(filter);
+ }
+
+ }
+
+ public void setMinShouldMatch(int minShouldMatch) {
+ this.minShouldMatch = minShouldMatch;
+ }
+
+ public boolean isMatchAll() {
+ return (mustFilters.isEmpty() && shouldFilters.isEmpty());
+ }
+
+ public JsonObject getJsonObject() {
+ /*
+ * Specify a null config for now, but if we want normalize all the builders, we can do it at one
+ * location, when we are ready.
+ */
+ JsonBuilderFactory factory = Json.createBuilderFactory(null);
+
+ JsonObjectBuilder boolBuilder = factory.createObjectBuilder();
+
+ if(!mustFilters.isEmpty()){
+ JsonArrayBuilder mustArrayBuilder = factory.createArrayBuilder();
+
+ for (MatchFilterCriteriaEntity matchCriteria : mustFilters) {
+ mustArrayBuilder.add(matchCriteria.getJsonObject());
+ }
+
+ JsonArray mustArray = mustArrayBuilder.build();
+ boolBuilder.add("must", mustArray);
+ }
+
+ if (!shouldFilters.isEmpty()) {
+ JsonArray shouldArray = null;
+ JsonArrayBuilder shouldArrayBuilder = factory.createArrayBuilder();
+
+ for (MatchFilterCriteriaEntity matchCriteria : shouldFilters) {
+ shouldArrayBuilder.add(matchCriteria.getJsonObject());
+ }
+
+ shouldArray = shouldArrayBuilder.build();
+ boolBuilder.add("should", shouldArray).add("min_should_match", minShouldMatch);
+ }
+
+ JsonObjectBuilder queryObjectBuilder = factory.createObjectBuilder();
+
+ /*
+ * If both filter lists are empty then we are doing an aggregation
+ * based off fields. Just match-all for the query.
+ */
+ if(isMatchAll()) {
+ JsonObject matchAllObject = factory.createObjectBuilder().build();
+ queryObjectBuilder.add("match_all", matchAllObject);
+ } else {
+ queryObjectBuilder.add("bool", boolBuilder.build());
+ }
+
+ return queryObjectBuilder.build();
+ }
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/entity/FilteredAggregationQueryBuilder.java b/src/main/java/org/onap/aai/sparky/search/filters/entity/FilteredAggregationQueryBuilder.java
new file mode 100644
index 0000000..ef334f2
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/entity/FilteredAggregationQueryBuilder.java
@@ -0,0 +1,63 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.json.Json;
+import javax.json.JsonBuilderFactory;
+import javax.json.JsonObject;
+import javax.json.JsonObjectBuilder;
+
+public class FilteredAggregationQueryBuilder {
+
+ private List<AggregationEntity> aggregationEntities;
+
+ public FilteredAggregationQueryBuilder() {
+ aggregationEntities = new ArrayList<AggregationEntity>();
+ }
+
+ public void addAggregationEntity(AggregationEntity aggregationEntity) {
+ if (!aggregationEntities.contains(aggregationEntity)) {
+ aggregationEntities.add(aggregationEntity);
+ }
+ }
+
+ public JsonObject getJsonObject() {
+
+ /*
+ * Specify a null config for now, but if we want normalize all the builders, we can do it at one
+ * location, when we are ready.
+ */
+ JsonBuilderFactory factory = Json.createBuilderFactory(null);
+
+ JsonObjectBuilder aggsArrayBuilder = factory.createObjectBuilder();
+
+ for (AggregationEntity aggEntity : aggregationEntities) {
+ aggsArrayBuilder.add(aggEntity.getAggregationName(), aggEntity.getJsonObject());
+ }
+
+ return aggsArrayBuilder.build();
+ }
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntity.java b/src/main/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntity.java
new file mode 100644
index 0000000..3b59279
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntity.java
@@ -0,0 +1,75 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.entity;
+
+import javax.json.Json;
+import javax.json.JsonBuilderFactory;
+import javax.json.JsonObject;
+
+public class MatchFilterCriteriaEntity {
+
+ private String criteriaName;
+ private String criteriaValue;
+
+ public MatchFilterCriteriaEntity(String criteriaName, String criteriaValue) {
+ super();
+ this.criteriaName = criteriaName;
+ this.criteriaValue = criteriaValue;
+ }
+
+ public String getCriteriaName() {
+ return criteriaName;
+ }
+
+ public void setCriteriaName(String criteriaName) {
+ this.criteriaName = criteriaName;
+ }
+
+ public String getCriteriaValue() {
+ return criteriaValue;
+ }
+
+ public void setCriteriaValue(String criteriaValue) {
+ this.criteriaValue = criteriaValue;
+ }
+
+ public JsonObject getJsonObject() {
+
+ /*
+ * Specify a null config for now, but if we want normalize all the builders, we can do it at one
+ * location, when we are ready.
+ */
+ JsonBuilderFactory factory = Json.createBuilderFactory(null);
+
+ return factory.createObjectBuilder()
+ .add("match", factory.createObjectBuilder().add(criteriaName, criteriaValue)).build();
+
+ }
+
+ @Override
+ public String toString() {
+ return "MatchFilterCriteriaEntity [criteriaName=" + criteriaName + ", criteriaValue="
+ + criteriaValue + "]";
+ }
+
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/entity/SearchFilter.java b/src/main/java/org/onap/aai/sparky/search/filters/entity/SearchFilter.java
new file mode 100644
index 0000000..1b23203
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/entity/SearchFilter.java
@@ -0,0 +1,86 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.entity;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * A base entity to contain the details of the filter id and values from the FE to the BE for the
+ * purpose of driving DAL calls into ElasticSearch, Search Abstraction Service, or as a utility
+ * object within the query builders.
+ *
+ * The class has unique identifier for the filter id, and then 1 or more filter values. The value
+ * list has been introduced to help us with a multi-select use case that will need to be supported
+ * eventually.
+ */
+public class SearchFilter {
+
+ private String filterId;
+ private List<String> values;
+
+ public SearchFilter() {
+ values = new ArrayList<String>();
+ }
+
+ public SearchFilter(String filterId) {
+ this();
+ this.filterId = filterId;
+ }
+
+ public SearchFilter(String filterId, String... values) {
+ this();
+ this.filterId = filterId;
+ this.values.addAll(Arrays.asList(values));
+ }
+
+ public String getFilterId() {
+ return filterId;
+ }
+
+ public void setFilterId(String filterId) {
+ this.filterId = filterId;
+ }
+
+ public List<String> getValues() {
+ return values;
+ }
+
+ public void setValues(List<String> values) {
+ this.values = values;
+ }
+
+ public void addValue(String v) {
+ if (!values.contains(v)) {
+ values.add(v);
+ }
+
+ }
+
+ @Override
+ public String toString() {
+ return "SearchFilter [filterId=" + filterId + ", values=" + values + "]";
+ }
+
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntity.java b/src/main/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntity.java
new file mode 100644
index 0000000..2770052
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntity.java
@@ -0,0 +1,178 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onap.aai.sparky.search.filters.config.UiFilterConfig;
+import org.onap.aai.sparky.search.filters.config.UiFilterOptionsValuesConfig;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+/**
+ * Stores data for a single filter for a given UI view.
+ * <p>
+ * When a UI view wants to know which filters it should display, an object of this class is created for each
+ * filter discovered and stores data for that filter. Each filter/object of this class is added to a
+ * ViewFilterList object which is then serialized to JSON and returned to the view in the response body.
+ */
+@JsonInclude(Include.NON_NULL)
+public class UiFilterEntity {
+ private String filterId;
+ private String filterName;
+ private String displayName;
+ private String dataType;
+
+ private String multiSelect;
+ private String watermark;
+ private UiFilterOptionsValuesConfig defaultValue;
+ private String optionsType;
+
+ private List<UiFilterOptionsValuesConfig> optionsValues;
+
+ private List<UiFilterValueEntity> filterValueList;
+
+ public UiFilterEntity() {}
+
+ public UiFilterEntity(UiFilterConfig filterConfig) {
+ if (filterConfig.getFilterId() != null) {
+ this.setFilterId(filterConfig.getFilterId());
+ }
+ if (filterConfig.getFilterName() != null) {
+ this.setFilterName(filterConfig.getFilterName());
+ }
+ if (filterConfig.getDisplayName() != null) {
+ this.setDisplayName(filterConfig.getDisplayName());
+ }
+ if (filterConfig.getDataType() != null) {
+ this.setDataType(filterConfig.getDataType());
+ }
+ if (filterConfig.getMultiSelect() != null) {
+ this.setMultiSelect(filterConfig.getMultiSelect());
+ }
+ if (filterConfig.getWatermark() != null) {
+ this.setWatermark(filterConfig.getWatermark());
+ }
+ if (filterConfig.getDefaultValue() != null) {
+ this.setDefaultValue(filterConfig.getDefaultValue());
+ }
+ if (filterConfig.getOptionsType() != null) {
+ this.setOptionsType(filterConfig.getOptionsType());
+ }
+ if(filterConfig.getOptionsValues() != null && !filterConfig.getOptionsValues().isEmpty()) {
+ this.setOptionsValues(filterConfig.getOptionsValues());
+ } else {
+ this.optionsValues = new ArrayList<UiFilterOptionsValuesConfig>();
+ }
+ }
+
+ public void addFilterValue(UiFilterValueEntity valueEntity) {
+ if (null == filterValueList) {
+ filterValueList = new ArrayList<>();
+ }
+
+ this.filterValueList.add(valueEntity);
+ }
+
+ public String getFilterId() {
+ return filterId;
+ }
+
+ public String getFilterName() {
+ return filterName;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public String getDataType() {
+ return dataType;
+ }
+
+ public UiFilterOptionsValuesConfig getDefaultValue() {
+ return defaultValue;
+ }
+
+ public List<UiFilterValueEntity> getFilterValueList() {
+ return filterValueList;
+ }
+
+ public void setFilterId(String filterId) {
+ this.filterId = filterId;
+ }
+
+ public void setFilterName(String filterName) {
+ this.filterName = filterName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public void setDataType(String dataType) {
+ this.dataType = dataType;
+ }
+
+ public String getMultiSelect() {
+ return multiSelect;
+ }
+
+ public void setMultiSelect(String multiSelect) {
+ this.multiSelect = multiSelect;
+ }
+
+ public String getWatermark() {
+ return watermark;
+ }
+
+ public void setWatermark(String watermark) {
+ this.watermark = watermark;
+ }
+
+ public String getOptionsType() {
+ return optionsType;
+ }
+
+ public void setOptionsType(String optionsType) {
+ this.optionsType = optionsType;
+ }
+
+ public List<UiFilterOptionsValuesConfig> getOptionsValues() {
+ return optionsValues;
+ }
+
+ public void setOptionsValues(List<UiFilterOptionsValuesConfig> optionsValues) {
+ this.optionsValues = optionsValues;
+ }
+
+ public void setDefaultValue(UiFilterOptionsValuesConfig defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ public void setFilterValueList(List<UiFilterValueEntity> values) {
+ this.filterValueList = values;
+ }
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntity.java b/src/main/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntity.java
new file mode 100644
index 0000000..a0bbd90
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntity.java
@@ -0,0 +1,78 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.entity;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+/**
+ * This class represents a single item or value to populate the FE filter component with.
+ * A drop-down list, for example, may be populated with the values from several instances of this class.
+ */
+@JsonInclude(Include.NON_NULL)
+public class UiFilterValueEntity {
+ private String filterId;
+ private String filterValue;
+ private String displayName; // The string that will be rendered in the view
+
+ public UiFilterValueEntity() {}
+
+ public UiFilterValueEntity(String filterId, String filterValue, String displayName) {
+ this.filterId = filterId;
+ this.filterValue = filterValue;
+ this.displayName = displayName;
+ }
+
+ public String getFilterId() {
+ return filterId;
+ }
+
+ public String getFilterValue() {
+ return filterValue;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setFilterId(String filterId) {
+ this.filterId = filterId;
+ }
+
+ public void setFilterValue(String filterValue) {
+ this.filterValue = filterValue;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ @Override
+ public String toString() {
+ return "UiFilterValueEntity [" + (filterId != null ? "filterId=" + filterId + ", " : "")
+ + (filterValue != null ? "filterValue=" + filterValue + ", " : "")
+ + (displayName != null ? "displayName=" + displayName : "") + "]";
+ }
+
+
+}
diff --git a/src/main/java/org/onap/aai/sparky/search/filters/entity/UiFiltersEntity.java b/src/main/java/org/onap/aai/sparky/search/filters/entity/UiFiltersEntity.java
new file mode 100644
index 0000000..2e8fd17
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/search/filters/entity/UiFiltersEntity.java
@@ -0,0 +1,51 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.search.filters.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a list of filters that a given UI view should display.
+ * <p>
+ * When a UI view wants to know which filters it should display, an object of this class is created to keep
+ * track of all the filters that are discovered for that view and is then serialized to JSON and returned to
+ * the view in the response body.
+ */
+public class UiFiltersEntity {
+ private List<UiFilterEntity> filters = new ArrayList<>();
+
+
+
+ public void addFilter(UiFilterEntity viewFilter) {
+ filters.add(viewFilter);
+ }
+
+ public List<UiFilterEntity> getFilters() {
+ return filters;
+ }
+
+ public void setFilters(List<UiFilterEntity> filters) {
+ this.filters = filters;
+ }
+}
diff --git a/src/main/java/org/onap/aai/sparky/security/portal/PortalRestAPIServiceImpl.java b/src/main/java/org/onap/aai/sparky/security/portal/PortalRestAPIServiceImpl.java
index 798022a..9e405b5 100644
--- a/src/main/java/org/onap/aai/sparky/security/portal/PortalRestAPIServiceImpl.java
+++ b/src/main/java/org/onap/aai/sparky/security/portal/PortalRestAPIServiceImpl.java
@@ -176,13 +176,8 @@ public class PortalRestAPIServiceImpl implements IPortalRestAPIService {
// Role interface
/////////////////////////////////////////////////////////////////////////////
- /*
- * (non-Javadoc)
- *
- * @see com.att.fusion.core.onboarding.crossapi.IPortalRestAPIService#getAvailableRoles()
- */
@Override
- public List<EcompRole> getAvailableRoles(String role) throws PortalAPIException {
+ public List<EcompRole> getAvailableRoles(String requestedLoginId) throws PortalAPIException {
LOG.debug("Get available roles");
return UserManager.getRoles();
}
@@ -250,5 +245,4 @@ public class PortalRestAPIServiceImpl implements IPortalRestAPIService {
formatter.applyPattern(message);
return formatter.format(args);
}
-
} \ No newline at end of file
diff --git a/src/main/java/org/onap/aai/sparky/synchronizer/config/NetworkStatisticsConfig.java b/src/main/java/org/onap/aai/sparky/synchronizer/config/NetworkStatisticsConfig.java
new file mode 100644
index 0000000..90429a1
--- /dev/null
+++ b/src/main/java/org/onap/aai/sparky/synchronizer/config/NetworkStatisticsConfig.java
@@ -0,0 +1,237 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 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=========================================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.aai.sparky.synchronizer.config;
+
+public class NetworkStatisticsConfig {
+
+ private int numSamplesPerThreadForRunningAverage;
+
+ private String bytesHistogramLabel;
+
+ private long bytesHistogramMaxYAxis;
+
+ private int bytesHistogramNumBins;
+
+ private int bytesHistogramNumDecimalPoints;
+
+ private String queueLengthHistogramLabel;
+
+ private long queueLengthHistogramMaxYAxis;
+
+ private int queueLengthHistogramNumBins;
+
+ private int queueLengthHistogramNumDecimalPoints;
+
+ private String taskAgeHistogramLabel;
+
+ private long taskAgeHistogramMaxYAxis;
+
+ private int taskAgeHistogramNumBins;
+
+ private int taskAgeHistogramNumDecimalPoints;
+
+ private String responseTimeHistogramLabel;
+
+ private long responseTimeHistogramMaxYAxis;
+
+ private int responseTimeHistogramNumBins;
+
+ private int responseTimeHistogramNumDecimalPoints;
+
+ private String tpsHistogramLabel;
+
+ private long tpsHistogramMaxYAxis;
+
+ private int tpsHistogramNumBins;
+
+ private int tpsHistogramNumDecimalPoints;
+
+ public int getNumSamplesPerThreadForRunningAverage() {
+ return numSamplesPerThreadForRunningAverage;
+ }
+
+ public void setNumSamplesPerThreadForRunningAverage(int numSamplesPerThreadForRunningAverage) {
+ this.numSamplesPerThreadForRunningAverage = numSamplesPerThreadForRunningAverage;
+ }
+
+ public String getBytesHistogramLabel() {
+ return bytesHistogramLabel;
+ }
+
+ public void setBytesHistogramLabel(String bytesHistogramLabel) {
+ this.bytesHistogramLabel = bytesHistogramLabel;
+ }
+
+ public long getBytesHistogramMaxYAxis() {
+ return bytesHistogramMaxYAxis;
+ }
+
+ public void setBytesHistogramMaxYAxis(long bytesHistogramMaxYAxis) {
+ this.bytesHistogramMaxYAxis = bytesHistogramMaxYAxis;
+ }
+
+ public int getBytesHistogramNumBins() {
+ return bytesHistogramNumBins;
+ }
+
+ public void setBytesHistogramNumBins(int bytesHistogramNumBins) {
+ this.bytesHistogramNumBins = bytesHistogramNumBins;
+ }
+
+ public int getBytesHistogramNumDecimalPoints() {
+ return bytesHistogramNumDecimalPoints;
+ }
+
+ public void setBytesHistogramNumDecimalPoints(int bytesHistogramNumDecimalPoints) {
+ this.bytesHistogramNumDecimalPoints = bytesHistogramNumDecimalPoints;
+ }
+
+ public String getQueueLengthHistogramLabel() {
+ return queueLengthHistogramLabel;
+ }
+
+ public void setQueueLengthHistogramLabel(String queueLengthHistogramLabel) {
+ this.queueLengthHistogramLabel = queueLengthHistogramLabel;
+ }
+
+ public long getQueueLengthHistogramMaxYAxis() {
+ return queueLengthHistogramMaxYAxis;
+ }
+
+ public void setQueueLengthHistogramMaxYAxis(long queueLengthHistogramMaxYAxis) {
+ this.queueLengthHistogramMaxYAxis = queueLengthHistogramMaxYAxis;
+ }
+
+ public int getQueueLengthHistogramNumBins() {
+ return queueLengthHistogramNumBins;
+ }
+
+ public void setQueueLengthHistogramNumBins(int queueLengthHistogramNumBins) {
+ this.queueLengthHistogramNumBins = queueLengthHistogramNumBins;
+ }
+
+ public int getQueueLengthHistogramNumDecimalPoints() {
+ return queueLengthHistogramNumDecimalPoints;
+ }
+
+ public void setQueueLengthHistogramNumDecimalPoints(int queueLengthHistogramNumDecimalPoints) {
+ this.queueLengthHistogramNumDecimalPoints = queueLengthHistogramNumDecimalPoints;
+ }
+
+ public String getTaskAgeHistogramLabel() {
+ return taskAgeHistogramLabel;
+ }
+
+ public void setTaskAgeHistogramLabel(String taskAgeHistogramLabel) {
+ this.taskAgeHistogramLabel = taskAgeHistogramLabel;
+ }
+
+ public long getTaskAgeHistogramMaxYAxis() {
+ return taskAgeHistogramMaxYAxis;
+ }
+
+ public void setTaskAgeHistogramMaxYAxis(long taskAgeHistogramMaxYAxis) {
+ this.taskAgeHistogramMaxYAxis = taskAgeHistogramMaxYAxis;
+ }
+
+ public int getTaskAgeHistogramNumBins() {
+ return taskAgeHistogramNumBins;
+ }
+
+ public void setTaskAgeHistogramNumBins(int taskAgeHistogramNumBins) {
+ this.taskAgeHistogramNumBins = taskAgeHistogramNumBins;
+ }
+
+ public int getTaskAgeHistogramNumDecimalPoints() {
+ return taskAgeHistogramNumDecimalPoints;
+ }
+
+ public void setTaskAgeHistogramNumDecimalPoints(int taskAgeHistogramNumDecimalPoints) {
+ this.taskAgeHistogramNumDecimalPoints = taskAgeHistogramNumDecimalPoints;
+ }
+
+ public String getResponseTimeHistogramLabel() {
+ return responseTimeHistogramLabel;
+ }
+
+ public void setResponseTimeHistogramLabel(String responseTimeHistogramLabel) {
+ this.responseTimeHistogramLabel = responseTimeHistogramLabel;
+ }
+
+ public long getResponseTimeHistogramMaxYAxis() {
+ return responseTimeHistogramMaxYAxis;
+ }
+
+ public void setResponseTimeHistogramMaxYAxis(long responseTimeHistogramMaxYAxis) {
+ this.responseTimeHistogramMaxYAxis = responseTimeHistogramMaxYAxis;
+ }
+
+ public int getResponseTimeHistogramNumBins() {
+ return responseTimeHistogramNumBins;
+ }
+
+ public void setResponseTimeHistogramNumBins(int responseTimeHistogramNumBins) {
+ this.responseTimeHistogramNumBins = responseTimeHistogramNumBins;
+ }
+
+ public int getResponseTimeHistogramNumDecimalPoints() {
+ return responseTimeHistogramNumDecimalPoints;
+ }
+
+ public void setResponseTimeHistogramNumDecimalPoints(int responseTimeHistogramNumDecimalPoints) {
+ this.responseTimeHistogramNumDecimalPoints = responseTimeHistogramNumDecimalPoints;
+ }
+
+ public String getTpsHistogramLabel() {
+ return tpsHistogramLabel;
+ }
+
+ public void setTpsHistogramLabel(String tpsHistogramLabel) {
+ this.tpsHistogramLabel = tpsHistogramLabel;
+ }
+
+ public long getTpsHistogramMaxYAxis() {
+ return tpsHistogramMaxYAxis;
+ }
+
+ public void setTpsHistogramMaxYAxis(long tpsHistogramMaxYAxis) {
+ this.tpsHistogramMaxYAxis = tpsHistogramMaxYAxis;
+ }
+
+ public int getTpsHistogramNumBins() {
+ return tpsHistogramNumBins;
+ }
+
+ public void setTpsHistogramNumBins(int tpsHistogramNumBins) {
+ this.tpsHistogramNumBins = tpsHistogramNumBins;
+ }
+
+ public int getTpsHistogramNumDecimalPoints() {
+ return tpsHistogramNumDecimalPoints;
+ }
+
+ public void setTpsHistogramNumDecimalPoints(int tpsHistogramNumDecimalPoints) {
+ this.tpsHistogramNumDecimalPoints = tpsHistogramNumDecimalPoints;
+ }
+
+}
diff --git a/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java b/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java
index f7fc4a2..8569712 100644
--- a/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java
+++ b/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java
@@ -40,7 +40,7 @@ public class TierSupportUiConstants {
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";
@@ -56,7 +56,10 @@ public class TierSupportUiConstants {
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 =
@@ -65,6 +68,10 @@ public class TierSupportUiConstants {
"/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";
// JUnit testing synchronizer.properties file
public static String TEST_CONFIG_FILE =
@@ -183,6 +190,21 @@ public class TierSupportUiConstants {
}
/**
+ * @return the cONFIG_FILTERS_BASE_LOCATION
+ */
+ public static String getCONFIG_FILTERS_BASE_LOCATION() {
+ return CONFIG_FILTERS_BASE_LOCATION;
+ }
+
+ /**
+ * @param cONFIG_FILTERS_BASE_LOCATION the cONFIG_FILTERS_BASE_LOCATION to set
+ */
+ public static void setCONFIG_FILTERS_BASE_LOCATION(String cONFIG_FILTERS_BASE_LOCATION) {
+ CONFIG_FILTERS_BASE_LOCATION = cONFIG_FILTERS_BASE_LOCATION;
+ }
+
+
+ /**
* @return the cONFIG_AUTH_LOCATION
*/
public static String getCONFIG_AUTH_LOCATION() {
diff --git a/src/test/java/org/onap/aai/sparky/search/filters/FilterProcessorTest.java b/src/test/java/org/onap/aai/sparky/search/filters/FilterProcessorTest.java
new file mode 100644
index 0000000..a6c4f22
--- /dev/null
+++ b/src/test/java/org/onap/aai/sparky/search/filters/FilterProcessorTest.java
@@ -0,0 +1,373 @@
+/**
+ * ============LICENSE_START=================================================== SPARKY (AAI UI
+ * service) ============================================================================ Copyright ©
+ * 2017 AT&T Intellectual Property. Copyright © 2017 Amdocs All rights reserved.
+ * ============================================================================ 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=====================================================
+ *
+ * ECOMP and OpenECOMP are trademarks and service marks of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.sparky.search.filters;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonObject;
+import javax.json.JsonReader;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.component.restlet.RestletConstants;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+import org.onap.aai.sparky.search.filters.FilterProcessor;
+import org.onap.aai.sparky.search.filters.FilteredSearchHelper;
+import org.onap.aai.sparky.search.filters.config.UiFilterConfig;
+import org.onap.aai.sparky.search.filters.config.UiFilterListItemConfig;
+import org.onap.aai.sparky.search.filters.config.UiFilterOptionsValuesConfig;
+import org.onap.aai.sparky.search.filters.config.FiltersDetailsConfig;
+import org.onap.aai.sparky.search.filters.config.FiltersConfig;
+import org.onap.aai.sparky.search.filters.config.UiViewListItemConfig;
+import org.onap.aai.sparky.search.filters.entity.DiscoverFiltersRequest;
+import org.onap.aai.sparky.search.filters.entity.ViewConfiguration;
+import org.onap.aai.sparky.search.filters.entity.ViewFilter;
+import org.onap.aai.sparky.util.NodeUtils;
+import org.onap.aai.sparky.search.filters.config.FiltersForViewsConfig;
+import org.restlet.Request;
+import org.restlet.Response;
+import org.restlet.data.MediaType;
+import org.restlet.data.Status;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class FilterProcessorTest {
+
+ private FilterProcessor filterProcessor;
+ private Exchange mockExchange;
+ private Message mockRequestMessage;
+ private Message mockResponseMessage;
+ private Request mockRestletRequest;
+ private Response mockRestletResponse;
+ private FilteredSearchHelper filteredSearchHelper;
+ private ObjectMapper mapper;
+
+ protected UiViewListItemConfig generateViewConfig(ViewConfiguration viewConfig) {
+
+ UiViewListItemConfig uiViewConfig = new UiViewListItemConfig(viewConfig.getViewName(), null);
+
+ List<UiFilterListItemConfig> filters = new ArrayList<UiFilterListItemConfig>();
+
+ for (ViewFilter viewFilter : viewConfig.getViewFilters()) {
+ filters.add(new UiFilterListItemConfig(viewFilter.getId(), viewFilter.getDefaultValue()));
+ }
+
+ uiViewConfig.setListOfFilters(filters);
+
+ return uiViewConfig;
+ }
+
+ protected FiltersConfig generateDefaultViewsFilterConfig() {
+
+ FiltersForViewsConfig uiViewsConfig = new FiltersForViewsConfig();
+ FiltersConfig viewFilterConfig = FiltersConfig.getInstance();
+
+ List<UiViewListItemConfig> views = new ArrayList<UiViewListItemConfig>();
+
+ // Default filter value to use below
+ UiFilterOptionsValuesConfig defaultValue =
+ new UiFilterOptionsValuesConfig("Today", "Last 0 hours");
+
+ // VNF View - 4 Filters
+ ViewConfiguration vnfViewConfig = new ViewConfiguration("vnfSearch");
+ vnfViewConfig.addViewFilter(new ViewFilter("1", null));
+ vnfViewConfig.addViewFilter(new ViewFilter("2", null));
+ vnfViewConfig.addViewFilter(new ViewFilter("7", null));
+ vnfViewConfig.addViewFilter(new ViewFilter("8", null));
+ views.add(generateViewConfig(vnfViewConfig));
+
+ // View and Inspect (Schema) - 0 Filters
+ ViewConfiguration viewInspectConfig = new ViewConfiguration("viewInspect");
+ views.add(generateViewConfig(viewInspectConfig));
+
+ // Data Integrity - 4 Filters
+ ViewConfiguration dataIntegrityConfig = new ViewConfiguration("dataIntegrity");
+ dataIntegrityConfig.addViewFilter(new ViewFilter("3", null));
+ dataIntegrityConfig.addViewFilter(new ViewFilter("4", null));
+ dataIntegrityConfig.addViewFilter(new ViewFilter("5", defaultValue));
+ dataIntegrityConfig.addViewFilter(new ViewFilter("6", null));
+ views.add(generateViewConfig(dataIntegrityConfig));
+
+ uiViewsConfig.setViews(views);
+
+ viewFilterConfig.setViewsConfig(uiViewsConfig);
+
+ List<UiFilterOptionsValuesConfig> optionsValues = new ArrayList<UiFilterOptionsValuesConfig>();
+ optionsValues.add(new UiFilterOptionsValuesConfig("Today", "Last 0 hours"));
+ optionsValues.add(new UiFilterOptionsValuesConfig("Since Yesterday", "Last 24 hours"));
+ optionsValues.add(new UiFilterOptionsValuesConfig("Since Last Week", "Last 7 days"));
+ optionsValues.add(new UiFilterOptionsValuesConfig("Since Last Month", "Last 30 days"));
+ optionsValues.add(new UiFilterOptionsValuesConfig("Custom Range", "Custom Range"));
+
+
+
+ FiltersDetailsConfig uiFiltersConfig = new FiltersDetailsConfig();
+
+ List<UiFilterConfig> uiFilterConfig = new ArrayList<UiFilterConfig>();
+ uiFilterConfig.add(new UiFilterConfig("1", "filterName1", "Display Name 1", "dropDown", "false",
+ "Any 1", null, "options", null, null));
+ uiFilterConfig.add(new UiFilterConfig("2", "filterName2", "Display Name 2", "dropDown", "false",
+ "Any 2", null, "options", null, null));
+ uiFilterConfig.add(new UiFilterConfig("3", "filterName3", "Display Name 3", "dropDown", "false",
+ "Any 3", null, "options", null, null));
+ uiFilterConfig.add(new UiFilterConfig("4", "filterName4", "Display Name 4", "dropDown", "false",
+ "Any 4", null, "options", null, null));
+ uiFilterConfig.add(new UiFilterConfig("5", "filterName5", "Display Name 5", "date", "false",
+ "Any 5", defaultValue, "dynamicOptions", optionsValues, null));
+ uiFilterConfig.add(new UiFilterConfig("6", "filterName6", "Display Name 6", "dropDown", "false",
+ "Any 6", null, "options", null, null));
+ uiFilterConfig.add(new UiFilterConfig("7", "filterName7", "Display Name 7", "dropDown", "false",
+ "Any 7", null, "options", null, null));
+ uiFilterConfig.add(new UiFilterConfig("8", "filterName8", "Display Name 8", "dropDown", "false",
+ "Any 8", null, "options", null, null));
+
+ uiFiltersConfig.setFilters(uiFilterConfig);
+
+ viewFilterConfig.setFiltersConfig(uiFiltersConfig);
+
+ return viewFilterConfig;
+ }
+
+ @Before
+ public void init() {
+ mockExchange = Mockito.mock(Exchange.class);
+ mockRequestMessage = Mockito.mock(Message.class);
+ mockResponseMessage = Mockito.mock(Message.class);
+ mockRestletRequest = Mockito.mock(Request.class);
+ mockRestletResponse = Mockito.mock(Response.class);
+
+ filteredSearchHelper = new FilteredSearchHelper(generateDefaultViewsFilterConfig());
+ filterProcessor = new FilterProcessor(filteredSearchHelper);
+
+ mapper = new ObjectMapper();
+ }
+
+
+ @Test
+ public void validateDefaultConstructor() {
+ assertNotNull(filterProcessor.getMapper());
+ assertNotNull(filterProcessor.getFilteredSearchHelper());
+ }
+
+ private void verifyResponseAndNumFiltersForBadRequest(Status expectedStatus,
+ int numExpectedFilters) throws JsonParseException, JsonMappingException, IOException {
+
+ ArgumentCaptor<Status> responseCodeCaptor = ArgumentCaptor.forClass(Status.class);
+ Mockito.verify(mockRestletResponse, Mockito.atLeast(1)).setStatus(responseCodeCaptor.capture());
+ assertEquals(expectedStatus, responseCodeCaptor.getValue());
+
+ ArgumentCaptor<String> entityPayload = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<MediaType> payloadMediaType = ArgumentCaptor.forClass(MediaType.class);
+ Mockito.verify(mockRestletResponse, Mockito.atLeast(1)).setEntity(entityPayload.capture(),
+ payloadMediaType.capture());
+ assertNotNull(entityPayload.getValue());
+
+ ArgumentCaptor<Response> responseObject = ArgumentCaptor.forClass(Response.class);
+ Mockito.verify(mockResponseMessage, Mockito.atLeast(1)).setBody(responseObject.capture());
+ assertEquals(MediaType.APPLICATION_JSON, payloadMediaType.getValue());
+
+ JsonReader jsonReader = Json.createReader(new StringReader(entityPayload.getValue()));
+ JsonObject responsePayload = jsonReader.readObject();
+
+ JsonObject filters = responsePayload.getJsonObject("filters");
+ assertEquals(0, filters.size());
+ }
+
+ private void initializeMocks(String requestPayload) {
+
+ Mockito.when(mockRequestMessage.getBody(String.class)).thenReturn(requestPayload);
+
+ Mockito.when(mockExchange.getIn()).thenReturn(mockRequestMessage);
+ Mockito.when(mockExchange.getOut()).thenReturn(mockResponseMessage);
+
+ Mockito.when(mockRequestMessage.getHeader(RestletConstants.RESTLET_REQUEST, Request.class))
+ .thenReturn(mockRestletRequest);
+ Mockito.when(mockRequestMessage.getHeader(RestletConstants.RESTLET_RESPONSE, Response.class))
+ .thenReturn(mockRestletResponse);
+ }
+
+
+ @Test
+ public void testGetFiltersWithValues_success_path() throws IOException {
+
+ // Initialize for call against 'vnfSearch'
+ DiscoverFiltersRequest vnfSearchrequest = new DiscoverFiltersRequest();
+ vnfSearchrequest.setViewName("vnfSearch");
+
+ initializeMocks(NodeUtils.convertObjectToJson(vnfSearchrequest, false));
+
+ // Test call against 'vnfSearch'
+ filterProcessor.getFiltersWithValues(mockExchange);
+
+ ArgumentCaptor<Status> vnfResponseCodeCaptor = ArgumentCaptor.forClass(Status.class);
+ Mockito.verify(mockRestletResponse, Mockito.atLeast(1))
+ .setStatus(vnfResponseCodeCaptor.capture());
+ assertEquals(Status.SUCCESS_OK, vnfResponseCodeCaptor.getValue());
+
+ ArgumentCaptor<String> vnfEntityPayload = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<MediaType> vnfPayloadMediaType = ArgumentCaptor.forClass(MediaType.class);
+ Mockito.verify(mockRestletResponse, Mockito.atLeast(1)).setEntity(vnfEntityPayload.capture(),
+ vnfPayloadMediaType.capture());
+ assertNotNull(vnfEntityPayload.getValue());
+
+ ArgumentCaptor<Response> vnfResponseObject = ArgumentCaptor.forClass(Response.class);
+ Mockito.verify(mockResponseMessage, Mockito.atLeast(1)).setBody(vnfResponseObject.capture());
+ assertEquals(MediaType.APPLICATION_JSON, vnfPayloadMediaType.getValue());
+
+ JsonReader vnfJsonReader = Json.createReader(new StringReader(vnfEntityPayload.getValue()));
+ JsonObject vnfResponsePayload = vnfJsonReader.readObject();
+
+ JsonObject vnfFilters = vnfResponsePayload.getJsonObject("filters");
+ assertNotNull(vnfFilters);
+ assertEquals(4, vnfFilters.size());
+
+ JsonObject filterOne = vnfFilters.getJsonObject("1");
+ assertNotNull(filterOne);
+ assertEquals("Display Name 1", filterOne.getString("label"));
+
+ JsonObject filterEight = vnfFilters.getJsonObject("8");
+ assertNotNull(filterEight);
+ JsonObject eightInnerControl =
+ filterEight.getJsonObject("controls").getJsonObject("filterName8");
+ assertEquals(4, eightInnerControl.size());
+ assertEquals("dropDown", eightInnerControl.getString("type"));
+ assertEquals("false", eightInnerControl.getString("multiSelect"));
+ assertEquals("Any 8", eightInnerControl.getString("watermark"));
+ assertEquals(0, eightInnerControl.getJsonArray("options").size());
+
+ // Initialize for call against 'dataIntegrity'
+ DiscoverFiltersRequest dataIntegrityRequest = new DiscoverFiltersRequest();
+ dataIntegrityRequest.setViewName("dataIntegrity");
+
+ initializeMocks(NodeUtils.convertObjectToJson(dataIntegrityRequest, false));
+
+ // Test call against 'dataIntegrity'
+ filterProcessor.getFiltersWithValues(mockExchange);
+
+ ArgumentCaptor<Status> dIResponseCodeCaptor = ArgumentCaptor.forClass(Status.class);
+ Mockito.verify(mockRestletResponse, Mockito.atLeast(1))
+ .setStatus(dIResponseCodeCaptor.capture());
+ assertEquals(Status.SUCCESS_OK, dIResponseCodeCaptor.getValue());
+
+ ArgumentCaptor<String> dIEntityPayload = ArgumentCaptor.forClass(String.class);
+ ArgumentCaptor<MediaType> dIPayloadMediaType = ArgumentCaptor.forClass(MediaType.class);
+ Mockito.verify(mockRestletResponse, Mockito.atLeast(1)).setEntity(dIEntityPayload.capture(),
+ dIPayloadMediaType.capture());
+ assertNotNull(dIEntityPayload.getValue());
+
+ ArgumentCaptor<Response> dIResponseObject = ArgumentCaptor.forClass(Response.class);
+ Mockito.verify(mockResponseMessage, Mockito.atLeast(1)).setBody(dIResponseObject.capture());
+ assertEquals(MediaType.APPLICATION_JSON, dIPayloadMediaType.getValue());
+
+ JsonReader dIJsonReader = Json.createReader(new StringReader(dIEntityPayload.getValue()));
+ JsonObject dIResponsePayload = dIJsonReader.readObject();
+
+ JsonObject dIFilters = dIResponsePayload.getJsonObject("filters");
+ assertNotNull(dIFilters);
+ assertEquals(4, dIFilters.size());
+
+ JsonObject filterFour = dIFilters.getJsonObject("4");
+ assertNotNull(filterFour);
+ assertEquals("Display Name 4", filterFour.getString("label"));
+
+ JsonObject filterFive = dIFilters.getJsonObject("5");
+ assertNotNull(filterFive);
+ JsonObject fiveInnerControl = filterFive.getJsonObject("controls").getJsonObject("filterName5");
+ assertEquals(5, fiveInnerControl.size());
+ assertEquals("date", fiveInnerControl.getString("type"));
+ assertEquals("false", fiveInnerControl.getString("multiSelect"));
+ assertEquals("Any 5", fiveInnerControl.getString("watermark"));
+ JsonArray dynamicOptions = fiveInnerControl.getJsonArray("dynamicOptions");
+ assertEquals(5, dynamicOptions.size());
+ JsonObject today = dynamicOptions.getJsonObject(0);
+ assertEquals("Today", today.getString("decode"));
+ }
+
+ @Test
+ public void testGetFiltersWithValues_viewNameNull() throws IOException {
+
+ DiscoverFiltersRequest discoverFiltersRequest = new DiscoverFiltersRequest();
+ initializeMocks(NodeUtils.convertObjectToJson(discoverFiltersRequest, false));
+
+ // Method under test
+ filterProcessor.getFiltersWithValues(mockExchange);
+
+ verifyResponseAndNumFiltersForBadRequest(Status.SUCCESS_OK, 0);
+ }
+
+ @Test
+ public void testGetFiltersWithValues_viewNameEmptyString() throws IOException {
+
+ DiscoverFiltersRequest discoverFiltersRequest = new DiscoverFiltersRequest();
+ discoverFiltersRequest.setViewName("");
+
+ initializeMocks(NodeUtils.convertObjectToJson(discoverFiltersRequest, false));
+
+ // Method under test
+ filterProcessor.getFiltersWithValues(mockExchange);
+
+ verifyResponseAndNumFiltersForBadRequest(Status.SUCCESS_OK, 0);
+ }
+
+ @Test
+ public void testGetFiltersWithValues_requestPayloadIsNull() throws IOException {
+
+ initializeMocks(null);
+
+ // Method under test
+ filterProcessor.getFiltersWithValues(mockExchange);
+
+ verifyResponseAndNumFiltersForBadRequest(Status.SUCCESS_OK, 0);
+ }
+
+ @Test
+ public void testGetFiltersWithValues_requestPayloadIsEmptyString() throws IOException {
+
+ initializeMocks("");
+
+ // Method under test
+ filterProcessor.getFiltersWithValues(mockExchange);
+
+ verifyResponseAndNumFiltersForBadRequest(Status.SUCCESS_OK, 0);
+ }
+
+ @Test
+ public void testGetFiltersWithValues_requestPayloadCausesException() throws IOException {
+
+ initializeMocks("{");
+
+ // Method under test
+ filterProcessor.getFiltersWithValues(mockExchange);
+
+ verifyResponseAndNumFiltersForBadRequest(Status.SUCCESS_OK, 0);
+ }
+}
diff --git a/src/test/java/org/onap/aai/sparky/search/filters/FilteredSearchHelperTest.java b/src/test/java/org/onap/aai/sparky/search/filters/FilteredSearchHelperTest.java
new file mode 100644
index 0000000..aa37d42
--- /dev/null
+++ b/src/test/java/org/onap/aai/sparky/search/filters/FilteredSearchHelperTest.java
@@ -0,0 +1,69 @@
+/**
+ * ============LICENSE_START===================================================
+ * SPARKY (AAI UI service)
+ * ============================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * All rights reserved.
+ * ============================================================================
+ * 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=====================================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.sparky.search.filters;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.aai.sparky.search.filters.FilteredSearchHelper;
+import org.onap.aai.sparky.search.filters.config.FiltersConfig;
+
+public class FilteredSearchHelperTest {
+
+ private static FilteredSearchHelper filteredSearchHelper;
+
+ @BeforeClass
+ public static void init() throws IOException {
+ FiltersConfig config = FiltersConfig.getInstance();
+ config.setFilterMappingsFileName("src/test/resources/filters/aaiui_views.json");
+ config.setFiltersFileName("src/test/resources/filters/aaiui_filters.json");
+ System.out.println("SETTING UIVIEWSCONFIG");
+ config.setViewsConfig(config.readUiViewsConfig());
+ System.out.println("SETTING UIFILTERSCONFIG");
+ config.setFiltersConfig(config.readUiFiltersConfig());
+
+ filteredSearchHelper = new FilteredSearchHelper(config);
+ }
+
+ @Test
+ public void testDoFilterDiscovery_validViewName() {
+ assertEquals(4, filteredSearchHelper.doFilterDiscovery("vnfSearch").getFilters().size());
+ assertEquals(4, filteredSearchHelper.doFilterDiscovery("dataIntegrity").getFilters().size());
+ }
+
+ @Test
+ public void testDoFilterDiscovery_invalidViewName_nameGiven() {
+ assertEquals(0, filteredSearchHelper.doFilterDiscovery("InvalidViewName").getFilters().size());
+ }
+
+ @Test
+ public void testDoFilterDiscovery_invalidViewName_emptyString() {
+ assertEquals(0, filteredSearchHelper.doFilterDiscovery("").getFilters().size());
+ }
+}
diff --git a/src/test/java/org/onap/aai/sparky/search/filters/entity/DiscoverFiltersRequest.java b/src/test/java/org/onap/aai/sparky/search/filters/entity/DiscoverFiltersRequest.java
new file mode 100644
index 0000000..336e3b1
--- /dev/null
+++ b/src/test/java/org/onap/aai/sparky/search/filters/entity/DiscoverFiltersRequest.java
@@ -0,0 +1,40 @@
+/**
+ * ============LICENSE_START===================================================
+ * SPARKY (AAI UI service)
+ * ============================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * All rights reserved.
+ * ============================================================================
+ * 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=====================================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.sparky.search.filters.entity;
+
+public class DiscoverFiltersRequest {
+
+ private String viewName;
+
+ public String getViewName() {
+ return viewName;
+ }
+
+ public void setViewName(String viewName) {
+ this.viewName = viewName;
+ }
+
+}
diff --git a/src/test/java/org/onap/aai/sparky/search/filters/entity/ViewConfiguration.java b/src/test/java/org/onap/aai/sparky/search/filters/entity/ViewConfiguration.java
new file mode 100644
index 0000000..f6c352b
--- /dev/null
+++ b/src/test/java/org/onap/aai/sparky/search/filters/entity/ViewConfiguration.java
@@ -0,0 +1,68 @@
+/**
+ * ============LICENSE_START===================================================
+ * SPARKY (AAI UI service)
+ * ============================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * All rights reserved.
+ * ============================================================================
+ * 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=====================================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.sparky.search.filters.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ViewConfiguration {
+
+ private String viewName;
+ private List<ViewFilter> viewFilters;
+
+ public ViewConfiguration() {
+ viewFilters = new ArrayList<ViewFilter>();
+ }
+
+ public ViewConfiguration(String viewName) {
+ viewFilters = new ArrayList<ViewFilter>();
+ this.setViewName(viewName);
+ }
+
+ public String getViewName() {
+ return viewName;
+ }
+
+ public void setViewName(String viewName) {
+ this.viewName = viewName;
+ }
+
+ public List<ViewFilter> getViewFilters() {
+ return viewFilters;
+ }
+
+ public void setViewFilters(List<ViewFilter> viewFilters) {
+ this.viewFilters = viewFilters;
+ }
+
+ public void addViewFilter(ViewFilter viewFilter) {
+ if (viewFilters != null) {
+ if (!viewFilters.contains(viewFilter)) {
+ viewFilters.add(viewFilter);
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/onap/aai/sparky/search/filters/entity/ViewFilter.java b/src/test/java/org/onap/aai/sparky/search/filters/entity/ViewFilter.java
new file mode 100644
index 0000000..94832d5
--- /dev/null
+++ b/src/test/java/org/onap/aai/sparky/search/filters/entity/ViewFilter.java
@@ -0,0 +1,57 @@
+/**
+ * ============LICENSE_START===================================================
+ * SPARKY (AAI UI service)
+ * ============================================================================
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * All rights reserved.
+ * ============================================================================
+ * 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=====================================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
+ */
+
+package org.onap.aai.sparky.search.filters.entity;
+
+import org.onap.aai.sparky.search.filters.config.UiFilterOptionsValuesConfig;
+
+public class ViewFilter {
+
+ private String id;
+ private UiFilterOptionsValuesConfig defaultValue;
+
+ public ViewFilter() {}
+
+ public ViewFilter(String id, UiFilterOptionsValuesConfig defaultValue) {
+ this.id = id;
+ this.defaultValue = defaultValue;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public UiFilterOptionsValuesConfig getDefaultValue() {
+ return defaultValue;
+ }
+
+ public void setDefaultValue(UiFilterOptionsValuesConfig defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+}
diff --git a/src/test/resources/filters/AggregationSuggestionEntity_getIndexDocumentJson_expected.json b/src/test/resources/filters/AggregationSuggestionEntity_getIndexDocumentJson_expected.json
new file mode 100644
index 0000000..53e9ec9
--- /dev/null
+++ b/src/test/resources/filters/AggregationSuggestionEntity_getIndexDocumentJson_expected.json
@@ -0,0 +1 @@
+"filterList":[{"filterId":"1"},{"filterId":"2"},{"filterId":"7"},{"filterId":"8"}] \ No newline at end of file
diff --git a/src/test/resources/filters/aaiui_filters.json b/src/test/resources/filters/aaiui_filters.json
new file mode 100644
index 0000000..31716ed
--- /dev/null
+++ b/src/test/resources/filters/aaiui_filters.json
@@ -0,0 +1,88 @@
+{
+ "filters": [
+ {
+ "filterId": "1",
+ "filterName": "Orchestration-Status",
+ "displayName": "Orchestration Status",
+ "dataType": "list",
+ "dataSource": {
+ "indexName": "aggregate_generic-vnf_index",
+ "docType": "default",
+ "fieldName": "orchestration-status"
+ }
+ },
+ {
+ "filterId": "2",
+ "filterName": "Prov-Status",
+ "displayName": "Provisioning Status",
+ "dataType": "list",
+ "dataSource": {
+ "indexName": "aggregate_generic-vnf_index",
+ "docType": "default",
+ "fieldName": "prov-status"
+ }
+ },
+ {
+ "filterId": "3",
+ "filterName": "Severity",
+ "displayName": "Severity",
+ "dataType": "list",
+ "dataSource": {
+ "indexName": "di-violations",
+ "docType": "default",
+ "fieldName": "severity"
+ }
+ },
+ {
+ "filterId": "4",
+ "filterName": "Category",
+ "displayName": "Category",
+ "dataType": "list",
+ "dataSource": {
+ "indexName": "di-violations",
+ "docType": "default",
+ "fieldName": "category"
+ }
+ },
+ {
+ "filterId": "5",
+ "filterName": "Date",
+ "displayName": "Date",
+ "dataType": "date"
+ },
+ {
+ "filterId": "6",
+ "filterName": "EntityType",
+ "displayName": "Object Type",
+ "dataType": "list",
+ "dataSource": {
+ "indexName": "di-violations",
+ "docType": "default",
+ "fieldName": "entityType"
+ }
+ },
+ {
+ "filterId": "7",
+ "filterName": "NF-Type",
+ "displayName": "Network Function Type",
+ "dataType": "list",
+ "dataSource": {
+ "indexName": "aggregate_generic-vnf_index",
+ "docType": "default",
+ "fieldName": "nf-type"
+ }
+ },
+ {
+ "filterId": "8",
+ "filterName": "NF-Role",
+ "displayName": "Network Function Role",
+ "dataType": "list",
+ "dataSource": {
+ "indexName": "aggregate_generic-vnf_index",
+ "docType": "default",
+ "fieldName": "nf-role"
+ }
+ }
+
+ ]
+} \ No newline at end of file
diff --git a/src/test/resources/filters/aaiui_views.json b/src/test/resources/filters/aaiui_views.json
new file mode 100644
index 0000000..e6ece9f
--- /dev/null
+++ b/src/test/resources/filters/aaiui_views.json
@@ -0,0 +1,38 @@
+{
+ "views": [
+ {
+ "viewName" : "vnfSearch",
+ "filters" : [
+ {
+ "filterId": "1"
+ },
+ {
+ "filterId": "2"
+ },
+ {
+ "filterId": "7"
+ },
+ {
+ "filterId": "8"
+ }
+ ]
+ },
+ {
+ "viewName" : "dataIntegrity",
+ "filters" : [
+ {
+ "filterId": "3"
+ },
+ {
+ "filterId": "4"
+ },
+ {
+ "filterId": "5"
+ },
+ {
+ "filterId": "6"
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/src/test/resources/filters/filterAggregationEndpoint_emptyRequestBody_expectedResponse.json b/src/test/resources/filters/filterAggregationEndpoint_emptyRequestBody_expectedResponse.json
new file mode 100644
index 0000000..95a2b16
--- /dev/null
+++ b/src/test/resources/filters/filterAggregationEndpoint_emptyRequestBody_expectedResponse.json
@@ -0,0 +1 @@
+{"count":0} \ No newline at end of file
diff --git a/src/test/resources/filters/filterAggregationEndpoint_emptyRequestFilterArray_expectedResponse.json b/src/test/resources/filters/filterAggregationEndpoint_emptyRequestFilterArray_expectedResponse.json
new file mode 100644
index 0000000..36ae0a5
--- /dev/null
+++ b/src/test/resources/filters/filterAggregationEndpoint_emptyRequestFilterArray_expectedResponse.json
@@ -0,0 +1 @@
+{"groupby_aggregation":[{"totalChartHits":0,"buckets":[]}]} \ No newline at end of file
diff --git a/src/test/resources/filters/filterAggregationEndpoint_emptyRequestFilterArray_requestBody.json b/src/test/resources/filters/filterAggregationEndpoint_emptyRequestFilterArray_requestBody.json
new file mode 100644
index 0000000..ba7d987
--- /dev/null
+++ b/src/test/resources/filters/filterAggregationEndpoint_emptyRequestFilterArray_requestBody.json
@@ -0,0 +1,3 @@
+{
+ "filters": []
+} \ No newline at end of file
diff --git a/src/test/resources/filters/filterAggregationEndpoint_successPath_expectedResponse.json b/src/test/resources/filters/filterAggregationEndpoint_successPath_expectedResponse.json
new file mode 100644
index 0000000..e2c5766
--- /dev/null
+++ b/src/test/resources/filters/filterAggregationEndpoint_successPath_expectedResponse.json
@@ -0,0 +1 @@
+{"total":116,"aggregations":{"prov-status":[{"doc_count":77,"key":""},{"doc_count":2,"key":"PREPROV"}],"orchestration-status":[{"doc_count":116,"key":"Created"}]}}
diff --git a/src/test/resources/filters/filterAggregationEndpoint_successPath_operationResult.json b/src/test/resources/filters/filterAggregationEndpoint_successPath_operationResult.json
new file mode 100644
index 0000000..753a11f
--- /dev/null
+++ b/src/test/resources/filters/filterAggregationEndpoint_successPath_operationResult.json
@@ -0,0 +1 @@
+{"took":39,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":116,"max_score":0.0,"hits":[]},"aggregations":{"prov-status":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[{"key":"","doc_count":77},{"key":"PREPROV","doc_count":2}]},"orchestration-status":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[{"key":"Created","doc_count":116}]}}} \ No newline at end of file
diff --git a/src/test/resources/filters/filterAggregationEndpoint_successPath_requestBody.json b/src/test/resources/filters/filterAggregationEndpoint_successPath_requestBody.json
new file mode 100644
index 0000000..c321760
--- /dev/null
+++ b/src/test/resources/filters/filterAggregationEndpoint_successPath_requestBody.json
@@ -0,0 +1,11 @@
+{
+ "filters": [
+ {
+ "filterId": "1",
+ "filterValue": "Created"
+ },
+ {
+ "filterId": "2"
+ }
+ ]
+} \ No newline at end of file