Updated Replace by Expression

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@99996 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-09-17 15:41:32 +00:00
parent 3f8baf4909
commit e6ba70d77b
12 changed files with 903 additions and 125 deletions

View File

@ -35,8 +35,10 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
*/ */
public class ReplaceColumnByExpressionDialog extends Window implements public class ReplaceColumnByExpressionDialog extends Window implements
MonitorDialogListener { MonitorDialogListener {
protected String WIDTH = "660px"; protected static final String WIDTH = "660px";
protected String HEIGHT = "400px"; protected static final String HEIGHT = "490px";
protected static final String HEIGHT_REDUCE = "404px";
protected ReplaceColumnByExpressionPanel replaceColumnByExpressionPanel; protected ReplaceColumnByExpressionPanel replaceColumnByExpressionPanel;
protected C_Expression cConditionExpression = null; protected C_Expression cConditionExpression = null;
protected C_Expression cReplaceExpression = null; protected C_Expression cReplaceExpression = null;
@ -49,22 +51,22 @@ public class ReplaceColumnByExpressionDialog extends Window implements
public ReplaceColumnByExpressionDialog(String columnId, public ReplaceColumnByExpressionDialog(String columnId,
ColumnTypeCode columnTypeCode, ColumnDataType dataTypeName, ColumnTypeCode columnTypeCode, ColumnDataType dataTypeName,
EventBus eventBus) { EventBus eventBus) {
initWindow();
this.eventBus = eventBus; this.eventBus = eventBus;
column = new ColumnData(); column = new ColumnData();
column.setColumnId(columnId); column.setColumnId(columnId);
column.setDataTypeName(dataTypeName.toString()); column.setDataTypeName(dataTypeName.toString());
column.setTypeCode(columnTypeCode.toString()); column.setTypeCode(columnTypeCode.toString());
initWindow();
create(); create();
} }
public ReplaceColumnByExpressionDialog(TRId trId, String columnName, public ReplaceColumnByExpressionDialog(TRId trId, String columnName,
EventBus eventBus) { EventBus eventBus) {
initWindow();
this.eventBus = eventBus; this.eventBus = eventBus;
this.trId = trId; this.trId = trId;
this.columnName = columnName; this.columnName = columnName;
initWindow();
load(trId, columnName); load(trId, columnName);
} }
@ -98,6 +100,14 @@ public class ReplaceColumnByExpressionDialog extends Window implements
} }
protected void create() { protected void create() {
if (column != null
&& column.getDataTypeName().compareTo(
ColumnDataType.Text.toString())==0) {
setHeight(HEIGHT);
} else {
setHeight(HEIGHT_REDUCE);
}
if (column.getTypeCode() if (column.getTypeCode()
.compareTo(ColumnTypeCode.ANNOTATION.toString()) == 0 .compareTo(ColumnTypeCode.ANNOTATION.toString()) == 0
|| column.getTypeCode().compareTo( || column.getTypeCode().compareTo(
@ -132,8 +142,8 @@ public class ReplaceColumnByExpressionDialog extends Window implements
this.cConditionExpression = exp; this.cConditionExpression = exp;
} }
protected void applyReplaceColumnByExpression(C_Expression cConditionExpression, protected void applyReplaceColumnByExpression(
String replaceValue) { C_Expression cConditionExpression, String replaceValue) {
this.cConditionExpression = cConditionExpression; this.cConditionExpression = cConditionExpression;
this.replaceValue = replaceValue; this.replaceValue = replaceValue;
@ -142,8 +152,8 @@ public class ReplaceColumnByExpressionDialog extends Window implements
callApplyReplaceByExpression(replaceColumnByExpressionSession); callApplyReplaceByExpression(replaceColumnByExpressionSession);
} }
protected void applyReplaceColumnByExpression(C_Expression cConditionExpression, protected void applyReplaceColumnByExpression(
C_Expression cReplaceExpression) { C_Expression cConditionExpression, C_Expression cReplaceExpression) {
this.cConditionExpression = cConditionExpression; this.cConditionExpression = cConditionExpression;
this.cReplaceExpression = cReplaceExpression; this.cReplaceExpression = cReplaceExpression;
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession( ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
@ -181,7 +191,8 @@ public class ReplaceColumnByExpressionDialog extends Window implements
protected void callApplyReplaceByExpression( protected void callApplyReplaceByExpression(
ReplaceColumnByExpressionSession replaceColumnByExpressionSession) { ReplaceColumnByExpressionSession replaceColumnByExpressionSession) {
Log.debug("Replace Column By Expression Session "+replaceColumnByExpressionSession); Log.debug("Replace Column By Expression Session "
+ replaceColumnByExpressionSession);
ExpressionServiceAsync.INSTANCE.startReplaceColumnByExpression( ExpressionServiceAsync.INSTANCE.startReplaceColumnByExpression(
replaceColumnByExpressionSession, new AsyncCallback<String>() { replaceColumnByExpressionSession, new AsyncCallback<String>() {

View File

@ -46,7 +46,9 @@ import com.sencha.gxt.widget.core.client.form.TextField;
*/ */
public class ReplaceColumnByExpressionPanel extends FramedPanel { public class ReplaceColumnByExpressionPanel extends FramedPanel {
protected static final String WIDTH = "648px"; protected static final String WIDTH = "648px";
protected static final String HEIGHT = "364px"; protected static final String HEIGHT = "454px";
protected static final String HEIGHT_REDUCE = "368px";
protected static final String CONDITIONWIDTH = "612px"; protected static final String CONDITIONWIDTH = "612px";
protected static final String CONDITIONHEIGHT = "120px"; protected static final String CONDITIONHEIGHT = "120px";
protected static final String REPLACEWIDTH = "612px"; protected static final String REPLACEWIDTH = "612px";
@ -74,7 +76,6 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
private FieldLabel allRowsField; private FieldLabel allRowsField;
private boolean allRows; private boolean allRows;
public ReplaceColumnByExpressionPanel( public ReplaceColumnByExpressionPanel(
ReplaceColumnByExpressionDialog parent, ColumnData column, ReplaceColumnByExpressionDialog parent, ColumnData column,
EventBus eventBus) { EventBus eventBus) {
@ -89,7 +90,13 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
protected void init() { protected void init() {
setWidth(WIDTH); setWidth(WIDTH);
if (column != null
&& column.getDataTypeName().compareTo(
ColumnDataType.Text.toString())==0) {
setHeight(HEIGHT); setHeight(HEIGHT);
} else {
setHeight(HEIGHT_REDUCE);
}
setBodyBorder(false); setBodyBorder(false);
setHeaderVisible(false); setHeaderVisible(false);
// Important: fixed rendering of widgets // Important: fixed rendering of widgets
@ -190,8 +197,10 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
} else { } else {
if (column.getDataTypeName().compareTo( if (column.getDataTypeName().compareTo(
ColumnDataType.Text.toString()) == 0) { ColumnDataType.Text.toString()) == 0) {
replaceWidget=new ReplaceWidget(column, REPLACEWIDTH, REPLACEHEIGHT); replaceWidget = new ReplaceWidget(column, REPLACEWIDTH,
replaceValueFieldSetLayout.add(replaceWidget, new VerticalLayoutData(1, -1)); REPLACEHEIGHT);
replaceValueFieldSetLayout.add(replaceWidget,
new VerticalLayoutData(1, -1));
} else { } else {
replaceValue = new TextField(); replaceValue = new TextField();
replaceValue.setToolTip("Replace Value"); replaceValue.setToolTip("Replace Value");
@ -279,27 +288,40 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
"Select a valid date as replace value!"); "Select a valid date as replace value!");
return; return;
} }
parent.applyReplaceColumnByExpression(cConditionExpression, value); parent.applyReplaceColumnByExpression(cConditionExpression,
value);
} }
} else { } else {
if (column.getDataTypeName().compareTo( if (column.getDataTypeName().compareTo(
ColumnDataType.Text.toString()) == 0) { ColumnDataType.Text.toString()) == 0) {
C_Expression replaceExpression=replaceWidget.getExpression(); C_Expression cReplaceExpression = null;
parent.applyReplaceColumnByExpression(cConditionExpression, replaceExpression); try {
cReplaceExpression = replaceWidget.getExpression();
if(cReplaceExpression==null){
UtilsGXT3.alert("Attention", "Replace expression is not valid!");
return;
}
} catch (Throwable e) {
UtilsGXT3.alert("Attention", "Replace expression is not valid!");
return;
}
parent.applyReplaceColumnByExpression(cConditionExpression,
cReplaceExpression);
} else { } else {
value = replaceValue.getCurrentValue(); value = replaceValue.getCurrentValue();
if (checkValue(value)) { if (checkValue(value)) {
parent.applyReplaceColumnByExpression(cConditionExpression, value); parent.applyReplaceColumnByExpression(cConditionExpression,
value);
} else { } else {
UtilsGXT3.alert("Error replace value", "Insert a valid value!"); UtilsGXT3.alert("Error replace value",
"Insert a valid value!");
return; return;
} }
} }
} }
} }
private boolean checkValue(String value) { private boolean checkValue(String value) {

View File

@ -3,6 +3,8 @@ package org.gcube.portlets.user.td.expressionwidget.client;
import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceElement; 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.ReplaceElementProperties;
import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceElementStore; import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceElementStore;
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceType;
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceTypeMap;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression; import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
@ -11,11 +13,13 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.event.logical.shared.SelectionHandler;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction; 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.Margins;
import com.sencha.gxt.core.client.util.ToggleGroup; import com.sencha.gxt.core.client.util.ToggleGroup;
import com.sencha.gxt.data.shared.ListStore; 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.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer; import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.SimpleContainer; import com.sencha.gxt.widget.core.client.container.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; 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.container.VerticalLayoutContainer.VerticalLayoutData;
@ -32,18 +36,58 @@ import com.sencha.gxt.widget.core.client.form.TextField;
*/ */
public class ReplaceWidget extends SimpleContainer { public class ReplaceWidget extends SimpleContainer {
private static final String EMPTY_TEXT_TO_STRING = "to string...";
private static final String EMPTY_TEXT_FROM_STRING = "from string...";
private static final String EMPTY_TEXT_TO_INDEX = "to index...";
private static final String EMPTY_TEXT_FROM_INDEX = "from index...";
private static final String EMPTY_TEXT_REGEXP = "regexp...";
private static final String EMPTY_TEXT_INSERT_A_STRING = "insert a string...";
private ReplaceWidget thisCont; private ReplaceWidget thisCont;
protected static final String HEIGHT = "210px"; protected static final String HEIGHT = "210px";
protected static final String WIDTH = "612px"; protected static final String WIDTH = "612px";
protected static final String COMBO_WIDTH = "150px";
protected FieldLabel matchLabel; protected FieldLabel matchLabel;
protected ToggleGroup groupMatch; protected ToggleGroup groupMatch;
protected VerticalLayoutContainer vert; protected VerticalLayoutContainer vert;
protected ColumnData column; protected ColumnData column;
protected String readableExpression; protected String readableExpression;
private TextField replaceValue; private String itemIdComboConcat;
private String itemIdComboLeaf;
private String itemIdFirstArg;
private String itemIdSecondArg;
private String itemIdHoriz;
public class ExpressionContainer {
private C_Expression expression;
private String readableExpression;
public ExpressionContainer(C_Expression expression,
String readableExpression) {
super();
this.expression = expression;
this.readableExpression = readableExpression;
}
public C_Expression getExpression() {
return expression;
}
public void setExpression(C_Expression expression) {
this.expression = expression;
}
public String getReadableExpression() {
return readableExpression;
}
public void setReadableExpression(String readableExpression) {
this.readableExpression = readableExpression;
}
}
public ReplaceWidget(ColumnData column) { public ReplaceWidget(ColumnData column) {
super(); super();
@ -76,29 +120,44 @@ public class ReplaceWidget extends SimpleContainer {
} }
protected void setup() { protected void setup() {
vert = new VerticalLayoutContainer(); itemIdComboConcat = "ComboConcat" + column.getName();
itemIdComboLeaf = "ComboLeaf" + column.getName();
itemIdFirstArg = "FirstArg" + column.getName();
itemIdSecondArg = "SecondArg" + column.getName();
itemIdHoriz = "Horiz" + column.getName();
vert = new VerticalLayoutContainer();
vert.setScrollMode(ScrollMode.AUTO);
final HBoxLayoutContainer horiz = new HBoxLayoutContainer(); final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
// final TextField firstArg = new TextField();
firstArg.setEmptyText("Insert a string");
firstArg.setItemId(itemIdFirstArg);
final TextField secondArg = new TextField();
secondArg.setEmptyText("");
secondArg.setItemId(itemIdSecondArg);
ReplaceElementStore factory = new ReplaceElementStore();
ReplaceElementProperties props = GWT ReplaceElementProperties props = GWT
.create(ReplaceElementProperties.class); .create(ReplaceElementProperties.class);
Log.debug("Props: " + props); Log.debug("Props: " + props);
ListStore<ReplaceElement> storeReplaceElement = new ListStore<ReplaceElement>(
props.id());
Log.debug("Store: " + storeReplaceElement);
ReplaceElementStore factory = new ReplaceElementStore();
storeReplaceElement.addAll(factory.replaceElements);
// Combo Leaf
ListStore<ReplaceElement> storeReplaceElementsLeaf = new ListStore<ReplaceElement>(
props.id());
Log.debug("Store Leaf: " + storeReplaceElementsLeaf);
storeReplaceElementsLeaf.addAll(factory.replaceElements);
Log.debug("Store created"); Log.debug("Store created");
ComboBox<ReplaceElement> comboReplaceElement = new ComboBox<ReplaceElement>( final ComboBox<ReplaceElement> comboReplaceElementsLeaf = new ComboBox<ReplaceElement>(
storeReplaceElement, props.label()); storeReplaceElementsLeaf, props.label());
Log.debug("Combo created"); Log.debug("Combo created");
comboReplaceElement comboReplaceElementsLeaf
.addSelectionHandler(new SelectionHandler<ReplaceElement>() { .addSelectionHandler(new SelectionHandler<ReplaceElement>() {
public void onSelection(SelectionEvent<ReplaceElement> event) { public void onSelection(SelectionEvent<ReplaceElement> event) {
@ -106,14 +165,43 @@ public class ReplaceWidget extends SimpleContainer {
ReplaceElement re = event.getSelectedItem(); ReplaceElement re = event.getSelectedItem();
Log.debug("Condition selected:" + re.toString()); Log.debug("Condition selected:" + re.toString());
switch (re.getReplaceType()) { switch (re.getReplaceType()) {
case Value:
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_INSERT_A_STRING);
secondArg.setVisible(false);
secondArg.setEmptyText("");
break;
case ColumnValue:
firstArg.setVisible(false);
firstArg.setEmptyText("");
secondArg.setVisible(false);
secondArg.setEmptyText("");
break;
case Concat: case Concat:
break; break;
case Equals: case SubstringByRegex:
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_REGEXP);
secondArg.setVisible(false);
secondArg.setEmptyText("");
break;
case SubstringByIndex:
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_FROM_INDEX);
secondArg.setVisible(true);
secondArg.setEmptyText(EMPTY_TEXT_TO_INDEX);
break;
case SubstringByCharSeq:
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_FROM_STRING);
secondArg.setVisible(true);
secondArg.setEmptyText(EMPTY_TEXT_TO_STRING);
break; break;
default: default:
break; break;
} }
vert.forceLayout();
thisCont.forceLayout(); thisCont.forceLayout();
} }
@ -121,35 +209,470 @@ public class ReplaceWidget extends SimpleContainer {
}); });
comboReplaceElement.setEmptyText("Select..."); comboReplaceElementsLeaf.setEmptyText("Select...");
comboReplaceElement.setWidth("230px"); comboReplaceElementsLeaf.setItemId(itemIdComboLeaf);
comboReplaceElement.setEditable(false); comboReplaceElementsLeaf.setWidth(COMBO_WIDTH);
comboReplaceElement.setTriggerAction(TriggerAction.ALL); comboReplaceElementsLeaf.setEditable(false);
comboReplaceElementsLeaf.setTriggerAction(TriggerAction.ALL);
// ComboConcat
ListStore<ReplaceElement> storeReplaceElementsConcat = new ListStore<ReplaceElement>(
props.id());
Log.debug("Store Concat: " + storeReplaceElementsConcat);
storeReplaceElementsConcat.addAll(factory.replaceElementsConcat);
Log.debug("Store created");
final ComboBox<ReplaceElement> comboReplaceElementsConcat = new ComboBox<ReplaceElement>(
storeReplaceElementsConcat, props.label());
Log.debug("Combo created");
comboReplaceElementsConcat
.addSelectionHandler(new SelectionHandler<ReplaceElement>() {
public void onSelection(SelectionEvent<ReplaceElement> event) {
if (event.getSelectedItem() != null) {
@SuppressWarnings("unchecked")
ComboBox<ReplaceElement> source = (ComboBox<ReplaceElement>) event
.getSource();
ReplaceElement re = event.getSelectedItem();
Log.debug("Condition selected:" + re.toString());
switch (re.getReplaceType()) {
case Value:
comboReplaceElementsLeaf.setVisible(false);
firstArg.setEmptyText(EMPTY_TEXT_INSERT_A_STRING);
firstArg.setVisible(true);
secondArg.setVisible(false);
secondArg.setEmptyText("");
removeConcat(source);
break;
case ColumnValue:
comboReplaceElementsLeaf.setVisible(false);
firstArg.setVisible(false);
firstArg.setEmptyText("");
secondArg.setVisible(false);
secondArg.setEmptyText("");
break;
case Concat:
if (!existConcat(source)) {
comboReplaceElementsLeaf.setVisible(true);
firstArg.setVisible(false);
firstArg.setEmptyText("");
secondArg.setVisible(false);
secondArg.setEmptyText("");
addConcat();
}
break;
case SubstringByRegex:
comboReplaceElementsLeaf.setVisible(false);
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_REGEXP);
secondArg.setVisible(false);
secondArg.setEmptyText("");
removeConcat(source);
break;
case SubstringByIndex:
comboReplaceElementsLeaf.setVisible(false);
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_FROM_INDEX);
secondArg.setVisible(true);
secondArg.setEmptyText(EMPTY_TEXT_TO_INDEX);
removeConcat(source);
break;
case SubstringByCharSeq:
comboReplaceElementsLeaf.setVisible(false);
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_FROM_STRING);
secondArg.setVisible(true);
secondArg.setEmptyText(EMPTY_TEXT_TO_STRING);
removeConcat(source);
break;
default:
break;
}
vert.forceLayout();
thisCont.forceLayout();
}
}
});
comboReplaceElementsConcat.setEmptyText("Select...");
comboReplaceElementsConcat.setItemId(itemIdComboConcat);
comboReplaceElementsConcat.setWidth(COMBO_WIDTH);
comboReplaceElementsConcat.setEditable(false);
comboReplaceElementsConcat.setTriggerAction(TriggerAction.ALL);
comboReplaceElementsConcat.setValue(storeReplaceElementsConcat.get(0),
true);
comboReplaceElement.setValue(storeReplaceElement.get(0), true);
// //
replaceValue = new TextField(); horiz.add(comboReplaceElementsConcat, new BoxLayoutData(new Margins(0)));
replaceValue.setToolTip("Replace Value"); horiz.add(comboReplaceElementsLeaf, new BoxLayoutData(new Margins(0)));
replaceValue.setValue(""); horiz.add(firstArg, new BoxLayoutData(new Margins(0)));
horiz.add(secondArg, new BoxLayoutData(new Margins(0)));
horiz.add(comboReplaceElement, new BoxLayoutData(new Margins(1))); horiz.setItemId(itemIdHoriz);
horiz.add(replaceValue, new BoxLayoutData(new Margins(1)));
vert.add(horiz, new VerticalLayoutData(-1, -1, new Margins(1))); vert.add(horiz, new VerticalLayoutData(-1, -1, new Margins(1)));
add(vert); add(vert, new MarginData(0));
firstArg.setVisible(true);
secondArg.setVisible(false);
comboReplaceElementsLeaf.setVisible(false);
comboReplaceElementsConcat.setVisible(true);
forceLayout();
}
protected void addConcat() {
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
final TextField firstArg = new TextField();
firstArg.setItemId(itemIdFirstArg);
final TextField secondArg = new TextField();
secondArg.setItemId(itemIdSecondArg);
ReplaceElementStore factory = new ReplaceElementStore();
ReplaceElementProperties props = GWT
.create(ReplaceElementProperties.class);
Log.debug("Props: " + props);
// Combo Leaf
ListStore<ReplaceElement> storeReplaceElementsLeaf = new ListStore<ReplaceElement>(
props.id());
Log.debug("Store Leaf: " + storeReplaceElementsLeaf);
storeReplaceElementsLeaf.addAll(factory.replaceElements);
Log.debug("Store created");
final ComboBox<ReplaceElement> comboReplaceElementsLeaf = new ComboBox<ReplaceElement>(
storeReplaceElementsLeaf, props.label());
Log.debug("Combo created");
comboReplaceElementsLeaf
.addSelectionHandler(new SelectionHandler<ReplaceElement>() {
public void onSelection(SelectionEvent<ReplaceElement> event) {
if (event.getSelectedItem() != null) {
ReplaceElement re = event.getSelectedItem();
Log.debug("Condition selected:" + re.toString());
switch (re.getReplaceType()) {
case Value:
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_INSERT_A_STRING);
secondArg.setVisible(false);
secondArg.setEmptyText("");
break;
case ColumnValue:
firstArg.setVisible(false);
firstArg.setEmptyText("");
secondArg.setVisible(false);
secondArg.setEmptyText("");
break;
case Concat:
break;
case SubstringByRegex:
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_REGEXP);
secondArg.setVisible(false);
secondArg.setEmptyText("");
break;
case SubstringByIndex:
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_FROM_INDEX);
secondArg.setVisible(true);
secondArg.setEmptyText(EMPTY_TEXT_TO_INDEX);
break;
case SubstringByCharSeq:
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_FROM_STRING);
secondArg.setVisible(true);
secondArg.setEmptyText(EMPTY_TEXT_TO_STRING);
break;
default:
break;
}
vert.forceLayout();
thisCont.forceLayout();
}
}
});
comboReplaceElementsLeaf.setEmptyText("Select...");
comboReplaceElementsLeaf.setItemId(itemIdComboLeaf);
comboReplaceElementsLeaf.setWidth(COMBO_WIDTH);
comboReplaceElementsLeaf.setEditable(false);
comboReplaceElementsLeaf.setTriggerAction(TriggerAction.ALL);
// ComboConcat
ListStore<ReplaceElement> storeReplaceElementsConcat = new ListStore<ReplaceElement>(
props.id());
Log.debug("Store Concat: " + storeReplaceElementsConcat);
storeReplaceElementsConcat.addAll(factory.replaceElementsConcat);
Log.debug("Store created");
final ComboBox<ReplaceElement> comboReplaceElementsConcat = new ComboBox<ReplaceElement>(
storeReplaceElementsConcat, props.label());
Log.debug("Combo created");
comboReplaceElementsConcat
.addSelectionHandler(new SelectionHandler<ReplaceElement>() {
public void onSelection(SelectionEvent<ReplaceElement> event) {
if (event.getSelectedItem() != null) {
@SuppressWarnings("unchecked")
ComboBox<ReplaceElement> source = (ComboBox<ReplaceElement>) event
.getSource();
ReplaceElement re = event.getSelectedItem();
Log.debug("Condition selected:" + re.toString());
switch (re.getReplaceType()) {
case Value:
comboReplaceElementsLeaf.setVisible(false);
firstArg.setEmptyText(EMPTY_TEXT_INSERT_A_STRING);
firstArg.setVisible(true);
secondArg.setVisible(false);
secondArg.setEmptyText("");
removeConcat(source);
break;
case ColumnValue:
comboReplaceElementsLeaf.setVisible(false);
firstArg.setVisible(false);
firstArg.setEmptyText("");
secondArg.setVisible(false);
secondArg.setEmptyText("");
break;
case Concat:
if (!existConcat(source)) {
comboReplaceElementsLeaf.setVisible(true);
firstArg.setVisible(false);
firstArg.setEmptyText("");
secondArg.setVisible(false);
secondArg.setEmptyText("");
addConcat();
}
break;
case SubstringByRegex:
comboReplaceElementsLeaf.setVisible(false);
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_REGEXP);
secondArg.setVisible(false);
secondArg.setEmptyText("");
removeConcat(source);
break;
case SubstringByIndex:
comboReplaceElementsLeaf.setVisible(false);
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_FROM_INDEX);
secondArg.setVisible(true);
secondArg.setEmptyText(EMPTY_TEXT_TO_INDEX);
removeConcat(source);
break;
case SubstringByCharSeq:
comboReplaceElementsLeaf.setVisible(false);
firstArg.setVisible(true);
firstArg.setEmptyText(EMPTY_TEXT_FROM_STRING);
secondArg.setVisible(true);
secondArg.setEmptyText(EMPTY_TEXT_TO_STRING);
removeConcat(source);
break;
default:
break;
}
vert.forceLayout();
thisCont.forceLayout();
} }
public C_Expression getExpression() { }
C_Expression exp = null;
Log.debug("C_Expression:" + exp); });
return exp;
comboReplaceElementsConcat.setEmptyText("Select...");
comboReplaceElementsConcat.setItemId(itemIdComboConcat);
comboReplaceElementsConcat.setWidth(COMBO_WIDTH);
comboReplaceElementsConcat.setEditable(false);
comboReplaceElementsConcat.setTriggerAction(TriggerAction.ALL);
comboReplaceElementsConcat.setValue(storeReplaceElementsConcat.get(0),
true);
//
horiz.add(comboReplaceElementsConcat, new BoxLayoutData(new Margins(0)));
horiz.add(comboReplaceElementsLeaf, new BoxLayoutData(new Margins(0)));
horiz.add(firstArg, new BoxLayoutData(new Margins(0)));
horiz.add(secondArg, new BoxLayoutData(new Margins(0)));
horiz.setItemId(itemIdHoriz);
vert.add(horiz, new VerticalLayoutData(-1, -1, new Margins(1)));
firstArg.setVisible(true);
secondArg.setVisible(false);
comboReplaceElementsLeaf.setVisible(false);
comboReplaceElementsConcat.setVisible(true);
forceLayout();
}
private void removeConcat(ComboBox<ReplaceElement> source) {
HBoxLayoutContainer horiz = (HBoxLayoutContainer) source.getParent();
int index = vert.getWidgetIndex(horiz);
Log.debug("No concat for index: " + index);
index++;
for (int i = index; i < vert.getWidgetCount();) {
Log.debug("Remove horiz index: " + i);
vert.remove(i);
}
}
private boolean existConcat(ComboBox<ReplaceElement> source) {
boolean exist = false;
HBoxLayoutContainer horiz = (HBoxLayoutContainer) source.getParent();
int index = vert.getWidgetIndex(horiz);
Log.debug("No concat for index: " + index);
index++;
if (index < vert.getWidgetCount()) {
exist = true;
} else {
exist = false;
}
return exist;
}
public C_Expression getExpression() {
ExpressionContainer expressionContainer = null;
readableExpression = new String();
C_Expression expression = null;
if (vert.getWidgetCount() > 0) {
int index = 0;
expressionContainer = calcCExpression(index);
if (expressionContainer != null) {
readableExpression = expressionContainer
.getReadableExpression();
expression = expressionContainer.getExpression();
} else {
}
}
Log.debug("ReadableExpression: " + readableExpression);
Log.debug("C_Expression:" + expression);
return expression;
} }
public String getReadableExpression() { public String getReadableExpression() {
return readableExpression; return readableExpression;
} }
protected ExpressionContainer calcCExpression(int index) {
ExpressionContainer expressionContainer = null;
ExpressionContainer expContainerConcat = null;
C_Expression exp = null;
C_Expression expLeaf = null;
String readableExp = "";
String readableExpLeaf = "";
TextField firstArg;
TextField secondArg;
HBoxLayoutContainer horiz;
ReplaceTypeMap mapReplace = new ReplaceTypeMap();
horiz = (HBoxLayoutContainer) vert.getWidget(index);
@SuppressWarnings("unchecked")
ComboBox<ReplaceElement> comboConcat = (ComboBox<ReplaceElement>) horiz
.getItemByItemId(itemIdComboConcat);
Log.debug("combo: " + comboConcat.getCurrentValue().toString());
@SuppressWarnings("unchecked")
ComboBox<ReplaceElement> comboLeaf = (ComboBox<ReplaceElement>) horiz
.getItemByItemId(itemIdComboLeaf);
Log.debug("combo: " + comboConcat.getCurrentValue().toString());
firstArg = (TextField) horiz.getItemByItemId(itemIdFirstArg);
secondArg = (TextField) horiz.getItemByItemId(itemIdSecondArg);
Log.debug("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());
readableExp = mapReplace.getReadableExpression();
expressionContainer = new ExpressionContainer(exp, readableExp);
} else {
return null;
}
} else {
comboConcatReplaceType = comboConcat.getCurrentValue()
.getReplaceType();
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());
readableExpLeaf = mapReplace.getReadableExpression();
} else {
comboLeafReplaceType = comboLeaf.getCurrentValue()
.getReplaceType();
expLeaf = mapReplace.map(
column,
comboLeafReplaceType,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue());
readableExpLeaf = mapReplace.getReadableExpression();
}
index++;
if (index < vert.getWidgetCount()) {
expContainerConcat = calcCExpression(index);
if (expContainerConcat == null) {
return null;
} else {
exp = mapReplace.map(
column,
comboConcatReplaceType,
firstArg == null ? null : firstArg
.getCurrentValue(),
secondArg == null ? null : secondArg
.getCurrentValue(), expLeaf,
expContainerConcat.getExpression(),
readableExpLeaf, expContainerConcat
.getReadableExpression());
readableExp = mapReplace.getReadableExpression();
expressionContainer = new ExpressionContainer(exp,
readableExp);
}
} else {
return null;
}
} else {
exp = mapReplace.map(column, comboConcatReplaceType,
firstArg == null ? null : firstArg.getCurrentValue(),
secondArg == null ? null : secondArg.getCurrentValue());
readableExp = mapReplace.getReadableExpression();
expressionContainer = new ExpressionContainer(exp,
readableExp);
}
}
return expressionContainer;
}
} }

