From f215c727c4251d4a00506b4a7dd103bc04156b0f Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 17 Mar 2015 10:03:53 +0000 Subject: [PATCH] Updated Condition All Rows on Replace By Expression git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@113622 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../ReplaceColumnByExpressionDialog.java | 15 ++++--- .../ReplaceColumnByExpressionPanel.java | 44 +++++++++++++------ .../server/ExpressionServiceImpl.java | 42 +++++++++++------- 3 files changed, 63 insertions(+), 38 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionDialog.java index 9290a33..01f2954 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionDialog.java @@ -46,14 +46,14 @@ public class ReplaceColumnByExpressionDialog extends Window implements private static final String HEIGHT_REDUCE = "404px"; private ReplaceColumnByExpressionPanel replaceColumnByExpressionPanel; - private C_Expression cConditionExpression = null; - + private C_Expression cConditionExpression=null; private ColumnData column = null; private ArrayList columns; //private String columnName = null; private EventBus eventBus; private ReplaceColumnByExpressionType replaceColumnByExpressionType; + /** * @@ -190,21 +190,22 @@ public class ReplaceColumnByExpressionDialog extends Window implements } protected void applyReplaceColumnByExpression( - C_Expression cConditionExpression, String replaceValue) { + boolean allRows,C_Expression cConditionExpression, String replaceValue) { + this.cConditionExpression = cConditionExpression; ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession( - column, cConditionExpression, replaceValue); + column, allRows,cConditionExpression, replaceValue); callApplyReplaceByExpression(replaceColumnByExpressionSession); } - protected void applyReplaceColumnByExpression( + protected void applyReplaceColumnByExpression(boolean allRows, C_Expression cConditionExpression, C_Expression cReplaceExpression) { this.cConditionExpression = cConditionExpression; - //this.cReplaceExpression = cReplaceExpression; + ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession( - column, cConditionExpression, cReplaceExpression); + column, allRows, cConditionExpression, cReplaceExpression); callApplyReplaceByExpression(replaceColumnByExpressionSession); } diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionPanel.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionPanel.java index dcf21c1..8629b2a 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionPanel.java @@ -7,7 +7,6 @@ import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionRe import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceColumnByExpressionType; import org.gcube.portlets.user.td.expressionwidget.shared.exception.ConditionTypeMapException; import org.gcube.portlets.user.td.expressionwidget.shared.exception.ReplaceTypeMapException; -import org.gcube.portlets.user.td.expressionwidget.shared.model.leaf.TD_Value; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.widgetcommonevent.client.event.ExpressionEvent; @@ -130,8 +129,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel { || column.getDataTypeName().compareTo( ColumnDataType.Integer.toString()) == 0 || column.getDataTypeName().compareTo( - ColumnDataType.Numeric.toString()) == 0 - || column.getDataTypeName().compareTo( + ColumnDataType.Numeric.toString()) == 0 || column + .getDataTypeName().compareTo( ColumnDataType.Geometry.toString()) == 0)) { setHeight(HEIGHT); } else { @@ -331,9 +330,9 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel { } protected void applyReplaceColumnByExpression() { - C_Expression cConditionExpression; + C_Expression cConditionExpression = null; if (allRows) { - cConditionExpression = new TD_Value(ColumnDataType.Boolean, "true"); + } else { try { @@ -367,7 +366,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel { } else { if (column.getDataTypeName().compareTo( - ColumnDataType.Text.toString()) == 0|| column.getDataTypeName().compareTo( + ColumnDataType.Text.toString()) == 0 + || column.getDataTypeName().compareTo( ColumnDataType.Integer.toString()) == 0 || column.getDataTypeName().compareTo( ColumnDataType.Numeric.toString()) == 0 @@ -406,10 +406,18 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel { case Template: ExpressionEvent expressionEvent = new ExpressionEvent( ExpressionType.REPLACECOLUMNEXPRESSION); - C_ExpressionContainer container = new C_ExpressionContainer( - C_ExpressionContainer.Contains.C_Expression, - cConditionExpression, - conditionWidget.getReadableExpression()); + C_ExpressionContainer container; + if (allRows) { + container = new C_ExpressionContainer( + C_ExpressionContainer.Contains.C_Expression, + true,null, + "AllRows()"); + } else { + container = new C_ExpressionContainer( + C_ExpressionContainer.Contains.C_Expression, + cConditionExpression, + conditionWidget.getReadableExpression()); + } expressionEvent.setC_ConditionExpressionContainer(container); expressionEvent.setReplaceByValue(true); expressionEvent.setReplaceValue(replaceValue); @@ -421,7 +429,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel { eventBus.fireEvent(expressionEvent); break; case Replace: - parent.applyReplaceColumnByExpression(cConditionExpression, + parent.applyReplaceColumnByExpression(allRows,cConditionExpression, replaceValue); break; default: @@ -436,10 +444,18 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel { case Template: ExpressionEvent expressionEvent = new ExpressionEvent( ExpressionType.REPLACECOLUMNEXPRESSION); - C_ExpressionContainer conditionExpressionContainer = new C_ExpressionContainer( + C_ExpressionContainer conditionExpressionContainer; + if (allRows) { + conditionExpressionContainer = new C_ExpressionContainer( + C_ExpressionContainer.Contains.C_Expression, + true,null, + "AllRows()"); + } else { + conditionExpressionContainer = new C_ExpressionContainer( C_ExpressionContainer.Contains.C_Expression, cConditionExpression, conditionWidget.getReadableExpression()); + } expressionEvent .setC_ConditionExpressionContainer(conditionExpressionContainer); expressionEvent.setReplaceByValue(false); @@ -448,7 +464,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel { cReplaceExpression, replaceWidget.getReadableExpression()); expressionEvent .setC_ReplaceExpressionContainer(replaceExpressionContainer); - + expressionEvent.setTrId(column.getTrId()); expressionEvent.setColumnId(column.getColumnId()); expressionEvent.setColumnName(column.getName()); @@ -457,7 +473,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel { eventBus.fireEvent(expressionEvent); break; case Replace: - parent.applyReplaceColumnByExpression(cConditionExpression, + parent.applyReplaceColumnByExpression(allRows,cConditionExpression, cReplaceExpression); break; default: diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java index 517e4a8..1f0bdd2 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java @@ -109,17 +109,21 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements replaceColumnByExpressionSession); C_ExpressionParser parser = new C_ExpressionParser(); - Expression conditionExpression; - try { - conditionExpression = parser - .parse(replaceColumnByExpressionSession - .getcConditionExpression()); - } catch (ExpressionParserException e) { - logger.debug(e.getLocalizedMessage()); - throw new TDGWTServiceException(e.getLocalizedMessage()); - } - logger.debug("Service Condition Expression:" + conditionExpression); + Expression conditionExpression=null; + if (!replaceColumnByExpressionSession.isAllRows()) { + try { + conditionExpression = parser + .parse(replaceColumnByExpressionSession + .getcConditionExpression()); + } catch (ExpressionParserException e) { + logger.debug(e.getLocalizedMessage()); + throw new TDGWTServiceException(e.getLocalizedMessage()); + } + + logger.debug("Service Condition Expression:" + + conditionExpression); + } Expression replaceExpression = null; if (!replaceColumnByExpressionSession.isReplaceByValue()) { @@ -127,7 +131,7 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements .parse(replaceColumnByExpressionSession .getcReplaceExpression()); logger.debug("Service Replace Expression:" - + conditionExpression); + + replaceExpression); } TDGWTServiceImpl gwtService = new TDGWTServiceImpl(); @@ -184,14 +188,18 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements TRId newTRId; if (viewTable == null) { - newTRId = new TRId(String.valueOf(tr.getId().getValue()), - TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(table.getId() - .getValue()), table.getTableType().getName()); + newTRId = new TRId( + String.valueOf(tr.getId().getValue()), + TabularResourceTypeMap.map(tr.getTabularResourceType()), + tr.getTableType(), String.valueOf(table.getId() + .getValue()), table.getTableType().getName()); } else { - newTRId = new TRId(String.valueOf(tr.getId().getValue()), - TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(viewTable.getId() - .getValue()), viewTable.getTableType() + newTRId = new TRId( + String.valueOf(tr.getId().getValue()), + TabularResourceTypeMap.map(tr.getTabularResourceType()), + tr.getTableType(), String.valueOf(viewTable.getId() + .getValue()), viewTable.getTableType() .getName(), String.valueOf(table.getId() .getValue()), true);