From 1a1d110a35647b19ec79f49d91313e55c8cfc55c Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Mon, 18 May 2015 15:16:19 +0000 Subject: [PATCH] 81: Allow the creation and use of expressions on multi column in TDM portlet Task-Url: https://support.d4science.org/issues/81 Fixed Match and No Match operator git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@114783 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/MultiColumnExpressionPanel.java | 8 ++++--- .../TemplateMultiColumnExpressionDialog.java | 2 ++ .../ConditionOnMultiColumnWidget.java | 22 ++++++++++++++----- .../ConditionOnMultiColumnTypeMap.java | 22 +++++++++++-------- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnExpressionPanel.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnExpressionPanel.java index 15ac304..ede1ecc 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnExpressionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnExpressionPanel.java @@ -573,7 +573,7 @@ public class MultiColumnExpressionPanel extends FramedPanel { flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4))); - basicLayout.add(conditionsField, new VerticalLayoutData(-1, -1, + basicLayout.add(conditionsField, new VerticalLayoutData(1, -1, new Margins(1))); basicLayout.add(flowButton, new VerticalLayoutData(1, 36, new Margins( 5, 2, 5, 2))); @@ -713,7 +713,7 @@ public class MultiColumnExpressionPanel extends FramedPanel { protected void applySeleceted() { - Log.debug("Apply: " + column); + C_Expression exp; C_ExpressionContainer condContainer = null; @@ -737,7 +737,7 @@ public class MultiColumnExpressionPanel extends FramedPanel { ExpressionWrapperNotification expressionWrapperNotification = new ExpressionWrapperNotification( exWrapper); - Log.debug("Notification: " + expressionWrapperNotification); + Log.debug("Apply: "+expressionWrapperNotification); parentTemplateDialog.onExpression(expressionWrapperNotification); break; case Rule: @@ -765,6 +765,7 @@ public class MultiColumnExpressionPanel extends FramedPanel { UtilsGXT3.alert("Attention", e.getLocalizedMessage()); return; } + Log.debug("Apply: "+exp); parentMultiFilterDialog.applyFilter(exp); break; case RowDeleteByExpression: @@ -776,6 +777,7 @@ public class MultiColumnExpressionPanel extends FramedPanel { return; } C_Expression notExp = new C_Not(exp); + Log.debug("Apply: "+exp); parentRowsDeleteByExpressionDialog.deleteRowsByExpression( notExp); diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/TemplateMultiColumnExpressionDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/TemplateMultiColumnExpressionDialog.java index f0cc1cc..842715f 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/TemplateMultiColumnExpressionDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/TemplateMultiColumnExpressionDialog.java @@ -111,6 +111,7 @@ public class TemplateMultiColumnExpressionDialog extends Window implements HTML errorMessage = new HTML( "Attention no columns with a type supported(Dimension and TimeDimension is not supported)!"); add(errorMessage); + close(); UtilsGXT3.alert("Attention","Attention no columns with a type supported(Dimension and TimeDimension is not supported)!"); } @@ -155,6 +156,7 @@ public class TemplateMultiColumnExpressionDialog extends Window implements hide(); } + @SuppressWarnings("unused") private void fireFailed(Throwable caught) { if (listeners != null) { for (ExpressionWrapperNotificationListener listener : listeners) { diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/expression/ConditionOnMultiColumnWidget.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/expression/ConditionOnMultiColumnWidget.java index 50e90d9..748a9f7 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/expression/ConditionOnMultiColumnWidget.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/expression/ConditionOnMultiColumnWidget.java @@ -654,12 +654,10 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer { case NOT_LESSER: case BEGINS_WITH: case ENDS_WITH: - case MATCH_REGEX: case CONTAINS: case NOT_BEGINS_WITH: case NOT_ENDS_WITH: case NOT_CONTAINS: - case NOT_MATCH_REGEX: case IN: case NOT_IN: comboFirstArgType.reset(); @@ -695,9 +693,12 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer { comboThreshold.setVisible(false); break; + case MATCH_REGEX: + case NOT_MATCH_REGEX: case SOUNDEX: comboFirstArgType.reset(); comboFirstArgType.setValue(ArgType.VALUE, true); + firstArgValue.reset(); comboFirstArgType.setVisible(false); comboFirstArgColumn.setVisible(false); @@ -715,6 +716,8 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer { case LEVENSHTEIN: comboFirstArgType.reset(); comboFirstArgType.setValue(ArgType.VALUE, true); + firstArgValue.reset(); + storeThreshold.clear(); storeThreshold .addAll(ThresholdStore.thresholdsLevenshtein); @@ -741,6 +744,8 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer { case SIMILARITY: comboFirstArgType.reset(); comboFirstArgType.setValue(ArgType.VALUE, true); + firstArgValue.reset(); + storeThreshold.clear(); storeThreshold .addAll(ThresholdStore.thresholdsSimilarity); @@ -1441,12 +1446,10 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer { case NOT_LESSER: case BEGINS_WITH: case ENDS_WITH: - case MATCH_REGEX: case CONTAINS: case NOT_BEGINS_WITH: case NOT_ENDS_WITH: case NOT_CONTAINS: - case NOT_MATCH_REGEX: case IN: case NOT_IN: comboFirstArgType.reset(); @@ -1484,10 +1487,13 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer { btnAdd.setVisible(true); btnDel.setVisible(true); break; + case MATCH_REGEX: + case NOT_MATCH_REGEX: case SOUNDEX: comboFirstArgType.reset(); comboFirstArgType.setValue(ArgType.VALUE, true); - + firstArgValue.reset(); + comboFirstArgType.setVisible(false); comboFirstArgColumn.setVisible(false); firstArgValue.setVisible(true); @@ -1505,6 +1511,8 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer { case LEVENSHTEIN: comboFirstArgType.reset(); comboFirstArgType.setValue(ArgType.VALUE, true); + firstArgValue.reset(); + storeThreshold.clear(); storeThreshold .addAll(ThresholdStore.thresholdsLevenshtein); @@ -1533,6 +1541,8 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer { case SIMILARITY: comboFirstArgType.reset(); comboFirstArgType.setValue(ArgType.VALUE, true); + firstArgValue.reset(); + storeThreshold.clear(); storeThreshold .addAll(ThresholdStore.thresholdsSimilarity); @@ -1842,6 +1852,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer { C_Expression singleCondition = calcExpression(horiz); exp = singleCondition; expSet = true; + break; case COMMA: if (depthStack.isEmpty()) { return null; @@ -2032,6 +2043,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer { ConditionOnMultiColumnTypeMap mapOp = new ConditionOnMultiColumnTypeMap(); + expression = mapOp.map( column, comboOp.getCurrentValue().getOperatorType(), diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/condition/ConditionOnMultiColumnTypeMap.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/condition/ConditionOnMultiColumnTypeMap.java index 4956723..7e74709 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/condition/ConditionOnMultiColumnTypeMap.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/condition/ConditionOnMultiColumnTypeMap.java @@ -60,7 +60,10 @@ public class ConditionOnMultiColumnTypeMap { ArgType secondArgType, ColumnData secondArgColumn, String secondArg, Threshold threshold) throws ConditionTypeMapException { - Log.debug("ConditionOnMultiColumnTypeMap"); + Log.debug("ConditionOnMultiColumnTypeMap: [" + column + ", " + + operatorType + ", " + firstArgType + ", " + firstArgColumn + + ", "+firstArg+" "+ secondArgType + ", " + secondArgColumn + + ", "+secondArg+", "+threshold+"]"); C_Expression exp = null; if (column.getTrId() == null) { exp = mapPlaceHolder(column, operatorType, firstArgType, @@ -237,7 +240,8 @@ public class ConditionOnMultiColumnTypeMap { default: break; } - + + Log.debug("CExpression: "+exp); return exp; } @@ -855,9 +859,8 @@ public class ConditionOnMultiColumnTypeMap { exp = new C_Not(exp); break; case NOT_LESSER: - exp = columnReferenceNotLesser(column, firstArgType, firstArgColumn, - firstArg, dataType, - columnReference); + exp = columnReferenceNotLesser(column, firstArgType, + firstArgColumn, firstArg, dataType, columnReference); break; case NOT_LIKE: break; @@ -889,7 +892,9 @@ public class ConditionOnMultiColumnTypeMap { default: break; } - + + + Log.debug("CExpression: "+exp); return exp; } @@ -938,8 +943,7 @@ public class ConditionOnMultiColumnTypeMap { C_Expression exp; checkTypeArgument(column, firstArg); C_Soundex soundexPlaceHolder = new C_Soundex(columnReference); - C_Soundex soundexValue = new C_Soundex(new TD_Value(dataType, - firstArg)); + C_Soundex soundexValue = new C_Soundex(new TD_Value(dataType, firstArg)); exp = new C_Equals(soundexPlaceHolder, soundexValue); return exp; } @@ -969,7 +973,7 @@ public class ConditionOnMultiColumnTypeMap { throw new ConditionTypeMapException( "No valid first argument type selected!"); } - + return exp; }