Updated ReplceByExpression to support Template

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@101692 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-11-24 16:02:15 +00:00
parent 15985bfe4a
commit 1e2f1821d4
10 changed files with 458 additions and 161 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/tabular-data-expression-widget-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/tabular-data-expression-widget-1.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/tabular-data-expression-widget-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/tabular-data-expression-widget-1.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -32,5 +32,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/tabular-data-expression-widget-1.3.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/tabular-data-expression-widget-1.4.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -36,22 +36,22 @@ import com.sencha.gxt.widget.core.client.form.TextField;
*/
public class ColumnExpressionPanel extends FramedPanel {
private enum ColumnExpressionPanelType {
MultiColumnFilter, ColumnFilter, ColumnRule;
MultiColumnFilter, ColumnFilter, Template;
}
protected String WIDTH_MULTI = "642px";
protected String HEIGHT_MULTI = "290px";
protected String WIDTH = "648px";
protected String HEIGHT = "364px";
private String WIDTH_MULTI = "642px";
private String HEIGHT_MULTI = "290px";
private String WIDTH = "648px";
private String HEIGHT = "364px";
protected ColumnExpressionPanelType type;
protected EventBus eventBus;
private ColumnExpressionPanelType type;
private EventBus eventBus;
protected ColumnExpressionDialog parentRuleDialog;
protected ColumnFilterDialog parentFilterDialog;
protected MultiColumnFilterTabPanel parentMultiColumnFilterTabPanel;
private ColumnExpressionDialog parentRuleDialog;
private ColumnFilterDialog parentFilterDialog;
private MultiColumnFilterTabPanel parentMultiColumnFilterTabPanel;
protected ColumnData column;
private ColumnData column;
private TextButton btnApply;
private TextButton btnSearch;
@ -100,7 +100,7 @@ public class ColumnExpressionPanel extends FramedPanel {
super();
setWidth(WIDTH);
setHeight(HEIGHT);
type = ColumnExpressionPanelType.ColumnRule;
type = ColumnExpressionPanelType.Template;
this.parentRuleDialog = parent;
this.column = column;
this.eventBus = eventBus;
@ -129,7 +129,7 @@ public class ColumnExpressionPanel extends FramedPanel {
flowButton.setPack(BoxLayoutPack.CENTER);
switch (type) {
case ColumnRule:
case Template:
properties = new FieldSet();
properties.setHeadingText("Properties");
properties.setCollapsible(false);
@ -334,16 +334,16 @@ public class ColumnExpressionPanel extends FramedPanel {
}
switch (type) {
case ColumnRule:
case Template:
parentRuleDialog.setExpression(exp);
ExpressionEvent expressionEvent = new ExpressionEvent(
ExpressionType.CREATECOLUMNEXPRESSION);
ExpressionType.COLUMNEXPRESSION);
C_ExpressionContainer container = new C_ExpressionContainer();
container.setId(C_ExpressionContainer.Contains.C_Expression);
container.setExp(exp);
container.setReadableExpression(conditionWidget
.getReadableExpression());
expressionEvent.setC_ExpressionContainer(container);
expressionEvent.setC_ConditionExpressionContainer(container);
expressionEvent.setTrId(column.getTrId());
expressionEvent.setColumnId(column.getColumnId());
expressionEvent.setColumnName(column.getName());
@ -373,7 +373,7 @@ public class ColumnExpressionPanel extends FramedPanel {
protected void close() {
switch (type) {
case ColumnRule:
case Template:
ExpressionEvent expressionEvent = new ExpressionEvent(
ExpressionType.EXPRESSIONNULL);
Log.debug(expressionEvent.toString());

View File

@ -1,7 +1,10 @@
package org.gcube.portlets.user.td.expressionwidget.client;
import java.util.ArrayList;
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceColumnByExpressionType;
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
@ -37,37 +40,50 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
*/
public class ReplaceColumnByExpressionDialog extends Window implements
MonitorDialogListener {
protected static final String WIDTH = "880px";
protected static final String HEIGHT = "490px";
protected static final String HEIGHT_REDUCE = "404px";
private static final String WIDTH = "880px";
private static final String HEIGHT = "490px";
private static final String HEIGHT_REDUCE = "404px";
protected ReplaceColumnByExpressionPanel replaceColumnByExpressionPanel;
protected C_Expression cConditionExpression = null;
protected C_Expression cReplaceExpression = null;
protected String replaceValue;
protected ColumnData column = null;
protected TRId trId;
protected String columnName = null;
protected EventBus eventBus;
private ReplaceColumnByExpressionPanel replaceColumnByExpressionPanel;
private C_Expression cConditionExpression = null;
private ColumnData column = null;
private ArrayList<ColumnData> columns;
//private String columnName = null;
private EventBus eventBus;
private ReplaceColumnByExpressionType replaceColumnByExpressionType;
public ReplaceColumnByExpressionDialog(String columnId,
ColumnTypeCode columnTypeCode, ColumnDataType dataTypeName,
EventBus eventBus) {
/**
*
* Columns must have set columnId, label, columnTypeCode and ColumnDataType
*
* @param column
* The column selected
* @param columns
* @param eventBus
*/
public ReplaceColumnByExpressionDialog(ColumnData column,
ArrayList<ColumnData> columns, EventBus eventBus) {
this.eventBus = eventBus;
column = new ColumnData();
column.setColumnId(columnId);
column.setDataTypeName(dataTypeName.toString());
column.setTypeCode(columnTypeCode.toString());
this.column = column;
this.columns = columns;
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Template;
initWindow();
create();
}
/**
*
* @param trId
* @param columnName
* @param eventBus
*/
public ReplaceColumnByExpressionDialog(TRId trId, String columnName,
EventBus eventBus) {
this.eventBus = eventBus;
this.trId = trId;
this.columnName = columnName;
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
initWindow();
load(trId, columnName);
@ -102,9 +118,21 @@ public class ReplaceColumnByExpressionDialog extends Window implements
}
protected void create() {
if (column != null
&& column.getDataTypeName().compareTo(
ColumnDataType.Text.toString()) == 0) {
if (column == null) {
UtilsGXT3.info("Attention ",
"You must select a column!");
hide();
return;
}
if (column.isViewColumn()) {
UtilsGXT3.info("Attention is View Column",
"You can not make expressions on view column for now!");
hide();
return;
}
if (column.getDataTypeName().compareTo(ColumnDataType.Text.toString()) == 0) {
setHeight(HEIGHT);
} else {
setHeight(HEIGHT_REDUCE);
@ -122,8 +150,20 @@ public class ReplaceColumnByExpressionDialog extends Window implements
ColumnTypeCode.CODENAME.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.MEASURE.toString()) == 0) {
replaceColumnByExpressionPanel = new ReplaceColumnByExpressionPanel(
this, column, eventBus);
switch (replaceColumnByExpressionType) {
case Replace:
replaceColumnByExpressionPanel = new ReplaceColumnByExpressionPanel(
this, column, eventBus);
break;
case Template:
replaceColumnByExpressionPanel = new ReplaceColumnByExpressionPanel(
this, column, columns, eventBus);
break;
default:
break;
}
add(replaceColumnByExpressionPanel);
} else {
@ -147,7 +187,7 @@ public class ReplaceColumnByExpressionDialog extends Window implements
protected void applyReplaceColumnByExpression(
C_Expression cConditionExpression, String replaceValue) {
this.cConditionExpression = cConditionExpression;
this.replaceValue = replaceValue;
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
column, cConditionExpression, replaceValue);
@ -157,7 +197,7 @@ public class ReplaceColumnByExpressionDialog extends Window implements
protected void applyReplaceColumnByExpression(
C_Expression cConditionExpression, C_Expression cReplaceExpression) {
this.cConditionExpression = cConditionExpression;
this.cReplaceExpression = cReplaceExpression;
//this.cReplaceExpression = cReplaceExpression;
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
column, cConditionExpression, cReplaceExpression);
callApplyReplaceByExpression(replaceColumnByExpressionSession);
@ -187,15 +227,9 @@ public class ReplaceColumnByExpressionDialog extends Window implements
public void onSuccess(ColumnData result) {
Log.debug("Retrived column: " + result);
if (result.isViewColumn()) {
UtilsGXT3
.info("View Column",
"You can not make expressions on view column for now");
hide();
} else {
column = result;
create();
}
column = result;
create();
}
});

View File

@ -1,14 +1,19 @@
package org.gcube.portlets.user.td.expressionwidget.client;
import java.util.ArrayList;
import java.util.Date;
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceColumnByExpressionType;
import org.gcube.portlets.user.td.expressionwidget.shared.exception.OperatorTypeMapException;
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ReplaceTypeMapException;
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.TD_Value;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ExpressionEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ExpressionType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_ExpressionContainer;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeMap;
@ -52,25 +57,28 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
private static final String GEOMETRY_REGEXPR = "(\\s*POINT\\s*\\(\\s*(-)?\\d+(\\.\\d+)?\\s+(-)?\\d+(\\.\\d+)?\\s*\\)\\s*$)"
+ "|(\\s*LINESTRING\\s*\\((\\s*(-)?\\d+(\\.\\d+)?\\s+(-)?\\d+(\\.\\d+)?\\s*,)+\\s*((-)?\\d+(\\.\\d+)?\\s+(-)?\\d+(\\.\\d+)?\\s*)\\)\\s*$)";
protected static final String WIDTH = "868px";
protected static final String HEIGHT = "454px";
protected static final String HEIGHT_REDUCE = "368px";
private static final String WIDTH = "868px";
private static final String HEIGHT = "454px";
private static final String HEIGHT_REDUCE = "368px";
protected static final String CONDITIONWIDTH = "832px";
protected static final String CONDITIONHEIGHT = "120px";
protected static final String CONDITION_LAYOUT_WIDTH = "832px";
protected static final String REPLACEWIDTH = "832px";
protected static final String REPLACEHEIGHT = "120px";
protected static final String ALL_ROWS_FIELD_WIDTH = "832px";
private static final String CONDITIONWIDTH = "832px";
private static final String CONDITIONHEIGHT = "120px";
private static final String CONDITION_LAYOUT_WIDTH = "832px";
private static final String REPLACEWIDTH = "832px";
private static final String REPLACEHEIGHT = "120px";
private static final String ALL_ROWS_FIELD_WIDTH = "832px";
protected static final String RADIO_LABEL_BY_CONDITION = "By Condition";
protected static final String RADIO_LABEL_ALL_ROWS = "All Rows";
private static final String RADIO_LABEL_BY_CONDITION = "By Condition";
private static final String RADIO_LABEL_ALL_ROWS = "All Rows";
protected EventBus eventBus;
private EventBus eventBus;
protected ReplaceColumnByExpressionDialog parent;
private ReplaceColumnByExpressionDialog parent;
protected ColumnData column;
private ColumnData column;
private ArrayList<ColumnData> columns;
private ReplaceColumnByExpressionType replaceColumnByExpressionType;
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
@ -88,6 +96,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
private FieldLabel allRowsField;
private boolean allRows;
public ReplaceColumnByExpressionPanel(
ReplaceColumnByExpressionDialog parent, ColumnData column,
EventBus eventBus) {
@ -95,7 +105,23 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
this.parent = parent;
this.column = column;
this.eventBus = eventBus;
Log.debug(column.toString());
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
Log.debug("Column: " + column);
init();
create();
}
public ReplaceColumnByExpressionPanel(
ReplaceColumnByExpressionDialog parent, ColumnData column,
ArrayList<ColumnData> columns, EventBus eventBus) {
super();
this.parent = parent;
this.column = column;
this.columns = columns;
this.eventBus = eventBus;
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Template;
Log.debug("Column: " + column);
Log.debug("Columns: " + columns);
init();
create();
}
@ -209,8 +235,25 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
} else {
if (column.getDataTypeName().compareTo(
ColumnDataType.Text.toString()) == 0) {
replaceWidget = new ReplaceWidget(column, REPLACEWIDTH,
REPLACEHEIGHT, eventBus);
switch(replaceColumnByExpressionType){
case Replace:
replaceWidget = new ReplaceWidget(column, REPLACEWIDTH,
REPLACEHEIGHT, eventBus);
break;
case Template:
replaceWidget = new ReplaceWidget(column, columns, REPLACEWIDTH,
REPLACEHEIGHT, eventBus);
break;
default:
Log.debug("Attention Replace Widget have not a valid type");
UtilsGXT3.alert("Attention", "Attention Replace Widget have not a valid type");
if(parent!=null){
parent.hide();
}
return;
}
replaceValueFieldSetLayout.add(replaceWidget,
new VerticalLayoutData(1, -1));
} else {
@ -283,7 +326,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
if (allRows) {
cConditionExpression = new TD_Value(ColumnDataType.Boolean, "true");
} else {
try {
cConditionExpression = conditionWidget.getExpression();
} catch (OperatorTypeMapException e) {
@ -291,7 +334,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
return;
}
}
String value = null;
if (column.getDataTypeName().compareTo(ColumnDataType.Date.toString()) == 0) {
@ -308,8 +351,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
"Select a valid date as replace value!");
return;
}
parent.applyReplaceColumnByExpression(cConditionExpression,
value);
callApplyReplaceColumnByExpression(cConditionExpression, value);
}
@ -325,16 +367,15 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
return;
}
} catch (ReplaceTypeMapException e) {
UtilsGXT3.alert("Attention",
e.getLocalizedMessage());
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
return;
}
parent.applyReplaceColumnByExpression(cConditionExpression,
callApplyReplaceColumnByExpression(cConditionExpression,
cReplaceExpression);
} else {
value = replaceValue.getCurrentValue();
if (checkValue(value)) {
parent.applyReplaceColumnByExpression(cConditionExpression,
callApplyReplaceColumnByExpression(cConditionExpression,
value);
} else {
return;
@ -344,6 +385,69 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
}
protected void callApplyReplaceColumnByExpression(
C_Expression cConditionExpression, String replaceValue) {
switch (replaceColumnByExpressionType) {
case Template:
ExpressionEvent expressionEvent = new ExpressionEvent(
ExpressionType.REPLACECOLUMNEXPRESSION);
C_ExpressionContainer container = new C_ExpressionContainer(
C_ExpressionContainer.Contains.C_Expression,
cConditionExpression,
conditionWidget.getReadableExpression());
expressionEvent.setC_ConditionExpressionContainer(container);
expressionEvent.setReplaceByValue(true);
expressionEvent.setReplaceValue(replaceValue);
expressionEvent.setTrId(column.getTrId());
expressionEvent.setColumnId(column.getColumnId());
expressionEvent.setColumnName(column.getName());
Log.debug(expressionEvent.toString());
parent.hide();
eventBus.fireEvent(expressionEvent);
break;
case Replace:
parent.applyReplaceColumnByExpression(cConditionExpression,
replaceValue);
break;
default:
break;
}
}
protected void callApplyReplaceColumnByExpression(
C_Expression cConditionExpression, C_Expression cReplaceExpression) {
switch (replaceColumnByExpressionType) {
case Template:
ExpressionEvent expressionEvent = new ExpressionEvent(
ExpressionType.REPLACECOLUMNEXPRESSION);
C_ExpressionContainer conditionExpressionContainer = new C_ExpressionContainer(
C_ExpressionContainer.Contains.C_Expression,
cConditionExpression,
conditionWidget.getReadableExpression());
expressionEvent.setC_ConditionExpressionContainer(conditionExpressionContainer);
expressionEvent.setReplaceByValue(false);
C_ExpressionContainer replaceExpressionContainer = new C_ExpressionContainer(
C_ExpressionContainer.Contains.C_Expression,
cReplaceExpression,
replaceWidget.getReadableExpression());
expressionEvent.setC_ReplaceExpressionContainer(replaceExpressionContainer);;
expressionEvent.setTrId(column.getTrId());
expressionEvent.setColumnId(column.getColumnId());
expressionEvent.setColumnName(column.getName());
Log.debug(expressionEvent.toString());
parent.hide();
eventBus.fireEvent(expressionEvent);
break;
case Replace:
parent.applyReplaceColumnByExpression(cConditionExpression,
cReplaceExpression);
break;
default:
break;
}
}
private boolean checkValue(String value) {
try {
boolean ok = false;
@ -378,24 +482,24 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
case Integer:
try {
Integer.parseInt(value);
} catch(Throwable e){
} catch (Throwable e) {
e.printStackTrace();
UtilsGXT3.alert("Error replace value",
"Insert a valid replace value for Integer type! ");
return false;
}
ok=true;
ok = true;
break;
case Numeric:
try {
Double.parseDouble(value);
} catch(Throwable e){
} catch (Throwable e) {
e.printStackTrace();
UtilsGXT3.alert("Error replace value",
"Insert a valid replace value for Numeric type! ");
return false;
}
ok=true;
ok = true;
break;
case Text:
ok = true;
@ -408,14 +512,31 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
} catch (Throwable e) {
e.printStackTrace();
UtilsGXT3.alert("Error replace value",
"Insert a valid replace value! "+e.getLocalizedMessage());
"Insert a valid replace value! " + e.getLocalizedMessage());
return false;
}
}
protected void close() {
parent.close();
switch (replaceColumnByExpressionType) {
case Template:
ExpressionEvent expressionEvent = new ExpressionEvent(
ExpressionType.EXPRESSIONNULL);
Log.debug(expressionEvent.toString());
parent.close();
eventBus.fireEvent(expressionEvent);
break;
case Replace:
if (parent != null) {
parent.close();
}
break;
default:
break;
}
}
}

View File

@ -6,6 +6,7 @@ import org.gcube.portlets.user.td.expressionwidget.client.properties.ColumnDataP
import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceElement;
import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceElementProperties;
import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceElementStore;
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceColumnByExpressionType;
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ReplaceTypeMapException;
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceType;
@ -29,7 +30,6 @@ import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.core.client.util.ToggleGroup;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
@ -39,7 +39,6 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.event.BeforeShowEvent;
import com.sencha.gxt.widget.core.client.form.ComboBox;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.TextField;
/**
@ -61,29 +60,30 @@ public class ReplaceWidget extends SimpleContainer {
private ReplaceWidget thisCont;
protected static final String HEIGHT = "210px";
protected static final String WIDTH = "832px";
protected static final String COMBO_WIDTH = "170px";
private static final String HEIGHT = "210px";
private static final String WIDTH = "832px";
private static final String COMBO_WIDTH = "170px";
protected EventBus eventBus;
protected TRId trId;
protected ArrayList<ColumnData> columns;
private EventBus eventBus;
private TRId trId;
private ArrayList<ColumnData> columns;
protected FieldLabel matchLabel;
protected ToggleGroup groupMatch;
// private FieldLabel matchLabel;
// private ToggleGroup groupMatch;
protected VerticalLayoutContainer vert;
private VerticalLayoutContainer vert;
// protected ColumnData column;
protected String readableExpression;
private String readableExpression;
private String itemIdComboConcat;
private String itemIdComboLeaf;
private String itemIdComboColumns;
private String itemIdFirstArg;
private String itemIdSecondArg;
private String itemIdHoriz;
private ReplaceColumnByExpressionType replaceColumnByExpressionType;
public class ExpressionContainer {
protected class ExpressionContainer {
private C_Expression expression;
private String readableExpression;
@ -114,23 +114,35 @@ public class ReplaceWidget extends SimpleContainer {
public ReplaceWidget(ColumnData column, EventBus eventBus) {
super();
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
create(column.getTrId(), WIDTH, HEIGHT, eventBus);
retrieveColumns();
}
public ReplaceWidget(ColumnData column, String width, String height,
EventBus eventBus) {
super();
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
create(column.getTrId(), width, height, eventBus);
retrieveColumns();
}
public ReplaceWidget(TRId trId, EventBus eventBus) {
create(trId, WIDTH, HEIGHT, eventBus);
}
public ReplaceWidget(TRId trId, String width, String height,
public ReplaceWidget(ColumnData column, ArrayList<ColumnData> columns,
EventBus eventBus) {
super();
create(trId, width, height, eventBus);
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Template;
this.columns = columns;
create(column.getTrId(), WIDTH, HEIGHT, eventBus);
setup();
}
public ReplaceWidget(ColumnData column, ArrayList<ColumnData> columns,
String width, String height, EventBus eventBus) {
super();
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Template;
this.columns = columns;
create(column.getTrId(), width, height, eventBus);
setup();
}
protected void create(TRId trId, String width, String height,
@ -150,7 +162,6 @@ public class ReplaceWidget extends SimpleContainer {
}
});
retrieveColumns();
}
@ -776,7 +787,8 @@ public class ReplaceWidget extends SimpleContainer {
return readableExpression;
}
protected ExpressionContainer calcCExpression(int index) throws ReplaceTypeMapException {
protected ExpressionContainer calcCExpression(int index)
throws ReplaceTypeMapException {
ExpressionContainer expressionContainer = null;
ExpressionContainer expContainerConcat = null;
C_Expression exp = null;
@ -797,28 +809,57 @@ public class ReplaceWidget extends SimpleContainer {
ComboBox<ReplaceElement> comboLeaf = (ComboBox<ReplaceElement>) horiz
.getItemByItemId(itemIdComboLeaf);
Log.debug("combo Leaf: " + comboLeaf.getCurrentValue());
@SuppressWarnings("unchecked")
ComboBox<ColumnData> comboColumns = (ComboBox<ColumnData>) horiz
.getItemByItemId(itemIdComboColumns);
Log.debug("combo columns: " + comboColumns.getCurrentValue());
ColumnData column=comboColumns.getCurrentValue();
ColumnData column = comboColumns.getCurrentValue();
firstArg = (TextField) horiz.getItemByItemId(itemIdFirstArg);
secondArg = (TextField) horiz.getItemByItemId(itemIdSecondArg);
Log.debug("[column: "+column+", firstArg: " + firstArg.getCurrentValue() + ", secondArg: "
+ secondArg.getCurrentValue()+"]");
Log.debug("[column: " + column + ", firstArg: "
+ firstArg.getCurrentValue() + ", secondArg: "
+ secondArg.getCurrentValue() + "]");
ReplaceType comboConcatReplaceType = null;
ReplaceType comboLeafReplaceType = null;
if (comboConcat.getCurrentValue() == null) {
if (index == vert.getWidgetCount() - 1) {
exp = mapReplace.map(column, ReplaceType.Null,
firstArg == null ? null : firstArg.getCurrentValue(),
secondArg == null ? null : secondArg.getCurrentValue(), false);
switch (replaceColumnByExpressionType) {
case Replace:
exp = mapReplace.map(
column,
ReplaceType.Null,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), false);
break;
case Template:
exp = mapReplace.map(
column,
ReplaceType.Null,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), true);
break;
default:
exp = mapReplace.map(
column,
ReplaceType.Null,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), false);
break;
}
readableExp = mapReplace.getReadableExpression();
expressionContainer = new ExpressionContainer(exp, readableExp);
} else {
throw new ReplaceTypeMapException("Fill all field!");
}
@ -828,25 +869,73 @@ public class ReplaceWidget extends SimpleContainer {
if (comboConcatReplaceType.compareTo(ReplaceType.Concat) == 0) {
if (comboLeaf.getCurrentValue() == null) {
expLeaf = mapReplace.map(
column,
ReplaceType.Null,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), false);
switch (replaceColumnByExpressionType) {
case Replace:
expLeaf = mapReplace.map(
column,
ReplaceType.Null,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), false);
break;
case Template:
expLeaf = mapReplace.map(
column,
ReplaceType.Null,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), true);
break;
default:
expLeaf = mapReplace.map(
column,
ReplaceType.Null,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), false);
break;
}
readableExpLeaf = mapReplace.getReadableExpression();
} else {
comboLeafReplaceType = comboLeaf.getCurrentValue()
.getReplaceType();
expLeaf = mapReplace.map(
column,
comboLeafReplaceType,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), false);
switch (replaceColumnByExpressionType) {
case Replace:
expLeaf = mapReplace.map(
column,
comboLeafReplaceType,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), false);
break;
case Template:
expLeaf = mapReplace.map(
column,
comboLeafReplaceType,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), true);
break;
default:
expLeaf = mapReplace.map(
column,
comboLeafReplaceType,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), false);
break;
}
readableExpLeaf = mapReplace.getReadableExpression();
}
@ -856,16 +945,45 @@ public class ReplaceWidget extends SimpleContainer {
if (expContainerConcat == null) {
return null;
} else {
exp = mapReplace.map(
column,
comboConcatReplaceType,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(),false, expLeaf,
expContainerConcat.getExpression(),
readableExpLeaf, expContainerConcat
.getReadableExpression());
switch (replaceColumnByExpressionType) {
case Replace:
exp = mapReplace.map(
column,
comboConcatReplaceType,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), false, expLeaf,
expContainerConcat.getExpression(),
readableExpLeaf, expContainerConcat
.getReadableExpression());
break;
case Template:
exp = mapReplace.map(
column,
comboConcatReplaceType,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), true, expLeaf,
expContainerConcat.getExpression(),
readableExpLeaf, expContainerConcat
.getReadableExpression());
break;
default:
exp = mapReplace.map(
column,
comboConcatReplaceType,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), false, expLeaf,
expContainerConcat.getExpression(),
readableExpLeaf, expContainerConcat
.getReadableExpression());
break;
}
readableExp = mapReplace.getReadableExpression();
expressionContainer = new ExpressionContainer(exp,
readableExp);
@ -875,9 +993,27 @@ public class ReplaceWidget extends SimpleContainer {
}
} else {
exp = mapReplace.map(column, comboConcatReplaceType,
firstArg == null ? null : firstArg.getCurrentValue(),
secondArg == null ? null : secondArg.getCurrentValue(),false);
switch (replaceColumnByExpressionType) {
case Replace:
exp = mapReplace.map(column, comboConcatReplaceType,
firstArg == null ? null : firstArg.getCurrentValue(),
secondArg == null ? null : secondArg.getCurrentValue(),
false);
break;
case Template:
exp = mapReplace.map(column, comboConcatReplaceType,
firstArg == null ? null : firstArg.getCurrentValue(),
secondArg == null ? null : secondArg.getCurrentValue(),
true);
break;
default:
exp = mapReplace.map(column, comboConcatReplaceType,
firstArg == null ? null : firstArg.getCurrentValue(),
secondArg == null ? null : secondArg.getCurrentValue(),
false);
break;
}
readableExp = mapReplace.getReadableExpression();
expressionContainer = new ExpressionContainer(exp, readableExp);

View File

@ -0,0 +1,5 @@
package org.gcube.portlets.user.td.expressionwidget.client.type;
public enum ReplaceColumnByExpressionType {
Replace, Template;
}

View File

@ -35,7 +35,6 @@ 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.leaf.TypedColumnReference;
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;
@ -44,6 +43,7 @@ import org.gcube.data.analysis.tabulardata.expression.logical.Not;
import org.gcube.data.analysis.tabulardata.expression.logical.Or;
import org.gcube.data.analysis.tabulardata.expression.logical.ValueIsIn;
import org.gcube.data.analysis.tabulardata.model.column.ColumnLocalId;
import org.gcube.data.analysis.tabulardata.model.column.ColumnReference;
import org.gcube.data.analysis.tabulardata.model.datatype.BooleanType;
import org.gcube.data.analysis.tabulardata.model.datatype.DataType;
import org.gcube.data.analysis.tabulardata.model.datatype.DateType;
@ -85,10 +85,10 @@ import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextEndsWith;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextMatchSQLRegexp;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextReplaceMatchingRegex;
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.C_TypedColumnReference;
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;
@ -122,8 +122,8 @@ public class C_ExpressionParser {
case "Range":
ex = getRange(exp);
break;
case "TypedColumnReference":
ex = getTypedColumnReference(exp);
case "ColumnReference":
ex = getColumnReference(exp);
break;
case "TD_Value":
TD_Value value = (TD_Value) exp;
@ -556,8 +556,8 @@ public class C_ExpressionParser {
return range;
}
protected Expression getTypedColumnReference(C_Expression exp) {
C_TypedColumnReference c = (C_TypedColumnReference) exp;
protected Expression getColumnReference(C_Expression exp) {
C_ColumnReference c = (C_ColumnReference) exp;
String tableIdS = null;
if (c.getTrId().isViewTable()) {
tableIdS = c.getTrId().getReferenceTargetTableId();
@ -566,8 +566,9 @@ public class C_ExpressionParser {
}
TableId tableId = new TableId(Long.valueOf(tableIdS));
ColumnLocalId columnId = new ColumnLocalId(c.getColumnId());
TypedColumnReference ref = new TypedColumnReference(tableId, columnId,
ColumnReference ref = new ColumnReference(tableId, columnId,
mapColumnDataType(c.getDataType()));
return ref;
}

View File

@ -19,7 +19,7 @@ import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C
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.C_TypedColumnReference;
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReference;
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;
@ -344,7 +344,7 @@ public class OperatorTypeMap {
ColumnDataType dataType = ColumnTypeMap.getColumnDataType(column
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_TypedColumnReference columnReference = new C_TypedColumnReference(
C_ColumnReference columnReference = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
Log.debug("Typed Column Reference:" + columnReference);
String readableColumnReference = column.getLabel();

View File

@ -3,20 +3,20 @@ 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;
public class C_TypedColumnReference extends C_Leaf {
public class C_ColumnReference extends C_Leaf {
private static final long serialVersionUID = 1007646449141930835L;
protected String id = "TypedColumnReference";
protected String id = "ColumnReference";
protected TRId trId;
protected String columnId;
protected ColumnDataType dataType;
public C_TypedColumnReference(){
public C_ColumnReference(){
}
public C_TypedColumnReference(TRId trId, ColumnDataType dataType, String columnId) {
public C_ColumnReference(TRId trId, ColumnDataType dataType, String columnId) {
this.trId=trId;
this.dataType=dataType;
this.columnId=columnId;

View File

@ -8,7 +8,7 @@ import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringPosition;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextReplaceMatchingRegex;
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReferencePlaceholder;
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_TypedColumnReference;
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.C_ColumnReference;
import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.TD_Value;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
@ -46,7 +46,7 @@ public class ReplaceTypeMap {
exp = mapPlaceHolder(column, replaceType, firstArg, secondArg,
firstE, secondE, readableFirstE,readableSecondE);
} else {
exp = mapTypedColumnReference(column, replaceType, firstArg,
exp = mapColumnReference(column, replaceType, firstArg,
secondArg, firstE, secondE,readableFirstE,readableSecondE);
}
return exp;
@ -163,7 +163,7 @@ public class ReplaceTypeMap {
return exp;
}
public C_Expression mapTypedColumnReference(ColumnData column,
public C_Expression mapColumnReference(ColumnData column,
ReplaceType replaceType, String firstArg, String secondArg,
C_Expression firstE, C_Expression secondE, String readableFirstE, String readableSecondE) throws ReplaceTypeMapException {
Log.debug("OperatorTypeMap Map Typed Column Reference");
@ -197,7 +197,7 @@ public class ReplaceTypeMap {
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_TypedColumnReference columnRef = new C_TypedColumnReference(
C_ColumnReference columnRef = new C_ColumnReference(
column.getTrId(), dataType, column.getColumnId());
C_Expression columnReference;