View File

@ -2,6 +2,8 @@ package org.gcube.portlets.user.td.expressionwidget.client.properties;
import java.io.Serializable; import java.io.Serializable;
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceType;
/** /**
* *
* @author giancarlo email: <a * @author giancarlo email: <a

View File

@ -2,6 +2,8 @@ package org.gcube.portlets.user.td.expressionwidget.client.properties;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceType;
/** /**
* *
* @author "Giancarlo Panichi" <a * @author "Giancarlo Panichi" <a
@ -10,14 +12,33 @@ import java.util.ArrayList;
*/ */
public class ReplaceElementStore { public class ReplaceElementStore {
public ArrayList<ReplaceElement> replaceElementsConcat = new ArrayList<ReplaceElement>() {
private static final long serialVersionUID = 1690916203781730778L;
{
add(new ReplaceElement(1, ReplaceType.Value));
add(new ReplaceElement(2, ReplaceType.ColumnValue));
add(new ReplaceElement(3, ReplaceType.SubstringByRegex));
add(new ReplaceElement(4, ReplaceType.SubstringByIndex));
add(new ReplaceElement(5, ReplaceType.SubstringByCharSeq));
add(new ReplaceElement(6, ReplaceType.Concat));
}
};
public ArrayList<ReplaceElement> replaceElements = new ArrayList<ReplaceElement>() { public ArrayList<ReplaceElement> replaceElements = new ArrayList<ReplaceElement>() {
private static final long serialVersionUID = 1690916203781730778L; private static final long serialVersionUID = 1690916203781730778L;
{ {
add(new ReplaceElement(1, ReplaceType.Equals)); add(new ReplaceElement(1, ReplaceType.Value));
add(new ReplaceElement(2, ReplaceType.Concat)); add(new ReplaceElement(2, ReplaceType.ColumnValue));
add(new ReplaceElement(3, ReplaceType.SubstringByRegex));
add(new ReplaceElement(4, ReplaceType.SubstringByIndex));
add(new ReplaceElement(5, ReplaceType.SubstringByCharSeq));
} }
}; };
} }

