Updated Geometry Type Support

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@100067 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-09-19 15:50:10 +00:00
parent 0d1d8c0e78
commit b73de5a16e
14 changed files with 714 additions and 92 deletions

View File

@ -2,7 +2,7 @@ package org.gcube.portlets.user.td.expressionwidget.client;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.expressionwidget.client.help.HelpReplaceColumnByExpressionDialog;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.EntryPoint;
@ -21,8 +21,8 @@ public class ExpressionWidgetEntry implements EntryPoint {
public void onModuleLoad() { public void onModuleLoad() {
EventBus eventBus= new SimpleEventBus(); EventBus eventBus= new SimpleEventBus();
TRId trId=new TRId("154","1610"); //TRId trId=new TRId("154","1610");
String columnName="zwqvvx"; //String columnName="zwqvvx";
//Column Expression Dialog //Column Expression Dialog
//ColumnExpressionDialog expressionDialog=new ColumnExpressionDialog("1", ColumnTypeCode.ATTRIBUTE, ColumnDataType.Integer, eventBus); //ColumnExpressionDialog expressionDialog=new ColumnExpressionDialog("1", ColumnTypeCode.ATTRIBUTE, ColumnDataType.Integer, eventBus);
@ -39,8 +39,11 @@ public class ExpressionWidgetEntry implements EntryPoint {
//multiColumnFilterDialog.show(); //multiColumnFilterDialog.show();
//Replace Column By Expression Dialog //Replace Column By Expression Dialog
ReplaceColumnByExpressionDialog replaceColumnByExpression= new ReplaceColumnByExpressionDialog(trId, columnName, eventBus); //ReplaceColumnByExpressionDialog replaceColumnByExpression= new ReplaceColumnByExpressionDialog(trId, columnName, eventBus);
replaceColumnByExpression.show(); //replaceColumnByExpression.show();
HelpReplaceColumnByExpressionDialog help= new HelpReplaceColumnByExpressionDialog(eventBus);
help.show();
Log.info("Hello!"); Log.info("Hello!");
} }

View File

@ -14,6 +14,8 @@ import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler; import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.regexp.shared.MatchResult;
import com.google.gwt.regexp.shared.RegExp;
import com.google.gwt.user.client.ui.HasHorizontalAlignment; import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasValue; import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
@ -45,6 +47,8 @@ import com.sencha.gxt.widget.core.client.form.TextField;
* *
*/ */
public class ReplaceColumnByExpressionPanel extends FramedPanel { 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 = "698px"; protected static final String WIDTH = "698px";
protected static final String HEIGHT = "454px"; protected static final String HEIGHT = "454px";
@ -57,6 +61,9 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
protected static final String REPLACEHEIGHT = "120px"; protected static final String REPLACEHEIGHT = "120px";
protected static final String ALL_ROWS_FIELD_WIDTH = "662px"; protected static final String ALL_ROWS_FIELD_WIDTH = "662px";
protected static final String RADIO_LABEL_BY_CONDITION = "By Condition";
protected static final String RADIO_LABEL_ALL_ROWS = "All Rows";
protected EventBus eventBus; protected EventBus eventBus;
protected ReplaceColumnByExpressionDialog parent; protected ReplaceColumnByExpressionDialog parent;
@ -95,7 +102,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
setWidth(WIDTH); setWidth(WIDTH);
if (column != null if (column != null
&& column.getDataTypeName().compareTo( && column.getDataTypeName().compareTo(
ColumnDataType.Text.toString())==0) { ColumnDataType.Text.toString()) == 0) {
setHeight(HEIGHT); setHeight(HEIGHT);
} else { } else {
setHeight(HEIGHT_REDUCE); setHeight(HEIGHT_REDUCE);
@ -140,10 +147,10 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
conditionsVerticalLayout.setWidth(CONDITION_LAYOUT_WIDTH); conditionsVerticalLayout.setWidth(CONDITION_LAYOUT_WIDTH);
Radio radioAllRowsTrue = new Radio(); Radio radioAllRowsTrue = new Radio();
radioAllRowsTrue.setBoxLabel("true"); radioAllRowsTrue.setBoxLabel(RADIO_LABEL_ALL_ROWS);
Radio radioAllRowsFalse = new Radio(); Radio radioAllRowsFalse = new Radio();
radioAllRowsFalse.setBoxLabel("false"); radioAllRowsFalse.setBoxLabel(RADIO_LABEL_BY_CONDITION);
radioAllRowsTrue.setValue(true); radioAllRowsTrue.setValue(true);
allRows = true; allRows = true;
@ -167,9 +174,9 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
hp.add(radioAllRowsTrue); hp.add(radioAllRowsTrue);
hp.add(radioAllRowsFalse); hp.add(radioAllRowsFalse);
hp.setWidth("100px"); hp.setWidth("140px");
allRowsField = new FieldLabel(hp, "All rows"); allRowsField = new FieldLabel(hp, "Select");
allRowsField.setWidth(ALL_ROWS_FIELD_WIDTH); allRowsField.setWidth(ALL_ROWS_FIELD_WIDTH);
conditionWidget = new ConditionWidget(column, CONDITIONWIDTH, conditionWidget = new ConditionWidget(column, CONDITIONWIDTH,
@ -259,7 +266,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
protected void callAllRowChange(ValueChangeEvent<HasValue<Boolean>> event) { protected void callAllRowChange(ValueChangeEvent<HasValue<Boolean>> event) {
ToggleGroup group = (ToggleGroup) event.getSource(); ToggleGroup group = (ToggleGroup) event.getSource();
Radio radio = (Radio) group.getValue(); Radio radio = (Radio) group.getValue();
if (radio.getBoxLabel().compareTo("true") == 0) { if (radio.getBoxLabel().compareTo(RADIO_LABEL_ALL_ROWS) == 0) {
conditionWidget.setEnabled(false); conditionWidget.setEnabled(false);
allRows = true; allRows = true;
} else { } else {
@ -302,12 +309,14 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
C_Expression cReplaceExpression = null; C_Expression cReplaceExpression = null;
try { try {
cReplaceExpression = replaceWidget.getExpression(); cReplaceExpression = replaceWidget.getExpression();
if(cReplaceExpression==null){ if (cReplaceExpression == null) {
UtilsGXT3.alert("Attention", "Replace expression is not valid!"); UtilsGXT3.alert("Attention",
"Replace expression is not valid!");
return; return;
} }
} catch (Throwable e) { } catch (Throwable e) {
UtilsGXT3.alert("Attention", "Replace expression is not valid!"); UtilsGXT3.alert("Attention",
"Replace expression is not valid!");
return; return;
} }
parent.applyReplaceColumnByExpression(cConditionExpression, parent.applyReplaceColumnByExpression(cConditionExpression,
@ -319,7 +328,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
value); value);
} else { } else {
UtilsGXT3.alert("Error replace value", UtilsGXT3.alert("Error replace value",
"Insert a valid value!"); "Insert a valid replace value!");
return; return;
} }
} }
@ -341,7 +350,14 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
ok = true; ok = true;
break; break;
case Geometry: case Geometry:
RegExp regExp = RegExp.compile(GEOMETRY_REGEXPR);
MatchResult matcher = regExp.exec(value);
boolean matchFound = matcher != null;
if (matchFound) {
ok = true; ok = true;
} else {
ok = false;
}
break; break;
case Integer: case Integer:
Integer.parseInt(value); Integer.parseInt(value);

View File

@ -0,0 +1,72 @@
package org.gcube.portlets.user.td.expressionwidget.client.help;
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class HelpReplaceColumnByExpressionDialog extends Window {
protected static final String WIDTH = "800px";
protected static final String HEIGHT = "600px";
protected EventBus eventBus;
protected HelpReplaceColumnByExpressionPanel helpReplaceColumnByExpressionPanel;
public HelpReplaceColumnByExpressionDialog(EventBus eventBus) {
this.eventBus = eventBus;
initWindow();
create();
}
protected void initWindow() {
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(false);
setHeadingText("Help Replace Column By Expression");
setClosable(true);
getHeader().setIcon(
ExpressionResources.INSTANCE.columnReplaceByExpression());
}
/**
* {@inheritDoc}
*/
@Override
protected void initTools() {
super.initTools();
closeBtn.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
close();
}
});
}
protected void create() {
helpReplaceColumnByExpressionPanel = new HelpReplaceColumnByExpressionPanel(
this, eventBus);
add(helpReplaceColumnByExpressionPanel);
}
protected void close() {
hide();
}
}

View File

@ -0,0 +1,97 @@
package org.gcube.portlets.user.td.expressionwidget.client.help;
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
import com.allen_sauer.gwt.log.client.Log;
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.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
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;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class HelpReplaceColumnByExpressionPanel extends FramedPanel {
protected static final String WIDTH = "698px";
protected static final String HEIGHT = "454px";
protected EventBus eventBus;
protected HelpReplaceColumnByExpressionDialog parent;
private TextButton btnClose;
public HelpReplaceColumnByExpressionPanel(
HelpReplaceColumnByExpressionDialog parent, EventBus eventBus) {
super();
this.parent = parent;
this.eventBus = eventBus;
init();
create();
}
protected void init() {
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setHeaderVisible(false);
// Important: fixed rendering of widgets
forceLayoutOnResize = true;
}
protected void create() {
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
basicLayout.setAdjustForScroll(true);
basicLayout.setScrollMode(ScrollMode.AUTO);
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
flowButton.setPack(BoxLayoutPack.CENTER);
//
btnClose = new TextButton("Close");
btnClose.setIcon(ExpressionResources.INSTANCE.close());
btnClose.setIconAlign(IconAlign.RIGHT);
btnClose.setTitle("Close");
btnClose.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Close");
close();
}
});
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
// Add to basic layout
//basicLayout.add(properties, new VerticalLayoutData(-1, -1, new Margins(
// 1)));
basicLayout.add(flowButton, new VerticalLayoutData(-1, 36, new Margins(
5, 2, 5, 2)));
add(basicLayout);
}
protected void close() {
parent.close();
}
}

View File

@ -0,0 +1,7 @@
package org.gcube.portlets.user.td.expressionwidget.client.help;
public class HelpTemplate {
}

View File

@ -93,20 +93,9 @@ public class OperationsStore {
private static final long serialVersionUID = -1095217157799110522L; private static final long serialVersionUID = -1095217157799110522L;
{ {
add(new Operation(1,"EQUALS","The value is equal to",C_OperatorType.EQUALS)); //[ADDITION, DIVISION, MODULUS, MULTIPLICATION, SUBTRACTION, IS_NOT_NULL, IS_NULL, NOT, COUNT, MAX, MIN, ST_EXTENT]
add(new Operation(2,"GREATER","The value is greater than",C_OperatorType.GREATER)); add(new Operation(1,"IS_NULL","The value is null",C_OperatorType.IS_NULL));
add(new Operation(3,"GREATER_OR_EQUALS","The value is greater than or equal to",C_OperatorType.GREATER_OR_EQUALS)); add(new Operation(2,"IS_NOT_NULL","The value is not null",C_OperatorType.IS_NOT_NULL));
add(new Operation(4,"LESSER","The value is less than",C_OperatorType.LESSER));
add(new Operation(5,"LESSER_OR_EQUALS","The value is less than or equal to",C_OperatorType.LESSER_OR_EQUALS));
add(new Operation(6,"NOT_EQUALS","The value is not equal to",C_OperatorType.NOT_EQUALS));
add(new Operation(7,"NOT_GREATER","The value is not greater than",C_OperatorType.NOT_GREATER));
add(new Operation(8,"NOT_LESSER","The value is not less than",C_OperatorType.NOT_LESSER));
add(new Operation(9,"IS_NULL","The value is null",C_OperatorType.IS_NULL));
add(new Operation(10,"IS_NOT_NULL","The value is not null",C_OperatorType.IS_NOT_NULL));
add(new Operation(11,"BETWEEN","The value is between",C_OperatorType.BETWEEN));
add(new Operation(12,"NOT_BETWEEN","The value is not between",C_OperatorType.NOT_BETWEEN));
add(new Operation(13,"IN","The value is in",C_OperatorType.IN));
add(new Operation(14,"NOT_IN","The value is not in",C_OperatorType.NOT_IN));
}}; }};

