2770052dd5c2f287a44b11932e56b70a6de66b66
[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 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 package org.onap.aai.sparky.search.filters.entity;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28 import org.onap.aai.sparky.search.filters.config.UiFilterConfig;
29 import org.onap.aai.sparky.search.filters.config.UiFilterOptionsValuesConfig;
30
31 import com.fasterxml.jackson.annotation.JsonInclude;
32 import com.fasterxml.jackson.annotation.JsonInclude.Include;
33
34 /**
35  * Stores data for a single filter for a given UI view.
36  * <p>
37  * When a UI view wants to know which filters it should display, an object of this class is created for each
38  * filter discovered and stores data for that filter. Each filter/object of this class is added to a
39  * ViewFilterList object which is then serialized to JSON and returned to the view in the response body. 
40  */
41 @JsonInclude(Include.NON_NULL)
42 public class UiFilterEntity {
43   private String filterId;
44   private String filterName;
45   private String displayName;
46   private String dataType;
47   
48   private String multiSelect;
49   private String watermark;
50   private UiFilterOptionsValuesConfig defaultValue;
51   private String optionsType;
52   
53   private List<UiFilterOptionsValuesConfig> optionsValues;
54   
55   private List<UiFilterValueEntity> filterValueList;
56
57   public UiFilterEntity() {}
58   
59   public UiFilterEntity(UiFilterConfig filterConfig) {
60     if (filterConfig.getFilterId() != null) {
61       this.setFilterId(filterConfig.getFilterId());
62     }
63     if (filterConfig.getFilterName() != null) {
64       this.setFilterName(filterConfig.getFilterName());
65     }
66     if (filterConfig.getDisplayName() != null) {
67       this.setDisplayName(filterConfig.getDisplayName());
68     }
69     if (filterConfig.getDataType() != null) {
70       this.setDataType(filterConfig.getDataType());
71     }
72     if (filterConfig.getMultiSelect() != null) {
73       this.setMultiSelect(filterConfig.getMultiSelect());
74     }
75     if (filterConfig.getWatermark() != null) {
76       this.setWatermark(filterConfig.getWatermark());
77     }
78     if (filterConfig.getDefaultValue() != null) {
79       this.setDefaultValue(filterConfig.getDefaultValue());
80     }
81     if (filterConfig.getOptionsType() != null) {
82       this.setOptionsType(filterConfig.getOptionsType());
83     }
84     if(filterConfig.getOptionsValues() != null && !filterConfig.getOptionsValues().isEmpty()) {
85       this.setOptionsValues(filterConfig.getOptionsValues());
86     } else {
87       this.optionsValues = new ArrayList<UiFilterOptionsValuesConfig>();
88     }
89   }
90   
91   public void addFilterValue(UiFilterValueEntity valueEntity) {
92     if (null == filterValueList) {
93       filterValueList = new ArrayList<>();
94     }
95
96     this.filterValueList.add(valueEntity);
97   }
98
99   public String getFilterId() {
100     return filterId;
101   }
102
103   public String getFilterName() {
104     return filterName;
105   }
106   
107   public String getDisplayName() {
108     return displayName;
109   }
110
111   public String getDataType() {
112     return dataType;
113   }
114   
115   public UiFilterOptionsValuesConfig getDefaultValue() {
116     return defaultValue;
117   }
118   
119   public List<UiFilterValueEntity> getFilterValueList() {
120     return filterValueList;
121   }
122
123   public void setFilterId(String filterId) {
124     this.filterId = filterId;
125   }
126
127   public void setFilterName(String filterName) {
128     this.filterName = filterName;
129   }
130   
131   public void setDisplayName(String displayName) {
132     this.displayName = displayName;
133   }
134
135   public void setDataType(String dataType) {
136     this.dataType = dataType;
137   }
138   
139   public String getMultiSelect() {
140     return multiSelect;
141   }
142
143   public void setMultiSelect(String multiSelect) {
144     this.multiSelect = multiSelect;
145   }
146
147   public String getWatermark() {
148     return watermark;
149   }
150
151   public void setWatermark(String watermark) {
152     this.watermark = watermark;
153   }
154
155   public String getOptionsType() {
156     return optionsType;
157   }
158
159   public void setOptionsType(String optionsType) {
160     this.optionsType = optionsType;
161   }
162   
163   public List<UiFilterOptionsValuesConfig> getOptionsValues() {
164     return optionsValues;
165   }
166
167   public void setOptionsValues(List<UiFilterOptionsValuesConfig> optionsValues) {
168     this.optionsValues = optionsValues;
169   }
170
171   public void setDefaultValue(UiFilterOptionsValuesConfig defaultValue) {
172     this.defaultValue = defaultValue;
173   }
174   
175   public void setFilterValueList(List<UiFilterValueEntity> values) {
176     this.filterValueList = values;
177   }
178 }