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,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<ColumnData> 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);
}

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.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:

View File

@ -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);