View File

@ -8,6 +8,12 @@ import java.util.List;
import org.gcube.data.analysis.tabulardata.expression.Expression; import org.gcube.data.analysis.tabulardata.expression.Expression;
import org.gcube.data.analysis.tabulardata.expression.MultivaluedExpression; import org.gcube.data.analysis.tabulardata.expression.MultivaluedExpression;
import org.gcube.data.analysis.tabulardata.expression.composite.aggregation.Avg;
import org.gcube.data.analysis.tabulardata.expression.composite.aggregation.Count;
import org.gcube.data.analysis.tabulardata.expression.composite.aggregation.Max;
import org.gcube.data.analysis.tabulardata.expression.composite.aggregation.Min;
import org.gcube.data.analysis.tabulardata.expression.composite.aggregation.ST_Extent;
import org.gcube.data.analysis.tabulardata.expression.composite.aggregation.Sum;
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.Equals; import org.gcube.data.analysis.tabulardata.expression.composite.comparable.Equals;
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.GreaterOrEquals; import org.gcube.data.analysis.tabulardata.expression.composite.comparable.GreaterOrEquals;
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.GreaterThan; import org.gcube.data.analysis.tabulardata.expression.composite.comparable.GreaterThan;
@ -46,12 +52,19 @@ import org.gcube.data.analysis.tabulardata.model.datatype.NumericType;
import org.gcube.data.analysis.tabulardata.model.datatype.TextType; import org.gcube.data.analysis.tabulardata.model.datatype.TextType;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDBoolean; import org.gcube.data.analysis.tabulardata.model.datatype.value.TDBoolean;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDDate; import org.gcube.data.analysis.tabulardata.model.datatype.value.TDDate;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDGeometry;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDInteger; import org.gcube.data.analysis.tabulardata.model.datatype.value.TDInteger;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDNumeric; import org.gcube.data.analysis.tabulardata.model.datatype.value.TDNumeric;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDText; import org.gcube.data.analysis.tabulardata.model.datatype.value.TDText;
import org.gcube.data.analysis.tabulardata.model.datatype.value.TDTypeValue; import org.gcube.data.analysis.tabulardata.model.datatype.value.TDTypeValue;
import org.gcube.data.analysis.tabulardata.model.table.TableId; import org.gcube.data.analysis.tabulardata.model.table.TableId;
import org.gcube.portlets.user.td.expressionwidget.shared.expression.C_MultivaluedExpression; import org.gcube.portlets.user.td.expressionwidget.shared.expression.C_MultivaluedExpression;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation.C_Avg;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation.C_Count;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation.C_Max;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation.C_Min;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation.C_ST_Extent;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation.C_Sum;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_Equals; import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_Equals;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_GreaterOrEquals; import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_GreaterOrEquals;
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_GreaterThan; import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_GreaterThan;
@ -93,7 +106,7 @@ 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); logger.debug("Parse: " + exp);
Expression ex = null; Expression ex = null;
switch (exp.getId()) { switch (exp.getId()) {
@ -174,16 +187,35 @@ public class C_ExpressionParser {
ex = getConcat(exp); ex = getConcat(exp);
break; break;
case "SubstringByIndex": case "SubstringByIndex":
ex =getSubstringByIndex(exp); ex = getSubstringByIndex(exp);
break; break;
case "SubstringByRegex": case "SubstringByRegex":
ex =getSubstringByRegex(exp); ex = getSubstringByRegex(exp);
break; break;
case "SubstringPosition": case "SubstringPosition":
ex =getSubstringPosition(exp); ex = getSubstringPosition(exp);
break; break;
case "TextReplaceMatchingRegex": case "TextReplaceMatchingRegex":
ex =getTextReplaceMatchingRegex(exp); ex = getTextReplaceMatchingRegex(exp);
break;
case "Avg":
ex = getAvg(exp);
break;
case "Count":
ex = getCount(exp);
break;
case "Max":
ex = getMax(exp);
break;
case "Min":
ex = getMin(exp);
break;
case "Sum":
ex = getSum(exp);
break;
case "ST_Extent":
ex = getSTExtent(exp);
break;
default: default:
break; break;
} }
@ -210,9 +242,10 @@ public class C_ExpressionParser {
private Expression getValueIsIn(C_Expression exp) { private Expression getValueIsIn(C_Expression exp) {
C_ValueIsIn v = (C_ValueIsIn) exp; C_ValueIsIn v = (C_ValueIsIn) exp;
MultivaluedExpression multivalued=parseMultivalued(v.getRightArgument()); MultivaluedExpression multivalued = parseMultivalued(v
ValueIsIn valueIsIn = new ValueIsIn(parse(v.getLeftArgument()),multivalued .getRightArgument());
); ValueIsIn valueIsIn = new ValueIsIn(parse(v.getLeftArgument()),
multivalued);
return valueIsIn; return valueIsIn;
} }
@ -356,7 +389,9 @@ public class C_ExpressionParser {
} }
protected TDTypeValue getExpressionValue(TD_Value value) { protected TDTypeValue getExpressionValue(TD_Value value) {
TDTypeValue ex = null; TDTypeValue ex = null;
try {
switch (value.getValueType()) { switch (value.getValueType()) {
case Boolean: case Boolean:
ex = new TDBoolean(Boolean.valueOf(value.getValue())); ex = new TDBoolean(Boolean.valueOf(value.getValue()));
@ -372,7 +407,11 @@ public class C_ExpressionParser {
ex = new TDDate(d); ex = new TDDate(d);
break; break;
case Geometry: case Geometry:
// ex = new TDGeometry(value.getValue()); if (TDGeometry.validateGeometry(value.getValue())) {
ex = new TDGeometry(value.getValue());
} else {
ex = null;
}
break; break;
case Integer: case Integer:
ex = new TDInteger(Integer.valueOf(value.getValue())); ex = new TDInteger(Integer.valueOf(value.getValue()));
@ -386,7 +425,9 @@ public class C_ExpressionParser {
default: default:
break; break;
} }
} catch (Throwable e) {
logger.error("type error parsing value " + value+" "+ e.getLocalizedMessage());
}
return ex; return ex;
} }
@ -467,11 +508,11 @@ public class C_ExpressionParser {
protected Expression getTypedColumnReference(C_Expression exp) { protected Expression getTypedColumnReference(C_Expression exp) {
C_TypedColumnReference c = (C_TypedColumnReference) exp; C_TypedColumnReference c = (C_TypedColumnReference) exp;
String tableIdS=null; String tableIdS = null;
if(c.getTrId().isViewTable()){ if (c.getTrId().isViewTable()) {
tableIdS=c.getTrId().getReferenceTargetTableId(); tableIdS = c.getTrId().getReferenceTargetTableId();
} else { } else {
tableIdS=c.getTrId().getTableId(); tableIdS = c.getTrId().getTableId();
} }
TableId tableId = new TableId(Long.valueOf(tableIdS)); TableId tableId = new TableId(Long.valueOf(tableIdS));
ColumnLocalId columnId = new ColumnLocalId(c.getColumnId()); ColumnLocalId columnId = new ColumnLocalId(c.getColumnId());
@ -491,8 +532,7 @@ public class C_ExpressionParser {
private Expression getConcat(C_Expression exp) { private Expression getConcat(C_Expression exp) {
C_Concat concat = (C_Concat) exp; C_Concat concat = (C_Concat) exp;
Concat conc = new Concat( Concat conc = new Concat(parse(concat.getLeftArgument()),
parse(concat.getLeftArgument()),
parse(concat.getRightArgument())); parse(concat.getRightArgument()));
return conc; return conc;
} }
@ -501,7 +541,8 @@ public class C_ExpressionParser {
C_SubstringByIndex subByIndex = (C_SubstringByIndex) exp; C_SubstringByIndex subByIndex = (C_SubstringByIndex) exp;
SubstringByIndex sByIndex = new SubstringByIndex( SubstringByIndex sByIndex = new SubstringByIndex(
parse(subByIndex.getSourceString()), parse(subByIndex.getSourceString()),
parse(subByIndex.getFromIndex()), parse(subByIndex.getToIndex())); parse(subByIndex.getFromIndex()),
parse(subByIndex.getToIndex()));
return sByIndex; return sByIndex;
} }
@ -523,16 +564,62 @@ public class C_ExpressionParser {
private Expression getTextReplaceMatchingRegex(C_Expression exp) { private Expression getTextReplaceMatchingRegex(C_Expression exp) {
C_TextReplaceMatchingRegex textReplaceMatchingRegex = (C_TextReplaceMatchingRegex) exp; C_TextReplaceMatchingRegex textReplaceMatchingRegex = (C_TextReplaceMatchingRegex) exp;
TDText tdRegexp=new TDText(textReplaceMatchingRegex.getRegexp().getValue()); TDText tdRegexp = new TDText(textReplaceMatchingRegex.getRegexp()
TDText tdReplacing=new TDText(textReplaceMatchingRegex.getReplacing().getValue()); .getValue());
TDText tdReplacing = new TDText(textReplaceMatchingRegex.getReplacing()
.getValue());
TextReplaceMatchingRegex textRepRegex = new TextReplaceMatchingRegex( TextReplaceMatchingRegex textRepRegex = new TextReplaceMatchingRegex(
parse(textReplaceMatchingRegex.getToCheckText()), parse(textReplaceMatchingRegex.getToCheckText()), tdRegexp,
tdRegexp,
tdReplacing); tdReplacing);
return textRepRegex; return textRepRegex;
} }
private Expression getAvg(C_Expression exp) {
C_Avg avg = (C_Avg) exp;
Avg av = new Avg(
parse(avg.getArgument()));
return av;
}
private Expression getCount(C_Expression exp) {
C_Count count = (C_Count) exp;
Count cnt = new Count(
parse(count.getArgument()));
return cnt;
}
private Expression getMax(C_Expression exp) {
C_Max max = (C_Max) exp;
Max ma = new Max(
parse(max.getArgument()));
return ma;
}
private Expression getMin(C_Expression exp) {
C_Min min = (C_Min) exp;
Min mi = new Min(
parse(min.getArgument()));
return mi;
}
private Expression getSTExtent(C_Expression exp) {
C_ST_Extent stExtent = (C_ST_Extent) exp;
ST_Extent stEx = new ST_Extent(
parse(stExtent.getArgument()));
return stEx;
}
private Expression getSum(C_Expression exp) {
C_Sum sum = (C_Sum) exp;
Sum sm = new Sum(
parse(sum.getArgument()));
return sm;
}
} }

View File

@ -17,6 +17,9 @@ public enum C_OperatorType {
ALL, AND, ANY, BETWEEN, NOT_BETWEEN, EXISTS, IN, NOT_IN, ALL, AND, ANY, BETWEEN, NOT_BETWEEN, EXISTS, IN, NOT_IN,
LIKE, NOT_LIKE, NOT, OR, IS_NULL, UNIQUE, IS_NOT_NULL, LIKE, NOT_LIKE, NOT, OR, IS_NULL, UNIQUE, IS_NOT_NULL,
// AGGREGATION
AVG, COUNT, MAX, MIN, SUM, ST_EXTENT,
// STRING // STRING
BEGINS_WITH, ENDS_WITH, CONTAINS, MATCH_REGEX, BEGINS_WITH, ENDS_WITH, CONTAINS, MATCH_REGEX,

View File

@ -0,0 +1,57 @@
package org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation;
import org.gcube.portlets.user.td.expressionwidget.shared.model.C_OperatorType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_Avg extends C_Expression {
private static final long serialVersionUID = 7728851019516221450L;
protected String id = "Avg";
protected C_Expression argument;
public C_Avg() {
}
/**
*
* @param argument
*/
public C_Avg(C_Expression argument) {
this.argument = argument;
}
public C_OperatorType getOperator() {
return C_OperatorType.AVG;
}
public String getReturnedDataType() {
return "DataType";
}
@Override
public String getId() {
return id;
}
public C_Expression getArgument() {
return argument;
}
public void setArgument(C_Expression argument) {
this.argument = argument;
}
@Override
public String toString() {
return "C_Avg [id=" + id + ", argument=" + argument + "]";
}
}

View File

@ -0,0 +1,60 @@
package org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation;
import org.gcube.portlets.user.td.expressionwidget.shared.model.C_OperatorType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_Count extends C_Expression {
private static final long serialVersionUID = 7728851019516221450L;
protected String id = "Count";
protected C_Expression argument;
public C_Count() {
}
/**
*
* @param argument
*/
public C_Count(C_Expression argument) {
this.argument = argument;
}
public C_OperatorType getOperator() {
return C_OperatorType.COUNT;
}
public String getReturnedDataType() {
return "Integer";
}
@Override
public String getId() {
return id;
}
public C_Expression getArgument() {
return argument;
}
public void setArgument(C_Expression argument) {
this.argument = argument;
}
@Override
public String toString() {
return "C_Count [id=" + id + ", argument=" + argument + "]";
}
}

View File

@ -0,0 +1,60 @@
package org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation;
import org.gcube.portlets.user.td.expressionwidget.shared.model.C_OperatorType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_Max extends C_Expression {
private static final long serialVersionUID = 7765751618067012879L;
protected String id = "Max";
protected C_Expression argument;
public C_Max() {
}
/**
*
* @param argument
*/
public C_Max(C_Expression argument) {
this.argument = argument;
}
public C_OperatorType getOperator() {
return C_OperatorType.MAX;
}
public String getReturnedDataType() {
return "DataType";
}
@Override
public String getId() {
return id;
}
public C_Expression getArgument() {
return argument;
}
public void setArgument(C_Expression argument) {
this.argument = argument;
}
@Override
public String toString() {
return "C_Max [id=" + id + ", argument=" + argument + "]";
}
}

View File

@ -0,0 +1,57 @@
package org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation;
import org.gcube.portlets.user.td.expressionwidget.shared.model.C_OperatorType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_Min extends C_Expression {
private static final long serialVersionUID = -7717661319471699474L;
protected String id = "Min";
protected C_Expression argument;
public C_Min() {
}
/**
*
* @param argument
*/
public C_Min(C_Expression argument) {
this.argument = argument;
}
public C_OperatorType getOperator() {
return C_OperatorType.MIN;
}
public String getReturnedDataType() {
return "DataType";
}
@Override
public String getId() {
return id;
}
public C_Expression getArgument() {
return argument;
}
public void setArgument(C_Expression argument) {
this.argument = argument;
}
@Override
public String toString() {
return "C_Min [id=" + id + ", argument=" + argument + "]";
}
}

View File

@ -0,0 +1,57 @@
package org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation;
import org.gcube.portlets.user.td.expressionwidget.shared.model.C_OperatorType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_ST_Extent extends C_Expression {
private static final long serialVersionUID = -3889328695012258308L;
protected String id = "ST_Extent";
protected C_Expression argument;
public C_ST_Extent() {
}
/**
*
* @param argument
*/
public C_ST_Extent(C_Expression argument) {
this.argument = argument;
}
public C_OperatorType getOperator() {
return C_OperatorType.ST_EXTENT;
}
public String getReturnedDataType() {
return "DataType";
}
@Override
public String getId() {
return id;
}
public C_Expression getArgument() {
return argument;
}
public void setArgument(C_Expression argument) {
this.argument = argument;
}
@Override
public String toString() {
return "ST_Extent [id=" + id + ", argument=" + argument + "]";
}
}

View File

@ -0,0 +1,57 @@
package org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation;
import org.gcube.portlets.user.td.expressionwidget.shared.model.C_OperatorType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class C_Sum extends C_Expression {
private static final long serialVersionUID = 1365651146183648884L;
protected String id = "Sum";
protected C_Expression argument;
public C_Sum() {
}
/**
*
* @param argument
*/
public C_Sum(C_Expression argument) {
this.argument = argument;
}
public C_OperatorType getOperator() {
return C_OperatorType.SUM;
}
public String getReturnedDataType() {
return "DataType";
}
@Override
public String getId() {
return id;
}
public C_Expression getArgument() {
return argument;
}
public void setArgument(C_Expression argument) {
this.argument = argument;
}
@Override
public String toString() {
return "C_Sum [id=" + id + ", argument=" + argument + "]";
}
}