Updated expression for Template

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@114204 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-17 10:25:30 +00:00
parent 023c72d122
commit f681088abf
8 changed files with 121 additions and 118 deletions

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.td.expressionwidget.client;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.user.td.expressionwidget.client.expression.ConditionWidget; import org.gcube.portlets.user.td.expressionwidget.client.expression.ConditionWidget;
import org.gcube.portlets.user.td.expressionwidget.client.notification.ExpressionWrapperNotification;
import org.gcube.portlets.user.td.expressionwidget.client.properties.ColumnDataPropertiesCombo; 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.ColumnDataTypeProperties;
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources; import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
@ -15,7 +16,6 @@ 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.expressionwidget.shared.rule.type.TDBaseColumnRuleType;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.type.TDRuleColumnType; 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.monitorwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ExpressionWrapperEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.expression.C_ExpressionContainer; 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.expression.ExpressionWrapper;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression; import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
@ -48,6 +48,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.ComboBox; import com.sencha.gxt.widget.core.client.form.ComboBox;
import com.sencha.gxt.widget.core.client.form.FieldLabel; import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.FieldSet; import com.sencha.gxt.widget.core.client.form.FieldSet;
import com.sencha.gxt.widget.core.client.form.TextArea;
import com.sencha.gxt.widget.core.client.form.TextField; import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.info.Info; import com.sencha.gxt.widget.core.client.info.Info;
@ -58,6 +59,7 @@ import com.sencha.gxt.widget.core.client.info.Info;
* *
*/ */
public class ColumnExpressionPanel extends FramedPanel { public class ColumnExpressionPanel extends FramedPanel {
private static final String RULE_DESCRIPTION_HEIGHT = "44px";
private static final String RULE_PLACE_HOLDER_ID = "RulePlaceHolderId"; private static final String RULE_PLACE_HOLDER_ID = "RulePlaceHolderId";
private enum ColumnExpressionPanelType { private enum ColumnExpressionPanelType {
@ -71,9 +73,9 @@ public class ColumnExpressionPanel extends FramedPanel {
private static final String RULE_HEIGHT = "388px"; private static final String RULE_HEIGHT = "388px";
private ColumnExpressionPanelType type; private ColumnExpressionPanelType type;
private EventBus eventBus;
private ColumnExpressionDialog parentTemplateDialog;
private TemplateColumnExpressionDialog parentTemplateDialog;
private ColumnFilterDialog parentFilterDialog; private ColumnFilterDialog parentFilterDialog;
private RowsDeleteByExpressionDialog parentRowsDeleteByExpressionDialog; private RowsDeleteByExpressionDialog parentRowsDeleteByExpressionDialog;
private MultiColumnFilterTabPanel parentMultiColumnFilterTabPanel; private MultiColumnFilterTabPanel parentMultiColumnFilterTabPanel;
@ -92,7 +94,7 @@ public class ColumnExpressionPanel extends FramedPanel {
private RuleDescriptionData initialRuleDescriptionData; private RuleDescriptionData initialRuleDescriptionData;
private TextField ruleName; private TextField ruleName;
private TextField ruleDescription; private TextArea ruleDescription;
// private ComboBox<ColumnTypeCodeElement> comboColumnTypeCode; // private ComboBox<ColumnTypeCodeElement> comboColumnTypeCode;
// private ComboBox<ColumnDataTypeElement> comboMeasureType; // private ComboBox<ColumnDataTypeElement> comboMeasureType;
@ -119,7 +121,6 @@ public class ColumnExpressionPanel extends FramedPanel {
this.parentMultiColumnFilterTabPanel = parentMultiColumnFilterTabPanel; this.parentMultiColumnFilterTabPanel = parentMultiColumnFilterTabPanel;
this.column = column; this.column = column;
this.columns = null; this.columns = null;
this.eventBus = eventBus;
Log.debug("Column:" + column); Log.debug("Column:" + column);
createOnMultiColumnFilter(); createOnMultiColumnFilter();
@ -141,7 +142,6 @@ public class ColumnExpressionPanel extends FramedPanel {
this.parentFilterDialog = parentFilterDialog; this.parentFilterDialog = parentFilterDialog;
this.column = column; this.column = column;
this.columns = columns; this.columns = columns;
this.eventBus = eventBus;
Log.debug("Column:" + column); Log.debug("Column:" + column);
createOnFilter(); createOnFilter();
} }
@ -163,7 +163,6 @@ public class ColumnExpressionPanel extends FramedPanel {
this.parentRowsDeleteByExpressionDialog = parentRowsDeleteByExpressionDialog; this.parentRowsDeleteByExpressionDialog = parentRowsDeleteByExpressionDialog;
this.column = column; this.column = column;
this.columns = columns; this.columns = columns;
this.eventBus = eventBus;
Log.debug("Column:" + column); Log.debug("Column:" + column);
createOnRowsDeleteByExpression(); createOnRowsDeleteByExpression();
} }
@ -175,7 +174,7 @@ public class ColumnExpressionPanel extends FramedPanel {
* @param eventBus * @param eventBus
*/ */
public ColumnExpressionPanel( public ColumnExpressionPanel(
ColumnExpressionDialog parentColumnExpressionDialog, TemplateColumnExpressionDialog parentColumnExpressionDialog,
ColumnData column, EventBus eventBus) { ColumnData column, EventBus eventBus) {
super(); super();
setWidth(WIDTH); setWidth(WIDTH);
@ -184,7 +183,6 @@ public class ColumnExpressionPanel extends FramedPanel {
this.parentTemplateDialog = parentColumnExpressionDialog; this.parentTemplateDialog = parentColumnExpressionDialog;
this.column = column; this.column = column;
this.columns = null; this.columns = null;
this.eventBus = eventBus;
Log.debug("Column:" + column); Log.debug("Column:" + column);
createOnTemplate(); createOnTemplate();
@ -203,7 +201,6 @@ public class ColumnExpressionPanel extends FramedPanel {
this.parentRuleDialog = parentRuleDialog; this.parentRuleDialog = parentRuleDialog;
this.column = null; this.column = null;
this.columns = null; this.columns = null;
this.eventBus = eventBus;
Log.debug("Column:" + column); Log.debug("Column:" + column);
createOnRule(); createOnRule();
@ -219,7 +216,6 @@ public class ColumnExpressionPanel extends FramedPanel {
this.initialRuleDescriptionData = ruleDescriptionData; this.initialRuleDescriptionData = ruleDescriptionData;
this.column = null; this.column = null;
this.columns = null; this.columns = null;
this.eventBus = eventBus;
Log.debug("Column:" + column); Log.debug("Column:" + column);
createOnRule(); createOnRule();
@ -308,7 +304,8 @@ public class ColumnExpressionPanel extends FramedPanel {
} }
FieldLabel ruleNameLabel = new FieldLabel(ruleName, "Rule Name"); FieldLabel ruleNameLabel = new FieldLabel(ruleName, "Rule Name");
ruleDescription = new TextField(); ruleDescription = new TextArea();
ruleDescription.setHeight(RULE_DESCRIPTION_HEIGHT);
ruleDescription.setToolTip("Rule Description"); ruleDescription.setToolTip("Rule Description");
if (initialRuleDescriptionData != null) { if (initialRuleDescriptionData != null) {
ruleDescription.setValue(initialRuleDescriptionData ruleDescription.setValue(initialRuleDescriptionData
@ -662,8 +659,8 @@ public class ColumnExpressionPanel extends FramedPanel {
columnMockUp.getColumnDataType()); columnMockUp.getColumnDataType());
RuleDescriptionData ruleDescriptionData = new RuleDescriptionData( RuleDescriptionData ruleDescriptionData = new RuleDescriptionData(
0, ruleNameS, ruleDescriptionS, null, RuleScopeType.COLUMN, 0, ruleNameS, ruleDescriptionS, null,
tdBaseColumnRule, exp); RuleScopeType.COLUMN, tdBaseColumnRule, exp);
return ruleDescriptionData; return ruleDescriptionData;
} else { } else {
UtilsGXT3.alert("Attention", "Enter a valid condition!"); UtilsGXT3.alert("Attention", "Enter a valid condition!");
@ -1108,7 +1105,6 @@ public class ColumnExpressionPanel extends FramedPanel {
C_Expression exp; C_Expression exp;
C_ExpressionContainer condContainer = null; C_ExpressionContainer condContainer = null;
ExpressionWrapper exWrapper = null; ExpressionWrapper exWrapper = null;
ExpressionWrapperEvent expressionEvent = null;
switch (type) { switch (type) {
case Template: case Template:
@ -1119,7 +1115,6 @@ public class ColumnExpressionPanel extends FramedPanel {
UtilsGXT3.alert("Attention", e.getLocalizedMessage()); UtilsGXT3.alert("Attention", e.getLocalizedMessage());
return; return;
} }
parentTemplateDialog.setExpression(exp);
condContainer = new C_ExpressionContainer(); condContainer = new C_ExpressionContainer();
condContainer.setId(C_ExpressionContainer.Contains.C_Expression); condContainer.setId(C_ExpressionContainer.Contains.C_Expression);
condContainer.setExp(exp); condContainer.setExp(exp);
@ -1127,10 +1122,11 @@ public class ColumnExpressionPanel extends FramedPanel {
.getReadableExpression()); .getReadableExpression());
exWrapper = new ExpressionWrapper(column.getTrId(), column, exWrapper = new ExpressionWrapper(column.getTrId(), column,
condContainer); condContainer);
expressionEvent = new ExpressionWrapperEvent(exWrapper);
Log.debug(expressionEvent.toString()); ExpressionWrapperNotification expressionWrapperNotification = new ExpressionWrapperNotification(
parentTemplateDialog.hide(); exWrapper);
eventBus.fireEvent(expressionEvent); Log.debug("Notification: "+expressionWrapperNotification);
parentTemplateDialog.onExpression(expressionWrapperNotification);
break; break;
case Rule: case Rule:
if (!conditionWidget.isEnabled()) { if (!conditionWidget.isEnabled()) {
@ -1191,12 +1187,7 @@ public class ColumnExpressionPanel extends FramedPanel {
protected void close() { protected void close() {
switch (type) { switch (type) {
case Template: case Template:
ExpressionWrapper exWrapper = new ExpressionWrapper(); parentTemplateDialog.close();
ExpressionWrapperEvent expressionEvent = new ExpressionWrapperEvent(
exWrapper);
Log.debug(expressionEvent.toString());
parentTemplateDialog.hide();
eventBus.fireEvent(expressionEvent);
break; break;
case Rule: case Rule:
parentRuleDialog.close(); parentRuleDialog.close();

View File

@ -97,8 +97,6 @@ public class ReplaceExpressionDialog extends Window implements
} }
/** /**
* *
* ColumnMockUp and ColumnMockUpList must have set columnId, label, columnTypeCode and * ColumnMockUp and ColumnMockUpList must have set columnId, label, columnTypeCode and

View File

@ -9,7 +9,6 @@ import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionRe
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceExpressionType; import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceExpressionType;
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ReplaceTypeMapException; import org.gcube.portlets.user.td.expressionwidget.shared.exception.ReplaceTypeMapException;
import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3; 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.expression.C_ExpressionContainer; 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.expression.ExpressionWrapper;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression; import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
@ -392,17 +391,14 @@ public class ReplaceExpressionPanel extends FramedPanel {
} }
ExpressionWrapper exWrapper; ExpressionWrapper exWrapper;
ExpressionWrapperEvent expressionEvent;
ExpressionWrapperNotification expressionWrapperNotification; ExpressionWrapperNotification expressionWrapperNotification;
switch (type) { switch (type) {
case Template: case Template:
exWrapper = new ExpressionWrapper( exWrapper = new ExpressionWrapper(
replaceValue, column.getTrId(),column); replaceValue, column.getTrId(), column);
expressionEvent = new ExpressionWrapperEvent( expressionWrapperNotification=new ExpressionWrapperNotification(exWrapper);
exWrapper); parent.applyReplaceColumnByExpression(expressionWrapperNotification);
Log.debug(expressionEvent.toString());
eventBus.fireEvent(expressionEvent);
close(); close();
break; break;
case Replace: case Replace:
@ -430,23 +426,17 @@ public class ReplaceExpressionPanel extends FramedPanel {
} }
ExpressionWrapper exWrapper; ExpressionWrapper exWrapper;
ExpressionWrapperEvent expressionEvent;
ExpressionWrapperNotification expressionWrapperNotification; ExpressionWrapperNotification expressionWrapperNotification;
C_ExpressionContainer replaceExpressionContainer; C_ExpressionContainer replaceExpressionContainer;
switch (type) { switch (type) {
case Template: case Template:
replaceExpressionContainer = new C_ExpressionContainer( replaceExpressionContainer = new C_ExpressionContainer(
C_ExpressionContainer.Contains.C_Expression, C_ExpressionContainer.Contains.C_Expression,
cReplaceExpression, replaceWidget.getReadableExpression()); cReplaceExpression, replaceWidget.getReadableExpression());
exWrapper = new ExpressionWrapper( exWrapper = new ExpressionWrapper(
replaceExpressionContainer, column.getTrId(), column); replaceExpressionContainer, column.getTrId(), column);
expressionEvent = new ExpressionWrapperEvent( expressionWrapperNotification=new ExpressionWrapperNotification(exWrapper);
exWrapper); parent.applyReplaceColumnByExpression(expressionWrapperNotification);
Log.debug(expressionEvent.toString());
eventBus.fireEvent(expressionEvent);
close();
break; break;
case Replace: case Replace:
case AddColumn: case AddColumn:

View File

@ -174,7 +174,6 @@ public class RuleDialog extends Window implements
if (listeners != null) { if (listeners != null) {
for (RuleDialogNotificationListener listener : listeners) { for (RuleDialogNotificationListener listener : listeners) {
listener.failed(caught); listener.failed(caught);
;
} }
} }
hide(); hide();

View File

@ -1,17 +1,18 @@
package org.gcube.portlets.user.td.expressionwidget.client; package org.gcube.portlets.user.td.expressionwidget.client;
import java.util.ArrayList;
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.resources.ExpressionResources;
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
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.TDGWTIsLockedException; 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.gwtservice.shared.exception.TDGWTSessionExpiredException;
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.event.SessionExpiredEvent;
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.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
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.ColumnData;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnMockUp; import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnMockUp;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode; import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
@ -29,15 +30,16 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/** /**
* *
* @author "Giancarlo Panichi" * @author "Giancarlo Panichi" <a
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class ColumnExpressionDialog extends Window { public class TemplateColumnExpressionDialog extends Window implements
HasExpressionWrapperNotificationListener {
private static final String WIDTH = "660px"; private static final String WIDTH = "660px";
private static final String HEIGHT = "426px"; private static final String HEIGHT = "426px";
private ArrayList<ExpressionWrapperNotificationListener> listeners;
private ColumnExpressionPanel columnExpressionPanel; private ColumnExpressionPanel columnExpressionPanel;
private C_Expression exp = null;
private ColumnData column = null; private ColumnData column = null;
private TRId trId; private TRId trId;
private String columnId = null; private String columnId = null;
@ -48,16 +50,15 @@ public class ColumnExpressionDialog extends Window {
* @param columnMockUp * @param columnMockUp
* @param eventBus * @param eventBus
*/ */
public ColumnExpressionDialog( public TemplateColumnExpressionDialog(ColumnMockUp columnMockUp, EventBus eventBus) {
ColumnMockUp columnMockUp, listeners = new ArrayList<ExpressionWrapperNotificationListener>();
EventBus eventBus) {
initWindow();
this.eventBus = eventBus; this.eventBus = eventBus;
column = new ColumnData(); column = new ColumnData();
column.setColumnId(columnMockUp.getColumnId()); column.setColumnId(columnMockUp.getColumnId());
column.setLabel(columnMockUp.getLabel()); column.setLabel(columnMockUp.getLabel());
column.setDataTypeName(columnMockUp.getColumnDataType().toString()); column.setDataTypeName(columnMockUp.getColumnDataType().toString());
column.setTypeCode(columnMockUp.getColumnType().toString()); column.setTypeCode(columnMockUp.getColumnType().toString());
initWindow();
create(); create();
} }
@ -68,12 +69,12 @@ public class ColumnExpressionDialog extends Window {
* @param columnId * @param columnId
* @param eventBus * @param eventBus
*/ */
public ColumnExpressionDialog(TRId trId, String columnId, public TemplateColumnExpressionDialog(TRId trId, String columnId, EventBus eventBus) {
EventBus eventBus) { listeners = new ArrayList<ExpressionWrapperNotificationListener>();
initWindow();
this.eventBus = eventBus; this.eventBus = eventBus;
this.trId = trId; this.trId = trId;
this.columnId = columnId; this.columnId = columnId;
initWindow();
load(); load();
} }
@ -100,7 +101,6 @@ public class ColumnExpressionDialog extends Window {
closeBtn.addSelectHandler(new SelectHandler() { closeBtn.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) { public void onSelect(SelectEvent event) {
close(); close();
} }
@ -108,15 +108,10 @@ public class ColumnExpressionDialog extends Window {
} }
protected void close (){ protected void close() {
ExpressionWrapper exWrapper=new ExpressionWrapper(); fireAborted();
ExpressionWrapperEvent expressionEvent = new ExpressionWrapperEvent(exWrapper);
Log.debug(expressionEvent.toString());
hide();
eventBus.fireEvent(expressionEvent);
} }
protected void create() { protected void create() {
if (column.getTypeCode() if (column.getTypeCode()
.compareTo(ColumnTypeCode.ANNOTATION.toString()) == 0 .compareTo(ColumnTypeCode.ANNOTATION.toString()) == 0
@ -148,18 +143,12 @@ public class ColumnExpressionDialog extends Window {
} }
} }
public C_Expression getExpression() { protected void onExpression(ExpressionWrapperNotification expressionWrapperNotification){
return exp; fireNotification(expressionWrapperNotification);
}
protected void setExpression(C_Expression exp) {
Log.debug("New Expression set:" + exp.toString());
this.exp = exp;
} }
protected void load() { protected void load() {
TDGWTServiceAsync.INSTANCE.getColumn(columnId,trId, TDGWTServiceAsync.INSTANCE.getColumn(columnId, trId,
new AsyncCallback<ColumnData>() { new AsyncCallback<ColumnData>() {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -174,10 +163,13 @@ public class ColumnExpressionDialog extends Window {
} else { } else {
Log.error("Error retrieving column: " Log.error("Error retrieving column: "
+ caught.getMessage()); + caught.getMessage());
UtilsGXT3.alert("Error","Error retrieving column: " UtilsGXT3.alert(
"Error",
"Error retrieving column: "
+ caught.getMessage()); + caught.getMessage());
} }
} }
fireFailed(caught);
} }
@ -191,4 +183,47 @@ public class ColumnExpressionDialog extends Window {
} }
@Override
public void addExpressionWrapperNotificationListener(
ExpressionWrapperNotificationListener handler) {
listeners.add(handler);
}
@Override
public void removeExpressionWrapperNotificationListener(
ExpressionWrapperNotificationListener handler) {
listeners.remove(handler);
}
private void fireNotification(ExpressionWrapperNotification expressionWrapperNotification) {
if (listeners != null) {
for (ExpressionWrapperNotificationListener listener : listeners) {
listener.onExpression(expressionWrapperNotification);
}
}
hide();
}
private void fireAborted() {
if (listeners != null) {
for (ExpressionWrapperNotificationListener listener : listeners) {
listener.aborted();
}
}
hide();
}
private void fireFailed(Throwable caught) {
if (listeners != null) {
for (ExpressionWrapperNotificationListener listener : listeners) {
listener.failed(caught);
}
}
hide();
}
} }

View File

@ -58,6 +58,6 @@ public interface ExpressionService extends RemoteService {
public String saveColumnRule(RuleDescriptionData ruleDescriptionData) public String saveColumnRule(RuleDescriptionData ruleDescriptionData)
throws TDGWTServiceException; throws TDGWTServiceException;
public void removeRuleById(String ruleId) throws TDGWTServiceException; public void removeRulesById(ArrayList<RuleDescriptionData> rules) throws TDGWTServiceException;
} }

View File

@ -44,5 +44,5 @@ public interface ExpressionServiceAsync {
void saveColumnRule(RuleDescriptionData ruleDescriptionData, void saveColumnRule(RuleDescriptionData ruleDescriptionData,
AsyncCallback<String> callback); AsyncCallback<String> callback);
void removeRuleById(String ruleId, AsyncCallback<Void> callback); void removeRulesById(ArrayList<RuleDescriptionData> rules, AsyncCallback<Void> callback);
} }

View File

@ -237,7 +237,8 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
C_Expression cexp = parser.parse(serviceExpression); C_Expression cexp = parser.parse(serviceExpression);
RuleDescriptionData ruleData = new RuleDescriptionData( RuleDescriptionData ruleData = new RuleDescriptionData(
ruleDescription.getId(), ruleDescription.getName(), ruleDescription.getId(), ruleDescription.getName(),
ruleDescription.getDescription(),ruleDescription.getOwner(), ruleDescription.getDescription(),
ruleDescription.getOwner(),
RuleScopeMap.map(ruleDescription.getScope()), cexp); RuleScopeMap.map(ruleDescription.getScope()), cexp);
rulesDes.add(ruleData); rulesDes.add(ruleData);
@ -288,7 +289,8 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
C_Expression cexp = parser.parse(serviceExpression); C_Expression cexp = parser.parse(serviceExpression);
RuleDescriptionData ruleData = new RuleDescriptionData( RuleDescriptionData ruleData = new RuleDescriptionData(
ruleDescription.getId(), ruleDescription.getName(), ruleDescription.getId(), ruleDescription.getName(),
ruleDescription.getDescription(),ruleDescription.getOwner(), ruleDescription.getDescription(),
ruleDescription.getOwner(),
RuleScopeMap.map(ruleDescription.getScope()), cexp); RuleScopeMap.map(ruleDescription.getScope()), cexp);
rulesDes.add(ruleData); rulesDes.add(ruleData);
@ -317,8 +319,7 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public String saveColumnRule( public String saveColumnRule(RuleDescriptionData ruleDescriptionData)
RuleDescriptionData ruleDescriptionData)
throws TDGWTServiceException { throws TDGWTServiceException {
try { try {
HttpSession session = this.getThreadLocalRequest().getSession(); HttpSession session = this.getThreadLocalRequest().getSession();
@ -345,15 +346,16 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
RuleColumnType ruleColumnType = RuleColumnTypeMap RuleColumnType ruleColumnType = RuleColumnTypeMap
.map(ruleDescriptionData.getTdRuleColumnType()); .map(ruleDescriptionData.getTdRuleColumnType());
RuleId ruleId=service.saveColumnRule(ruleDescriptionData.getName(), RuleId ruleId = service.saveColumnRule(
ruleDescriptionData.getName(),
ruleDescriptionData.getDescription(), conditionExpression, ruleDescriptionData.getDescription(), conditionExpression,
ruleColumnType); ruleColumnType);
logger.debug("RuleId: "+ruleId); logger.debug("RuleId: " + ruleId);
String ruleIdent=null; String ruleIdent = null;
if(ruleId!=null){ if (ruleId != null) {
ruleIdent=String.valueOf(ruleId.getValue()); ruleIdent = String.valueOf(ruleId.getValue());
} }
return ruleIdent; return ruleIdent;
@ -374,41 +376,31 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
} }
/** /**
* *
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public void removeRuleById( public void removeRulesById(ArrayList<RuleDescriptionData> rules)
String ruleId)
throws TDGWTServiceException { throws TDGWTServiceException {
try { try {
HttpSession session = this.getThreadLocalRequest().getSession(); HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getAslSession(session); ASLSession aslSession = SessionUtil.getAslSession(session);
logger.debug("RemoveRuleById() :" + ruleId); logger.debug("RemoveRuleById() :" + rules);
if(ruleId==null|| ruleId.isEmpty()){ if (rules == null || !(rules.size() > 0)) {
throw new TDGWTServiceException("Error removing the rule, ruleId="+ruleId); throw new TDGWTServiceException(
"Error removing the rule, no rules selected");
} }
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();
long rId=0; for (RuleDescriptionData ruleDescriptionData : rules) {
RuleId id = new RuleId(ruleDescriptionData.getId());
try{
rId=Long.parseLong(ruleId);
} catch(NumberFormatException e){
throw new TDGWTServiceException("Error removing the rule, ruleId="+ruleId);
}
RuleId id=new RuleId(rId);
service.removeRuleById(id); service.removeRuleById(id);
}
return; return;
} catch (TDGWTServiceException e) { } catch (TDGWTServiceException e) {
@ -419,7 +411,7 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
} catch (Throwable e) { } catch (Throwable e) {
logger.error("Error in getRule(): " + e.getLocalizedMessage()); logger.error("Error in removeRuleById(): " + e.getLocalizedMessage());
e.printStackTrace(); e.printStackTrace();
throw new TDGWTServiceException("Error removing the rules: " throw new TDGWTServiceException("Error removing the rules: "
+ e.getLocalizedMessage()); + e.getLocalizedMessage());
@ -427,8 +419,6 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
} }
/** /**
* Retrieve and set Tabular Resource Type * Retrieve and set Tabular Resource Type
* *