tabular-data-expression-widget/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/operation/OperationsStore.java

87 lines
3.2 KiB
Java

package org.gcube.portlets.user.td.expressionwidget.client.operation;
import java.util.ArrayList;
import org.gcube.portlets.user.td.expressionwidget.shared.model.OperatorType;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class OperationsStore {
static ArrayList<Operation> operations;
static ArrayList<Operation> operationsNumeric = new ArrayList<Operation>() {
private static final long serialVersionUID = -6559885743626876431L;
{
add(new Operation(1,"EQUALS","Equals",OperatorType.EQUALS));
add(new Operation(2,"GREATER","Greater",OperatorType.GREATER));
add(new Operation(3,"GREATER_OR_EQUALS","Greater or equals",OperatorType.GREATER_OR_EQUALS));
add(new Operation(4,"LESSER","Lesser",OperatorType.LESSER));
add(new Operation(5,"LESSER_OR_EQUALS","Lesser or equals",OperatorType.LESSER_OR_EQUALS));
add(new Operation(6,"NOT_EQUALS","Not equals",OperatorType.NOT_EQUALS));
add(new Operation(7,"NOT_GREATER","Not greater",OperatorType.NOT_GREATER));
add(new Operation(8,"NOT_LESSER","Not lesser",OperatorType.NOT_LESSER));
add(new Operation(9,"IS_NULL","Is null",OperatorType.IS_NULL));
add(new Operation(10,"IS_NOT_NULL","Is not null",OperatorType.IS_NOT_NULL));
add(new Operation(11,"BETWEEN","Between",OperatorType.BETWEEN));
add(new Operation(12,"IN","In",OperatorType.IN));
}};
static ArrayList<Operation> operationsText = new ArrayList<Operation>() {
private static final long serialVersionUID = -6559885743626876431L;
{
add(new Operation(1,"BEGIN_WITH","Begin with",OperatorType.BEGINS_WITH));
add(new Operation(2,"CONTAINS","Contains",OperatorType.CONTAINS));
add(new Operation(3,"ENDS_WITH","End with",OperatorType.ENDS_WITH));
add(new Operation(4,"MATCH","Match",OperatorType.MATCH_REGEX));
add(new Operation(5,"NOT_BEGIN_WITH","Not begin with",OperatorType.BEGINS_WITH));
add(new Operation(6,"NOT_CONTAINS","Not contains",OperatorType.CONTAINS));
add(new Operation(7,"NOT_ENDS_WITH","Not end with",OperatorType.ENDS_WITH));
add(new Operation(8,"NOT_MATCH","Not match",OperatorType.MATCH_REGEX));
add(new Operation(10,"IS_NULL","Is null",OperatorType.IS_NULL));
add(new Operation(11,"IS_NOT_NULL","Is not null",OperatorType.IS_NOT_NULL));
add(new Operation(12,"BETWEEN","Between",OperatorType.BETWEEN));
add(new Operation(13,"IN","In",OperatorType.IN));
}};
public static ArrayList<Operation> getAll(String dataTypeName){
if(dataTypeName.compareTo("Boolean")==0){
operations=operationsNumeric;
} else {
if(dataTypeName.compareTo("Date")==0){
operations=operationsNumeric;
} else {
if(dataTypeName.compareTo("Integer")==0){
operations=operationsNumeric;
} else {
if(dataTypeName.compareTo("Geometry")==0){
operations=operationsNumeric;
} else {
if(dataTypeName.compareTo("Numeric")==0){
operations=operationsNumeric;
} else {
if(dataTypeName.compareTo("Text")==0){
operations=operationsText;
} else {
operations=operationsText;
}
}
}
}
}
}
return operations;
}
}