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
This commit is contained in:
Giancarlo Panichi 2015-03-17 10:03:53 +00:00
parent 2995538566
commit f215c727c4
3 changed files with 63 additions and 38 deletions

View File

@ -46,8 +46,7 @@ public class ReplaceColumnByExpressionDialog extends Window implements
private static final String HEIGHT_REDUCE = "404px"; private static final String HEIGHT_REDUCE = "404px";
private ReplaceColumnByExpressionPanel replaceColumnByExpressionPanel; private ReplaceColumnByExpressionPanel replaceColumnByExpressionPanel;
private C_Expression cConditionExpression = null; private C_Expression cConditionExpression=null;
private ColumnData column = null; private ColumnData column = null;
private ArrayList<ColumnData> columns; private ArrayList<ColumnData> columns;
@ -55,6 +54,7 @@ public class ReplaceColumnByExpressionDialog extends Window implements
private EventBus eventBus; private EventBus eventBus;
private ReplaceColumnByExpressionType replaceColumnByExpressionType; private ReplaceColumnByExpressionType replaceColumnByExpressionType;
/** /**
* *
* Columns must have set columnId, label, columnTypeCode and ColumnDataType * Columns must have set columnId, label, columnTypeCode and ColumnDataType
@ -190,21 +190,22 @@ public class ReplaceColumnByExpressionDialog extends Window implements
} }
protected void applyReplaceColumnByExpression( protected void applyReplaceColumnByExpression(
C_Expression cConditionExpression, String replaceValue) { boolean allRows,C_Expression cConditionExpression, String replaceValue) {
this.cConditionExpression = cConditionExpression; this.cConditionExpression = cConditionExpression;
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession( ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
column, cConditionExpression, replaceValue); column, allRows,cConditionExpression, replaceValue);
callApplyReplaceByExpression(replaceColumnByExpressionSession); callApplyReplaceByExpression(replaceColumnByExpressionSession);
} }
protected void applyReplaceColumnByExpression( protected void applyReplaceColumnByExpression(boolean allRows,
C_Expression cConditionExpression, C_Expression cReplaceExpression) { C_Expression cConditionExpression, C_Expression cReplaceExpression) {
this.cConditionExpression = cConditionExpression; this.cConditionExpression = cConditionExpression;
//this.cReplaceExpression = cReplaceExpression;
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession( ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
column, cConditionExpression, cReplaceExpression); column, allRows, cConditionExpression, cReplaceExpression);
callApplyReplaceByExpression(replaceColumnByExpressionSession); callApplyReplaceByExpression(replaceColumnByExpressionSession);
} }

View File

@ -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.client.type.ReplaceColumnByExpressionType;
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ConditionTypeMapException; 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.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.gwtservice.shared.tr.ColumnData;
import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ExpressionEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.ExpressionEvent;
@ -130,8 +129,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|| column.getDataTypeName().compareTo( || column.getDataTypeName().compareTo(
ColumnDataType.Integer.toString()) == 0 ColumnDataType.Integer.toString()) == 0
|| column.getDataTypeName().compareTo( || column.getDataTypeName().compareTo(
ColumnDataType.Numeric.toString()) == 0 ColumnDataType.Numeric.toString()) == 0 || column
|| column.getDataTypeName().compareTo( .getDataTypeName().compareTo(
ColumnDataType.Geometry.toString()) == 0)) { ColumnDataType.Geometry.toString()) == 0)) {
setHeight(HEIGHT); setHeight(HEIGHT);
} else { } else {
@ -331,9 +330,9 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
} }
protected void applyReplaceColumnByExpression() { protected void applyReplaceColumnByExpression() {
C_Expression cConditionExpression; C_Expression cConditionExpression = null;
if (allRows) { if (allRows) {
cConditionExpression = new TD_Value(ColumnDataType.Boolean, "true");
} else { } else {
try { try {
@ -367,7 +366,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
} else { } else {
if (column.getDataTypeName().compareTo( if (column.getDataTypeName().compareTo(
ColumnDataType.Text.toString()) == 0|| column.getDataTypeName().compareTo( ColumnDataType.Text.toString()) == 0
|| column.getDataTypeName().compareTo(
ColumnDataType.Integer.toString()) == 0 ColumnDataType.Integer.toString()) == 0
|| column.getDataTypeName().compareTo( || column.getDataTypeName().compareTo(
ColumnDataType.Numeric.toString()) == 0 ColumnDataType.Numeric.toString()) == 0
@ -406,10 +406,18 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
case Template: case Template:
ExpressionEvent expressionEvent = new ExpressionEvent( ExpressionEvent expressionEvent = new ExpressionEvent(
ExpressionType.REPLACECOLUMNEXPRESSION); ExpressionType.REPLACECOLUMNEXPRESSION);
C_ExpressionContainer container = new C_ExpressionContainer( 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, C_ExpressionContainer.Contains.C_Expression,
cConditionExpression, cConditionExpression,
conditionWidget.getReadableExpression()); conditionWidget.getReadableExpression());
}
expressionEvent.setC_ConditionExpressionContainer(container); expressionEvent.setC_ConditionExpressionContainer(container);
expressionEvent.setReplaceByValue(true); expressionEvent.setReplaceByValue(true);
expressionEvent.setReplaceValue(replaceValue); expressionEvent.setReplaceValue(replaceValue);
@ -421,7 +429,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
eventBus.fireEvent(expressionEvent); eventBus.fireEvent(expressionEvent);
break; break;
case Replace: case Replace:
parent.applyReplaceColumnByExpression(cConditionExpression, parent.applyReplaceColumnByExpression(allRows,cConditionExpression,
replaceValue); replaceValue);
break; break;
default: default:
@ -436,10 +444,18 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
case Template: case Template:
ExpressionEvent expressionEvent = new ExpressionEvent( ExpressionEvent expressionEvent = new ExpressionEvent(
ExpressionType.REPLACECOLUMNEXPRESSION); 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, C_ExpressionContainer.Contains.C_Expression,
cConditionExpression, cConditionExpression,
conditionWidget.getReadableExpression()); conditionWidget.getReadableExpression());
}
expressionEvent expressionEvent
.setC_ConditionExpressionContainer(conditionExpressionContainer); .setC_ConditionExpressionContainer(conditionExpressionContainer);
expressionEvent.setReplaceByValue(false); expressionEvent.setReplaceByValue(false);
@ -457,7 +473,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
eventBus.fireEvent(expressionEvent); eventBus.fireEvent(expressionEvent);
break; break;
case Replace: case Replace:
parent.applyReplaceColumnByExpression(cConditionExpression, parent.applyReplaceColumnByExpression(allRows,cConditionExpression,
cReplaceExpression); cReplaceExpression);
break; break;
default: default:

View File

@ -109,7 +109,9 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
replaceColumnByExpressionSession); replaceColumnByExpressionSession);
C_ExpressionParser parser = new C_ExpressionParser(); C_ExpressionParser parser = new C_ExpressionParser();
Expression conditionExpression;
Expression conditionExpression=null;
if (!replaceColumnByExpressionSession.isAllRows()) {
try { try {
conditionExpression = parser conditionExpression = parser
.parse(replaceColumnByExpressionSession .parse(replaceColumnByExpressionSession
@ -119,7 +121,9 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
throw new TDGWTServiceException(e.getLocalizedMessage()); throw new TDGWTServiceException(e.getLocalizedMessage());
} }
logger.debug("Service Condition Expression:" + conditionExpression); logger.debug("Service Condition Expression:"
+ conditionExpression);
}
Expression replaceExpression = null; Expression replaceExpression = null;
if (!replaceColumnByExpressionSession.isReplaceByValue()) { if (!replaceColumnByExpressionSession.isReplaceByValue()) {
@ -127,7 +131,7 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
.parse(replaceColumnByExpressionSession .parse(replaceColumnByExpressionSession
.getcReplaceExpression()); .getcReplaceExpression());
logger.debug("Service Replace Expression:" logger.debug("Service Replace Expression:"
+ conditionExpression); + replaceExpression);
} }
TDGWTServiceImpl gwtService = new TDGWTServiceImpl(); TDGWTServiceImpl gwtService = new TDGWTServiceImpl();
@ -184,13 +188,17 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
TRId newTRId; TRId newTRId;
if (viewTable == null) { if (viewTable == null) {
newTRId = new TRId(String.valueOf(tr.getId().getValue()), newTRId = new TRId(
TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(table.getId() String.valueOf(tr.getId().getValue()),
TabularResourceTypeMap.map(tr.getTabularResourceType()),
tr.getTableType(), String.valueOf(table.getId()
.getValue()), table.getTableType().getName()); .getValue()), table.getTableType().getName());
} else { } else {
newTRId = new TRId(String.valueOf(tr.getId().getValue()), newTRId = new TRId(
TabularResourceTypeMap.map(tr.getTabularResourceType()), tr.getTableType(), String.valueOf(viewTable.getId() String.valueOf(tr.getId().getValue()),
TabularResourceTypeMap.map(tr.getTabularResourceType()),
tr.getTableType(), String.valueOf(viewTable.getId()
.getValue()), viewTable.getTableType() .getValue()), viewTable.getTableType()
.getName(), String.valueOf(table.getId() .getName(), String.valueOf(table.getId()
.getValue()), true); .getValue()), true);