Updated Rule
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@114026 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
96443d5629
commit
b4e626cfc4
|
@ -14,6 +14,8 @@ import org.gcube.portlets.user.td.expressionwidget.client.store.ColumnTypeCodeSt
|
||||||
import org.gcube.portlets.user.td.expressionwidget.client.store.LocaleTypeElement;
|
import org.gcube.portlets.user.td.expressionwidget.client.store.LocaleTypeElement;
|
||||||
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.model.logical.C_Not;
|
import org.gcube.portlets.user.td.expressionwidget.shared.model.logical.C_Not;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
|
||||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
|
||||||
|
@ -36,8 +38,6 @@ import com.google.gwt.core.client.Scheduler;
|
||||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
|
||||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
import com.google.web.bindery.event.shared.EventBus;
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
@ -69,6 +69,8 @@ import com.sencha.gxt.widget.core.client.info.Info;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ColumnExpressionPanel extends FramedPanel {
|
public class ColumnExpressionPanel extends FramedPanel {
|
||||||
|
private static final String RULE_PLACE_HOLDER_ID = "RulePlaceHolderId";
|
||||||
|
|
||||||
private enum ColumnExpressionPanelType {
|
private enum ColumnExpressionPanelType {
|
||||||
MultiColumnFilter, ColumnFilter, RowDeleteByExpression, Template, Rule;
|
MultiColumnFilter, ColumnFilter, RowDeleteByExpression, Template, Rule;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +100,9 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
private ComboBox<ColumnData> comboCols;
|
private ComboBox<ColumnData> comboCols;
|
||||||
private RuleDialog parentRuleDialog;
|
private RuleDialog parentRuleDialog;
|
||||||
|
|
||||||
private TextField columnTag;
|
private TextField ruleName;
|
||||||
|
private TextField ruleDescription;
|
||||||
|
|
||||||
private ComboBox<ColumnTypeCodeElement> comboColumnTypeCode;
|
private ComboBox<ColumnTypeCodeElement> comboColumnTypeCode;
|
||||||
private ComboBox<ColumnDataTypeElement> comboMeasureType;
|
private ComboBox<ColumnDataTypeElement> comboMeasureType;
|
||||||
private ComboBox<ColumnDataTypeElement> comboAttributeType;
|
private ComboBox<ColumnDataTypeElement> comboAttributeType;
|
||||||
|
@ -109,7 +113,6 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
private FieldLabel comboAttributeTypeLabel;
|
private FieldLabel comboAttributeTypeLabel;
|
||||||
private FieldLabel comboMeasureTypeLabel;
|
private FieldLabel comboMeasureTypeLabel;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param parentMultiColumnFilterTabPanel
|
* @param parentMultiColumnFilterTabPanel
|
||||||
|
@ -291,20 +294,14 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
private void createColumnMockUp(VerticalLayoutContainer propertiesLayout) {
|
private void createColumnMockUp(VerticalLayoutContainer propertiesLayout) {
|
||||||
columnTag = new TextField();
|
ruleName = new TextField();
|
||||||
columnTag.setToolTip("Column Label");
|
ruleName.setToolTip("Rule Name");
|
||||||
columnTag.addValueChangeHandler(new ValueChangeHandler<String>() {
|
FieldLabel ruleNameLabel = new FieldLabel(ruleName, "Rule Name");
|
||||||
|
|
||||||
@Override
|
ruleDescription = new TextField();
|
||||||
public void onValueChange(ValueChangeEvent<String> event) {
|
ruleDescription.setToolTip("Rule Description");
|
||||||
updateColumnTag(event.getValue());
|
FieldLabel ruleDescriptionLabel = new FieldLabel(ruleDescription,
|
||||||
|
"Rule Description");
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
FieldLabel columnLabel = new FieldLabel(columnTag, "Column Label");
|
|
||||||
|
|
||||||
// combo TypeCode
|
// combo TypeCode
|
||||||
ColumnTypeCodeProperties propsColumnTypeCode = GWT
|
ColumnTypeCodeProperties propsColumnTypeCode = GWT
|
||||||
|
@ -325,7 +322,8 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
comboColumnTypeCode.setTypeAhead(true);
|
comboColumnTypeCode.setTypeAhead(true);
|
||||||
comboColumnTypeCode.setTriggerAction(TriggerAction.ALL);
|
comboColumnTypeCode.setTriggerAction(TriggerAction.ALL);
|
||||||
|
|
||||||
comboColumnTypeCodeLabel=new FieldLabel(comboColumnTypeCode, "Column Type");
|
comboColumnTypeCodeLabel = new FieldLabel(comboColumnTypeCode,
|
||||||
|
"Column Type");
|
||||||
|
|
||||||
// comboMeasureType
|
// comboMeasureType
|
||||||
ColumnDataTypeProperties propsMeasureType = GWT
|
ColumnDataTypeProperties propsMeasureType = GWT
|
||||||
|
@ -397,11 +395,12 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
comboLocaleTypeLabel = new FieldLabel(comboLocaleType, "Locale");
|
comboLocaleTypeLabel = new FieldLabel(comboLocaleType, "Locale");
|
||||||
|
|
||||||
propertiesLayout.add(columnLabel, new VerticalLayoutData(1, -1,
|
propertiesLayout.add(ruleNameLabel, new VerticalLayoutData(1, -1,
|
||||||
new Margins(0)));
|
new Margins(0)));
|
||||||
propertiesLayout.add(
|
propertiesLayout.add(ruleDescriptionLabel, new VerticalLayoutData(1,
|
||||||
comboColumnTypeCodeLabel,
|
-1, new Margins(0)));
|
||||||
new VerticalLayoutData(1, -1, new Margins(0)));
|
propertiesLayout.add(comboColumnTypeCodeLabel, new VerticalLayoutData(
|
||||||
|
1, -1, new Margins(0)));
|
||||||
propertiesLayout.add(comboLocaleTypeLabel, new VerticalLayoutData(1,
|
propertiesLayout.add(comboLocaleTypeLabel, new VerticalLayoutData(1,
|
||||||
-1, new Margins(0)));
|
-1, new Margins(0)));
|
||||||
propertiesLayout.add(comboMeasureTypeLabel, new VerticalLayoutData(1,
|
propertiesLayout.add(comboMeasureTypeLabel, new VerticalLayoutData(1,
|
||||||
|
@ -409,7 +408,6 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
propertiesLayout.add(comboAttributeTypeLabel, new VerticalLayoutData(1,
|
propertiesLayout.add(comboAttributeTypeLabel, new VerticalLayoutData(1,
|
||||||
-1, new Margins(0)));
|
-1, new Margins(0)));
|
||||||
|
|
||||||
comboColumnTypeCodeLabel.setVisible(false);
|
|
||||||
comboMeasureTypeLabel.setVisible(false);
|
comboMeasureTypeLabel.setVisible(false);
|
||||||
comboAttributeTypeLabel.setVisible(false);
|
comboAttributeTypeLabel.setVisible(false);
|
||||||
comboLocaleTypeLabel.setVisible(false);
|
comboLocaleTypeLabel.setVisible(false);
|
||||||
|
@ -507,31 +505,6 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateColumnTag(String value) {
|
|
||||||
if(value==null|| value.isEmpty()){
|
|
||||||
comboColumnTypeCodeLabel.setVisible(false);
|
|
||||||
comboMeasureTypeLabel.setVisible(false);
|
|
||||||
comboAttributeTypeLabel.setVisible(false);
|
|
||||||
comboLocaleTypeLabel.setVisible(false);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
comboColumnTypeCodeLabel.setVisible(true);
|
|
||||||
comboMeasureTypeLabel.setVisible(false);
|
|
||||||
comboAttributeTypeLabel.setVisible(false);
|
|
||||||
comboLocaleTypeLabel.setVisible(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
comboColumnTypeCode.reset();
|
|
||||||
comboMeasureType.reset();
|
|
||||||
comboAttributeType.reset();
|
|
||||||
comboLocaleType.reset();
|
|
||||||
updateCondition();
|
|
||||||
forceLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void updateColumnType(ColumnTypeCode type) {
|
protected void updateColumnType(ColumnTypeCode type) {
|
||||||
Log.debug("Update ColumnTypeCode " + type.toString());
|
Log.debug("Update ColumnTypeCode " + type.toString());
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -582,9 +555,6 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
protected ColumnMockUp retrieveColumnMockUp() {
|
protected ColumnMockUp retrieveColumnMockUp() {
|
||||||
ColumnMockUp columnMockUp = null;
|
ColumnMockUp columnMockUp = null;
|
||||||
|
|
||||||
String labelS = columnTag.getCurrentValue();
|
|
||||||
|
|
||||||
if (labelS != null && !labelS.isEmpty()) {
|
|
||||||
ColumnTypeCodeElement columnTypeCodeElement = comboColumnTypeCode
|
ColumnTypeCodeElement columnTypeCodeElement = comboColumnTypeCode
|
||||||
.getCurrentValue();
|
.getCurrentValue();
|
||||||
if (columnTypeCodeElement != null) {
|
if (columnTypeCodeElement != null) {
|
||||||
|
@ -594,11 +564,11 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
case MEASURE:
|
case MEASURE:
|
||||||
columnDataTypeElement = comboMeasureType.getCurrentValue();
|
columnDataTypeElement = comboMeasureType.getCurrentValue();
|
||||||
if (columnDataTypeElement != null) {
|
if (columnDataTypeElement != null) {
|
||||||
ColumnDataType dataType = columnDataTypeElement
|
ColumnDataType dataType = columnDataTypeElement.getType();
|
||||||
.getType();
|
|
||||||
if (dataType != null) {
|
if (dataType != null) {
|
||||||
columnMockUp = new ColumnMockUp(null, labelS,
|
columnMockUp = new ColumnMockUp(null,
|
||||||
labelS, type, dataType, "");
|
RULE_PLACE_HOLDER_ID, RULE_PLACE_HOLDER_ID,
|
||||||
|
type, dataType, "");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -608,14 +578,13 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ATTRIBUTE:
|
case ATTRIBUTE:
|
||||||
columnDataTypeElement = comboAttributeType
|
columnDataTypeElement = comboAttributeType.getCurrentValue();
|
||||||
.getCurrentValue();
|
|
||||||
if (columnDataTypeElement != null) {
|
if (columnDataTypeElement != null) {
|
||||||
ColumnDataType dataType = columnDataTypeElement
|
ColumnDataType dataType = columnDataTypeElement.getType();
|
||||||
.getType();
|
|
||||||
if (dataType != null) {
|
if (dataType != null) {
|
||||||
columnMockUp = new ColumnMockUp(null, labelS,
|
columnMockUp = new ColumnMockUp(null,
|
||||||
labelS, type, dataType, "");
|
RULE_PLACE_HOLDER_ID, RULE_PLACE_HOLDER_ID,
|
||||||
|
type, dataType, "");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
@ -626,16 +595,16 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
case CODE:
|
case CODE:
|
||||||
case CODEDESCRIPTION:
|
case CODEDESCRIPTION:
|
||||||
case ANNOTATION:
|
case ANNOTATION:
|
||||||
columnMockUp = new ColumnMockUp(null, labelS, labelS, type,
|
columnMockUp = new ColumnMockUp(null, RULE_PLACE_HOLDER_ID,
|
||||||
"");
|
RULE_PLACE_HOLDER_ID, type, "");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CODENAME:
|
case CODENAME:
|
||||||
LocaleTypeElement locale = comboLocaleType
|
LocaleTypeElement locale = comboLocaleType.getCurrentValue();
|
||||||
.getCurrentValue();
|
|
||||||
if (locale != null) {
|
if (locale != null) {
|
||||||
columnMockUp = new ColumnMockUp(null, labelS, labelS,
|
columnMockUp = new ColumnMockUp(null, RULE_PLACE_HOLDER_ID,
|
||||||
type, locale.getLocaleName(), "");
|
RULE_PLACE_HOLDER_ID, type, locale.getLocaleName(),
|
||||||
|
"");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -647,13 +616,127 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
return columnMockUp;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ColumnMockUp checkEnterData() {
|
||||||
|
ColumnMockUp columnMockUp = null;
|
||||||
|
|
||||||
|
String ruleNameS = ruleName.getCurrentValue();
|
||||||
|
|
||||||
|
if (ruleNameS != null && !ruleNameS.isEmpty()) {
|
||||||
|
|
||||||
|
String ruleDescriptionS = ruleDescription.getCurrentValue();
|
||||||
|
|
||||||
|
if (ruleDescriptionS != null && !ruleDescriptionS.isEmpty()) {
|
||||||
|
ColumnTypeCodeElement columnTypeCodeElement = comboColumnTypeCode
|
||||||
|
.getCurrentValue();
|
||||||
|
if (columnTypeCodeElement != null) {
|
||||||
|
ColumnTypeCode type = columnTypeCodeElement.getCode();
|
||||||
|
ColumnDataTypeElement columnDataTypeElement;
|
||||||
|
switch (type) {
|
||||||
|
case MEASURE:
|
||||||
|
columnDataTypeElement = comboMeasureType
|
||||||
|
.getCurrentValue();
|
||||||
|
if (columnDataTypeElement != null) {
|
||||||
|
ColumnDataType dataType = columnDataTypeElement
|
||||||
|
.getType();
|
||||||
|
if (dataType != null) {
|
||||||
|
columnMockUp = new ColumnMockUp(null,
|
||||||
|
RULE_PLACE_HOLDER_ID,
|
||||||
|
RULE_PLACE_HOLDER_ID, type, dataType,
|
||||||
|
"");
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.alert("Attention",
|
||||||
|
"Column data type not selected!");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.alert("Attention",
|
||||||
|
"Column data type not selected!");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ATTRIBUTE:
|
||||||
|
columnDataTypeElement = comboAttributeType
|
||||||
|
.getCurrentValue();
|
||||||
|
if (columnDataTypeElement != null) {
|
||||||
|
ColumnDataType dataType = columnDataTypeElement
|
||||||
|
.getType();
|
||||||
|
if (dataType != null) {
|
||||||
|
columnMockUp = new ColumnMockUp(null,
|
||||||
|
RULE_PLACE_HOLDER_ID,
|
||||||
|
RULE_PLACE_HOLDER_ID, type, dataType,
|
||||||
|
"");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.alert("Attention",
|
||||||
|
"Column data type not selected!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.alert("Attention",
|
||||||
|
"Column data type not selected!");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CODE:
|
||||||
|
case CODEDESCRIPTION:
|
||||||
|
case ANNOTATION:
|
||||||
|
columnMockUp = new ColumnMockUp(null,
|
||||||
|
RULE_PLACE_HOLDER_ID, RULE_PLACE_HOLDER_ID,
|
||||||
|
type, "");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CODENAME:
|
||||||
|
LocaleTypeElement locale = comboLocaleType
|
||||||
|
.getCurrentValue();
|
||||||
|
if (locale != null) {
|
||||||
|
columnMockUp = new ColumnMockUp(null,
|
||||||
|
RULE_PLACE_HOLDER_ID, RULE_PLACE_HOLDER_ID,
|
||||||
|
type, locale.getLocaleName(), "");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.alert("Attention", "No locale selected!");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
UtilsGXT3.alert("Attention",
|
||||||
|
"This column type is not supported now!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.alert("Attention", "Select a column type!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.alert("Attention",
|
||||||
|
"Enter a valid description for the rule!");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.alert("Attention", "Enter a valid name for the rule!");
|
||||||
|
}
|
||||||
return columnMockUp;
|
return columnMockUp;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected RuleDescriptionData retrieveRuleDescriptionData(C_Expression exp) {
|
||||||
|
ColumnMockUp columnMockUp = checkEnterData();
|
||||||
|
if (columnMockUp != null) {
|
||||||
|
if(exp!=null){
|
||||||
|
|
||||||
|
String ruleNameS = ruleName.getCurrentValue();
|
||||||
|
String ruleDescriptionS = ruleDescription.getCurrentValue();
|
||||||
|
RuleDescriptionData ruleDescriptionData = new RuleDescriptionData(
|
||||||
|
0, ruleNameS, ruleDescriptionS, RuleScopeType.COLUMN, exp);
|
||||||
|
return ruleDescriptionData;
|
||||||
|
} else {
|
||||||
|
UtilsGXT3.alert("Attention", "Enter a valid condition!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void updateMeasureType(ColumnDataType type) {
|
protected void updateMeasureType(ColumnDataType type) {
|
||||||
Log.debug("Update ColumnTypeCode " + type);
|
Log.debug("Update ColumnTypeCode " + type);
|
||||||
updateCondition();
|
updateCondition();
|
||||||
|
@ -664,7 +747,6 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
Log.debug("Update ColumnTypeCode " + type);
|
Log.debug("Update ColumnTypeCode " + type);
|
||||||
updateCondition();
|
updateCondition();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateLocaleType(LocaleTypeElement type) {
|
protected void updateLocaleType(LocaleTypeElement type) {
|
||||||
|
@ -1164,25 +1246,15 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
parentTemplateDialog.hide();
|
parentTemplateDialog.hide();
|
||||||
eventBus.fireEvent(expressionEvent);
|
eventBus.fireEvent(expressionEvent);
|
||||||
break;
|
break;
|
||||||
|
case Rule:
|
||||||
|
RuleDescriptionData ruleDescriptionData = retrieveRuleDescriptionData(exp);
|
||||||
|
if (ruleDescriptionData != null) {
|
||||||
|
parentRuleDialog.addRule(ruleDescriptionData);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ColumnFilter:
|
case ColumnFilter:
|
||||||
parentFilterDialog.applyFilter(column, exp);
|
parentFilterDialog.applyFilter(column, exp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Rule:
|
|
||||||
ColumnMockUp columnMockUp = new ColumnMockUp();
|
|
||||||
column = new ColumnData();
|
|
||||||
column.setColumnId(columnMockUp.getColumnId());
|
|
||||||
column.setLabel(columnMockUp.getLabel());
|
|
||||||
column.setDataTypeName(columnMockUp.getColumnDataType().toString());
|
|
||||||
column.setTypeCode(columnMockUp.getColumnType().toString());
|
|
||||||
condContainer = new C_ExpressionContainer();
|
|
||||||
condContainer.setId(C_ExpressionContainer.Contains.C_Expression);
|
|
||||||
condContainer.setExp(exp);
|
|
||||||
condContainer.setReadableExpression(conditionWidget
|
|
||||||
.getReadableExpression());
|
|
||||||
exWrapper = new ExpressionWrapper(null, column, condContainer);
|
|
||||||
parentRuleDialog.addRule(exWrapper);
|
|
||||||
break;
|
|
||||||
case RowDeleteByExpression:
|
case RowDeleteByExpression:
|
||||||
C_Expression notExp = new C_Not(exp);
|
C_Expression notExp = new C_Not(exp);
|
||||||
parentRowsDeleteByExpressionDialog.deleteRowsByExpression(column,
|
parentRowsDeleteByExpressionDialog.deleteRowsByExpression(column,
|
||||||
|
@ -1208,12 +1280,15 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
parentTemplateDialog.hide();
|
parentTemplateDialog.hide();
|
||||||
eventBus.fireEvent(expressionEvent);
|
eventBus.fireEvent(expressionEvent);
|
||||||
break;
|
break;
|
||||||
|
case Rule:
|
||||||
|
parentRuleDialog.close();
|
||||||
case ColumnFilter:
|
case ColumnFilter:
|
||||||
parentFilterDialog.close();
|
parentFilterDialog.close();
|
||||||
break;
|
break;
|
||||||
case RowDeleteByExpression:
|
case RowDeleteByExpression:
|
||||||
parentRowsDeleteByExpressionDialog.close();
|
parentRowsDeleteByExpressionDialog.close();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MultiColumnFilter:
|
case MultiColumnFilter:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.portlets.user.td.expressionwidget.client;
|
||||||
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.client.expression.ExpressionWrapper;
|
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.web.bindery.event.shared.EventBus;
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
@ -87,8 +87,8 @@ public class RuleDialog extends Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addRule(ExpressionWrapper exWrapper) {
|
public void addRule(RuleDescriptionData ruleDescriptionData) {
|
||||||
Log.debug("ExpressionWrapper: "+exWrapper);
|
Log.debug("RuleDescriptionData: "+ruleDescriptionData);
|
||||||
close();
|
close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.td.expressionwidget.client.rpc;
|
package org.gcube.portlets.user.td.expressionwidget.client.rpc;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
||||||
|
@ -45,4 +49,9 @@ public interface ExpressionService extends RemoteService {
|
||||||
public String startAddColumn(AddColumnSession addColumnSession)
|
public String startAddColumn(AddColumnSession addColumnSession)
|
||||||
throws TDGWTServiceException;
|
throws TDGWTServiceException;
|
||||||
|
|
||||||
|
public ArrayList<RuleDescriptionData> getRules()
|
||||||
|
throws TDGWTServiceException;
|
||||||
|
|
||||||
|
public ArrayList<RuleDescriptionData> getRules(RuleScopeType scope)
|
||||||
|
throws TDGWTServiceException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.td.expressionwidget.client.rpc;
|
package org.gcube.portlets.user.td.expressionwidget.client.rpc;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
||||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnByExpressionSession;
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnByExpressionSession;
|
||||||
|
@ -32,4 +36,9 @@ public interface ExpressionServiceAsync {
|
||||||
void startAddColumn(AddColumnSession addColumnSession,
|
void startAddColumn(AddColumnSession addColumnSession,
|
||||||
AsyncCallback<String> callback);
|
AsyncCallback<String> callback);
|
||||||
|
|
||||||
|
void getRules(AsyncCallback<ArrayList<RuleDescriptionData>> callback);
|
||||||
|
|
||||||
|
void getRules(RuleScopeType scope,
|
||||||
|
AsyncCallback<ArrayList<RuleDescriptionData>> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,8 +213,14 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
|
||||||
public ArrayList<RuleDescriptionData> getRule(RuleScopeType scope) throws TDGWTServiceException {
|
/**
|
||||||
|
*
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ArrayList<RuleDescriptionData> getRules(RuleScopeType scope)
|
||||||
|
throws TDGWTServiceException {
|
||||||
try {
|
try {
|
||||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
@ -223,9 +229,9 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
||||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||||
aslSession.getUsername(), aslSession.getScope()));
|
aslSession.getUsername(), aslSession.getScope()));
|
||||||
TabularDataService service = TabularDataServiceFactory.getService();
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
service.getRules();
|
|
||||||
|
|
||||||
List<RuleDescription> rules=service.getRulesByScope(RuleScopeMap.map(scope));
|
List<RuleDescription> rules = service.getRulesByScope(RuleScopeMap
|
||||||
|
.map(scope));
|
||||||
|
|
||||||
ArrayList<RuleDescriptionData> rulesDes = new ArrayList<RuleDescriptionData>();
|
ArrayList<RuleDescriptionData> rulesDes = new ArrayList<RuleDescriptionData>();
|
||||||
|
|
||||||
|
@ -234,27 +240,26 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
||||||
for (RuleDescription ruleDescription : rules) {
|
for (RuleDescription ruleDescription : rules) {
|
||||||
Expression serviceExpression = ruleDescription.getRule();
|
Expression serviceExpression = ruleDescription.getRule();
|
||||||
C_Expression cexp = parser.parse(serviceExpression);
|
C_Expression cexp = parser.parse(serviceExpression);
|
||||||
RuleDescriptionData ruleData=new RuleDescriptionData(ruleDescription.getId(),
|
RuleDescriptionData ruleData = new RuleDescriptionData(
|
||||||
ruleDescription.getName(), ruleDescription.getDescription(),
|
ruleDescription.getId(), ruleDescription.getName(),
|
||||||
RuleScopeMap.map(ruleDescription.getScope()),
|
ruleDescription.getDescription(),
|
||||||
cexp);
|
RuleScopeMap.map(ruleDescription.getScope()), cexp);
|
||||||
rulesDes.add(ruleData);
|
rulesDes.add(ruleData);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rulesDes;
|
return rulesDes;
|
||||||
|
|
||||||
} catch (TDGWTServiceException e) {
|
} catch (TDGWTServiceException e) {
|
||||||
logger.error(e.getLocalizedMessage(),e);
|
logger.error(e.getLocalizedMessage());
|
||||||
throw e;
|
throw e;
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
logger.error(e.getLocalizedMessage(),e);
|
logger.error(e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error(
|
logger.error("Error in getRule(): " + e.getLocalizedMessage());
|
||||||
"Error in getRule(): " + e.getLocalizedMessage(),
|
e.printStackTrace();
|
||||||
e);
|
|
||||||
throw new TDGWTServiceException("Error retrieving the rules: "
|
throw new TDGWTServiceException("Error retrieving the rules: "
|
||||||
+ e.getLocalizedMessage());
|
+ e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
|
@ -262,6 +267,57 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ArrayList<RuleDescriptionData> getRules()
|
||||||
|
throws TDGWTServiceException {
|
||||||
|
try {
|
||||||
|
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||||
|
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||||
|
|
||||||
|
logger.debug("GetRule()");
|
||||||
|
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||||
|
aslSession.getUsername(), aslSession.getScope()));
|
||||||
|
TabularDataService service = TabularDataServiceFactory.getService();
|
||||||
|
|
||||||
|
List<RuleDescription> rules = service.getRules();
|
||||||
|
|
||||||
|
ArrayList<RuleDescriptionData> rulesDes = new ArrayList<RuleDescriptionData>();
|
||||||
|
|
||||||
|
C_ExpressionParser parser = new C_ExpressionParser();
|
||||||
|
|
||||||
|
for (RuleDescription ruleDescription : rules) {
|
||||||
|
Expression serviceExpression = ruleDescription.getRule();
|
||||||
|
C_Expression cexp = parser.parse(serviceExpression);
|
||||||
|
RuleDescriptionData ruleData = new RuleDescriptionData(
|
||||||
|
ruleDescription.getId(), ruleDescription.getName(),
|
||||||
|
ruleDescription.getDescription(),
|
||||||
|
RuleScopeMap.map(ruleDescription.getScope()), cexp);
|
||||||
|
rulesDes.add(ruleData);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return rulesDes;
|
||||||
|
|
||||||
|
} catch (TDGWTServiceException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
throw e;
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
logger.error(e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
throw e;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
logger.error("Error in getRule(): " + e.getLocalizedMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new TDGWTServiceException("Error retrieving the rules: "
|
||||||
|
+ e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -73,6 +73,15 @@ public class RuleDescriptionData implements Serializable {
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getReadableExpression(){
|
||||||
|
if(expression!=null){
|
||||||
|
return expression.getReadableExpression();
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RuleDescriptionData [id=" + id + ", name=" + name
|
return "RuleDescriptionData [id=" + id + ", name=" + name
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package org.gcube.portlets.user.td.expressionwidget.shared.rule;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import com.google.gwt.editor.client.Editor.Path;
|
||||||
|
import com.sencha.gxt.core.client.ValueProvider;
|
||||||
|
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||||
|
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author giancarlo
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface RuleDescriptionDataProperties extends PropertyAccess<RuleDescriptionData> {
|
||||||
|
|
||||||
|
@Path("id")
|
||||||
|
ModelKeyProvider<RuleDescriptionData> id();
|
||||||
|
|
||||||
|
ValueProvider<RuleDescriptionData, String> name();
|
||||||
|
ValueProvider<RuleDescriptionData, String> description();
|
||||||
|
ValueProvider<RuleDescriptionData, String> readableExpression();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue