*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-package org.onap.aai.sparky.synchronizer.entity;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
+package org.onap.aai.sparky.sync.entity;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
+import org.onap.aai.sparky.search.filters.config.FiltersConfig;
+import org.onap.aai.sparky.search.filters.config.UiFilterListItemConfig;
+import org.onap.aai.sparky.search.filters.config.UiViewListItemConfig;
import org.onap.aai.sparky.util.NodeUtils;
-public class AggregationSuggestionEntity extends IndexableEntity implements IndexDocument {
-
- private List<String> inputs = new ArrayList<String>();
-
- /**
- * @return the inputs
- */
- public List<String> getInputs() {
- return inputs;
- }
-
- /**
- * @param inputs the inputs to set
- */
- public void setInputs(List<String> inputs) {
- this.inputs = inputs;
- }
-
- /**
- * @return the mapper
- */
- public ObjectMapper getMapper() {
- return mapper;
- }
+import com.fasterxml.jackson.databind.ObjectMapper;
- /**
- * @param mapper the mapper to set
- */
- public void setMapper(ObjectMapper mapper) {
- this.mapper = mapper;
- }
+public class AggregationSuggestionEntity extends IndexableEntity implements IndexDocument {
- /**
- * @return the outputString
- */
- public String getOutputString() {
- return outputString;
- }
+ private static final String FILTER_ID = "filterId";
+ private static final String FILTER_LIST = "filterList";
+ private List<String> inputs = new ArrayList<>();
private final String outputString = "VNFs";
protected ObjectMapper mapper = new ObjectMapper();
+ List<String> filterIds = new ArrayList<>();
public AggregationSuggestionEntity() {
super();
}
@Override
- public String getIndexDocumentJson() {
-
+ public String getAsJson() {
JSONArray inputArray = new JSONArray();
for (String input : inputs) {
input = input.replace(",", "");
entitySuggest.put("output", this.outputString);
entitySuggest.put("weight", 100);
+ JSONArray payloadFilters = new JSONArray();
+
+ for (String filterId : filterIds) {
+ JSONObject filterPayload = new JSONObject();
+ filterPayload.put(FILTER_ID, filterId);
+ payloadFilters.put(filterPayload);
+ }
+
JSONObject payloadNode = new JSONObject();
+ payloadNode.put(FILTER_LIST, payloadFilters);
entitySuggest.put("payload", payloadNode);
JSONObject rootNode = new JSONObject();
return rootNode.toString();
}
- @Override
- public ObjectNode getBulkImportEntity() {
- // TODO Auto-generated method stub
- return null;
+ public void initializeFilters() {
+ for (UiViewListItemConfig view : FiltersConfig.getInstance().getViewsConfig().getViews()) {
+ if (view.getViewName().equals("vnfSearch")) {
+ for (UiFilterListItemConfig currentViewFilter : view.getFilters()) {
+ filterIds.add(currentViewFilter.getFilterId());
+ }
+ }
+ }
}
+ public void setFilterIds(List<String> filterIds) {
+ this.filterIds = filterIds;
+ }
}