Dépôt officiel du code source de l'ERP OpenConcerto
Blame | Last modification | View Log | RSS feed
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU General Public License Version 3
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*/
package org.openconcerto.ui.light;
import org.openconcerto.utils.io.Transferable;
import java.util.Locale;
import net.minidev.json.JSONObject;
public class TableSearchParameterType implements Transferable {
// type from UserSearchItem type
private String type;
private String label;
private String valueType;
TableSearchParameterType() {
// For serialization
}
public TableSearchParameterType(String type) {
this.type = type;
}
public TableSearchParameterType(String type, String label, String valueType) {
this.type = type;
this.label = label;
this.valueType = valueType;
}
public String getType() {
return this.type;
}
public String getLabel() {
return this.label;
}
public String getValueType() {
return this.valueType;
}
@Override
public JSONObject toJSON() {
final JSONObject obj = new JSONObject();
obj.put("type", this.type);
obj.put("label", this.label);
obj.put("value-type", this.valueType);
return obj;
}
@Override
public void fromJSON(JSONObject json) {
this.type = json.getAsString("type");
this.label = json.getAsString("label");
this.valueType = json.getAsString("value-type");
}
public static TableSearchParameterType getContainsStringInstance(Locale locale) {
if (locale.equals(Locale.FRENCH)) {
return new TableSearchParameterType(UserSearchItem.TYPE_CONTAINS, "Contient", "string");
}
return new TableSearchParameterType(UserSearchItem.TYPE_CONTAINS, "Contains", "string");
}
public static TableSearchParameterType getIsStringInstance(Locale locale) {
if (locale.equals(Locale.FRENCH)) {
return new TableSearchParameterType(UserSearchItem.TYPE_IS, "Est", "string");
}
return new TableSearchParameterType(UserSearchItem.TYPE_IS, "Is", "string");
}
@Override
public String toString() {
return super.toString() + "type:" + this.type + " label:" + this.label + " value-type:" + this.valueType;
}
}