174 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.ui.light;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.utils.io.Transferable;
|
|
|
17 |
|
|
|
18 |
import java.util.Locale;
|
|
|
19 |
|
|
|
20 |
import net.minidev.json.JSONObject;
|
|
|
21 |
|
|
|
22 |
public class TableSearchParameterType implements Transferable {
|
|
|
23 |
|
|
|
24 |
// type from UserSearchItem type
|
|
|
25 |
private String type;
|
|
|
26 |
private String label;
|
|
|
27 |
private String valueType;
|
|
|
28 |
|
|
|
29 |
TableSearchParameterType() {
|
|
|
30 |
// For serialization
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
public TableSearchParameterType(String type) {
|
|
|
34 |
this.type = type;
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
public TableSearchParameterType(String type, String label, String valueType) {
|
|
|
38 |
this.type = type;
|
|
|
39 |
this.label = label;
|
|
|
40 |
this.valueType = valueType;
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
public String getType() {
|
|
|
44 |
return this.type;
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
public String getLabel() {
|
|
|
48 |
return this.label;
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
public String getValueType() {
|
|
|
52 |
return this.valueType;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
@Override
|
|
|
56 |
public JSONObject toJSON() {
|
|
|
57 |
final JSONObject obj = new JSONObject();
|
|
|
58 |
obj.put("type", this.type);
|
|
|
59 |
obj.put("label", this.label);
|
|
|
60 |
obj.put("value-type", this.valueType);
|
|
|
61 |
return obj;
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
@Override
|
|
|
65 |
public void fromJSON(JSONObject json) {
|
|
|
66 |
this.type = json.getAsString("type");
|
|
|
67 |
this.label = json.getAsString("label");
|
|
|
68 |
this.valueType = json.getAsString("value-type");
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
public static TableSearchParameterType getContainsStringInstance(Locale locale) {
|
|
|
72 |
if (locale.equals(Locale.FRENCH)) {
|
|
|
73 |
return new TableSearchParameterType(UserSearchItem.TYPE_CONTAINS, "Contient", "string");
|
|
|
74 |
}
|
|
|
75 |
return new TableSearchParameterType(UserSearchItem.TYPE_CONTAINS, "Contains", "string");
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
public static TableSearchParameterType getIsStringInstance(Locale locale) {
|
|
|
79 |
if (locale.equals(Locale.FRENCH)) {
|
|
|
80 |
return new TableSearchParameterType(UserSearchItem.TYPE_IS, "Est", "string");
|
|
|
81 |
}
|
|
|
82 |
return new TableSearchParameterType(UserSearchItem.TYPE_IS, "Is", "string");
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
@Override
|
|
|
86 |
public String toString() {
|
|
|
87 |
return super.toString() + "type:" + this.type + " label:" + this.label + " value-type:" + this.valueType;
|
|
|
88 |
}
|
|
|
89 |
}
|