diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/ExpressionWidget.gwt.xml b/src/main/java/org/gcube/portlets/user/td/expressionwidget/ExpressionWidget.gwt.xml
index 530ba0d..8fa7459 100644
--- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/ExpressionWidget.gwt.xml
+++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/ExpressionWidget.gwt.xml
@@ -26,16 +26,17 @@
-
-
-
+
-
+ -->
diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnFilterDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnFilterDialog.java
index 0a5e2d3..73dd354 100644
--- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnFilterDialog.java
+++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnFilterDialog.java
@@ -163,7 +163,7 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
protected void callApplyFilter() {
- filterColumnSession = new FilterColumnSession(column, exp);
+ filterColumnSession = new FilterColumnSession(trId, exp);
Log.debug(filterColumnSession.toString());
ExpressionServiceAsync.INSTANCE.startFilterColumn(filterColumnSession,
diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnExpressionPanel.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnExpressionPanel.java
index 491325f..6ae6c13 100644
--- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnExpressionPanel.java
+++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnExpressionPanel.java
@@ -781,7 +781,7 @@ public class MultiColumnExpressionPanel extends FramedPanel {
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
return;
}
- parentMultiFilterDialog.applyFilter(column, exp);
+ parentMultiFilterDialog.applyFilter(exp);
break;
case RowDeleteByExpression:
try {
diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnFilterDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnFilterDialog.java
index ec34424..5f3266e 100644
--- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnFilterDialog.java
+++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnFilterDialog.java
@@ -105,9 +105,8 @@ public class MultiColumnFilterDialog extends Window implements MonitorDialogList
this.exp = exp;
}
- protected void applyFilter(ColumnData column,C_Expression exp) {
+ protected void applyFilter(C_Expression exp) {
this.exp = exp;
- this.column= column;
callApplyFilter();
}
@@ -162,7 +161,7 @@ public class MultiColumnFilterDialog extends Window implements MonitorDialogList
protected void callApplyFilter() {
- filterColumnSession = new FilterColumnSession(column, exp);
+ filterColumnSession = new FilterColumnSession(trId, exp);
Log.debug(filterColumnSession.toString());
ExpressionServiceAsync.INSTANCE.startFilterColumn(filterColumnSession,
diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RowsDeleteByExpressionDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RowsDeleteByExpressionDialog.java
index 0431683..81f561a 100644
--- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RowsDeleteByExpressionDialog.java
+++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/RowsDeleteByExpressionDialog.java
@@ -163,7 +163,7 @@ public class RowsDeleteByExpressionDialog extends Window implements MonitorDialo
protected void callDeleteRows() {
- filterColumnSession = new FilterColumnSession(column, exp);
+ filterColumnSession = new FilterColumnSession(trId, exp);
Log.debug(filterColumnSession.toString());
ExpressionServiceAsync.INSTANCE.startFilterColumn(filterColumnSession,
diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/expression/ConditionOnMultiColumnWidget.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/expression/ConditionOnMultiColumnWidget.java
index 2eae660..5aa1bc8 100644
--- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/expression/ConditionOnMultiColumnWidget.java
+++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/expression/ConditionOnMultiColumnWidget.java
@@ -661,7 +661,6 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
case NOT_MATCH_REGEX:
case IN:
case NOT_IN:
- case SOUNDEX:
comboFirstArgType.reset();
comboFirstArgType.setVisible(true);
@@ -697,8 +696,27 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
btnAdd.setVisible(true);
btnDel.setVisible(false);
break;
+ case SOUNDEX:
+ comboFirstArgType.reset();
+ comboFirstArgType.setValue(ArgType.VALUE, true);
+
+ comboFirstArgType.setVisible(false);
+ comboFirstArgColumn.setVisible(false);
+ firstArgValue.setVisible(true);
+ firstArgDate.setVisible(false);
+ andText.setVisible(false);
+ comboSecondArgType.setVisible(false);
+ comboSecondArgColumn.setVisible(false);
+ secondArgValue.setVisible(false);
+ secondArgDate.setVisible(false);
+ thresholdText.setVisible(false);
+ comboThreshold.setVisible(false);
+ btnAdd.setVisible(true);
+ btnDel.setVisible(false);
+ break;
case LEVENSHTEIN:
comboFirstArgType.reset();
+ comboFirstArgType.setValue(ArgType.VALUE, true);
storeThreshold.clear();
storeThreshold
.addAll(ThresholdStore.thresholdsLevenshtein);
@@ -706,9 +724,9 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
comboThreshold.clear();
comboThreshold.reset();
- comboFirstArgType.setVisible(true);
+ comboFirstArgType.setVisible(false);
comboFirstArgColumn.setVisible(false);
- firstArgValue.setVisible(false);
+ firstArgValue.setVisible(true);
firstArgDate.setVisible(false);
andText.setVisible(false);
comboSecondArgType.setVisible(false);
@@ -726,6 +744,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
break;
case SIMILARITY:
comboFirstArgType.reset();
+ comboFirstArgType.setValue(ArgType.VALUE, true);
storeThreshold.clear();
storeThreshold
.addAll(ThresholdStore.thresholdsSimilarity);
@@ -733,9 +752,9 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
comboThreshold.clear();
comboThreshold.reset();
- comboFirstArgType.setVisible(true);
+ comboFirstArgType.setVisible(false);
comboFirstArgColumn.setVisible(false);
- firstArgValue.setVisible(false);
+ firstArgValue.setVisible(true);
firstArgDate.setVisible(false);
andText.setVisible(false);
comboSecondArgType.setVisible(false);
@@ -918,9 +937,20 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
}
});
-
+
+
+
+
comboDepth.setVisible(true);
- comboFirstElementColumn.setVisible(false);
+ comboDepth.setValue(DepthOfExpressionStore.bottomFirstElement, true);
+
+ storeFirstElementColumn.clear();
+ storeFirstElementColumn.addAll(columns);
+ storeFirstElementColumn.commitChanges();
+ comboFirstElementColumn.clear();
+ comboFirstElementColumn.reset();
+
+ comboFirstElementColumn.setVisible(true);
comboOperator.setVisible(false);
comboFirstArgType.setVisible(false);
comboFirstArgColumn.setVisible(false);
@@ -1426,7 +1456,6 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
case NOT_MATCH_REGEX:
case IN:
case NOT_IN:
- case SOUNDEX:
comboFirstArgType.reset();
comboFirstArgType.setVisible(true);
@@ -1462,8 +1491,27 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
btnAdd.setVisible(true);
btnDel.setVisible(true);
break;
+ case SOUNDEX:
+ comboFirstArgType.reset();
+ comboFirstArgType.setValue(ArgType.VALUE, true);
+
+ comboFirstArgType.setVisible(false);
+ comboFirstArgColumn.setVisible(false);
+ firstArgValue.setVisible(true);
+ firstArgDate.setVisible(false);
+ andText.setVisible(false);
+ comboSecondArgType.setVisible(false);
+ comboSecondArgColumn.setVisible(false);
+ secondArgValue.setVisible(false);
+ secondArgDate.setVisible(false);
+ thresholdText.setVisible(false);
+ comboThreshold.setVisible(false);
+ btnAdd.setVisible(true);
+ btnDel.setVisible(true);
+ break;
case LEVENSHTEIN:
comboFirstArgType.reset();
+ comboFirstArgType.setValue(ArgType.VALUE, true);
storeThreshold.clear();
storeThreshold
.addAll(ThresholdStore.thresholdsLevenshtein);
@@ -1471,9 +1519,9 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
comboThreshold.clear();
comboThreshold.reset();
- comboFirstArgType.setVisible(true);
+ comboFirstArgType.setVisible(false);
comboFirstArgColumn.setVisible(false);
- firstArgValue.setVisible(false);
+ firstArgValue.setVisible(true);
firstArgDate.setVisible(false);
andText.setVisible(false);
comboSecondArgType.setVisible(false);
@@ -1491,6 +1539,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
break;
case SIMILARITY:
comboFirstArgType.reset();
+ comboFirstArgType.setValue(ArgType.VALUE, true);
storeThreshold.clear();
storeThreshold
.addAll(ThresholdStore.thresholdsSimilarity);
@@ -1498,9 +1547,9 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
comboThreshold.clear();
comboThreshold.reset();
- comboFirstArgType.setVisible(true);
+ comboFirstArgType.setVisible(false);
comboFirstArgColumn.setVisible(false);
- firstArgValue.setVisible(false);
+ firstArgValue.setVisible(true);
firstArgDate.setVisible(false);
andText.setVisible(false);
comboSecondArgType.setVisible(false);
diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/multicolumn/DepthOfExpressionStore.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/multicolumn/DepthOfExpressionStore.java
index 7dd99fd..4753980 100644
--- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/multicolumn/DepthOfExpressionStore.java
+++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/multicolumn/DepthOfExpressionStore.java
@@ -15,7 +15,7 @@ public class DepthOfExpressionStore implements Serializable {
private static ArrayList store;
- private static DepthOfExpressionElement bottomFirstElement = new DepthOfExpressionElement(
+ public static DepthOfExpressionElement bottomFirstElement = new DepthOfExpressionElement(
0, DepthOfExpressionType.BOTTOM,
DepthOfExpressionType.BOTTOM.getLabel());
private static DepthOfExpressionElement startAndFirstElement = new DepthOfExpressionElement(
diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/condition/ConditionOnMultiColumnTypeMap.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/condition/ConditionOnMultiColumnTypeMap.java
index fbb15cf..4956723 100644
--- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/condition/ConditionOnMultiColumnTypeMap.java
+++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/condition/ConditionOnMultiColumnTypeMap.java
@@ -89,12 +89,12 @@ public class ConditionOnMultiColumnTypeMap {
dataType, column.getColumnId());
Log.debug("placeHolder:" + placeHolder);
- //TD_Value fArg;
+ // TD_Value fArg;
// TD_Value sArg;
// C_Range range;
- List arguments = new ArrayList();
- int separator;
+ // List arguments = new ArrayList();
+ // int separator;
switch (operatorType) {
case ADDITION:
@@ -121,55 +121,27 @@ public class ConditionOnMultiColumnTypeMap {
case DIVISION:
break;
case ENDS_WITH:
- checkTypeArgument(column, firstArg);
- exp = new C_TextEndsWith(placeHolder, new TD_Value(dataType,
- firstArg));
+ exp = placeHolderEndsWith(column, firstArgType, firstArgColumn,
+ firstArg, dataType, placeHolder);
break;
case EQUALS:
- checkTypeArgument(column, firstArg);
- exp = new C_Equals(placeHolder, new TD_Value(dataType, firstArg));
+ exp = placeHolderEquals(column, firstArgType, firstArgColumn,
+ firstArg, dataType, placeHolder);
break;
case EXISTS:
// exp=new C_Exi(placeHolder,new C_ConstantList(arguments));
break;
case GREATER:
- checkTypeArgument(column, firstArg);
- exp = new C_GreaterThan(placeHolder, new TD_Value(dataType,
- firstArg));
+ exp = placeHolderGreater(column, firstArgType, firstArgColumn,
+ firstArg, dataType, placeHolder);
break;
case GREATER_OR_EQUALS:
- checkTypeArgument(column, firstArg);
- exp = new C_GreaterOrEquals(placeHolder, new TD_Value(dataType,
- firstArg));
+ exp = placeHolderGreaterOrEquals(column, firstArgType,
+ firstArgColumn, firstArg, dataType, placeHolder);
break;
case IN:
- separator = firstArg.indexOf(",");
- if (separator == -1 || firstArg.length() == 1) {
- checkTypeArgument(column, firstArg);
- arguments.add(new TD_Value(dataType, firstArg));
- } else {
- String arg;
- boolean end = false;
- while (!end) {
- arg = firstArg.substring(0, separator);
- checkTypeArgument(column, arg);
- arguments.add(new TD_Value(dataType, arg));
- separator++;
- if (separator < firstArg.length()) {
- firstArg = firstArg.substring(separator,
- firstArg.length());
- separator = firstArg.indexOf(",");
- if (separator == -1) {
- checkTypeArgument(column, firstArg);
- arguments.add(new TD_Value(dataType, firstArg));
- end = true;
- }
- } else {
- end = true;
- }
- }
- }
- exp = new C_ValueIsIn(placeHolder, new C_ConstantList(arguments));
+ exp = placeHolderIn(column, firstArgType, firstArgColumn, firstArg,
+ dataType, placeHolder);
break;
case IS_NOT_NULL:
exp = new C_IsNotNull(placeHolder);
@@ -178,20 +150,18 @@ public class ConditionOnMultiColumnTypeMap {
exp = new C_IsNull(placeHolder);
break;
case LESSER:
- checkTypeArgument(column, firstArg);
- exp = new C_LessThan(placeHolder, new TD_Value(dataType, firstArg));
+ exp = placeHolderLesser(column, firstArgType, firstArgColumn,
+ firstArg, dataType, placeHolder);
break;
case LESSER_OR_EQUALS:
- checkTypeArgument(column, firstArg);
- exp = new C_LessOrEquals(placeHolder, new TD_Value(dataType,
- firstArg));
+ exp = placeHolderLesserOrEquals(column, firstArgType,
+ firstArgColumn, firstArg, dataType, placeHolder);
break;
case LIKE:
break;
case MATCH_REGEX:
- checkTypeArgument(column, firstArg);
- exp = new C_TextMatchSQLRegexp(placeHolder, new TD_Value(dataType,
- firstArg));
+ exp = placeHolderMatchRegex(column, firstArgType, firstArgColumn,
+ firstArg, dataType, placeHolder);
break;
case MODULUS:
break;
@@ -216,21 +186,297 @@ public class ConditionOnMultiColumnTypeMap {
exp = new C_Not(exp);
break;
case NOT_ENDS_WITH:
- checkTypeArgument(column, firstArg);
- exp = new C_TextEndsWith(placeHolder, new TD_Value(dataType,
- firstArg));
+ exp = placeHolderEndsWith(column, firstArgType, firstArgColumn,
+ firstArg, dataType, placeHolder);
exp = new C_Not(exp);
break;
case NOT_EQUALS:
- checkTypeArgument(column, firstArg);
- exp = new C_NotEquals(placeHolder, new TD_Value(dataType, firstArg));
+ exp = placeHolderNotEquals(column, firstArgType, firstArgColumn,
+ firstArg, dataType, placeHolder);
break;
case NOT_GREATER:
- checkTypeArgument(column, firstArg);
- exp = new C_NotGreater(placeHolder,
- new TD_Value(dataType, firstArg));
+ exp = placeHolderNotGreater(column, firstArgType, firstArgColumn,
+ firstArg, dataType, placeHolder);
break;
case NOT_IN:
+ exp = placeHolderIn(column, firstArgType, firstArgColumn, firstArg,
+ dataType, placeHolder);
+ exp = new C_Not(exp);
+ break;
+ case NOT_LESSER:
+ exp = placeHolderNotLess(column, firstArgType, firstArgColumn,
+ firstArg, dataType, placeHolder);
+ break;
+ case NOT_LIKE:
+ break;
+ case NOT_MATCH_REGEX:
+ exp = placeHolderMatchRegex(column, firstArgType, firstArgColumn,
+ firstArg, dataType, placeHolder);
+ exp = new C_Not(exp);
+ break;
+ case OR:
+ break;
+ case SELECT_IN:
+ break;
+ case SUBTRACTION:
+ break;
+ case UNIQUE:
+ break;
+ case SOUNDEX:
+ exp = placeHolderSoundex(column, firstArg, dataType, placeHolder);
+ break;
+ case LEVENSHTEIN:
+ exp = placeHolderLevenshtein(column, firstArg, threshold, dataType,
+ placeHolder);
+ break;
+ case SIMILARITY:
+ exp = placeHolderSimilarity(column, firstArg, threshold, dataType,
+ placeHolder);
+ break;
+
+ default:
+ break;
+ }
+
+ return exp;
+ }
+
+ protected C_Expression placeHolderSimilarity(ColumnData column,
+ String firstArg, Threshold threshold, ColumnDataType dataType,
+ C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp;
+ checkTypeArgument(column, firstArg);
+ C_Similarity similarity = new C_Similarity(placeHolder, new TD_Value(
+ dataType, firstArg));
+ Threshold thresholdSim;
+
+ if (threshold == null) {
+ thresholdSim = ThresholdStore.defaultThresholdSimilarity();
+ } else {
+ thresholdSim = threshold;
+ }
+ exp = new C_GreaterOrEquals(similarity, new TD_Value(
+ ColumnDataType.Numeric, thresholdSim.getLabel()));
+ return exp;
+ }
+
+ protected C_Expression placeHolderLevenshtein(ColumnData column,
+ String firstArg, Threshold threshold, ColumnDataType dataType,
+ C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp;
+ checkTypeArgument(column, firstArg);
+ C_Levenshtein levenshstein = new C_Levenshtein(placeHolder,
+ new TD_Value(dataType, firstArg));
+ Threshold thresholdLev;
+
+ if (threshold == null) {
+ thresholdLev = ThresholdStore.defaultThresholdLevenshtein();
+ } else {
+ thresholdLev = threshold;
+ }
+ exp = new C_LessOrEquals(levenshstein, new TD_Value(
+ ColumnDataType.Integer, thresholdLev.getIntegerValue()
+ .toString()));
+ return exp;
+ }
+
+ protected C_Expression placeHolderSoundex(ColumnData column,
+ String firstArg, ColumnDataType dataType,
+ C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp;
+ checkTypeArgument(column, firstArg);
+ C_Soundex soundexPlaceHolder = new C_Soundex(placeHolder);
+ C_Soundex soundexValue = new C_Soundex(new TD_Value(dataType, firstArg));
+ exp = new C_Equals(soundexPlaceHolder, soundexValue);
+ return exp;
+ }
+
+ protected C_Expression placeHolderNotLess(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReferencePlaceholder firstArgPlaceHolder = new C_ColumnReferencePlaceholder(
+ firstArgDataType, firstArgColumn.getColumnId());
+ exp = new C_NotLess(placeHolder, firstArgPlaceHolder);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_NotLess(placeHolder, fArg);
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+
+ }
+
+ return exp;
+ }
+
+ protected C_Expression placeHolderNotGreater(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReferencePlaceholder firstArgPlaceHolder = new C_ColumnReferencePlaceholder(
+ firstArgDataType, firstArgColumn.getColumnId());
+ exp = new C_NotGreater(placeHolder, firstArgPlaceHolder);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_NotGreater(placeHolder, fArg);
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+
+ }
+ return exp;
+ }
+
+ protected C_Expression placeHolderNotEquals(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReferencePlaceholder firstArgPlaceHolder = new C_ColumnReferencePlaceholder(
+ firstArgDataType, firstArgColumn.getColumnId());
+ exp = new C_NotEquals(placeHolder, firstArgPlaceHolder);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_NotEquals(placeHolder, fArg);
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+
+ }
+
+ return exp;
+ }
+
+ protected C_Expression placeHolderMatchRegex(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+ switch (firstArgType) {
+ case COLUMN:
+ // TODO
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReferencePlaceholder firstArgPlaceHolder = new C_ColumnReferencePlaceholder(
+ firstArgDataType, firstArgColumn.getColumnId());
+ exp = new C_TextMatchSQLRegexp(placeHolder, firstArgPlaceHolder);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_TextMatchSQLRegexp(placeHolder, fArg);
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+
+ }
+
+ return exp;
+ }
+
+ protected C_Expression placeHolderLesserOrEquals(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReferencePlaceholder firstArgPlaceHolder = new C_ColumnReferencePlaceholder(
+ firstArgDataType, firstArgColumn.getColumnId());
+ exp = new C_LessOrEquals(placeHolder, firstArgPlaceHolder);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_LessOrEquals(placeHolder, fArg);
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+
+ }
+
+ return exp;
+ }
+
+ protected C_Expression placeHolderLesser(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReferencePlaceholder firstArgPlaceHolder = new C_ColumnReferencePlaceholder(
+ firstArgDataType, firstArgColumn.getColumnId());
+ exp = new C_LessThan(placeHolder, firstArgPlaceHolder);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_LessThan(placeHolder, fArg);
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+
+ }
+
+ return exp;
+ }
+
+ protected C_Expression placeHolderIn(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ ArrayList arguments = new ArrayList();
+ int separator;
+
+ C_Expression exp = null;
+ switch (firstArgType) {
+ case COLUMN:
+ // TODO need Value is in on ColumnReference e ColumnPlaceHolder
+ /*
+ * ColumnDataType firstArgDataType = ColumnDataType
+ * .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ * C_ColumnReferencePlaceholder firstArgPlaceHolder = new
+ * C_ColumnReferencePlaceholder( firstArgDataType,
+ * firstArgColumn.getColumnId()); exp = new
+ * C_ValueIsIn(placeHolder,firstArgPlaceHolder);
+ */
+ break;
+ case VALUE:
separator = firstArg.indexOf(",");
if (separator == -1 || firstArg.length() == 1) {
checkTypeArgument(column, firstArg);
@@ -258,67 +504,120 @@ public class ConditionOnMultiColumnTypeMap {
}
}
exp = new C_ValueIsIn(placeHolder, new C_ConstantList(arguments));
- exp = new C_Not(exp);
break;
- case NOT_LESSER:
- checkTypeArgument(column, firstArg);
- exp = new C_NotLess(placeHolder, new TD_Value(dataType, firstArg));
- break;
- case NOT_LIKE:
- break;
- case NOT_MATCH_REGEX:
- checkTypeArgument(column, firstArg);
- exp = new C_TextMatchSQLRegexp(placeHolder, new TD_Value(dataType,
- firstArg));
- exp = new C_Not(exp);
- break;
- case OR:
- break;
- case SELECT_IN:
- break;
- case SUBTRACTION:
- break;
- case UNIQUE:
- break;
- case SOUNDEX:
- checkTypeArgument(column, firstArg);
- C_Soundex soundexPlaceHolder = new C_Soundex(placeHolder);
- C_Soundex soundexValue = new C_Soundex(new TD_Value(dataType,
- firstArg));
- exp = new C_Equals(soundexPlaceHolder, soundexValue);
- break;
- case LEVENSHTEIN:
- checkTypeArgument(column, firstArg);
- C_Levenshtein levenshstein = new C_Levenshtein(placeHolder,
- new TD_Value(dataType, firstArg));
- Threshold thresholdLev;
-
- if (threshold == null) {
- thresholdLev = ThresholdStore.defaultThresholdLevenshtein();
- } else {
- thresholdLev = threshold;
- }
- exp = new C_LessOrEquals(levenshstein, new TD_Value(
- ColumnDataType.Integer, thresholdLev.getIntegerValue()
- .toString()));
- break;
- case SIMILARITY:
- checkTypeArgument(column, firstArg);
- C_Similarity similarity = new C_Similarity(placeHolder,
- new TD_Value(dataType, firstArg));
- Threshold thresholdSim;
-
- if (threshold == null) {
- thresholdSim = ThresholdStore.defaultThresholdSimilarity();
- } else {
- thresholdSim = threshold;
- }
- exp = new C_GreaterOrEquals(similarity, new TD_Value(
- ColumnDataType.Numeric, thresholdSim.getLabel()));
- break;
-
default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+
+ }
+
+ return exp;
+ }
+
+ protected C_Expression placeHolderGreaterOrEquals(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReferencePlaceholder firstArgPlaceHolder = new C_ColumnReferencePlaceholder(
+ firstArgDataType, firstArgColumn.getColumnId());
+ exp = new C_GreaterOrEquals(placeHolder, firstArgPlaceHolder);
break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_GreaterOrEquals(placeHolder, fArg);
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+
+ }
+
+ return exp;
+ }
+
+ protected C_Expression placeHolderGreater(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReferencePlaceholder firstArgPlaceHolder = new C_ColumnReferencePlaceholder(
+ firstArgDataType, firstArgColumn.getColumnId());
+ exp = new C_GreaterThan(placeHolder, firstArgPlaceHolder);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_GreaterThan(placeHolder, fArg);
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+
+ }
+
+ return exp;
+ }
+
+ protected C_Expression placeHolderEquals(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReferencePlaceholder firstArgPlaceHolder = new C_ColumnReferencePlaceholder(
+ firstArgDataType, firstArgColumn.getColumnId());
+ exp = new C_Equals(placeHolder, firstArgPlaceHolder);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_Equals(placeHolder, fArg);
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+
+ }
+
+ return exp;
+ }
+
+ protected C_Expression placeHolderEndsWith(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReferencePlaceholder placeHolder)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReferencePlaceholder firstArgPlaceHolder = new C_ColumnReferencePlaceholder(
+ firstArgDataType, firstArgColumn.getColumnId());
+ exp = new C_TextEndsWith(placeHolder, firstArgPlaceHolder);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_TextEndsWith(placeHolder, fArg);
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+
}
return exp;
@@ -345,9 +644,8 @@ public class ConditionOnMultiColumnTypeMap {
break;
default:
- new ConditionTypeMapException(
+ throw new ConditionTypeMapException(
"No valid first argument type selected!");
- break;
}
@@ -377,9 +675,8 @@ public class ConditionOnMultiColumnTypeMap {
fArg = new TD_Value(dataType, firstArg);
break;
default:
- new ConditionTypeMapException(
+ throw new ConditionTypeMapException(
"No valid first argument type selected!");
- break;
}
switch (secondArgType) {
@@ -395,11 +692,11 @@ public class ConditionOnMultiColumnTypeMap {
sArg = new TD_Value(dataType, secondArg);
break;
default:
- new ConditionTypeMapException(
+ throw new ConditionTypeMapException(
"No valid second argument type selected!");
- break;
}
+ // TODO need Range on ColumnReference e ColumnPlaceHolder
// range = new C_Range(fArg, sArg);
// exp = new C_Between(placeHolder, range);
return exp;
@@ -427,9 +724,8 @@ public class ConditionOnMultiColumnTypeMap {
exp = new C_TextBeginsWith(placeHolder, fArg);
break;
default:
- new ConditionTypeMapException(
+ throw new ConditionTypeMapException(
"No valid first argument type selected!");
- break;
}
return exp;
@@ -451,13 +747,6 @@ public class ConditionOnMultiColumnTypeMap {
column.getTrId(), dataType, column.getColumnId());
Log.debug("Typed Column Reference:" + columnReference);
- TD_Value fArg;
- TD_Value sArg;
- C_Range range;
-
- List arguments = new ArrayList();
- int separator;
-
switch (operatorType) {
case ADDITION:
break;
@@ -468,77 +757,42 @@ public class ConditionOnMultiColumnTypeMap {
case ANY:
break;
case BEGINS_WITH:
- checkTypeArgument(column, firstArg);
- exp = new C_TextBeginsWith(columnReference, new TD_Value(dataType,
- firstArg));
+ exp = columnReferenceBeginsWith(column, firstArgType,
+ firstArgColumn, firstArg, dataType, columnReference);
break;
case BETWEEN:
- checkTypeArgument(column, firstArg);
- checkTypeArgument(column, secondArg);
- fArg = new TD_Value(dataType, firstArg);
- sArg = new TD_Value(dataType, secondArg);
- range = new C_Range(fArg, sArg);
- exp = new C_Between(columnReference, range);
+ exp = columnReferenceBetween(column, firstArgType, firstArgColumn,
+ firstArg, secondArgType, secondArgColumn, secondArg,
+ dataType, columnReference);
break;
case CONTAINS:
- checkTypeArgument(column, firstArg);
- fArg = new TD_Value(dataType, firstArg);
- exp = new C_TextContains(columnReference, fArg);
+ exp = columnReferenceContains(column, firstArgType, firstArgColumn,
+ firstArg, dataType, columnReference);
break;
case DIVISION:
break;
case ENDS_WITH:
- checkTypeArgument(column, firstArg);
- exp = new C_TextEndsWith(columnReference, new TD_Value(dataType,
- firstArg));
+ exp = columnReferenceEndsWith(column, firstArgType, firstArgColumn,
+ firstArg, dataType, columnReference);
break;
case EQUALS:
- checkTypeArgument(column, firstArg);
- exp = new C_Equals(columnReference,
- new TD_Value(dataType, firstArg));
+ exp = columnReferenceEquals(column, firstArgType, firstArgColumn,
+ firstArg, dataType, columnReference);
break;
case EXISTS:
// exp=new C_Exi(placeHolder,new C_ConstantList(arguments));
break;
case GREATER:
- checkTypeArgument(column, firstArg);
- exp = new C_GreaterThan(columnReference, new TD_Value(dataType,
- firstArg));
+ exp = columnReferenceGreater(column, firstArgType, firstArgColumn,
+ firstArg, dataType, columnReference);
break;
case GREATER_OR_EQUALS:
- checkTypeArgument(column, firstArg);
- exp = new C_GreaterOrEquals(columnReference, new TD_Value(dataType,
- firstArg));
+ exp = columnReferenceGreaterOrEquals(column, firstArgType,
+ firstArgColumn, firstArg, dataType, columnReference);
break;
case IN:
- separator = firstArg.indexOf(",");
- if (separator == -1 || firstArg.length() == 1) {
- checkTypeArgument(column, firstArg);
- arguments.add(new TD_Value(dataType, firstArg));
- } else {
- String arg;
- boolean end = false;
- while (!end) {
- arg = firstArg.substring(0, separator);
- checkTypeArgument(column, arg);
- arguments.add(new TD_Value(dataType, arg));
- separator++;
- if (separator < firstArg.length()) {
- firstArg = firstArg.substring(separator,
- firstArg.length());
- separator = firstArg.indexOf(",");
- if (separator == -1) {
- checkTypeArgument(column, firstArg);
- arguments.add(new TD_Value(dataType, firstArg));
- end = true;
- }
- } else {
- end = true;
- }
- }
- }
- exp = new C_ValueIsIn(columnReference,
- new C_ConstantList(arguments));
+ exp = columnReferenceIn(column, firstArgType, firstArgColumn,
+ firstArg, dataType, columnReference);
break;
case IS_NOT_NULL:
exp = new C_IsNotNull(columnReference);
@@ -547,21 +801,18 @@ public class ConditionOnMultiColumnTypeMap {
exp = new C_IsNull(columnReference);
break;
case LESSER:
- checkTypeArgument(column, firstArg);
- exp = new C_LessThan(columnReference, new TD_Value(dataType,
- firstArg));
+ exp = columnReferenceLesser(column, firstArgType, firstArgColumn,
+ firstArg, dataType, columnReference);
break;
case LESSER_OR_EQUALS:
- checkTypeArgument(column, firstArg);
- exp = new C_LessOrEquals(columnReference, new TD_Value(dataType,
- firstArg));
+ exp = columnReferenceLesserOrEquals(column, firstArgType,
+ firstArgColumn, firstArg, dataType, columnReference);
break;
case LIKE:
break;
case MATCH_REGEX:
- checkTypeArgument(column, firstArg);
- exp = new C_TextMatchSQLRegexp(columnReference, new TD_Value(
- dataType, firstArg));
+ exp = columnReferenceMatchRegex(column, firstArgType,
+ firstArgColumn, firstArg, dataType, columnReference);
break;
case MODULUS:
break;
@@ -570,84 +821,49 @@ public class ConditionOnMultiColumnTypeMap {
case NOT:
break;
case NOT_BEGINS_WITH:
- checkTypeArgument(column, firstArg);
- exp = new C_TextBeginsWith(columnReference, new TD_Value(dataType,
- firstArg));
+ exp = columnReferenceBeginsWith(column, firstArgType,
+ firstArgColumn, firstArg, dataType, columnReference);
exp = new C_Not(exp);
break;
case NOT_BETWEEN:
- checkTypeArgument(column, firstArg);
- checkTypeArgument(column, secondArg);
- fArg = new TD_Value(dataType, firstArg);
- sArg = new TD_Value(dataType, secondArg);
- range = new C_Range(fArg, sArg);
- exp = new C_Between(columnReference, range);
+ exp = columnReferenceBetween(column, firstArgType, firstArgColumn,
+ firstArg, secondArgType, secondArgColumn, secondArg,
+ dataType, columnReference);
exp = new C_Not(exp);
break;
case NOT_CONTAINS:
- checkTypeArgument(column, firstArg);
- fArg = new TD_Value(dataType, firstArg);
- exp = new C_TextContains(columnReference, fArg);
+ exp = columnReferenceContains(column, firstArgType, firstArgColumn,
+ firstArg, dataType, columnReference);
exp = new C_Not(exp);
break;
case NOT_ENDS_WITH:
- checkTypeArgument(column, firstArg);
- exp = new C_TextEndsWith(columnReference, new TD_Value(dataType,
- firstArg));
+ exp = columnReferenceEndsWith(column, firstArgType, firstArgColumn,
+ firstArg, dataType, columnReference);
exp = new C_Not(exp);
break;
case NOT_EQUALS:
- checkTypeArgument(column, firstArg);
- exp = new C_NotEquals(columnReference, new TD_Value(dataType,
- firstArg));
+ exp = columnReferenceNotEquals(column, firstArgType,
+ firstArgColumn, firstArg, dataType, columnReference);
break;
case NOT_GREATER:
- checkTypeArgument(column, firstArg);
- exp = new C_NotGreater(columnReference, new TD_Value(dataType,
- firstArg));
+ exp = columnReferenceNotGreater(column, firstArgType,
+ firstArgColumn, firstArg, dataType, columnReference);
break;
case NOT_IN:
- separator = firstArg.indexOf(",");
- if (separator == -1 || firstArg.length() == 1) {
- checkTypeArgument(column, firstArg);
- arguments.add(new TD_Value(dataType, firstArg));
- } else {
- String arg;
- boolean end = false;
- while (!end) {
- arg = firstArg.substring(0, separator);
- checkTypeArgument(column, arg);
- arguments.add(new TD_Value(dataType, arg));
- separator++;
- if (separator < firstArg.length()) {
- firstArg = firstArg.substring(separator,
- firstArg.length());
- separator = firstArg.indexOf(",");
- if (separator == -1) {
- checkTypeArgument(column, firstArg);
- arguments.add(new TD_Value(dataType, firstArg));
- end = true;
- }
- } else {
- end = true;
- }
- }
- }
- exp = new C_ValueIsIn(columnReference,
- new C_ConstantList(arguments));
+ exp = columnReferenceIn(column, firstArgType, firstArgColumn,
+ firstArg, dataType, columnReference);
exp = new C_Not(exp);
break;
case NOT_LESSER:
- checkTypeArgument(column, firstArg);
- exp = new C_NotLess(columnReference, new TD_Value(dataType,
- firstArg));
+ exp = columnReferenceNotLesser(column, firstArgType, firstArgColumn,
+ firstArg, dataType,
+ columnReference);
break;
case NOT_LIKE:
break;
case NOT_MATCH_REGEX:
- checkTypeArgument(column, firstArg);
- exp = new C_TextMatchSQLRegexp(columnReference, new TD_Value(
- dataType, firstArg));
+ exp = columnReferenceMatchRegex(column, firstArgType,
+ firstArgColumn, firstArg, dataType, columnReference);
exp = new C_Not(exp);
break;
case OR:
@@ -659,40 +875,16 @@ public class ConditionOnMultiColumnTypeMap {
case UNIQUE:
break;
case SOUNDEX:
- checkTypeArgument(column, firstArg);
- C_Soundex soundexPlaceHolder = new C_Soundex(columnReference);
- C_Soundex soundexValue = new C_Soundex(new TD_Value(dataType,
- firstArg));
- exp = new C_Equals(soundexPlaceHolder, soundexValue);
+ exp = columnReferenceSoundex(column, firstArg, dataType,
+ columnReference);
break;
case LEVENSHTEIN:
- checkTypeArgument(column, firstArg);
- C_Levenshtein levenshstein = new C_Levenshtein(columnReference,
- new TD_Value(dataType, firstArg));
- Threshold thresholdLev;
-
- if (threshold == null) {
- thresholdLev = ThresholdStore.defaultThresholdLevenshtein();
- } else {
- thresholdLev = threshold;
- }
- exp = new C_LessOrEquals(levenshstein, new TD_Value(
- ColumnDataType.Integer, thresholdLev.getIntegerValue()
- .toString()));
+ exp = columnReferenceLevenshtein(column, firstArg, threshold,
+ dataType, columnReference);
break;
case SIMILARITY:
- checkTypeArgument(column, firstArg);
- C_Similarity similarity = new C_Similarity(columnReference,
- new TD_Value(dataType, firstArg));
- Threshold thresholdSim;
-
- if (threshold == null) {
- thresholdSim = ThresholdStore.defaultThresholdSimilarity();
- } else {
- thresholdSim = threshold;
- }
- exp = new C_GreaterOrEquals(similarity, new TD_Value(
- ColumnDataType.Numeric, thresholdSim.getLabel()));
+ exp = columnReferenceSimilarity(column, firstArg, threshold,
+ dataType, columnReference);
break;
default:
break;
@@ -701,6 +893,516 @@ public class ConditionOnMultiColumnTypeMap {
return exp;
}
+ protected C_Expression columnReferenceSimilarity(ColumnData column,
+ String firstArg, Threshold threshold, ColumnDataType dataType,
+ C_ColumnReference columnReference) throws ConditionTypeMapException {
+ C_Expression exp;
+ checkTypeArgument(column, firstArg);
+ C_Similarity similarity = new C_Similarity(columnReference,
+ new TD_Value(dataType, firstArg));
+ Threshold thresholdSim;
+
+ if (threshold == null) {
+ thresholdSim = ThresholdStore.defaultThresholdSimilarity();
+ } else {
+ thresholdSim = threshold;
+ }
+ exp = new C_GreaterOrEquals(similarity, new TD_Value(
+ ColumnDataType.Numeric, thresholdSim.getLabel()));
+ return exp;
+ }
+
+ protected C_Expression columnReferenceLevenshtein(ColumnData column,
+ String firstArg, Threshold threshold, ColumnDataType dataType,
+ C_ColumnReference columnReference) throws ConditionTypeMapException {
+ C_Expression exp;
+ checkTypeArgument(column, firstArg);
+ C_Levenshtein levenshstein = new C_Levenshtein(columnReference,
+ new TD_Value(dataType, firstArg));
+ Threshold thresholdLev;
+
+ if (threshold == null) {
+ thresholdLev = ThresholdStore.defaultThresholdLevenshtein();
+ } else {
+ thresholdLev = threshold;
+ }
+ exp = new C_LessOrEquals(levenshstein, new TD_Value(
+ ColumnDataType.Integer, thresholdLev.getIntegerValue()
+ .toString()));
+ return exp;
+ }
+
+ protected C_Expression columnReferenceSoundex(ColumnData column,
+ String firstArg, ColumnDataType dataType,
+ C_ColumnReference columnReference) throws ConditionTypeMapException {
+ C_Expression exp;
+ checkTypeArgument(column, firstArg);
+ C_Soundex soundexPlaceHolder = new C_Soundex(columnReference);
+ C_Soundex soundexValue = new C_Soundex(new TD_Value(dataType,
+ firstArg));
+ exp = new C_Equals(soundexPlaceHolder, soundexValue);
+ return exp;
+ }
+
+ protected C_Expression columnReferenceNotLesser(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReference firstArgColumnReference = new C_ColumnReference(
+ firstArgColumn.getTrId(), firstArgDataType,
+ firstArgColumn.getColumnId());
+ exp = new C_NotLess(columnReference, firstArgColumnReference);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_NotLess(columnReference, fArg);
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ return exp;
+ }
+
+ protected C_Expression columnReferenceNotGreater(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReference firstArgColumnReference = new C_ColumnReference(
+ firstArgColumn.getTrId(), firstArgDataType,
+ firstArgColumn.getColumnId());
+ exp = new C_NotGreater(columnReference, firstArgColumnReference);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_NotGreater(columnReference, fArg);
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ return exp;
+ }
+
+ protected C_Expression columnReferenceNotEquals(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReference firstArgColumnReference = new C_ColumnReference(
+ firstArgColumn.getTrId(), firstArgDataType,
+ firstArgColumn.getColumnId());
+ exp = new C_NotEquals(columnReference, firstArgColumnReference);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_NotEquals(columnReference, fArg);
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ return exp;
+ }
+
+ protected C_Expression columnReferenceMatchRegex(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ // TODO
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReference firstArgColumnReference = new C_ColumnReference(
+ firstArgColumn.getTrId(), firstArgDataType,
+ firstArgColumn.getColumnId());
+ exp = new C_TextMatchSQLRegexp(columnReference,
+ firstArgColumnReference);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_TextMatchSQLRegexp(columnReference, fArg);
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ return exp;
+ }
+
+ protected C_Expression columnReferenceLesserOrEquals(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReference firstArgColumnReference = new C_ColumnReference(
+ firstArgColumn.getTrId(), firstArgDataType,
+ firstArgColumn.getColumnId());
+ exp = new C_LessOrEquals(columnReference, firstArgColumnReference);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_LessOrEquals(columnReference, fArg);
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ return exp;
+ }
+
+ protected C_Expression columnReferenceLesser(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReference firstArgColumnReference = new C_ColumnReference(
+ firstArgColumn.getTrId(), firstArgDataType,
+ firstArgColumn.getColumnId());
+ exp = new C_LessThan(columnReference, firstArgColumnReference);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_LessThan(columnReference, fArg);
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ return exp;
+ }
+
+ protected C_Expression columnReferenceIn(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ ArrayList arguments = new ArrayList();
+ int separator;
+
+ C_Expression exp = null;
+ switch (firstArgType) {
+ case COLUMN:
+ // TODO need ValueIsIn on ColumnReference e ColumnPlaceHolder
+ /*
+ * ColumnDataType firstArgDataType = ColumnDataType
+ * .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ * C_ColumnReference firstArgColumnReference = new
+ * C_ColumnReference( firstArgColumn.getTrId(), firstArgDataType,
+ * firstArgColumn.getColumnId()); exp = new
+ * C_ValueIsIn(columnReference, firstArgColumnReference);
+ */
+ break;
+ case VALUE:
+ separator = firstArg.indexOf(",");
+ if (separator == -1 || firstArg.length() == 1) {
+ checkTypeArgument(column, firstArg);
+ arguments.add(new TD_Value(dataType, firstArg));
+ } else {
+ String arg;
+ boolean end = false;
+ while (!end) {
+ arg = firstArg.substring(0, separator);
+ checkTypeArgument(column, arg);
+ arguments.add(new TD_Value(dataType, arg));
+ separator++;
+ if (separator < firstArg.length()) {
+ firstArg = firstArg.substring(separator,
+ firstArg.length());
+ separator = firstArg.indexOf(",");
+ if (separator == -1) {
+ checkTypeArgument(column, firstArg);
+ arguments.add(new TD_Value(dataType, firstArg));
+ end = true;
+ }
+ } else {
+ end = true;
+ }
+ }
+ }
+
+ exp = new C_ValueIsIn(columnReference,
+ new C_ConstantList(arguments));
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+
+ }
+ return exp;
+ }
+
+ protected C_Expression columnReferenceGreaterOrEquals(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReference firstArgColumnReference = new C_ColumnReference(
+ firstArgColumn.getTrId(), firstArgDataType,
+ firstArgColumn.getColumnId());
+ exp = new C_GreaterOrEquals(columnReference,
+ firstArgColumnReference);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_GreaterOrEquals(columnReference, fArg);
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ return exp;
+ }
+
+ protected C_Expression columnReferenceGreater(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReference firstArgColumnReference = new C_ColumnReference(
+ firstArgColumn.getTrId(), firstArgDataType,
+ firstArgColumn.getColumnId());
+ exp = new C_GreaterThan(columnReference, firstArgColumnReference);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_GreaterThan(columnReference, fArg);
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ return exp;
+ }
+
+ protected C_Expression columnReferenceEquals(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReference firstArgColumnReference = new C_ColumnReference(
+ firstArgColumn.getTrId(), firstArgDataType,
+ firstArgColumn.getColumnId());
+ exp = new C_Equals(columnReference, firstArgColumnReference);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_Equals(columnReference, fArg);
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ return exp;
+ }
+
+ protected C_Expression columnReferenceEndsWith(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReference firstArgColumnReference = new C_ColumnReference(
+ firstArgColumn.getTrId(), firstArgDataType,
+ firstArgColumn.getColumnId());
+ exp = new C_TextEndsWith(columnReference, firstArgColumnReference);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_TextEndsWith(columnReference, fArg);
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ return exp;
+ }
+
+ protected C_Expression columnReferenceContains(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReference firstArgColumnReference = new C_ColumnReference(
+ firstArgColumn.getTrId(), firstArgDataType,
+ firstArgColumn.getColumnId());
+ exp = new C_TextContains(columnReference, firstArgColumnReference);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_TextContains(columnReference, fArg);
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ return exp;
+ }
+
+ protected C_Expression columnReferenceBetween(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ArgType secondArgType, ColumnData secondArgColumn,
+ String secondArg, ColumnDataType dataType,
+ C_ColumnReference columnReference) throws ConditionTypeMapException {
+ C_Expression exp = null;
+ C_Leaf fArg;
+ C_Leaf sArg;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ fArg = new C_ColumnReference(firstArgColumn.getTrId(),
+ firstArgDataType, firstArgColumn.getColumnId());
+
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ fArg = new TD_Value(dataType, firstArg);
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ switch (secondArgType) {
+ case COLUMN:
+ ColumnDataType secondArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(secondArgColumn.getDataTypeName());
+ sArg = new C_ColumnReference(secondArgColumn.getTrId(),
+ secondArgDataType, secondArgColumn.getColumnId());
+ break;
+ case VALUE:
+ checkTypeArgument(column, secondArg);
+ sArg = new TD_Value(dataType, secondArg);
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid second argument type selected!");
+ }
+
+ // TODO
+ // C_Range range = new C_Range(fArg, sArg);
+ // exp = new C_Between(columnReference, range);
+ return exp;
+ }
+
+ protected C_Expression columnReferenceBeginsWith(ColumnData column,
+ ArgType firstArgType, ColumnData firstArgColumn, String firstArg,
+ ColumnDataType dataType, C_ColumnReference columnReference)
+ throws ConditionTypeMapException {
+ C_Expression exp = null;
+
+ switch (firstArgType) {
+ case COLUMN:
+ ColumnDataType firstArgDataType = ColumnDataType
+ .getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
+ C_ColumnReference firstArgColumnReference = new C_ColumnReference(
+ firstArgColumn.getTrId(), firstArgDataType,
+ firstArgColumn.getColumnId());
+ exp = new C_TextBeginsWith(columnReference, firstArgColumnReference);
+ break;
+ case VALUE:
+ checkTypeArgument(column, firstArg);
+ TD_Value fArg = new TD_Value(dataType, firstArg);
+ exp = new C_TextBeginsWith(columnReference, fArg);
+
+ break;
+ default:
+ throw new ConditionTypeMapException(
+ "No valid first argument type selected!");
+ }
+
+ return exp;
+ }
+
public C_Expression createC_Or(List arguments) {
C_Or or = new C_Or(arguments);
return or;
diff --git a/src/main/resources/org/gcube/portlets/user/td/expressionwidget/ExpressionWidget.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/ExpressionWidget.gwt.xml
index 3b873d7..c2c3922 100644
--- a/src/main/resources/org/gcube/portlets/user/td/expressionwidget/ExpressionWidget.gwt.xml
+++ b/src/main/resources/org/gcube/portlets/user/td/expressionwidget/ExpressionWidget.gwt.xml
@@ -36,8 +36,9 @@
- -->
-
+
+ -->
+