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