81: Allow the creation and use of expressions on multi column in TDM portlet
Task-Url: https://support.d4science.org/issues/81 Updated Expression to support Between on column git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@114836 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
21cfb22d0c
commit
a6c1afeaef
|
@ -36,7 +36,7 @@ public class ColumnTypeCodeElement {
|
|||
}
|
||||
|
||||
public String getLabel() {
|
||||
return code.getColumnTypeCodeLabel();
|
||||
return code.getLabel();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ import org.gcube.data.analysis.tabulardata.expression.composite.text.Upper;
|
|||
import org.gcube.data.analysis.tabulardata.expression.functions.Cast;
|
||||
import org.gcube.data.analysis.tabulardata.expression.leaf.ColumnReferencePlaceholder;
|
||||
import org.gcube.data.analysis.tabulardata.expression.leaf.ConstantList;
|
||||
import org.gcube.data.analysis.tabulardata.expression.leaf.Range;
|
||||
import org.gcube.data.analysis.tabulardata.expression.logical.And;
|
||||
import org.gcube.data.analysis.tabulardata.expression.logical.Between;
|
||||
import org.gcube.data.analysis.tabulardata.expression.logical.IsNotNull;
|
||||
|
@ -118,7 +117,6 @@ import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C
|
|||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReference;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReferencePlaceholder;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ConstantList;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_Range;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.TD_Value;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.logical.C_And;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.logical.C_Between;
|
||||
|
@ -334,10 +332,6 @@ public class C_ExpressionParser {
|
|||
return getColumnReference(exp);
|
||||
}
|
||||
|
||||
if (exp instanceof Range) {
|
||||
return getRange(exp);
|
||||
}
|
||||
|
||||
if (exp instanceof ConstantList) {
|
||||
return getConstantList(exp);
|
||||
}
|
||||
|
@ -414,9 +408,6 @@ public class C_ExpressionParser {
|
|||
return getConstantList((ConstantList) exp);
|
||||
}
|
||||
|
||||
if (exp instanceof Range) {
|
||||
return getRange((Range)exp);
|
||||
}
|
||||
|
||||
if (exp instanceof ExternalReferenceExpression) {
|
||||
return null;
|
||||
|
@ -472,12 +463,9 @@ public class C_ExpressionParser {
|
|||
private C_Expression getBetween(Expression exp)
|
||||
throws ExpressionParserException {
|
||||
Between bet = (Between) exp;
|
||||
C_Expression crange = parse(bet.getRightArgument());
|
||||
C_Between between = null;
|
||||
if (crange instanceof C_Range) {
|
||||
C_Range range = (C_Range) crange;
|
||||
between = new C_Between(parse(bet.getLeftArgument()), range);
|
||||
}
|
||||
C_Between between=new C_Between(parse(bet.getLeftArgument()),
|
||||
parse(bet.getMinRangeArgument()),
|
||||
parse(bet.getMaxRangeArgument()));
|
||||
return between;
|
||||
}
|
||||
|
||||
|
@ -700,22 +688,6 @@ public class C_ExpressionParser {
|
|||
return col;
|
||||
}
|
||||
|
||||
private C_Expression getRange(Expression exp)
|
||||
throws ExpressionParserException {
|
||||
Range c = (Range) exp;
|
||||
C_Range range = new C_Range(getExpressionValue(c.getMinimum()),
|
||||
getExpressionValue(c.getMaximum()));
|
||||
return range;
|
||||
}
|
||||
|
||||
private C_MultivaluedExpression getRange(Range range)
|
||||
throws ExpressionParserException {
|
||||
|
||||
C_Range r = new C_Range(getExpressionValue(range.getMinimum()),
|
||||
getExpressionValue(range.getMaximum()));
|
||||
return r;
|
||||
}
|
||||
|
||||
private C_Expression getColumnReference(Expression exp) {
|
||||
ColumnReference c = (ColumnReference) exp;
|
||||
String tableId = String.valueOf(c.getTableId().getValue());
|
||||
|
@ -950,7 +922,7 @@ public class C_ExpressionParser {
|
|||
public Expression parse(C_Expression exp) throws ExpressionParserException {
|
||||
logger.debug("Parse: " + exp);
|
||||
Expression ex = null;
|
||||
|
||||
|
||||
switch (exp.getId()) {
|
||||
case "ColumnReferencePlaceholder":
|
||||
ex = getColumnReferencePlaceholder(exp);
|
||||
|
@ -958,9 +930,6 @@ public class C_ExpressionParser {
|
|||
case "ConstantList":
|
||||
ex = getConstantlist(exp);
|
||||
break;
|
||||
case "Range":
|
||||
ex = getRange(exp);
|
||||
break;
|
||||
case "ColumnReference":
|
||||
ex = getColumnReference(exp);
|
||||
break;
|
||||
|
@ -1111,9 +1080,6 @@ public class C_ExpressionParser {
|
|||
case "ConstantList":
|
||||
ex = getConstantlist(exp);
|
||||
break;
|
||||
case "Range":
|
||||
ex = getRange(exp);
|
||||
break;
|
||||
case "ExternalReferenceExpression":
|
||||
break;
|
||||
default:
|
||||
|
@ -1169,10 +1135,8 @@ public class C_ExpressionParser {
|
|||
private Expression getBetween(C_Expression exp)
|
||||
throws ExpressionParserException {
|
||||
C_Between bet = (C_Between) exp;
|
||||
C_Range crange = bet.getRightArgument();
|
||||
Range range = new Range(getExpressionValue(crange.getMinimum()),
|
||||
getExpressionValue(crange.getMaximum()));
|
||||
Between between = new Between(parse(bet.getLeftArgument()), range);
|
||||
Between between = new Between(parse(bet.getLeftArgument()),
|
||||
parse(bet.getMinRangeArgument()), parse(bet.getMaxRangeArgument()));
|
||||
|
||||
return between;
|
||||
}
|
||||
|
@ -1415,21 +1379,6 @@ public class C_ExpressionParser {
|
|||
return col;
|
||||
}
|
||||
|
||||
private Expression getRange(C_Expression exp)
|
||||
throws ExpressionParserException {
|
||||
C_Range c = (C_Range) exp;
|
||||
Range range = new Range(getExpressionValue(c.getMinimum()),
|
||||
getExpressionValue(c.getMaximum()));
|
||||
return range;
|
||||
}
|
||||
|
||||
private MultivaluedExpression getRange(C_MultivaluedExpression exp)
|
||||
throws ExpressionParserException {
|
||||
C_Range c = (C_Range) exp;
|
||||
Range range = new Range(getExpressionValue(c.getMinimum()),
|
||||
getExpressionValue(c.getMaximum()));
|
||||
return range;
|
||||
}
|
||||
|
||||
private Expression getColumnReference(C_Expression exp) {
|
||||
C_ColumnReference c = (C_ColumnReference) exp;
|
||||
|
|
|
@ -134,7 +134,7 @@ public class RuleTypeMap {
|
|||
Class<? extends DataType> dataType = entry.getValue();
|
||||
ColumnDataType columnDataType = ColumnDataTypeMap
|
||||
.mapFromDataTypeClass(dataType);
|
||||
RuleColumnPlaceHolderDescriptor ruleColumnPlaceHolderDescriptor = new RuleColumnPlaceHolderDescriptor(
|
||||
RuleColumnPlaceHolderDescriptor ruleColumnPlaceHolderDescriptor = new RuleColumnPlaceHolderDescriptor(id,
|
||||
id, columnDataType);
|
||||
descriptors.add(ruleColumnPlaceHolderDescriptor);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnRef
|
|||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReferencePlaceholder;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ConstantList;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_Leaf;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_Range;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.TD_Value;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.logical.C_And;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.logical.C_Between;
|
||||
|
@ -665,7 +664,6 @@ public class ConditionOnMultiColumnTypeMap {
|
|||
C_Expression exp = null;
|
||||
C_Leaf fArg;
|
||||
C_Leaf sArg;
|
||||
C_Range range;
|
||||
|
||||
switch (firstArgType) {
|
||||
case COLUMN:
|
||||
|
@ -700,9 +698,8 @@ public class ConditionOnMultiColumnTypeMap {
|
|||
"No valid second argument type selected!");
|
||||
}
|
||||
|
||||
// TODO need Range on ColumnReference e ColumnPlaceHolder
|
||||
// range = new C_Range(fArg, sArg);
|
||||
// exp = new C_Between(placeHolder, range);
|
||||
|
||||
exp = new C_Between(placeHolder, fArg, sArg);
|
||||
return exp;
|
||||
}
|
||||
|
||||
|
@ -1338,7 +1335,7 @@ public class ConditionOnMultiColumnTypeMap {
|
|||
C_Expression exp = null;
|
||||
C_Leaf fArg;
|
||||
C_Leaf sArg;
|
||||
|
||||
|
||||
switch (firstArgType) {
|
||||
case COLUMN:
|
||||
ColumnDataType firstArgDataType = ColumnDataType
|
||||
|
@ -1372,9 +1369,7 @@ public class ConditionOnMultiColumnTypeMap {
|
|||
"No valid second argument type selected!");
|
||||
}
|
||||
|
||||
// TODO
|
||||
// C_Range range = new C_Range(fArg, sArg);
|
||||
// exp = new C_Between(columnReference, range);
|
||||
exp = new C_Between(columnReference, fArg, sArg);
|
||||
return exp;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C
|
|||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReference;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReferencePlaceholder;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ConstantList;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_Range;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.TD_Value;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.logical.C_And;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.logical.C_Between;
|
||||
|
@ -85,7 +84,6 @@ public class ConditionTypeMap {
|
|||
|
||||
TD_Value fArg;
|
||||
TD_Value sArg;
|
||||
C_Range range;
|
||||
|
||||
List<TD_Value> arguments = new ArrayList<TD_Value>();
|
||||
int separator;
|
||||
|
@ -111,8 +109,7 @@ public class ConditionTypeMap {
|
|||
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(placeHolder, range);
|
||||
exp = new C_Between(placeHolder, fArg, sArg);
|
||||
readableExpression = "Between(" + readablePlaceHolder + ", Range("
|
||||
+ firstArg + ", " + secondArg + "))";
|
||||
break;
|
||||
|
@ -239,8 +236,7 @@ public class ConditionTypeMap {
|
|||
|
||||
fArg = new TD_Value(dataType, firstArg);
|
||||
sArg = new TD_Value(dataType, secondArg);
|
||||
range = new C_Range(fArg, sArg);
|
||||
exp = new C_Between(placeHolder, range);
|
||||
exp = new C_Between(placeHolder, fArg, sArg);
|
||||
exp = new C_Not(exp);
|
||||
readableExpression = "Not(Between(" + readablePlaceHolder
|
||||
+ ", Range(" + firstArg + ", " + secondArg + ")))";
|
||||
|
@ -397,7 +393,6 @@ public class ConditionTypeMap {
|
|||
|
||||
TD_Value fArg;
|
||||
TD_Value sArg;
|
||||
C_Range range;
|
||||
|
||||
List<TD_Value> arguments = new ArrayList<TD_Value>();
|
||||
int separator;
|
||||
|
@ -423,8 +418,7 @@ public class ConditionTypeMap {
|
|||
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 = new C_Between(columnReference, fArg, sArg);
|
||||
readableExpression = "Between(" + readableColumnReference
|
||||
+ ", Range(" + firstArg + ", " + secondArg + "))";
|
||||
break;
|
||||
|
@ -553,8 +547,7 @@ public class ConditionTypeMap {
|
|||
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 = new C_Between(columnReference, fArg, sArg);
|
||||
exp = new C_Not(exp);
|
||||
readableExpression = "Not(Between(" + readableColumnReference
|
||||
+ ", Range(" + firstArg + ", " + secondArg + ")))";
|
||||
|
|
|
@ -28,7 +28,7 @@ public class C_Cast extends C_Expression {
|
|||
if (leftArgument != null && rightArgument != null) {
|
||||
this.readableExpression = "Cast("
|
||||
+ leftArgument.getReadableExpression() + ","
|
||||
+ rightArgument.getColumnDataTypeLabel() + ")";
|
||||
+ rightArgument.getLabel() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class C_ColumnReference extends C_Leaf {
|
|||
}
|
||||
if (tableId != null && columnId != null && dataType != null) {
|
||||
this.readableExpression = "ColumnReference(" + tableId + ","
|
||||
+ dataType.getColumnDataTypeLabel() + "," + columnId + ")";
|
||||
+ dataType.getLabel() + "," + columnId + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class C_ColumnReferencePlaceholder extends C_Leaf {
|
|||
this.columnId = columnId;
|
||||
if (dataType != null && columnId != null) {
|
||||
this.readableExpression = "$"+columnId+"["
|
||||
+ dataType.getColumnDataTypeLabel() + "]";
|
||||
+ dataType.getLabel() + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.shared.model.leaf;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.expression.C_MultivaluedExpression;
|
||||
|
||||
public class C_Range extends C_Leaf implements C_MultivaluedExpression {
|
||||
|
||||
private static final long serialVersionUID = -2328040312495639444L;
|
||||
protected String id = "Range";
|
||||
|
||||
protected TD_Value minimum;
|
||||
protected TD_Value maximum;
|
||||
|
||||
public C_Range() {
|
||||
|
||||
}
|
||||
|
||||
public C_Range(TD_Value minimum, TD_Value maximum) {
|
||||
this.minimum = minimum;
|
||||
this.maximum = maximum;
|
||||
if (minimum != null && maximum != null) {
|
||||
this.readableExpression = "Range("
|
||||
+ minimum.getReadableExpression() + ","
|
||||
+ maximum.getReadableExpression() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdMulti() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public TD_Value getMinimum() {
|
||||
return minimum;
|
||||
}
|
||||
|
||||
public void setMinimum(TD_Value minimum) {
|
||||
this.minimum = minimum;
|
||||
}
|
||||
|
||||
public TD_Value getMaximum() {
|
||||
return maximum;
|
||||
}
|
||||
|
||||
public void setMaximum(TD_Value maximum) {
|
||||
this.maximum = maximum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getReadableMultivaluedString() {
|
||||
return readableExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Range [id=" + id + ", minimum=" + minimum + ", maximum="
|
||||
+ maximum + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +1,12 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.shared.model.logical;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.C_OperatorType;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_Range;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class C_Between extends C_Expression {
|
||||
|
@ -15,32 +14,38 @@ public class C_Between extends C_Expression {
|
|||
private static final long serialVersionUID = 5367101215792568854L;
|
||||
protected String id = "Between";
|
||||
protected C_Expression leftArgument;
|
||||
protected C_Range rightArgument;
|
||||
protected C_Expression minRangeArgument;
|
||||
protected C_Expression maxRangeArgument;
|
||||
|
||||
public C_Between() {
|
||||
|
||||
public C_Between(){
|
||||
|
||||
}
|
||||
|
||||
public C_Between(C_Expression leftArgument, C_Range rightArgument) {
|
||||
|
||||
public C_Between(C_Expression leftArgument, C_Expression minRangeArgument,
|
||||
C_Expression maxRangeArgument
|
||||
|
||||
) {
|
||||
this.leftArgument = leftArgument;
|
||||
this.rightArgument = rightArgument;
|
||||
if (leftArgument != null && rightArgument != null) {
|
||||
this.minRangeArgument = minRangeArgument;
|
||||
this.maxRangeArgument = maxRangeArgument;
|
||||
|
||||
if (leftArgument != null && minRangeArgument != null
|
||||
&& maxRangeArgument != null) {
|
||||
this.readableExpression = "Between("
|
||||
+ leftArgument.getReadableExpression() + ","
|
||||
+ rightArgument.getReadableExpression() + ")";
|
||||
+ minRangeArgument.getReadableExpression() + ","
|
||||
+ maxRangeArgument.getReadableExpression() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public C_OperatorType getOperator() {
|
||||
public C_OperatorType getOperator() {
|
||||
return C_OperatorType.BETWEEN;
|
||||
}
|
||||
|
||||
public String getReturnedDataType() {
|
||||
|
||||
public String getReturnedDataType() {
|
||||
return "Boolean";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
|
@ -54,20 +59,29 @@ public class C_Between extends C_Expression {
|
|||
this.leftArgument = leftArgument;
|
||||
}
|
||||
|
||||
public C_Range getRightArgument() {
|
||||
return rightArgument;
|
||||
public C_Expression getMinRangeArgument() {
|
||||
return minRangeArgument;
|
||||
}
|
||||
|
||||
public void setRightArgument(C_Range rightArgument) {
|
||||
this.rightArgument = rightArgument;
|
||||
public void setMinRangeArgument(C_Expression minRangeArgument) {
|
||||
this.minRangeArgument = minRangeArgument;
|
||||
}
|
||||
|
||||
public C_Expression getMaxRangeArgument() {
|
||||
return maxRangeArgument;
|
||||
}
|
||||
|
||||
public void setMaxRangeArgument(C_Expression maxRangeArgument) {
|
||||
this.maxRangeArgument = maxRangeArgument;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Between [id=" + id + ", leftArgument=" + leftArgument
|
||||
+ ", rightArgument=" + rightArgument + "]";
|
||||
return "C_Between [id=" + id + ", leftArgument=" + leftArgument
|
||||
+ ", minRangeArgument=" + minRangeArgument
|
||||
+ ", maxRangeArgument=" + maxRangeArgument + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue