Updated Rules

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@114287 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-21 11:37:33 +00:00
parent c7b1e2e0fc
commit 79bccecd8a
5 changed files with 53 additions and 229 deletions

View File

@ -73,7 +73,6 @@ public class ColumnExpressionPanel extends FramedPanel {
private static final String RULE_HEIGHT = "388px";
private ColumnExpressionPanelType type;
private TemplateColumnExpressionDialog parentTemplateDialog;
private ColumnFilterDialog parentFilterDialog;
@ -96,14 +95,10 @@ public class ColumnExpressionPanel extends FramedPanel {
private TextField ruleName;
private TextArea ruleDescription;
// private ComboBox<ColumnTypeCodeElement> comboColumnTypeCode;
// private ComboBox<ColumnDataTypeElement> comboMeasureType;
private ComboBox<ColumnDataTypeElement> comboAttributeType;
private ComboBox<ColumnDataTypeElement> comboDataType;
// private FieldLabel comboColumnTypeCodeLabel;
private FieldLabel comboAttributeTypeLabel;
private FieldLabel comboDataTypeLabel;
// private FieldLabel comboMeasureTypeLabel;
/**
*
@ -291,11 +286,14 @@ public class ColumnExpressionPanel extends FramedPanel {
5, 2, 5, 2)));
add(basicLayout);
conditionWidget.disable();
if (initialRuleDescriptionData == null) {
conditionWidget.disable();
} else {
updateCondition();
}
}
// TODO
private void createColumnMockUp(VerticalLayoutContainer propertiesLayout) {
ruleName = new TextField();
ruleName.setToolTip("Rule Name");
@ -314,74 +312,35 @@ public class ColumnExpressionPanel extends FramedPanel {
FieldLabel ruleDescriptionLabel = new FieldLabel(ruleDescription,
"Rule Description");
/*
* combo TypeCode ColumnTypeCodeProperties propsColumnTypeCode = GWT
* .create(ColumnTypeCodeProperties.class);
* ListStore<ColumnTypeCodeElement> storeComboTypeCode = new
* ListStore<ColumnTypeCodeElement>( propsColumnTypeCode.id());
* storeComboTypeCode.addAll(ColumnTypeCodeStore
* .getColumnTypeCodesForRule());
*
* comboColumnTypeCode = new ComboBox<ColumnTypeCodeElement>(
* storeComboTypeCode, propsColumnTypeCode.label());
* Log.trace("ComboColumnTypeCode created");
*
* addHandlersForComboColumnTypeCode(propsColumnTypeCode.label());
*
* comboColumnTypeCode.setEmptyText("Select a column type...");
* comboColumnTypeCode.setWidth(191);
* comboColumnTypeCode.setTypeAhead(true);
* comboColumnTypeCode.setTriggerAction(TriggerAction.ALL);
*
* comboColumnTypeCodeLabel = new FieldLabel(comboColumnTypeCode,
* "Column Type");
*
* // comboMeasureType ColumnDataTypeProperties propsMeasureType = GWT
* .create(ColumnDataTypeProperties.class);
* ListStore<ColumnDataTypeElement> storeComboMeasureType = new
* ListStore<ColumnDataTypeElement>( propsMeasureType.id());
* storeComboMeasureType.addAll(ColumnDataTypeStore.getMeasureType());
*
* comboMeasureType = new ComboBox<ColumnDataTypeElement>(
* storeComboMeasureType, propsMeasureType.label());
* Log.trace("ComboMeasureType created");
*
* addHandlersForComboMeasureType(propsMeasureType.label());
*
* comboMeasureType.setEmptyText("Select a measure type...");
* comboMeasureType.setWidth(191); comboMeasureType.setTypeAhead(true);
* comboMeasureType.setTriggerAction(TriggerAction.ALL);
*
* comboMeasureTypeLabel = new FieldLabel(comboMeasureType,
* "Measure Type");
*/
// comboAttributeType
ColumnDataTypeProperties propsAttributeType = GWT
// comboDataType
ColumnDataTypeProperties propsDataType = GWT
.create(ColumnDataTypeProperties.class);
ListStore<ColumnDataTypeElement> storeComboAttributeType = new ListStore<ColumnDataTypeElement>(
propsAttributeType.id());
storeComboAttributeType.addAll(ColumnDataTypeStore.getAttributeType());
ListStore<ColumnDataTypeElement> storeComboDataType = new ListStore<ColumnDataTypeElement>(
propsDataType.id());
storeComboDataType.addAll(ColumnDataTypeStore.getAttributeType());
comboAttributeType = new ComboBox<ColumnDataTypeElement>(
storeComboAttributeType, propsAttributeType.label());
Log.trace("ComboAttributeType created");
comboDataType = new ComboBox<ColumnDataTypeElement>(
storeComboDataType, propsDataType.label());
Log.trace("ComboDataType created");
addHandlersForComboAttributeType(propsAttributeType.label());
addHandlersForComboAttributeType(propsDataType.label());
comboAttributeType.setEmptyText("Select a column type...");
comboAttributeType.setWidth(191);
comboAttributeType.setTypeAhead(true);
comboAttributeType.setTriggerAction(TriggerAction.ALL);
comboDataType.setEmptyText("Select a column type...");
comboDataType.setWidth(191);
comboDataType.setTypeAhead(true);
comboDataType.setTriggerAction(TriggerAction.ALL);
if (initialRuleDescriptionData != null) {
Log.debug("Initial RuleDescriptionData: "+initialRuleDescriptionData);
Log.debug("Initial RuleDescriptionData: "
+ initialRuleDescriptionData);
ColumnDataType cdt = retrieveColumnDataType();
if (cdt != null) {
Log.debug("Retrieved column data type: "+cdt);
Log.debug("Retrieved column data type: " + cdt);
ColumnDataTypeElement cdte = ColumnDataTypeStore
.selectedAttributeElement(cdt);
if (cdte != null) {
comboAttributeType.setValue(cdte);
comboDataType.setValue(cdte);
}
} else {
@ -389,24 +348,18 @@ public class ColumnExpressionPanel extends FramedPanel {
}
}
comboAttributeTypeLabel = new FieldLabel(comboAttributeType,
comboDataTypeLabel = new FieldLabel(comboDataType,
"Data Type");
propertiesLayout.add(ruleNameLabel, new VerticalLayoutData(1, -1,
new Margins(0)));
propertiesLayout.add(ruleDescriptionLabel, new VerticalLayoutData(1,
-1, new Margins(0)));
/*
* propertiesLayout.add(comboColumnTypeCodeLabel, new
* VerticalLayoutData( 1, -1, new Margins(0)));
* propertiesLayout.add(comboMeasureTypeLabel, new VerticalLayoutData(1,
* -1, new Margins(0)));
*/
propertiesLayout.add(comboAttributeTypeLabel, new VerticalLayoutData(1,
propertiesLayout.add(comboDataTypeLabel, new VerticalLayoutData(1,
-1, new Margins(0)));
// comboMeasureTypeLabel.setVisible(false);
// comboAttributeTypeLabel.setVisible(false);
}
@ -422,36 +375,10 @@ public class ColumnExpressionPanel extends FramedPanel {
}
/*
* protected void addHandlersForComboColumnTypeCode( final
* LabelProvider<ColumnTypeCodeElement> labelProvider) { comboColumnTypeCode
* .addSelectionHandler(new SelectionHandler<ColumnTypeCodeElement>() {
* public void onSelection( SelectionEvent<ColumnTypeCodeElement> event) {
* Info.display( "Column Type Selected", "You selected " +
* (event.getSelectedItem() == null ? "nothing" :
* labelProvider.getLabel(event .getSelectedItem()) + "!"));
* Log.debug("ComboColumnTypeCode selected: " + event.getSelectedItem());
* ColumnTypeCodeElement columnType = event .getSelectedItem();
* updateColumnType(columnType.getCode()); }
*
* }); }
*
* protected void addHandlersForComboMeasureType( final
* LabelProvider<ColumnDataTypeElement> labelProvider) { comboMeasureType
* .addSelectionHandler(new SelectionHandler<ColumnDataTypeElement>() {
* public void onSelection( SelectionEvent<ColumnDataTypeElement> event) {
* Info.display( "Measure Type Selected", "You selected " +
* (event.getSelectedItem() == null ? "nothing" :
* labelProvider.getLabel(event .getSelectedItem()) + "!"));
* Log.debug("ComboMeasureType selected: " + event.getSelectedItem());
* ColumnDataTypeElement measureType = event .getSelectedItem();
* updateMeasureType(measureType.getType()); }
*
* }); }
*/
protected void addHandlersForComboAttributeType(
final LabelProvider<ColumnDataTypeElement> labelProvider) {
comboAttributeType
comboDataType
.addSelectionHandler(new SelectionHandler<ColumnDataTypeElement>() {
public void onSelection(
SelectionEvent<ColumnDataTypeElement> event) {
@ -466,25 +393,13 @@ public class ColumnExpressionPanel extends FramedPanel {
+ event.getSelectedItem());
ColumnDataTypeElement attributeType = event
.getSelectedItem();
updateAttributeType(attributeType.getType());
updateDataType(attributeType.getType());
}
});
}
/*
* protected void updateColumnType(ColumnTypeCode type) {
* Log.debug("Update ColumnTypeCode " + type.toString()); switch (type) {
* case ATTRIBUTE: comboMeasureTypeLabel.setVisible(false);
* comboAttributeTypeLabel.setVisible(true); comboAttributeType.reset();
* break; case MEASURE: comboMeasureTypeLabel.setVisible(true);
* comboAttributeTypeLabel.setVisible(false); comboMeasureType.reset();
* break; default: comboMeasureTypeLabel.setVisible(false);
* comboAttributeTypeLabel.setVisible(false); break; }
*
* updateCondition(); forceLayout(); }
*/
protected void updateCondition() {
ColumnMockUp columnMockUp = retrieveColumnMockUp();
if (columnMockUp != null) {
@ -493,7 +408,6 @@ public class ColumnExpressionPanel extends FramedPanel {
column.setColumnId(columnMockUp.getColumnId());
column.setLabel(columnMockUp.getLabel());
column.setDataTypeName(columnMockUp.getColumnDataType().toString());
// column.setTypeCode(columnMockUp.getColumnType().toString());
conditionWidget.update(column);
conditionWidget.enable();
} else {
@ -502,101 +416,12 @@ public class ColumnExpressionPanel extends FramedPanel {
forceLayout();
}
/*
* protected ColumnMockUp retrieveColumnMockUp() { ColumnMockUp columnMockUp
* = null;
*
* 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 {
*
* }
*
* } else {
*
* } 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 { } } else {
*
* } 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(); columnMockUp = new ColumnMockUp(null,
* RULE_PLACE_HOLDER_ID, RULE_PLACE_HOLDER_ID, type, "", "");
*
* break; default: break; } } 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(); columnMockUp = new ColumnMockUp(null,
* RULE_PLACE_HOLDER_ID, RULE_PLACE_HOLDER_ID, type, "", "");
*
* 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;
*
* }
*/
protected ColumnMockUp retrieveColumnMockUp() {
ColumnMockUp columnMockUp = null;
ColumnDataTypeElement columnDataTypeElement = comboAttributeType
ColumnDataTypeElement columnDataTypeElement = comboDataType
.getCurrentValue();
if (columnDataTypeElement != null) {
ColumnDataType dataType = columnDataTypeElement.getType();
@ -624,7 +449,7 @@ public class ColumnExpressionPanel extends FramedPanel {
String ruleDescriptionS = ruleDescription.getCurrentValue();
if (ruleDescriptionS != null && !ruleDescriptionS.isEmpty()) {
ColumnDataTypeElement columnDataTypeElement = comboAttributeType
ColumnDataTypeElement columnDataTypeElement = comboDataType
.getCurrentValue();
if (columnDataTypeElement != null) {
ColumnDataType dataType = columnDataTypeElement.getType();
@ -675,15 +500,10 @@ public class ColumnExpressionPanel extends FramedPanel {
}
}
/*
* protected void updateMeasureType(ColumnDataType type) {
* Log.debug("Update ColumnTypeCode " + type); updateCondition();
*
* }
*/
protected void updateAttributeType(ColumnDataType type) {
Log.debug("Update ColumnTypeCode " + type);
protected void updateDataType(ColumnDataType type) {
Log.debug("Update ColumnDataType: " + type);
updateCondition();
}
@ -1129,7 +949,7 @@ public class ColumnExpressionPanel extends FramedPanel {
ExpressionWrapperNotification expressionWrapperNotification = new ExpressionWrapperNotification(
exWrapper);
Log.debug("Notification: "+expressionWrapperNotification);
Log.debug("Notification: " + expressionWrapperNotification);
parentTemplateDialog.onExpression(expressionWrapperNotification);
break;
case Rule:

View File

@ -8,7 +8,7 @@ import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleScopeType;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RulesOnColumnApplySession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyColumnRulesSession;
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.ReplaceColumnByExpressionSession;
@ -65,6 +65,6 @@ public interface ExpressionService extends RemoteService {
public void removeRulesById(ArrayList<RuleDescriptionData> rules) throws TDGWTServiceException;
public String startRulesOnColumnApply(RulesOnColumnApplySession ruleOnColumnApplySession)
public String startApplyColumnRules(ApplyColumnRulesSession ruleOnColumnApplySession)
throws TDGWTServiceException;
}

View File

@ -7,7 +7,7 @@ import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleScopeType;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RulesOnColumnApplySession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyColumnRulesSession;
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.ReplaceColumnByExpressionSession;
@ -52,8 +52,8 @@ public interface ExpressionServiceAsync {
void removeRulesById(ArrayList<RuleDescriptionData> rules,
AsyncCallback<Void> callback);
void startRulesOnColumnApply(
RulesOnColumnApplySession ruleOnColumnApplySession,
void startApplyColumnRules(
ApplyColumnRulesSession ruleOnColumnApplySession,
AsyncCallback<String> callback);
}

View File

@ -27,7 +27,7 @@ import org.gcube.portlets.user.td.gwtservice.server.trservice.ColumnDataTypeMap;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleScopeType;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RulesOnColumnApplySession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyColumnRulesSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.type.TDRuleColumnType;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.AddColumnSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
@ -513,18 +513,21 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
}
}
/**
*
* {@inheritDoc}
*/
@Override
public String startRulesOnColumnApply(
RulesOnColumnApplySession ruleOnColumnApplySession)
public String startApplyColumnRules(
ApplyColumnRulesSession applyColumnRulesSession)
throws TDGWTServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
String taskId = startRulesOnColumnApply(ruleOnColumnApplySession,
String taskId = startApplyColumnnRules(applyColumnRulesSession,
session);
return taskId;

View File

@ -23,6 +23,7 @@ public interface RuleDescriptionDataProperties extends PropertyAccess<RuleDescr
ModelKeyProvider<RuleDescriptionData> id();
ValueProvider<RuleDescriptionData, String> name();
ValueProvider<RuleDescriptionData, String> scopeLabel();
ValueProvider<RuleDescriptionData, String> description();
ValueProvider<RuleDescriptionData, String> owner();
ValueProvider<RuleDescriptionData, String> readableExpression();