Updated Rule

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@114086 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-15 16:52:33 +00:00
parent 704f570300
commit f4f6c3b3fd
14 changed files with 616 additions and 502 deletions

View File

@ -2,31 +2,22 @@ package org.gcube.portlets.user.td.expressionwidget.client;
import java.util.ArrayList;
import org.gcube.portlets.user.td.expressionwidget.client.expression.ConditionWidget;
import org.gcube.portlets.user.td.expressionwidget.client.properties.ColumnDataPropertiesCombo;
import org.gcube.portlets.user.td.expressionwidget.client.properties.ColumnDataTypeProperties;
import org.gcube.portlets.user.td.expressionwidget.client.properties.ColumnTypeCodeProperties;
import org.gcube.portlets.user.td.expressionwidget.client.properties.LocaleTypeProperties;
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
import org.gcube.portlets.user.td.expressionwidget.client.store.ColumnDataTypeElement;
import org.gcube.portlets.user.td.expressionwidget.client.store.ColumnDataTypeStore;
import org.gcube.portlets.user.td.expressionwidget.client.store.ColumnTypeCodeElement;
import org.gcube.portlets.user.td.expressionwidget.client.store.ColumnTypeCodeStore;
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.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.expressionwidget.shared.rule.type.TDBaseColumnRuleType;
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.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.type.TDRuleColumnType;
import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ExpressionWrapperEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.expression.C_ExpressionContainer;
import org.gcube.portlets.user.td.widgetcommonevent.client.expression.ExpressionWrapper;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
@ -35,11 +26,8 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeC
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
@ -101,18 +89,19 @@ public class ColumnExpressionPanel extends FramedPanel {
private ComboBox<ColumnData> comboCols;
private RuleDialog parentRuleDialog;
private RuleDescriptionData initialRuleDescriptionData;
private TextField ruleName;
private TextField ruleDescription;
private ComboBox<ColumnTypeCodeElement> comboColumnTypeCode;
private ComboBox<ColumnDataTypeElement> comboMeasureType;
// private ComboBox<ColumnTypeCodeElement> comboColumnTypeCode;
// private ComboBox<ColumnDataTypeElement> comboMeasureType;
private ComboBox<ColumnDataTypeElement> comboAttributeType;
private ListStore<LocaleTypeElement> storeComboLocaleType;
private ComboBox<LocaleTypeElement> comboLocaleType;
private FieldLabel comboColumnTypeCodeLabel;
private FieldLabel comboLocaleTypeLabel;
// private FieldLabel comboColumnTypeCodeLabel;
private FieldLabel comboAttributeTypeLabel;
private FieldLabel comboMeasureTypeLabel;
// private FieldLabel comboMeasureTypeLabel;
/**
*
@ -220,8 +209,23 @@ public class ColumnExpressionPanel extends FramedPanel {
createOnRule();
}
public ColumnExpressionPanel(RuleDialog parentRuleDialog,
RuleDescriptionData ruleDescriptionData, EventBus eventBus) {
super();
setWidth(WIDTH);
setHeight(HEIGHT);
type = ColumnExpressionPanelType.Rule;
this.parentRuleDialog = parentRuleDialog;
this.initialRuleDescriptionData = ruleDescriptionData;
this.column = null;
this.columns = null;
this.eventBus = eventBus;
Log.debug("Column:" + column);
createOnRule();
}
protected void createOnRule() {
// Important: fixed rendering of widgets
forceLayoutOnResize = true;
setBodyBorder(false);
@ -291,61 +295,69 @@ public class ColumnExpressionPanel extends FramedPanel {
5, 2, 5, 2)));
add(basicLayout);
conditionWidget.disable();
}
// TODO
private void createColumnMockUp(VerticalLayoutContainer propertiesLayout) {
ruleName = new TextField();
ruleName.setToolTip("Rule Name");
if (initialRuleDescriptionData != null) {
ruleName.setValue(initialRuleDescriptionData.getName());
}
FieldLabel ruleNameLabel = new FieldLabel(ruleName, "Rule Name");
ruleDescription = new TextField();
ruleDescription.setToolTip("Rule Description");
if (initialRuleDescriptionData != null) {
ruleDescription.setValue(initialRuleDescriptionData
.getDescription());
}
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");
/*
* 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
.create(ColumnDataTypeProperties.class);
@ -364,103 +376,78 @@ public class ColumnExpressionPanel extends FramedPanel {
comboAttributeType.setTypeAhead(true);
comboAttributeType.setTriggerAction(TriggerAction.ALL);
comboAttributeTypeLabel = new FieldLabel(comboAttributeType,
"Attribute Type");
if (initialRuleDescriptionData != null) {
ColumnDataType cdt = retrieveColumnDataType();
if (cdt != null) {
ColumnDataTypeElement cdte = ColumnDataTypeStore
.selectedAttributeElement(cdt);
if (cdte != null) {
comboAttributeType.setValue(cdte);
// comboLocaleType
LocaleTypeProperties propsLocaleType = GWT
.create(LocaleTypeProperties.class);
storeComboLocaleType = new ListStore<LocaleTypeElement>(
propsLocaleType.id());
comboLocaleType = new ComboBox<LocaleTypeElement>(storeComboLocaleType,
propsLocaleType.label()) {
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
retrieveLocales();
}
});
}
}
};
Log.trace("ComboLocaleType created");
}
addHandlersForComboLocaleType(propsLocaleType.label());
comboLocaleType.setEmptyText("Select a locale type...");
comboLocaleType.setWidth(191);
comboLocaleType.setTypeAhead(true);
comboLocaleType.setTriggerAction(TriggerAction.ALL);
comboLocaleTypeLabel = new FieldLabel(comboLocaleType, "Locale");
comboAttributeTypeLabel = new FieldLabel(comboAttributeType,
"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(comboLocaleTypeLabel, new VerticalLayoutData(1,
-1, new Margins(0)));
propertiesLayout.add(comboMeasureTypeLabel, 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,
-1, new Margins(0)));
comboMeasureTypeLabel.setVisible(false);
comboAttributeTypeLabel.setVisible(false);
comboLocaleTypeLabel.setVisible(false);
// comboMeasureTypeLabel.setVisible(false);
// comboAttributeTypeLabel.setVisible(false);
}
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());
}
private ColumnDataType retrieveColumnDataType() {
TDRuleColumnType tdRuleColumnType = initialRuleDescriptionData
.getTdRuleColumnType();
if (tdRuleColumnType instanceof TDBaseColumnRuleType) {
TDBaseColumnRuleType tdBaseColumnRuleType = (TDBaseColumnRuleType) tdRuleColumnType;
return tdBaseColumnRuleType.getColumnDataType();
}
return null;
});
}
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 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
@ -484,67 +471,28 @@ public class ColumnExpressionPanel extends FramedPanel {
});
}
protected void addHandlersForComboLocaleType(
final LabelProvider<LocaleTypeElement> labelProvider) {
comboLocaleType
.addSelectionHandler(new SelectionHandler<LocaleTypeElement>() {
public void onSelection(
SelectionEvent<LocaleTypeElement> event) {
Info.display(
"Locale Type Selected",
"You selected "
+ (event.getSelectedItem() == null ? "nothing"
: labelProvider.getLabel(event
.getSelectedItem())
+ "!"));
Log.debug("ComboLocaleType selected: "
+ event.getSelectedItem());
LocaleTypeElement localeType = event.getSelectedItem();
updateLocaleType(localeType);
}
});
}
protected void updateColumnType(ColumnTypeCode type) {
Log.debug("Update ColumnTypeCode " + type.toString());
switch (type) {
case CODENAME:
comboLocaleTypeLabel.setVisible(true);
comboMeasureTypeLabel.setVisible(false);
comboAttributeTypeLabel.setVisible(false);
break;
case ATTRIBUTE:
comboLocaleTypeLabel.setVisible(false);
comboMeasureTypeLabel.setVisible(false);
comboAttributeTypeLabel.setVisible(true);
comboAttributeType.reset();
break;
case MEASURE:
comboLocaleTypeLabel.setVisible(false);
comboMeasureTypeLabel.setVisible(true);
comboAttributeTypeLabel.setVisible(false);
comboMeasureType.reset();
break;
default:
comboLocaleTypeLabel.setVisible(false);
comboMeasureTypeLabel.setVisible(false);
comboAttributeTypeLabel.setVisible(false);
break;
}
updateCondition();
forceLayout();
}
/*
* 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) {
column = new ColumnData();
column.setId(columnMockUp.getId());
column.setColumnId(columnMockUp.getColumnId());
column.setLabel(columnMockUp.getLabel());
column.setDataTypeName(columnMockUp.getColumnDataType().toString());
column.setTypeCode(columnMockUp.getColumnType().toString());
// column.setTypeCode(columnMockUp.getColumnType().toString());
conditionWidget.update(column);
conditionWidget.enable();
} else {
@ -553,72 +501,116 @@ 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;
ColumnTypeCodeElement columnTypeCodeElement = comboColumnTypeCode
ColumnDataTypeElement columnDataTypeElement = comboAttributeType
.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:
if (columnDataTypeElement != null) {
ColumnDataType dataType = columnDataTypeElement.getType();
if (dataType != null) {
columnMockUp = new ColumnMockUp(null, RULE_PLACE_HOLDER_ID,
RULE_PLACE_HOLDER_ID, type, "");
break;
dataType, RULE_PLACE_HOLDER_ID);
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 {
} else {
}
break;
default:
break;
}
} else {
}
return columnMockUp;
return columnMockUp;
}
protected ColumnMockUp checkEnterData() {
@ -631,83 +623,24 @@ public class ColumnExpressionPanel extends FramedPanel {
String ruleDescriptionS = ruleDescription.getCurrentValue();
if (ruleDescriptionS != null && !ruleDescriptionS.isEmpty()) {
ColumnTypeCodeElement columnTypeCodeElement = comboColumnTypeCode
ColumnDataTypeElement columnDataTypeElement = comboAttributeType
.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:
if (columnDataTypeElement != null) {
ColumnDataType dataType = columnDataTypeElement.getType();
if (dataType != null) {
columnMockUp = new ColumnMockUp(null,
RULE_PLACE_HOLDER_ID, RULE_PLACE_HOLDER_ID,
type, "");
break;
RULE_PLACE_HOLDER_ID, dataType,
RULE_PLACE_HOLDER_ID);
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:
} else {
UtilsGXT3.alert("Attention",
"This column type is not supported now!");
break;
"Column data type not selected!");
}
} else {
UtilsGXT3.alert("Attention", "Select a column type!");
UtilsGXT3.alert("Attention",
"Column data type not selected!");
}
} else {
UtilsGXT3.alert("Attention",
"Enter a valid description for the rule!");
@ -729,7 +662,7 @@ public class ColumnExpressionPanel extends FramedPanel {
columnMockUp.getColumnDataType());
RuleDescriptionData ruleDescriptionData = new RuleDescriptionData(
0, ruleNameS, ruleDescriptionS, RuleScopeType.COLUMN,
0, ruleNameS, ruleDescriptionS, null, RuleScopeType.COLUMN,
tdBaseColumnRule, exp);
return ruleDescriptionData;
} else {
@ -741,11 +674,12 @@ public class ColumnExpressionPanel extends FramedPanel {
}
}
protected void updateMeasureType(ColumnDataType type) {
Log.debug("Update ColumnTypeCode " + type);
updateCondition();
}
/*
* protected void updateMeasureType(ColumnDataType type) {
* Log.debug("Update ColumnTypeCode " + type); updateCondition();
*
* }
*/
protected void updateAttributeType(ColumnDataType type) {
Log.debug("Update ColumnTypeCode " + type);
@ -753,57 +687,6 @@ public class ColumnExpressionPanel extends FramedPanel {
}
protected void updateLocaleType(LocaleTypeElement type) {
Log.debug("Update LocalType" + type);
updateCondition();
}
protected void retrieveLocales() {
TDGWTServiceAsync.INSTANCE
.getLocales(new AsyncCallback<ArrayList<String>>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert("Error Locked",
caught.getLocalizedMessage());
} else {
if (caught instanceof TDGWTIsFinalException) {
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert("Error Final",
caught.getLocalizedMessage());
} else {
Log.debug(caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving locales",
caught.getLocalizedMessage());
}
}
}
}
@Override
public void onSuccess(ArrayList<String> result) {
storeComboLocaleType.clear();
ArrayList<LocaleTypeElement> locales = new ArrayList<LocaleTypeElement>();
LocaleTypeElement locale;
for (String local : result) {
locale = new LocaleTypeElement(local);
locales.add(locale);
}
storeComboLocaleType.addAll(locales);
storeComboLocaleType.commitChanges();
// comboColumnReferenceTypeLabel.setVisible(true);
}
});
}
protected void createOnTemplate() {
// Important: fixed rendering of widgets
forceLayoutOnResize = true;
@ -1223,20 +1106,19 @@ public class ColumnExpressionPanel extends FramedPanel {
Log.debug("Apply: " + column);
C_Expression exp;
try {
exp = conditionWidget.getExpression();
} catch (ConditionTypeMapException e) {
Log.debug(e.getLocalizedMessage());
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
return;
}
C_ExpressionContainer condContainer = null;
ExpressionWrapper exWrapper = null;
ExpressionWrapperEvent expressionEvent = null;
switch (type) {
case Template:
try {
exp = conditionWidget.getExpression();
} catch (ConditionTypeMapException e) {
Log.debug(e.getLocalizedMessage());
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
return;
}
parentTemplateDialog.setExpression(exp);
condContainer = new C_ExpressionContainer();
condContainer.setId(C_ExpressionContainer.Contains.C_Expression);
@ -1251,21 +1133,53 @@ public class ColumnExpressionPanel extends FramedPanel {
eventBus.fireEvent(expressionEvent);
break;
case Rule:
if (!conditionWidget.isEnabled()) {
UtilsGXT3.alert("Attention", "Fill all field!");
return;
}
try {
exp = conditionWidget.getExpression();
} catch (ConditionTypeMapException e) {
Log.debug(e.getLocalizedMessage());
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
return;
}
RuleDescriptionData ruleDescriptionData = retrieveRuleDescriptionData(exp);
if (ruleDescriptionData != null) {
parentRuleDialog.addRule(ruleDescriptionData);
}
break;
case ColumnFilter:
try {
exp = conditionWidget.getExpression();
} catch (ConditionTypeMapException e) {
Log.debug(e.getLocalizedMessage());
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
return;
}
parentFilterDialog.applyFilter(column, exp);
break;
case RowDeleteByExpression:
try {
exp = conditionWidget.getExpression();
} catch (ConditionTypeMapException e) {
Log.debug(e.getLocalizedMessage());
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
return;
}
C_Expression notExp = new C_Not(exp);
parentRowsDeleteByExpressionDialog.deleteRowsByExpression(column,
notExp);
break;
case MultiColumnFilter:
try {
exp = conditionWidget.getExpression();
} catch (ConditionTypeMapException e) {
Log.debug(e.getLocalizedMessage());
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
return;
}
parentMultiColumnFilterTabPanel.applyFilter(column, exp);
break;
default:

View File

@ -2,7 +2,6 @@ package org.gcube.portlets.user.td.expressionwidget.client;
import org.gcube.portlets.user.td.expressionwidget.client.expression.ReplaceExpressionDialog;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.TabResourceType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;

View File

@ -3,6 +3,8 @@ package org.gcube.portlets.user.td.expressionwidget.client;
import java.util.ArrayList;
import java.util.Date;
import org.gcube.portlets.user.td.expressionwidget.client.expression.ConditionWidget;
import org.gcube.portlets.user.td.expressionwidget.client.expression.ReplaceWidget;
import org.gcube.portlets.user.td.expressionwidget.client.properties.ColumnDataPropertiesCombo;
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceExpressionType;

View File

@ -1,9 +1,10 @@
package org.gcube.portlets.user.td.expressionwidget.client.expression;
package org.gcube.portlets.user.td.expressionwidget.client;
import java.util.ArrayList;
import org.gcube.portlets.user.td.expressionwidget.client.expression.ExpressionWrapperNotification.ExpressionWrapperNotificationListener;
import org.gcube.portlets.user.td.expressionwidget.client.expression.ExpressionWrapperNotification.HasExpressionWrapperNotificationListener;
import org.gcube.portlets.user.td.expressionwidget.client.notification.ExpressionWrapperNotification;
import org.gcube.portlets.user.td.expressionwidget.client.notification.ExpressionWrapperNotification.ExpressionWrapperNotificationListener;
import org.gcube.portlets.user.td.expressionwidget.client.notification.ExpressionWrapperNotification.HasExpressionWrapperNotificationListener;
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceExpressionType;
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;

View File

@ -1,9 +1,10 @@
package org.gcube.portlets.user.td.expressionwidget.client.expression;
package org.gcube.portlets.user.td.expressionwidget.client;
import java.util.ArrayList;
import java.util.Date;
import org.gcube.portlets.user.td.expressionwidget.client.ReplaceWidget;
import org.gcube.portlets.user.td.expressionwidget.client.expression.ReplaceWidget;
import org.gcube.portlets.user.td.expressionwidget.client.notification.ExpressionWrapperNotification;
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceExpressionType;
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ReplaceTypeMapException;

View File

@ -1,10 +1,20 @@
package org.gcube.portlets.user.td.expressionwidget.client;
import java.util.ArrayList;
import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleDialogNotification;
import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleDialogNotification.HasRuleDialogNotificationListener;
import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleDialogNotification.RuleDialogNotificationListener;
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
@ -12,30 +22,43 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class RuleDialog extends Window {
public class RuleDialog extends Window implements
HasRuleDialogNotificationListener {
private static final String WIDTH = "660px";
private static final String HEIGHT = "460px";
private ColumnExpressionPanel columnExpressionPanel;
private EventBus eventBus;
private ArrayList<RuleDialogNotificationListener> listeners;
private RuleDescriptionData initialRuleDescriptionData;
/**
*
* @param columnMockUp
* @param eventBus
*/
public RuleDialog(EventBus eventBus) {
listeners = new ArrayList<RuleDialogNotificationListener>();
initWindow();
this.eventBus = eventBus;
create();
this.eventBus = eventBus;
columnExpressionPanel = new ColumnExpressionPanel(this, eventBus);
add(columnExpressionPanel);
}
public RuleDialog(RuleDescriptionData ruleDescriptionData, EventBus eventBus) {
listeners = new ArrayList<RuleDialogNotificationListener>();
initWindow();
this.eventBus = eventBus;
this.initialRuleDescriptionData = ruleDescriptionData;
columnExpressionPanel = new ColumnExpressionPanel(this,
ruleDescriptionData, eventBus);
add(columnExpressionPanel);
}
protected void initWindow() {
setWidth(WIDTH);
@ -49,10 +72,7 @@ public class RuleDialog extends Window {
getHeader().setIcon(ExpressionResources.INSTANCE.rule());
}
/**
* {@inheritDoc}
*/
@ -62,36 +82,103 @@ public class RuleDialog extends Window {
closeBtn.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
close();
}
});
}
protected void close (){
//ExpressionWrapper exWrapper=new ExpressionWrapper();
//ExpressionWrapperEvent expressionEvent = new ExpressionWrapperEvent(exWrapper);
//Log.debug(expressionEvent.toString());
hide();
//eventBus.fireEvent(expressionEvent);
}
protected void create() {
columnExpressionPanel = new ColumnExpressionPanel(this,
eventBus);
add(columnExpressionPanel);
protected void close() {
fireAborted();
}
public void addRule(RuleDescriptionData ruleDescriptionData) {
Log.debug("RuleDescriptionData: "+ruleDescriptionData);
close();
Log.debug("RuleDescriptionData: " + ruleDescriptionData);
if (initialRuleDescriptionData == null) {
saveColumnRule(ruleDescriptionData);
} else {
updateColumnRule(ruleDescriptionData);
}
}
public void saveColumnRule(RuleDescriptionData ruleDescriptionData) {
ExpressionServiceAsync.INSTANCE.saveColumnRule(ruleDescriptionData,
new AsyncCallback<String>() {
@Override
public void onSuccess(String ruleId) {
Log.debug("Saved Rule: " + ruleId);
UtilsGXT3.info("Save Rule", "The rule is saved!");
fireNotification(ruleId);
}
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error saving column rule: "
+ caught.getLocalizedMessage());
caught.printStackTrace();
UtilsGXT3.alert("Error saving column rule",
caught.getLocalizedMessage());
fireFailed(caught);
}
}
});
}
private void updateColumnRule(RuleDescriptionData ruleDescriptionData) {
fireAborted();
}
@Override
public void addRuleDialogNotificationListener(
RuleDialogNotificationListener handler) {
listeners.add(handler);
}
@Override
public void removeRuleDialogNotificationListener(
RuleDialogNotificationListener handler) {
listeners.remove(handler);
}
private void fireNotification(String ruleId) {
if (listeners != null) {
for (RuleDialogNotificationListener listener : listeners) {
listener.onNotification(new RuleDialogNotification(ruleId));
}
}
hide();
}
private void fireAborted() {
if (listeners != null) {
for (RuleDialogNotificationListener listener : listeners) {
listener.aborted();
}
}
hide();
}
private void fireFailed(Throwable caught) {
if (listeners != null) {
for (RuleDialogNotificationListener listener : listeners) {
listener.failed(caught);
;
}
}
hide();
}
}

View File

@ -1,4 +1,4 @@
package org.gcube.portlets.user.td.expressionwidget.client;
package org.gcube.portlets.user.td.expressionwidget.client.expression;
import java.util.ArrayList;
import java.util.Date;

View File

@ -1,4 +1,4 @@
package org.gcube.portlets.user.td.expressionwidget.client;
package org.gcube.portlets.user.td.expressionwidget.client.expression;
import java.util.ArrayList;

View File

@ -1,4 +1,4 @@
package org.gcube.portlets.user.td.expressionwidget.client.expression;
package org.gcube.portlets.user.td.expressionwidget.client.notification;
import org.gcube.portlets.user.td.widgetcommonevent.client.expression.ExpressionWrapper;

View File

@ -0,0 +1,48 @@
package org.gcube.portlets.user.td.expressionwidget.client.notification;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class RuleDialogNotification {
private String ruleId;
public interface RuleDialogNotificationListener {
void onNotification(RuleDialogNotification ruleDialogNotification);
void aborted();
void failed(Throwable throwable);
}
public interface HasRuleDialogNotificationListener {
public void addRuleDialogNotificationListener(
RuleDialogNotificationListener handler);
public void removeRuleDialogNotificationListener(
RuleDialogNotificationListener handler);
}
public RuleDialogNotification(String ruleId) {
this.ruleId = ruleId;
}
public String getRuleId() {
return ruleId;
}
public void setRuleId(String ruleId) {
this.ruleId = ruleId;
}
@Override
public String toString() {
return "RuleDialogNotification [ruleId=" + ruleId + "]";
}
}

View File

@ -5,9 +5,6 @@ import java.util.ArrayList;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
/**
*
* @author "Giancarlo Panichi" <a
@ -18,54 +15,58 @@ public class ColumnDataTypeStore implements Serializable {
private static final long serialVersionUID = -1908324094430432681L;
protected static ArrayList<ColumnDataTypeElement> store;
protected static ColumnDataTypeElement integerElement=new ColumnDataTypeElement(1,ColumnDataType.Integer);
protected static ColumnDataTypeElement numericElement=new ColumnDataTypeElement(2,ColumnDataType.Numeric);
protected static ColumnDataTypeElement booleanElement=new ColumnDataTypeElement(3,ColumnDataType.Boolean);
protected static ColumnDataTypeElement textElement=new ColumnDataTypeElement(4,ColumnDataType.Text);
protected static ColumnDataTypeElement dateElement=new ColumnDataTypeElement(5,ColumnDataType.Date);
protected static ColumnDataTypeElement geometryElement=new ColumnDataTypeElement(6,ColumnDataType.Geometry);
private static ArrayList<ColumnDataTypeElement> store;
public static ArrayList<ColumnDataTypeElement> getMeasureType(){
store=new ArrayList<ColumnDataTypeElement>();
private static ColumnDataTypeElement integerElement = new ColumnDataTypeElement(
1, ColumnDataType.Integer);
private static ColumnDataTypeElement numericElement = new ColumnDataTypeElement(
2, ColumnDataType.Numeric);
private static ColumnDataTypeElement booleanElement = new ColumnDataTypeElement(
3, ColumnDataType.Boolean);
private static ColumnDataTypeElement textElement = new ColumnDataTypeElement(
4, ColumnDataType.Text);
private static ColumnDataTypeElement dateElement = new ColumnDataTypeElement(
5, ColumnDataType.Date);
private static ColumnDataTypeElement geometryElement = new ColumnDataTypeElement(
6, ColumnDataType.Geometry);
public static ArrayList<ColumnDataTypeElement> getMeasureType() {
store = new ArrayList<ColumnDataTypeElement>();
store.add(integerElement);
store.add(numericElement);
return store;
}
public static int selectedMeasurePosition(String selected){
int position=0;
if(selected.compareTo(ColumnDataType.Integer.toString())==0){
position=1;
public static int selectedMeasurePosition(String selected) {
int position = 0;
if (selected.compareTo(ColumnDataType.Integer.toString()) == 0) {
position = 1;
} else {
if(selected.compareTo(ColumnDataType.Numeric.toString())==0){
position=2;
if (selected.compareTo(ColumnDataType.Numeric.toString()) == 0) {
position = 2;
} else {
}
}
return position;
}
public static ColumnDataType selectedMeasure(String selected){
if(selected.compareTo(ColumnDataType.Integer.toString())==0){
public static ColumnDataType selectedMeasure(String selected) {
if (selected.compareTo(ColumnDataType.Integer.toString()) == 0) {
return ColumnDataType.Integer;
} else {
if(selected.compareTo(ColumnDataType.Numeric.toString())==0){
if (selected.compareTo(ColumnDataType.Numeric.toString()) == 0) {
return ColumnDataType.Numeric;
} else {
return null;
}
}
}
public static ColumnDataTypeElement selectedMeasureElement(String selected){
if(selected.compareTo(ColumnDataType.Integer.toString())==0){
public static ColumnDataTypeElement selectedMeasureElement(String selected) {
if (selected.compareTo(ColumnDataType.Integer.toString()) == 0) {
return integerElement;
} else {
if(selected.compareTo(ColumnDataType.Numeric.toString())==0){
if (selected.compareTo(ColumnDataType.Numeric.toString()) == 0) {
return numericElement;
} else {
return null;
@ -73,11 +74,28 @@ public class ColumnDataTypeStore implements Serializable {
}
}
public static ColumnDataTypeElement selectedMeasureElement(
ColumnDataType columnDataType) {
if (columnDataType == null) {
return null;
}
switch (columnDataType) {
case Integer:
return integerElement;
case Numeric:
return numericElement;
default:
return null;
}
}
public static ArrayList<ColumnDataTypeElement> getAttributeType(){
store=new ArrayList<ColumnDataTypeElement>();
public static ArrayList<ColumnDataTypeElement> getAttributeType() {
store = new ArrayList<ColumnDataTypeElement>();
store.add(integerElement);
store.add(numericElement);
store.add(booleanElement);
@ -86,95 +104,124 @@ public class ColumnDataTypeStore implements Serializable {
store.add(geometryElement);
return store;
}
public static int selectedAttributePosition(String selected){
int position=0;
if(selected.compareTo(ColumnDataType.Integer.toString())==0){
position=1;
public static int selectedAttributePosition(String selected) {
int position = 0;
if (selected.compareTo(ColumnDataType.Integer.toString()) == 0) {
position = 1;
} else {
if(selected.compareTo(ColumnDataType.Numeric.toString())==0){
position=2;
if (selected.compareTo(ColumnDataType.Numeric.toString()) == 0) {
position = 2;
} else {
if(selected.compareTo(ColumnDataType.Boolean.toString())==0){
position=3;
if (selected.compareTo(ColumnDataType.Boolean.toString()) == 0) {
position = 3;
} else {
if(selected.compareTo(ColumnDataType.Text.toString())==0){
position=4;
if (selected.compareTo(ColumnDataType.Text.toString()) == 0) {
position = 4;
} else {
if(selected.compareTo(ColumnDataType.Date.toString())==0){
position=5;
if (selected.compareTo(ColumnDataType.Date.toString()) == 0) {
position = 5;
} else {
if(selected.compareTo(ColumnDataType.Geometry.toString())==0){
position=6;
if (selected.compareTo(ColumnDataType.Geometry
.toString()) == 0) {
position = 6;
} else {
}
}
}
}
}
}
return position;
}
public static ColumnDataType selectedAttribute(String selected){
if(selected.compareTo(ColumnDataType.Integer.toString())==0){
public static ColumnDataType selectedAttribute(String selected) {
if (selected.compareTo(ColumnDataType.Integer.toString()) == 0) {
return ColumnDataType.Integer;
} else {
if(selected.compareTo(ColumnDataType.Numeric.toString())==0){
if (selected.compareTo(ColumnDataType.Numeric.toString()) == 0) {
return ColumnDataType.Numeric;
} else {
if(selected.compareTo(ColumnDataType.Boolean.toString())==0){
if (selected.compareTo(ColumnDataType.Boolean.toString()) == 0) {
return ColumnDataType.Boolean;
} else {
if(selected.compareTo(ColumnDataType.Text.toString())==0){
if (selected.compareTo(ColumnDataType.Text.toString()) == 0) {
return ColumnDataType.Text;
} else {
if(selected.compareTo(ColumnDataType.Date.toString())==0){
if (selected.compareTo(ColumnDataType.Date.toString()) == 0) {
return ColumnDataType.Date;
} else {
if(selected.compareTo(ColumnDataType.Geometry.toString())==0){
if (selected.compareTo(ColumnDataType.Geometry
.toString()) == 0) {
return ColumnDataType.Geometry;
} else {
return null;
}
}
}
}
}
}
}
public static ColumnDataTypeElement selectedAttributeElement(String selected){
if(selected.compareTo(ColumnDataType.Integer.toString())==0){
public static ColumnDataTypeElement selectedAttributeElement(String selected) {
if (selected.compareTo(ColumnDataType.Integer.toString()) == 0) {
return integerElement;
} else {
if(selected.compareTo(ColumnDataType.Numeric.toString())==0){
if (selected.compareTo(ColumnDataType.Numeric.toString()) == 0) {
return numericElement;
} else {
if(selected.compareTo(ColumnDataType.Boolean.toString())==0){
if (selected.compareTo(ColumnDataType.Boolean.toString()) == 0) {
return booleanElement;
} else {
if(selected.compareTo(ColumnDataType.Text.toString())==0){
if (selected.compareTo(ColumnDataType.Text.toString()) == 0) {
return textElement;
} else {
if(selected.compareTo(ColumnDataType.Date.toString())==0){
if (selected.compareTo(ColumnDataType.Date.toString()) == 0) {
return dateElement;
} else {
if(selected.compareTo(ColumnDataType.Geometry.toString())==0){
if (selected.compareTo(ColumnDataType.Geometry
.toString()) == 0) {
return geometryElement;
} else {
return null;
}
}
}
}
}
}
}
public static ColumnDataTypeElement selectedAttributeElement(
ColumnDataType columnDataType) {
if (columnDataType == null) {
return null;
}
switch (columnDataType) {
case Boolean:
return booleanElement;
case Date:
return dateElement;
case Geometry:
return geometryElement;
case Integer:
return integerElement;
case Numeric:
return numericElement;
case Text:
return textElement;
default:
return null;
}
}
}

View File

@ -237,7 +237,7 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
C_Expression cexp = parser.parse(serviceExpression);
RuleDescriptionData ruleData = new RuleDescriptionData(
ruleDescription.getId(), ruleDescription.getName(),
ruleDescription.getDescription(),
ruleDescription.getDescription(),ruleDescription.getOwner(),
RuleScopeMap.map(ruleDescription.getScope()), cexp);
rulesDes.add(ruleData);
@ -288,7 +288,7 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
C_Expression cexp = parser.parse(serviceExpression);
RuleDescriptionData ruleData = new RuleDescriptionData(
ruleDescription.getId(), ruleDescription.getName(),
ruleDescription.getDescription(),
ruleDescription.getDescription(),ruleDescription.getOwner(),
RuleScopeMap.map(ruleDescription.getScope()), cexp);
rulesDes.add(ruleData);

View File

@ -17,6 +17,7 @@ public class RuleDescriptionData implements Serializable {
private long id;
private String name;
private String description;
private String owner;
private RuleScopeType scope;
private TDRuleColumnType tdRuleColumnType;
private C_Expression expression;
@ -25,26 +26,28 @@ public class RuleDescriptionData implements Serializable {
super();
}
public RuleDescriptionData(long id, String name, String description,
public RuleDescriptionData(long id, String name, String description, String owner,
RuleScopeType scope,
C_Expression expression) {
super();
this.id = id;
this.name = name;
this.description = description;
this.owner=owner;
this.scope = scope;
this.tdRuleColumnType = null;
this.expression = expression;
}
public RuleDescriptionData(long id, String name, String description,
public RuleDescriptionData(long id, String name, String description,String owner,
RuleScopeType scope, TDRuleColumnType tdRuleColumnType,
C_Expression expression) {
super();
this.id = id;
this.name = name;
this.description = description;
this.owner=owner;
this.scope = scope;
this.tdRuleColumnType = tdRuleColumnType;
this.expression = expression;
@ -74,6 +77,14 @@ public class RuleDescriptionData implements Serializable {
this.description = description;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public RuleScopeType getScope() {
return scope;
}
@ -97,6 +108,7 @@ public class RuleDescriptionData implements Serializable {
public void setExpression(C_Expression expression) {
this.expression = expression;
}
public String getReadableExpression() {
if (expression != null) {
@ -109,9 +121,11 @@ public class RuleDescriptionData implements Serializable {
@Override
public String toString() {
return "RuleDescriptionData [id=" + id + ", name=" + name
+ ", description=" + description + ", scope=" + scope
+ ", tdRuleColumnType=" + tdRuleColumnType + ", expression="
+ expression + "]";
+ ", description=" + description + ", owner=" + owner
+ ", scope=" + scope + ", tdRuleColumnType=" + tdRuleColumnType
+ ", expression=" + expression + "]";
}
}

View File

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