Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@99958 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-09-16 17:06:06 +00:00
parent 78fa7df755
commit 3f8baf4909
14 changed files with 860 additions and 45 deletions

View File

@ -33,20 +33,22 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ReplaceColumnByExpressionDialog extends Window implements MonitorDialogListener {
public class ReplaceColumnByExpressionDialog extends Window implements
MonitorDialogListener {
protected String WIDTH = "660px";
protected String HEIGHT = "400px";
protected ReplaceColumnByExpressionPanel replaceColumnByExpressionPanel;
protected C_Expression exp = null;
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 ReplaceColumnByExpressionSession replaceColumnByExpressionSession;
public ReplaceColumnByExpressionDialog(String columnId, ColumnTypeCode columnTypeCode,
ColumnDataType dataTypeName, EventBus eventBus) {
public ReplaceColumnByExpressionDialog(String columnId,
ColumnTypeCode columnTypeCode, ColumnDataType dataTypeName,
EventBus eventBus) {
initWindow();
this.eventBus = eventBus;
column = new ColumnData();
@ -57,7 +59,8 @@ public class ReplaceColumnByExpressionDialog extends Window implements MonitorDi
}
public ReplaceColumnByExpressionDialog(TRId trId, String columnName, EventBus eventBus) {
public ReplaceColumnByExpressionDialog(TRId trId, String columnName,
EventBus eventBus) {
initWindow();
this.eventBus = eventBus;
this.trId = trId;
@ -73,7 +76,8 @@ public class ReplaceColumnByExpressionDialog extends Window implements MonitorDi
setResizable(false);
setHeadingText("Replace Column By Expression");
setClosable(true);
getHeader().setIcon(ExpressionResources.INSTANCE.columnReplaceByExpression());
getHeader().setIcon(
ExpressionResources.INSTANCE.columnReplaceByExpression());
}
@ -106,8 +110,8 @@ public class ReplaceColumnByExpressionDialog extends Window implements MonitorDi
ColumnTypeCode.CODENAME.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.MEASURE.toString()) == 0) {
replaceColumnByExpressionPanel = new ReplaceColumnByExpressionPanel(this, column,
eventBus);
replaceColumnByExpressionPanel = new ReplaceColumnByExpressionPanel(
this, column, eventBus);
add(replaceColumnByExpressionPanel);
} else {
@ -120,18 +124,31 @@ public class ReplaceColumnByExpressionDialog extends Window implements MonitorDi
}
public C_Expression getExpression() {
return exp;
return cConditionExpression;
}
protected void setExpression(C_Expression exp) {
Log.debug("New Expression set:" + exp.toString());
this.exp = exp;
this.cConditionExpression = exp;
}
protected void applyReplaceColumnByExpression(C_Expression exp, String replaceValue) {
this.exp = exp;
this.replaceValue=replaceValue;
callApplyReplaceByExpression();
protected void applyReplaceColumnByExpression(C_Expression cConditionExpression,
String replaceValue) {
this.cConditionExpression = cConditionExpression;
this.replaceValue = replaceValue;
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
column, cConditionExpression, replaceValue);
callApplyReplaceByExpression(replaceColumnByExpressionSession);
}
protected void applyReplaceColumnByExpression(C_Expression cConditionExpression,
C_Expression cReplaceExpression) {
this.cConditionExpression = cConditionExpression;
this.cReplaceExpression = cReplaceExpression;
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
column, cConditionExpression, cReplaceExpression);
callApplyReplaceByExpression(replaceColumnByExpressionSession);
}
protected void load(TRId trId, String columnName) {
@ -162,12 +179,12 @@ public class ReplaceColumnByExpressionDialog extends Window implements MonitorDi
}
protected void callApplyReplaceByExpression() {
replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(column, exp,replaceValue);
Log.debug(replaceColumnByExpressionSession.toString());
protected void callApplyReplaceByExpression(
ReplaceColumnByExpressionSession replaceColumnByExpressionSession) {
Log.debug("Replace Column By Expression Session "+replaceColumnByExpressionSession);
ExpressionServiceAsync.INSTANCE.startReplaceColumnByExpression(replaceColumnByExpressionSession,
new AsyncCallback<String>() {
ExpressionServiceAsync.INSTANCE.startReplaceColumnByExpression(
replaceColumnByExpressionSession, new AsyncCallback<String>() {
@Override
public void onSuccess(String taskId) {
@ -185,9 +202,9 @@ public class ReplaceColumnByExpressionDialog extends Window implements MonitorDi
Log.error("Error submitting replace column by expression: "
+ caught.getLocalizedMessage());
caught.printStackTrace();
UtilsGXT3.alert(
"Error submitting replace column by expression",
caught.getLocalizedMessage());
UtilsGXT3
.alert("Error submitting replace column by expression",
caught.getLocalizedMessage());
}
}

View File

@ -1,14 +1,27 @@
package org.gcube.portlets.user.td.expressionwidget.client;
import java.util.Date;
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
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.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;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
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.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
@ -19,8 +32,10 @@ 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.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.DateField;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.FieldSet;
import com.sencha.gxt.widget.core.client.form.Radio;
import com.sencha.gxt.widget.core.client.form.TextField;
/**
@ -32,9 +47,10 @@ import com.sencha.gxt.widget.core.client.form.TextField;
public class ReplaceColumnByExpressionPanel extends FramedPanel {
protected static final String WIDTH = "648px";
protected static final String HEIGHT = "364px";
protected static final String CONDITIONWIDTH = "612px";
protected static final String CONDITIONHEIGHT = "150px";
protected static final String CONDITIONHEIGHT = "120px";
protected static final String REPLACEWIDTH = "612px";
protected static final String REPLACEHEIGHT = "120px";
protected EventBus eventBus;
@ -42,12 +58,22 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
protected ColumnData column;
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
private TextButton btnApply;
private TextButton btnClose;
private FieldSet conditionsFieldSet;
private ConditionWidget conditionWidget;
private ReplaceWidget replaceWidget;
private TextField replaceValue;
private DateField replaceValueDate;
private VerticalLayoutContainer conditionsVerticalLayout;
private FieldLabel allRowsField;
private boolean allRows;
public ReplaceColumnByExpressionPanel(
ReplaceColumnByExpressionDialog parent, ColumnData column,
@ -100,9 +126,53 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
conditionsFieldSet.setHeadingText("Conditions");
conditionsFieldSet.setCollapsible(false);
conditionWidget = new ConditionWidget(column,CONDITIONWIDTH, CONDITIONHEIGHT);
conditionsVerticalLayout = new VerticalLayoutContainer();
conditionsVerticalLayout.setWidth("612px");
Radio radioAllRowsTrue = new Radio();
radioAllRowsTrue.setBoxLabel("true");
Radio radioAllRowsFalse = new Radio();
radioAllRowsFalse.setBoxLabel("false");
radioAllRowsTrue.setValue(true);
allRows = true;
ToggleGroup toggleGroup = new ToggleGroup();
toggleGroup.add(radioAllRowsTrue);
toggleGroup.add(radioAllRowsFalse);
toggleGroup
.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
@Override
public void onValueChange(
ValueChangeEvent<HasValue<Boolean>> event) {
callAllRowChange(event);
}
});
HorizontalPanel hp = new HorizontalPanel();
hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
hp.add(radioAllRowsTrue);
hp.add(radioAllRowsFalse);
hp.setWidth("100px");
allRowsField = new FieldLabel(hp, "All rows");
allRowsField.setWidth("612px");
conditionWidget = new ConditionWidget(column, CONDITIONWIDTH,
CONDITIONHEIGHT);
conditionWidget.setEnabled(false);
Log.debug("ConditionWidget" + conditionWidget);
conditionsFieldSet.add(conditionWidget);
conditionsVerticalLayout.add(allRowsField, new VerticalLayoutData(100,
-1, new Margins(0)));
conditionsVerticalLayout.add(conditionWidget, new VerticalLayoutData(
-1, -1, new Margins(0)));
conditionsFieldSet.add(conditionsVerticalLayout);
// Value
FieldSet replaceValueFieldSet = new FieldSet();
@ -112,16 +182,29 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
VerticalLayoutContainer replaceValueFieldSetLayout = new VerticalLayoutContainer();
replaceValueFieldSet.add(replaceValueFieldSetLayout);
replaceValue = new TextField();
replaceValue.setToolTip("Replace Value");
replaceValue.setValue("");
replaceValueFieldSetLayout.add(new FieldLabel(replaceValue,
"Replace Value"), new VerticalLayoutData(1, -1));
if (column.getDataTypeName().compareTo(ColumnDataType.Date.toString()) == 0) {
replaceValueDate = new DateField();
replaceValueDate.setToolTip("Replace Value");
replaceValueFieldSetLayout.add(new FieldLabel(replaceValueDate,
"Replace Value"), new VerticalLayoutData(1, -1));
} else {
if (column.getDataTypeName().compareTo(
ColumnDataType.Text.toString()) == 0) {
replaceWidget=new ReplaceWidget(column, REPLACEWIDTH, REPLACEHEIGHT);
replaceValueFieldSetLayout.add(replaceWidget, new VerticalLayoutData(1, -1));
} else {
replaceValue = new TextField();
replaceValue.setToolTip("Replace Value");
replaceValue.setValue("");
replaceValueFieldSetLayout.add(new FieldLabel(replaceValue,
"Replace Value"), new VerticalLayoutData(1, -1));
}
}
//
btnApply = new TextButton("Apply");
btnApply.setIcon(ExpressionResources.INSTANCE.columnReplaceByExpression());
btnApply.setIcon(ExpressionResources.INSTANCE
.columnReplaceByExpression());
btnApply.setIconAlign(IconAlign.RIGHT);
btnApply.setTitle("Apply replace by expression");
btnApply.addSelectHandler(new SelectHandler() {
@ -146,29 +229,116 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
});
flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
//Add to basic layout
// Add to basic layout
basicLayout.add(properties, new VerticalLayoutData(-1, -1, new Margins(
1)));
basicLayout.add(conditionsFieldSet, new VerticalLayoutData(-1, -1,
new Margins(1)));
basicLayout.add(replaceValueFieldSet, new VerticalLayoutData(-1, -1, new Margins(
1)));
basicLayout.add(replaceValueFieldSet, new VerticalLayoutData(-1, -1,
new Margins(1)));
basicLayout.add(flowButton, new VerticalLayoutData(-1, 36, new Margins(
5, 2, 5, 2)));
add(basicLayout);
}
protected void applyReplaceColumnByExpression() {
C_Expression exp = conditionWidget.getExpression();
String value = replaceValue.getCurrentValue();
parent.applyReplaceColumnByExpression(exp,value);
protected void callAllRowChange(ValueChangeEvent<HasValue<Boolean>> event) {
ToggleGroup group = (ToggleGroup) event.getSource();
Radio radio = (Radio) group.getValue();
if (radio.getBoxLabel().compareTo("true") == 0) {
conditionWidget.setEnabled(false);
allRows = true;
} else {
conditionWidget.setEnabled(true);
allRows = false;
}
}
protected void applyReplaceColumnByExpression() {
C_Expression cConditionExpression;
if (allRows) {
cConditionExpression = new TD_Value(ColumnDataType.Boolean, "true");
} else {
cConditionExpression = conditionWidget.getExpression();
}
String value = null;
if (column.getDataTypeName().compareTo(ColumnDataType.Date.toString()) == 0) {
Date valueDate = replaceValueDate.getCurrentValue();
if (valueDate == null) {
UtilsGXT3.alert("Error replace value",
"Select a valid date as replace value!");
return;
} else {
try {
value = sdf.format(valueDate);
} catch (Throwable e) {
UtilsGXT3.alert("Error replace value",
"Select a valid date as replace value!");
return;
}
parent.applyReplaceColumnByExpression(cConditionExpression, value);
}
} else {
if (column.getDataTypeName().compareTo(
ColumnDataType.Text.toString()) == 0) {
C_Expression replaceExpression=replaceWidget.getExpression();
parent.applyReplaceColumnByExpression(cConditionExpression, replaceExpression);
} else {
value = replaceValue.getCurrentValue();
if (checkValue(value)) {
parent.applyReplaceColumnByExpression(cConditionExpression, value);
} else {
UtilsGXT3.alert("Error replace value", "Insert a valid value!");
return;
}
}
}
}
private boolean checkValue(String value) {
try {
boolean ok = false;
ColumnDataType columnDataType = ColumnTypeMap
.getColumnDataType(column.getDataTypeName());
switch (columnDataType) {
case Boolean:
Boolean.valueOf(value);
ok = true;
break;
case Date:
ok = true;
break;
case Geometry:
ok = true;
break;
case Integer:
Integer.parseInt(value);
break;
case Numeric:
Double.parseDouble(value);
break;
case Text:
ok = true;
break;
default:
break;
}
return ok;
} catch (Throwable e) {
return false;
}
}
protected void close() {
parent.close();
}
}

View File

@ -0,0 +1,155 @@
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.ReplaceElementProperties;
import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceElementStore;
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
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;
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.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;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ReplaceWidget extends SimpleContainer {
private ReplaceWidget thisCont;
protected static final String HEIGHT = "210px";
protected static final String WIDTH = "612px";
protected FieldLabel matchLabel;
protected ToggleGroup groupMatch;
protected VerticalLayoutContainer vert;
protected ColumnData column;
protected String readableExpression;
private TextField replaceValue;
public ReplaceWidget(ColumnData column) {
super();
create(column, WIDTH, HEIGHT);
}
public ReplaceWidget(ColumnData column, String width, String height) {
super();
create(column, width, height);
}
protected void create(ColumnData column, String width, String height) {
this.column = column;
setBorders(true);
setWidth(width);
setHeight(height);
forceLayoutOnResize = true;
thisCont = this;
setup();
addBeforeShowHandler(new BeforeShowEvent.BeforeShowHandler() {
@Override
public void onBeforeShow(BeforeShowEvent event) {
forceLayout();
}
});
}
protected void setup() {
vert = new VerticalLayoutContainer();
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
//
ReplaceElementProperties props = GWT
.create(ReplaceElementProperties.class);
Log.debug("Props: " + props);
ListStore<ReplaceElement> storeReplaceElement = new ListStore<ReplaceElement>(
props.id());
Log.debug("Store: " + storeReplaceElement);
ReplaceElementStore factory = new ReplaceElementStore();
storeReplaceElement.addAll(factory.replaceElements);
Log.debug("Store created");
ComboBox<ReplaceElement> comboReplaceElement = new ComboBox<ReplaceElement>(
storeReplaceElement, props.label());
Log.debug("Combo created");
comboReplaceElement
.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 Concat:
break;
case Equals:
break;
default:
break;
}
thisCont.forceLayout();
}
}
});
comboReplaceElement.setEmptyText("Select...");
comboReplaceElement.setWidth("230px");
comboReplaceElement.setEditable(false);
comboReplaceElement.setTriggerAction(TriggerAction.ALL);
comboReplaceElement.setValue(storeReplaceElement.get(0), true);
//
replaceValue = new TextField();
replaceValue.setToolTip("Replace Value");
replaceValue.setValue("");
horiz.add(comboReplaceElement, new BoxLayoutData(new Margins(1)));
horiz.add(replaceValue, new BoxLayoutData(new Margins(1)));
vert.add(horiz, new VerticalLayoutData(-1, -1, new Margins(1)));
add(vert);
}
public C_Expression getExpression() {
C_Expression exp = null;
Log.debug("C_Expression:" + exp);
return exp;
}
public String getReadableExpression() {
return readableExpression;
}
}

View File

@ -0,0 +1,54 @@
package org.gcube.portlets.user.td.expressionwidget.client.properties;
import java.io.Serializable;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ReplaceElement implements Serializable {
private static final long serialVersionUID = -1278177714679767844L;
private Integer id;
private ReplaceType replaceType;
public ReplaceElement() {
super();
}
public ReplaceElement(Integer id, ReplaceType replaceType) {
super();
this.id = id;
this.replaceType = replaceType;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getLabel() {
return replaceType.toString();
}
public ReplaceType getReplaceType() {
return replaceType;
}
public void setReplaceType(ReplaceType replaceType) {
this.replaceType = replaceType;
}
@Override
public String toString() {
return "ReplaceElement [id=" + id + ", replaceType=" + replaceType
+ "]";
}
}

View File

@ -0,0 +1,21 @@
package org.gcube.portlets.user.td.expressionwidget.client.properties;
import com.google.gwt.editor.client.Editor.Path;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface ReplaceElementProperties extends PropertyAccess<ReplaceElement> {
@Path("id")
ModelKeyProvider<ReplaceElement> id();
LabelProvider<ReplaceElement> label();
}

View File

@ -0,0 +1,23 @@
package org.gcube.portlets.user.td.expressionwidget.client.properties;
import java.util.ArrayList;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ReplaceElementStore {
public ArrayList<ReplaceElement> replaceElements = new ArrayList<ReplaceElement>() {
private static final long serialVersionUID = 1690916203781730778L;
{
add(new ReplaceElement(1, ReplaceType.Equals));
add(new ReplaceElement(2, ReplaceType.Concat));
}
};
}

View File

@ -0,0 +1,21 @@
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

@ -16,6 +16,10 @@ import org.gcube.data.analysis.tabulardata.expression.composite.comparable.LessT
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.NotEquals;
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.NotGreater;
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.NotLess;
import org.gcube.data.analysis.tabulardata.expression.composite.text.Concat;
import org.gcube.data.analysis.tabulardata.expression.composite.text.SubstringByIndex;
import org.gcube.data.analysis.tabulardata.expression.composite.text.SubstringByRegex;
import org.gcube.data.analysis.tabulardata.expression.composite.text.SubstringPosition;
import org.gcube.data.analysis.tabulardata.expression.composite.text.TextBeginsWith;
import org.gcube.data.analysis.tabulardata.expression.composite.text.TextContains;
import org.gcube.data.analysis.tabulardata.expression.composite.text.TextEndsWith;
@ -55,6 +59,10 @@ import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.compar
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_NotEquals;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_NotGreater;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_NotLess;
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.composite.text.C_TextBeginsWith;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextContains;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text.C_TextEndsWith;
@ -158,6 +166,18 @@ public class C_ExpressionParser {
case "ValueIsIn":
ex = getValueIsIn(exp);
break;
case "Concat":
ex = getConcat(exp);
break;
case "SubstringByIndex":
ex =getSubstringByIndex(exp);
break;
case "SubstringByRegex":
ex =getSubstringByRegex(exp);
break;
case "SubstringPosition":
ex =getSubstringPosition(exp);
break;
default:
break;
}
@ -462,5 +482,38 @@ public class C_ExpressionParser {
Equals eq = new Equals(left, right);
return eq;
}
private Expression getConcat(C_Expression exp) {
C_Concat concat = (C_Concat) exp;
Concat conc = new Concat(
parse(concat.getLeftArgument()),
parse(concat.getRightArgument()));
return conc;
}
private Expression getSubstringByIndex(C_Expression exp) {
C_SubstringByIndex subByIndex = (C_SubstringByIndex) exp;
SubstringByIndex sByIndex = new SubstringByIndex(
parse(subByIndex.getSourceString()),
parse(subByIndex.getFromIndex()), parse(subByIndex.getToIndex()));
return sByIndex;
}
private Expression getSubstringByRegex(C_Expression exp) {
C_SubstringByRegex subByRegex = (C_SubstringByRegex) exp;
SubstringByRegex sByRegex = new SubstringByRegex(
parse(subByRegex.getSourceString()),
parse(subByRegex.getRegex()));
return sByRegex;
}
private Expression getSubstringPosition(C_Expression exp) {
C_SubstringPosition subPosition = (C_SubstringPosition) exp;
SubstringPosition sPosition = new SubstringPosition(
parse(subPosition.getLeftArgument()),
parse(subPosition.getRightArgument()));
return sPosition;
}
}

View File

@ -101,7 +101,7 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
ExpressionSession.setReplaceColumnByExpressionSession(session, replaceColumnByExpressionSession);
C_ExpressionParser parser=new C_ExpressionParser();
Expression expression=parser.parse(replaceColumnByExpressionSession.getCexpression());
Expression expression=parser.parse(replaceColumnByExpressionSession.getcConditionExpression());
logger.debug("Service Expression:"+expression);

View File

@ -23,6 +23,7 @@ public enum C_OperatorType {
NOT_BEGINS_WITH, NOT_ENDS_WITH, NOT_CONTAINS, NOT_MATCH_REGEX,
CONCAT, SUBSTRINGBYINDEX, SUBSTRINGBYREGEX, SUBSTRINGPOSITION,
// COMPLEX

View File

@ -0,0 +1,69 @@
package org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text;
import org.gcube.portlets.user.td.expressionwidget.shared.model.C_OperatorType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_Concat extends C_Expression {
private static final long serialVersionUID = 5871179766613405166L;
protected String id = "Concat";
protected C_Expression leftArgument;
protected C_Expression rightArgument;
public C_Concat(){
super();
}
public C_Concat(C_Expression leftArgument,
C_Expression rightArgument) {
super();
this.leftArgument = leftArgument;
this.rightArgument = rightArgument;
}
public C_OperatorType getOperator() {
return C_OperatorType.CONCAT;
}
public String getReturnedDataType() {
return "Text";
}
@Override
public String getId() {
return id;
}
public C_Expression getLeftArgument() {
return leftArgument;
}
public void setLeftArgument(C_Expression leftArgument) {
this.leftArgument = leftArgument;
}
public C_Expression getRightArgument() {
return rightArgument;
}
public void setRightArgument(C_Expression rightArgument) {
this.rightArgument = rightArgument;
}
@Override
public String toString() {
return "C_Concat [id=" + id + ", leftArgument=" + leftArgument
+ ", rightArgument=" + rightArgument + "]";
}
}

View File

@ -0,0 +1,88 @@
package org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text;
import org.gcube.portlets.user.td.expressionwidget.shared.model.C_OperatorType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_SubstringByIndex extends C_Expression {
private static final long serialVersionUID = 5871179766613405166L;
protected String id = "SubstringByIndex";
private C_Expression sourceString;
private C_Expression fromIndex;
private C_Expression toIndex;
public C_SubstringByIndex(){
super();
}
public C_SubstringByIndex(C_Expression sourceString, C_Expression fromIndex, C_Expression toIndex) {
super();
this.sourceString = sourceString;
this.fromIndex=fromIndex;
this.toIndex=toIndex;
}
public C_OperatorType getOperator() {
return C_OperatorType.SUBSTRINGBYINDEX;
}
public String getReturnedDataType() {
return "Text";
}
@Override
public String getId() {
return id;
}
public C_Expression getSourceString() {
return sourceString;
}
public void setSourceString(C_Expression sourceString) {
this.sourceString = sourceString;
}
public C_Expression getFromIndex() {
return fromIndex;
}
public void setFromIndex(C_Expression fromIndex) {
this.fromIndex = fromIndex;
}
public C_Expression getToIndex() {
return toIndex;
}
public void setToIndex(C_Expression toIndex) {
this.toIndex = toIndex;
}
@Override
public String toString() {
return "C_SubstringByIndex [id=" + id + ", sourceString="
+ sourceString + ", fromIndex=" + fromIndex + ", toIndex="
+ toIndex + "]";
}
}

View File

@ -0,0 +1,67 @@
package org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text;
import org.gcube.portlets.user.td.expressionwidget.shared.model.C_OperatorType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_SubstringByRegex extends C_Expression {
private static final long serialVersionUID = 5871179766613405166L;
protected String id = "SubstringByRegex";
private C_Expression sourceString;
private C_Expression regex;
public C_SubstringByRegex() {
super();
}
public C_SubstringByRegex(String id, C_Expression sourceString,
C_Expression regex) {
super();
this.id = id;
this.sourceString = sourceString;
this.regex = regex;
}
public C_OperatorType getOperator() {
return C_OperatorType.SUBSTRINGBYREGEX;
}
public String getReturnedDataType() {
return "Text";
}
@Override
public String getId() {
return id;
}
public C_Expression getSourceString() {
return sourceString;
}
public void setSourceString(C_Expression sourceString) {
this.sourceString = sourceString;
}
public C_Expression getRegex() {
return regex;
}
public void setRegex(C_Expression regex) {
this.regex = regex;
}
@Override
public String toString() {
return "C_SubstringByRegex [id=" + id + ", sourceString="
+ sourceString + ", regex=" + regex + "]";
}
}

View File

@ -0,0 +1,76 @@
package org.gcube.portlets.user.td.expressionwidget.shared.model.composite.text;
import org.gcube.portlets.user.td.expressionwidget.shared.model.C_OperatorType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_SubstringPosition extends C_Expression {
private static final long serialVersionUID = 5871179766613405166L;
protected String id = "SubstringPosition";
private C_Expression leftArgument;
private C_Expression rightArgument;
public C_SubstringPosition() {
super();
}
public C_SubstringPosition(C_Expression leftArgument,
C_Expression rightArgument) {
super();
this.leftArgument = leftArgument;
this.rightArgument = rightArgument;
}
public C_OperatorType getOperator() {
return C_OperatorType.SUBSTRINGBYREGEX;
}
public String getReturnedDataType() {
return "Integer";
}
@Override
public String getId() {
return id;
}
public C_Expression getLeftArgument() {
return leftArgument;
}
public void setLeftArgument(C_Expression leftArgument) {
this.leftArgument = leftArgument;
}
public C_Expression getRightArgument() {
return rightArgument;
}
public void setRightArgument(C_Expression rightArgument) {
this.rightArgument = rightArgument;
}
@Override
public String toString() {
return "C_SubstringPosition [id=" + id + ", leftArgument="
+ leftArgument + ", rightArgument=" + rightArgument + "]";
}
}