81: Allow the creation and use of expressions on multi column in TDM portlet

Task-Url: https://support.d4science.org/issues/81

Fixed on ColumnReference the readable expression

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@115018 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-05-27 09:07:45 +00:00
parent dd77534fca
commit cb904672af
11 changed files with 130 additions and 183 deletions

View File

@ -127,10 +127,12 @@ import org.gcube.portlets.user.td.expressionwidget.shared.model.logical.C_Or;
import org.gcube.portlets.user.td.expressionwidget.shared.model.logical.C_ValueIsIn;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class C_ExpressionParser {
private static Logger logger = LoggerFactory
.getLogger(C_ExpressionParser.class);
@ -696,8 +698,13 @@ public class C_ExpressionParser {
TRId trId = new TRId();
trId.setTableId(tableId);
trId.setViewTable(false);
C_ColumnReference ref = new C_ColumnReference(trId, columnDataType,
columnId);
ColumnData column=new ColumnData();
column.setId(columnId);
column.setColumnId(columnId);
column.setTrId(trId);
column.setDataTypeName(columnDataType.toString());
column.setLabel("Unknow");
C_ColumnReference ref = new C_ColumnReference(column);
return ref;
}
@ -1383,16 +1390,16 @@ public class C_ExpressionParser {
private Expression getColumnReference(C_Expression exp) {
C_ColumnReference c = (C_ColumnReference) exp;
String tableIdS = null;
if (c.getTrId().isViewTable()) {
tableIdS = c.getTrId().getReferenceTargetTableId();
if (c.getColumn().getTrId().isViewTable()) {
tableIdS = c.getColumn().getTrId().getReferenceTargetTableId();
} else {
tableIdS = c.getTrId().getTableId();
tableIdS = c.getColumn().getTrId().getTableId();
}
TableId tableId = new TableId(Long.valueOf(tableIdS));
ColumnLocalId columnId = new ColumnLocalId(c.getColumnId());
ColumnLocalId columnId = new ColumnLocalId(c.getColumn().getColumnId());
ColumnReference ref = new ColumnReference(tableId, columnId,
mapColumnDataType(c.getDataType()));
mapColumnDataType(ColumnDataType.getColumnDataTypeFromId(c.getColumn().getDataTypeName())));
return ref;
}

View File

@ -754,7 +754,7 @@ public class ConditionOnMultiColumnTypeMap {
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_ColumnReference columnReference = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
column);
Log.debug("Typed Column Reference:" + columnReference);
switch (operatorType) {
@ -962,11 +962,8 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
C_ColumnReference firstArgColumnReference = new C_ColumnReference(
firstArgColumn.getTrId(), firstArgDataType,
firstArgColumn.getColumnId());
firstArgColumn);
exp = new C_NotLess(columnReference, firstArgColumnReference);
break;
case VALUE:
@ -991,11 +988,8 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
C_ColumnReference firstArgColumnReference = new C_ColumnReference(
firstArgColumn.getTrId(), firstArgDataType,
firstArgColumn.getColumnId());
firstArgColumn);
exp = new C_NotGreater(columnReference, firstArgColumnReference);
break;
case VALUE:
@ -1020,11 +1014,8 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
C_ColumnReference firstArgColumnReference = new C_ColumnReference(
firstArgColumn.getTrId(), firstArgDataType,
firstArgColumn.getColumnId());
firstArgColumn);
exp = new C_NotEquals(columnReference, firstArgColumnReference);
break;
case VALUE:
@ -1049,11 +1040,8 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
C_ColumnReference firstArgColumnReference = new C_ColumnReference(
firstArgColumn.getTrId(), firstArgDataType,
firstArgColumn.getColumnId());
firstArgColumn);
exp = new C_TextMatchSQLRegexp(columnReference,
firstArgColumnReference);
break;
@ -1079,11 +1067,8 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
C_ColumnReference firstArgColumnReference = new C_ColumnReference(
firstArgColumn.getTrId(), firstArgDataType,
firstArgColumn.getColumnId());
firstArgColumn);
exp = new C_LessOrEquals(columnReference, firstArgColumnReference);
break;
case VALUE:
@ -1108,11 +1093,8 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
C_ColumnReference firstArgColumnReference = new C_ColumnReference(
firstArgColumn.getTrId(), firstArgDataType,
firstArgColumn.getColumnId());
firstArgColumn);
exp = new C_LessThan(columnReference, firstArgColumnReference);
break;
case VALUE:
@ -1197,11 +1179,8 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
C_ColumnReference firstArgColumnReference = new C_ColumnReference(
firstArgColumn.getTrId(), firstArgDataType,
firstArgColumn.getColumnId());
firstArgColumn);
exp = new C_GreaterOrEquals(columnReference,
firstArgColumnReference);
break;
@ -1227,11 +1206,8 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
C_ColumnReference firstArgColumnReference = new C_ColumnReference(
firstArgColumn.getTrId(), firstArgDataType,
firstArgColumn.getColumnId());
firstArgColumn);
exp = new C_GreaterThan(columnReference, firstArgColumnReference);
break;
case VALUE:
@ -1256,11 +1232,8 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
C_ColumnReference firstArgColumnReference = new C_ColumnReference(
firstArgColumn.getTrId(), firstArgDataType,
firstArgColumn.getColumnId());
firstArgColumn);
exp = new C_Equals(columnReference, firstArgColumnReference);
break;
case VALUE:
@ -1285,11 +1258,8 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
C_ColumnReference firstArgColumnReference = new C_ColumnReference(
firstArgColumn.getTrId(), firstArgDataType,
firstArgColumn.getColumnId());
firstArgColumn);
exp = new C_TextEndsWith(columnReference, firstArgColumnReference);
break;
case VALUE:
@ -1314,11 +1284,8 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
C_ColumnReference firstArgColumnReference = new C_ColumnReference(
firstArgColumn.getTrId(), firstArgDataType,
firstArgColumn.getColumnId());
firstArgColumn);
exp = new C_TextContains(columnReference, firstArgColumnReference);
break;
case VALUE:
@ -1346,11 +1313,7 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
fArg = new C_ColumnReference(firstArgColumn.getTrId(),
firstArgDataType, firstArgColumn.getColumnId());
fArg = new C_ColumnReference(firstArgColumn);
break;
case VALUE:
if(firstArg==null|| firstArg.isEmpty()){
@ -1367,10 +1330,7 @@ public class ConditionOnMultiColumnTypeMap {
switch (secondArgType) {
case COLUMN:
ColumnDataType secondArgDataType = ColumnDataType
.getColumnDataTypeFromId(secondArgColumn.getDataTypeName());
sArg = new C_ColumnReference(secondArgColumn.getTrId(),
secondArgDataType, secondArgColumn.getColumnId());
sArg = new C_ColumnReference(secondArgColumn);
break;
case VALUE:
if(secondArg==null|| secondArg.isEmpty()){
@ -1397,11 +1357,8 @@ public class ConditionOnMultiColumnTypeMap {
switch (firstArgType) {
case COLUMN:
ColumnDataType firstArgDataType = ColumnDataType
.getColumnDataTypeFromId(firstArgColumn.getDataTypeName());
C_ColumnReference firstArgColumnReference = new C_ColumnReference(
firstArgColumn.getTrId(), firstArgDataType,
firstArgColumn.getColumnId());
firstArgColumn);
exp = new C_TextBeginsWith(columnReference, firstArgColumnReference);
break;
case VALUE:

View File

@ -330,7 +330,7 @@ public class ConditionTypeMap {
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_ColumnReference columnReference = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
column);
Log.debug("Typed Column Reference:" + columnReference);
TD_Value fArg;

View File

@ -1,37 +1,29 @@
package org.gcube.portlets.user.td.expressionwidget.shared.model.leaf;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_ColumnReference extends C_Leaf {
private static final long serialVersionUID = 1007646449141930835L;
protected String id = "ColumnReference";
protected TRId trId;
protected String columnId;
protected ColumnDataType dataType;
protected ColumnData column;
public C_ColumnReference() {
}
public C_ColumnReference(TRId trId, ColumnDataType dataType, String columnId) {
this.trId = trId;
this.dataType = dataType;
this.columnId = columnId;
String tableId = "";
if (trId != null) {
if (trId.isViewTable()) {
tableId = trId.getReferenceTargetTableId();
} else {
tableId = trId.getTableId();
}
}
if (tableId != null && columnId != null && dataType != null) {
this.readableExpression = "ColumnReference(" + tableId + ","
+ dataType.getLabel() + "," + columnId + ")";
public C_ColumnReference(ColumnData column) {
this.column = column;
if (column != null) {
this.readableExpression = "ColumnReference(" + column.getLabel()
+ ")";
}
}
@ -41,34 +33,17 @@ public class C_ColumnReference extends C_Leaf {
return id;
}
public TRId getTrId() {
return trId;
public ColumnData getColumn() {
return column;
}
public void setTrId(TRId trId) {
this.trId = trId;
}
public String getColumnId() {
return columnId;
}
public void setColumnId(String columnId) {
this.columnId = columnId;
}
public ColumnDataType getDataType() {
return dataType;
}
public void setDataType(ColumnDataType dataType) {
this.dataType = dataType;
public void setColumn(ColumnData column) {
this.column = column;
}
@Override
public String toString() {
return "TypedColumnReference [id=" + id + ", trId=" + trId
+ ", columnId=" + columnId + ", dataType=" + dataType + "]";
return "C_ColumnReference [id=" + id + ", column=" + column + "]";
}
}

View File

@ -2,6 +2,12 @@ package org.gcube.portlets.user.td.expressionwidget.shared.model.leaf;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_ColumnReferencePlaceholder extends C_Leaf {
private static final long serialVersionUID = 275747262118236529L;

View File

@ -4,6 +4,12 @@ import java.util.List;
import org.gcube.portlets.user.td.expressionwidget.shared.expression.C_MultivaluedExpression;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_ConstantList extends C_Leaf implements C_MultivaluedExpression {
private static final long serialVersionUID = 222662008523199480L;

View File

@ -2,6 +2,12 @@ package org.gcube.portlets.user.td.expressionwidget.shared.model.leaf;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_Leaf extends C_Expression {

View File

@ -2,6 +2,12 @@ package org.gcube.portlets.user.td.expressionwidget.shared.model.leaf;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class TD_Value extends C_Leaf {
private static final long serialVersionUID = 2802022467528178596L;

View File

@ -536,14 +536,12 @@ public class ReplaceTypeMap {
C_Expression exp;
TD_Value fArg;
TD_Value sArg;
Log.debug("Column Data Type Name:" + column.getDataTypeName());
C_ColumnReference columnRef = new C_ColumnReference(
column);
ColumnDataType dataType = ColumnDataType
.getColumnDataTypeFromId(column
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_ColumnReference columnRef = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
C_Expression columnReference;
if(dataType!=ColumnDataType.Text){
@ -569,16 +567,13 @@ public class ReplaceTypeMap {
C_Expression exp;
TD_Value fArg;
C_Expression posFrom;
C_Expression posTo;
Log.debug("Column Data Type Name:" + column.getDataTypeName());
C_Expression posTo;
C_ColumnReference columnRef = new C_ColumnReference(
column);
ColumnDataType dataType = ColumnDataType
.getColumnDataTypeFromId(column
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_ColumnReference columnRef = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
C_Expression columnReference;
if(dataType!=ColumnDataType.Text){
columnReference=new C_Cast(columnRef,ColumnDataType.Text);
@ -605,16 +600,15 @@ public class ReplaceTypeMap {
C_Expression exp;
TD_Value fArg;
TD_Value sArg;
Log.debug("Column Data Type Name:" + column.getDataTypeName());
C_ColumnReference columnRef = new C_ColumnReference(
column);
C_Expression columnReference;
ColumnDataType dataType = ColumnDataType
.getColumnDataTypeFromId(column
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_ColumnReference columnRef = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
C_Expression columnReference;
if(dataType!=ColumnDataType.Text){
columnReference=new C_Cast(columnRef,ColumnDataType.Text);
} else {
@ -637,15 +631,12 @@ public class ReplaceTypeMap {
throws ReplaceTypeMapException {
C_Expression exp;
TD_Value fArg;
Log.debug("Column Data Type Name:" + column.getDataTypeName());
C_ColumnReference columnRef = new C_ColumnReference(
column);
ColumnDataType dataType = ColumnDataType
.getColumnDataTypeFromId(column
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_ColumnReference columnRef = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
C_Expression columnReference;
if(dataType!=ColumnDataType.Text){
columnReference=new C_Cast(columnRef,ColumnDataType.Text);
@ -666,15 +657,13 @@ public class ReplaceTypeMap {
private C_Expression columnValueReference(ColumnData column,
ColumnDataType targetType) {
C_Expression exp;
Log.debug("Column Data Type Name:" + column.getDataTypeName());
C_ColumnReference columnRef = new C_ColumnReference(
column);
ColumnDataType dataType = ColumnDataType
.getColumnDataTypeFromId(column
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_ColumnReference columnRef = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
C_Expression columnReference;
if(dataType!=targetType){
columnReference=new C_Cast(columnRef,targetType);
@ -691,14 +680,13 @@ public class ReplaceTypeMap {
private C_Expression upperReference(ColumnData column,
ColumnDataType targetType) {
C_Expression exp;
Log.debug("Column Data Type Name:" + column.getDataTypeName());
C_ColumnReference columnRef = new C_ColumnReference(
column);
ColumnDataType dataType = ColumnDataType
.getColumnDataTypeFromId(column
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_ColumnReference columnRef = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
C_Expression columnReference;
if(dataType!=ColumnDataType.Text){
@ -718,14 +706,13 @@ public class ReplaceTypeMap {
private C_Expression lowerReference(ColumnData column,
ColumnDataType targetType) {
C_Expression exp;
Log.debug("Column Data Type Name:" + column.getDataTypeName());
C_ColumnReference columnRef = new C_ColumnReference(
column);
ColumnDataType dataType = ColumnDataType
.getColumnDataTypeFromId(column
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_ColumnReference columnRef = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
C_Expression columnReference;
if(dataType!=ColumnDataType.Text){
@ -746,14 +733,13 @@ public class ReplaceTypeMap {
private C_Expression trimReference(ColumnData column,
ColumnDataType targetType) {
C_Expression exp;
Log.debug("Column Data Type Name:" + column.getDataTypeName());
C_ColumnReference columnRef = new C_ColumnReference(
column);
ColumnDataType dataType = ColumnDataType
.getColumnDataTypeFromId(column
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_ColumnReference columnRef = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
C_Expression columnReference;
if(dataType!=ColumnDataType.Text){
@ -773,14 +759,13 @@ public class ReplaceTypeMap {
private C_Expression md5Reference(ColumnData column,
ColumnDataType targetType) {
C_Expression exp;
Log.debug("Column Data Type Name:" + column.getDataTypeName());
C_ColumnReference columnRef = new C_ColumnReference(
column);
ColumnDataType dataType = ColumnDataType
.getColumnDataTypeFromId(column
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_ColumnReference columnRef = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
C_Expression columnReference;
if(dataType!=ColumnDataType.Text){

View File

@ -1,9 +1,5 @@
package org.gcube.portlets.user.td.expressionwidget.shared.rule;
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
import com.google.gwt.editor.client.Editor.Path;
@ -13,21 +9,24 @@ import com.sencha.gxt.data.shared.PropertyAccess;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface RuleDescriptionDataProperties extends PropertyAccess<RuleDescriptionData> {
public interface RuleDescriptionDataProperties extends
PropertyAccess<RuleDescriptionData> {
@Path("id")
ModelKeyProvider<RuleDescriptionData> id();
ValueProvider<RuleDescriptionData, String> name();
ValueProvider<RuleDescriptionData, String> scopeLabel();
ValueProvider<RuleDescriptionData, String> description();
ValueProvider<RuleDescriptionData, String> ownerLogin();
ValueProvider<RuleDescriptionData, String> readableExpression();
}
ValueProvider<RuleDescriptionData, String> name();
ValueProvider<RuleDescriptionData, String> scopeLabel();
ValueProvider<RuleDescriptionData, String> description();
ValueProvider<RuleDescriptionData, String> ownerLogin();
ValueProvider<RuleDescriptionData, String> readableExpression();
}

View File

@ -10,18 +10,18 @@ import com.sencha.gxt.data.shared.PropertyAccess;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface RuleDescriptionDataPropertiesCombo extends PropertyAccess<RuleDescriptionData> {
public interface RuleDescriptionDataPropertiesCombo extends
PropertyAccess<RuleDescriptionData> {
@Path("id")
ModelKeyProvider<RuleDescriptionData> id();
LabelProvider<RuleDescriptionData> name();
@Path("name")
ValueProvider<RuleDescriptionData, String> nameProv();
}