View File

@ -1,21 +0,0 @@
package org.gcube.portlets.user.td.expressionwidget.client.properties;
public enum ReplaceType {
Equals("Equals"),
Concat("Concat");
/**
* @param text
*/
private ReplaceType(final String id) {
this.id = id;
}
private final String id;
@Override
public String toString() {
return id;
}
}

View File

@ -91,7 +91,9 @@ public class C_ExpressionParser {
protected SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); protected SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
public Expression parse(C_Expression exp) { public Expression parse(C_Expression exp) {
logger.debug("Parse: "+exp);
Expression ex = null; Expression ex = null;
switch (exp.getId()) { switch (exp.getId()) {
case "ColumnReferencePlaceholder": case "ColumnReferencePlaceholder":
ex = getColumnReferencePlaceholder(exp); ex = getColumnReferencePlaceholder(exp);

View File

@ -39,8 +39,6 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
protected static SimpleDateFormat sdf = new SimpleDateFormat( protected static SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd HH:mm"); "yyyy-MM-dd HH:mm");
/** /**
* *
* {@inheritDoc} * {@inheritDoc}
@ -58,16 +56,18 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
logger.error("FilterColumnSession is null"); logger.error("FilterColumnSession is null");
new ExpressionServiceException("FilterColumnSession is null"); new ExpressionServiceException("FilterColumnSession is null");
} }
ExpressionSession.setColumnFilterSession(session, filterColumnSession); ExpressionSession.setColumnFilterSession(session,
filterColumnSession);
C_ExpressionParser parser = new C_ExpressionParser(); C_ExpressionParser parser = new C_ExpressionParser();
Expression expression=parser.parse(filterColumnSession.getCexpression()); Expression expression = parser.parse(filterColumnSession
.getCexpression());
logger.debug("Service Expression:" + expression); logger.debug("Service Expression:" + expression);
TDGWTServiceImpl gwtService = new TDGWTServiceImpl(); TDGWTServiceImpl gwtService = new TDGWTServiceImpl();
String taskId= gwtService.startFilterColumn(filterColumnSession, expression, session); String taskId = gwtService.startFilterColumn(filterColumnSession,
expression, session);
return taskId; return taskId;
@ -75,8 +75,7 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
throw new TDGWTServiceException( throw new TDGWTServiceException("Error in Client Library Request: "
"Error in Client Library Request: "
+ e.getLocalizedMessage()); + e.getLocalizedMessage());
} }
} }
@ -86,7 +85,8 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public String startReplaceColumnByExpression(ReplaceColumnByExpressionSession replaceColumnByExpressionSession) public String startReplaceColumnByExpression(
ReplaceColumnByExpressionSession replaceColumnByExpressionSession)
throws TDGWTServiceException { throws TDGWTServiceException {
try { try {
@ -96,19 +96,32 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
if (replaceColumnByExpressionSession == null) { if (replaceColumnByExpressionSession == null) {
logger.error("ReplaceColumnByExpressionSession is null"); logger.error("ReplaceColumnByExpressionSession is null");
new ExpressionServiceException("ReplaceColumnByExpressionSession is null"); new ExpressionServiceException(
"ReplaceColumnByExpressionSession is null");
} }
ExpressionSession.setReplaceColumnByExpressionSession(session, replaceColumnByExpressionSession); ExpressionSession.setReplaceColumnByExpressionSession(session,
replaceColumnByExpressionSession);
C_ExpressionParser parser = new C_ExpressionParser(); C_ExpressionParser parser = new C_ExpressionParser();
Expression expression=parser.parse(replaceColumnByExpressionSession.getcConditionExpression()); Expression conditionExpression = parser
logger.debug("Service Expression:"+expression); .parse(replaceColumnByExpressionSession
.getcConditionExpression());
logger.debug("Service Condition Expression:" + conditionExpression);
Expression replaceExpression = null;
if (!replaceColumnByExpressionSession.isReplaceByValue()) {
replaceExpression = parser
.parse(replaceColumnByExpressionSession
.getcReplaceExpression());
logger.debug("Service Replace Expression:"
+ conditionExpression);
}
TDGWTServiceImpl gwtService = new TDGWTServiceImpl(); TDGWTServiceImpl gwtService = new TDGWTServiceImpl();
String taskId= gwtService.startReplaceColumnByExpression(replaceColumnByExpressionSession, expression, session); String taskId = gwtService.startReplaceColumnByExpression(
replaceColumnByExpressionSession, conditionExpression,
replaceExpression, session);
return taskId; return taskId;
} catch (TDGWTSessionExpiredException e) { } catch (TDGWTSessionExpiredException e) {
@ -121,10 +134,6 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
} }
} }
/** /**
* Retrieve and set Tabular Resource Type * Retrieve and set Tabular Resource Type
* *

View File

@ -21,10 +21,9 @@ public class C_SubstringByRegex extends C_Expression {
super(); super();
} }
public C_SubstringByRegex(String id, C_Expression sourceString, public C_SubstringByRegex(C_Expression sourceString,
C_Expression regex) { C_Expression regex) {
super(); super();
this.id = id;
this.sourceString = sourceString; this.sourceString = sourceString;
this.regex = regex; this.regex = regex;
} }

View File

@ -0,0 +1,26 @@
package org.gcube.portlets.user.td.expressionwidget.shared.replace;
public enum ReplaceType {
Null("Null"),
Value("Value"),
ColumnValue("Column Value"),
SubstringByRegex("Substring by Regex"),
SubstringByIndex("Substring by Index"),
SubstringByCharSeq("Substring by Char Seq."),
Concat("Concat");
/**
* @param text
*/
private ReplaceType(final String id) {
this.id = id;
}
private final String id;
@Override
public String toString() {
return id;
}
}

View File

@ -0,0 +1,184 @@
package org.gcube.portlets.user.td.expressionwidget.shared.replace;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_Concat;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringByIndex;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringByRegex;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_SubstringPosition;
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.TD_Value;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeMap;
import com.allen_sauer.gwt.log.client.Log;
/**
* OperatorTypeMap creates a C_Expression usable client-side
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ReplaceTypeMap {
private String readableExpression;
public ReplaceTypeMap() {
}
public C_Expression map(ColumnData column, ReplaceType replaceType,
String firstArg, String secondArg) {
return map(column, replaceType,firstArg, secondArg, null, null, null, null);
}
public C_Expression map(ColumnData column, ReplaceType replaceType,
String firstArg, String secondArg, C_Expression firstE,
C_Expression secondE, String readableFirstE, String readableSecondE) {
Log.debug("ReplaceTypeMap Map");
C_Expression exp = null;
readableExpression = new String();
if (column.getTrId() == null) {
exp = mapPlaceHolder(column, replaceType, firstArg, secondArg,
firstE, secondE, readableFirstE,readableSecondE);
} else {
exp = mapTypedColumnReference(column, replaceType, firstArg,
secondArg, firstE, secondE,readableFirstE,readableSecondE);
}
return exp;
}
public C_Expression mapPlaceHolder(ColumnData column,
ReplaceType replaceType, String firstArg, String secondArg,
C_Expression firstE, C_Expression secondE,String readableFirstE, String readableSecondE) {
Log.debug("OperatorTypeMap Map Place Holder");
C_Expression exp = null;
Log.debug("Column Data Type Name:" + column.getDataTypeName());
ColumnDataType dataType = ColumnTypeMap.getColumnDataType(column
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_ColumnReferencePlaceholder placeHolder = new C_ColumnReferencePlaceholder(
dataType, column.getColumnId());
Log.debug("placeHolder:" + placeHolder);
String readablePlaceHolder = column.getColumnId();
TD_Value fArg, sArg;
C_Expression posFrom, posTo;
switch (replaceType) {
case Null:
exp = new TD_Value(ColumnDataType.Text, "");
readableExpression = "Null()";
break;
case Value:
exp = new TD_Value(dataType, firstArg);
readableExpression = "Value(" + firstArg + ")";
break;
case ColumnValue:
exp = placeHolder;
readableExpression = "ColumnValue(" + readablePlaceHolder + ")";
break;
case Concat:
exp = new C_Concat(firstE, secondE);
readableExpression = "Concat(" + readableFirstE
+ ", " + readableSecondE + ")";
break;
case SubstringByRegex:
fArg = new TD_Value(ColumnDataType.Text, firstArg);
exp = new C_SubstringByRegex(placeHolder, fArg);
readableExpression = "SubStringByRegex(" + readablePlaceHolder
+ ", " + firstArg + ")";
break;
case SubstringByIndex:
fArg = new TD_Value(ColumnDataType.Integer, firstArg);
sArg = new TD_Value(ColumnDataType.Integer, secondArg);
exp = new C_SubstringByIndex(placeHolder, fArg, sArg);
readableExpression = "SubstringByIndex(" + readablePlaceHolder
+ ", " + firstArg + ", " + secondArg + ")";
break;
case SubstringByCharSeq:
fArg = new TD_Value(ColumnDataType.Text, firstArg);
posFrom = new C_SubstringPosition(placeHolder, fArg);
sArg = new TD_Value(ColumnDataType.Text, secondArg);
posTo = new C_SubstringPosition(placeHolder, fArg);
exp = new C_SubstringByIndex(placeHolder, posFrom, posTo);
readableExpression = "SubstringByCharSeq(" + readablePlaceHolder
+ ", " + firstArg + ", " + secondArg + ")";
break;
default:
break;
}
return exp;
}
public C_Expression mapTypedColumnReference(ColumnData column,
ReplaceType replaceType, String firstArg, String secondArg,
C_Expression firstE, C_Expression secondE, String readableFirstE, String readableSecondE) {
Log.debug("OperatorTypeMap Map Typed Column Reference");
C_Expression exp = null;
Log.debug("Column Data Type Name:" + column.getDataTypeName());
ColumnDataType dataType = ColumnTypeMap.getColumnDataType(column
.getDataTypeName());
Log.debug("Data Type:" + dataType);
C_TypedColumnReference columnReference = new C_TypedColumnReference(
column.getTrId(), dataType, column.getColumnId());
Log.debug("Typed Column Reference:" + columnReference);
String readableColumnReference = column.getLabel();
TD_Value fArg, sArg;
C_Expression posFrom, posTo;
switch (replaceType) {
case Null:
exp = new TD_Value(ColumnDataType.Text, "");
readableExpression = "Null()";
break;
case Value:
exp = new TD_Value(dataType, firstArg);
readableExpression = "Value(" + firstArg + ")";
break;
case ColumnValue:
exp = columnReference;
readableExpression = "ColumnValue(" + readableColumnReference + ")";
break;
case Concat:
exp = new C_Concat(firstE, secondE);
readableExpression = "Concat(" + readableFirstE
+ ", " + readableSecondE + ")";
break;
case SubstringByRegex:
fArg = new TD_Value(ColumnDataType.Text, firstArg);
exp = new C_SubstringByRegex(columnReference, fArg);
readableExpression = "SubStringByRegex(" + readableColumnReference
+ ", " + firstArg + ")";
break;
case SubstringByIndex:
fArg = new TD_Value(ColumnDataType.Integer, firstArg);
sArg = new TD_Value(ColumnDataType.Integer, secondArg);
exp = new C_SubstringByIndex(columnReference, fArg, sArg);
readableExpression = "SubstringByIndex(" + readableColumnReference
+ ", " + firstArg + ", " + secondArg + ")";
break;
case SubstringByCharSeq:
fArg = new TD_Value(ColumnDataType.Text, firstArg);
posFrom = new C_SubstringPosition(columnReference, fArg);
sArg = new TD_Value(ColumnDataType.Text, secondArg);
posTo = new C_SubstringPosition(columnReference, fArg);
exp = new C_SubstringByIndex(columnReference, posFrom, posTo);
readableExpression = "SubstringByCharSeq("
+ readableColumnReference + ", " + firstArg + ", "
+ secondArg + ")";
break;
default:
break;
}
return exp;
}
public String getReadableExpression() {
return readableExpression;
}
}