Adding interfaces in documentation
[aai/sparky-be.git] / src / main / java / org / onap / aai / sparky / search / filters / entity / UiFilterEntity.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.aai.sparky.search.filters.entity;
22
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import org.onap.aai.sparky.search.filters.config.UiFilterConfig;
27 import org.onap.aai.sparky.search.filters.config.UiFilterOptionsValuesConfig;
28
29 import com.fasterxml.jackson.annotation.JsonInclude;
30 import com.fasterxml.jackson.annotation.JsonInclude.Include;
31
32 /**
33  * Stores data for a single filter for a given UI view.
34  * <p>
35  * When a UI view wants to know which filters it should display, an object of this class is created for each
36  * filter discovered and stores data for that filter. Each filter/object of this class is added to a
37  * ViewFilterList object which is then serialized to JSON and returned to the view in the response body. 
38  */
39 @JsonInclude(Include.NON_NULL)
40 public class UiFilterEntity {
41   private String filterId;
42   private String filterName;
43   private String displayName;
44   private String dataType;
45   
46   private String multiSelect;
47   private String watermark;
48   private UiFilterOptionsValuesConfig defaultValue;
49   private String optionsType;
50   
51   private List<UiFilterOptionsValuesConfig> optionsValues;
52   
53   private List<UiFilterValueEntity> filterValueList;
54
55   public UiFilterEntity() {}
56   
57   public UiFilterEntity(UiFilterConfig filterConfig) {
58     if (filterConfig.getFilterId() != null) {
59       this.setFilterId(filterConfig.getFilterId());
60     }
61     if (filterConfig.getFilterName() != null) {
62       this.setFilterName(filterConfig.getFilterName());
63     }
64     if (filterConfig.getDisplayName() != null) {
65       this.setDisplayName(filterConfig.getDisplayName());
66     }
67     if (filterConfig.getDataType() != null) {
68       this.setDataType(filterConfig.getDataType());
69     }
70     if (filterConfig.getMultiSelect() != null) {
71       this.setMultiSelect(filterConfig.getMultiSelect());
72     }
73     if (filterConfig.getWatermark() != null) {
74       this.setWatermark(filterConfig.getWatermark());
75     }
76     if (filterConfig.getDefaultValue() != null) {
77       this.setDefaultValue(filterConfig.getDefaultValue());
78     }
79     if (filterConfig.getOptionsType() != null) {
80       this.setOptionsType(filterConfig.getOptionsType());
81     }
82     if(filterConfig.getOptionsValues() != null && !filterConfig.getOptionsValues().isEmpty()) {
83       this.setOptionsValues(filterConfig.getOptionsValues());
84     } else {
85       this.optionsValues = new ArrayList<UiFilterOptionsValuesConfig>();
86     }
87   }
88   
89   public void addFilterValue(UiFilterValueEntity valueEntity) {
90     if (null == filterValueList) {
91       filterValueList = new ArrayList<>();
92     }
93
94     this.filterValueList.add(valueEntity);
95   }
96
97   public String getFilterId() {
98     return filterId;
99   }
100
101   public String getFilterName() {
102     return filterName;
103   }
104   
105   public String getDisplayName() {
106     return displayName;
107   }
108
109   public String getDataType() {
110     return dataType;
111   }
112   
113   public UiFilterOptionsValuesConfig getDefaultValue() {
114     return defaultValue;
115   }
116   
117   public List<UiFilterValueEntity> getFilterValueList() {
118     return filterValueList;
119   }
120
121   public void setFilterId(String filterId) {
122     this.filterId = filterId;
123   }
124
125   public void setFilterName(String filterName) {
126     this.filterName = filterName;
127   }
128   
129   public void setDisplayName(String displayName) {
130     this.displayName = displayName;
131   }
132
133   public void setDataType(String dataType) {
134     this.dataType = dataType;
135   }
136   
137   public String getMultiSelect() {
138     return multiSelect;
139   }
140
141   public void setMultiSelect(String multiSelect) {
142     this.multiSelect = multiSelect;
143   }
144
145   public String getWatermark() {
146     return watermark;
147   }
148
149   public void setWatermark(String watermark) {
150     this.watermark = watermark;
151   }
152
153   public String getOptionsType() {
154     return optionsType;
155   }
156
157   public void setOptionsType(String optionsType) {
158     this.optionsType = optionsType;
159   }
160   
161   public List<UiFilterOptionsValuesConfig> getOptionsValues() {
162     return optionsValues;
163   }
164
165   public void setOptionsValues(List<UiFilterOptionsValuesConfig> optionsValues) {
166     this.optionsValues = optionsValues;
167   }
168
169   public void setDefaultValue(UiFilterOptionsValuesConfig defaultValue) {
170     this.defaultValue = defaultValue;
171   }
172   
173   public void setFilterValueList(List<UiFilterValueEntity> values) {
174     this.filterValueList = values;
175   }
176 }