Updated Rules

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@114301 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-21 14:54:58 +00:00
parent 12619508bf
commit b7ab7cc8fb
7 changed files with 131 additions and 34 deletions

View File

@ -906,6 +906,9 @@ public class TabularDataController {
case RULE_APPLY: case RULE_APPLY:
openApplyRule(); openApplyRule();
break; break;
case RULES_APPLIED_ON_TABULAR_RESOURCE:
openRulesAppliedOnTabularResource();
break;
case RULE_SHARE: case RULE_SHARE:
openShareRule(); openShareRule();
break; break;
@ -1752,6 +1755,22 @@ public class TabularDataController {
} }
private void openRulesAppliedOnTabularResource() {
Log.debug("Request Open Rules Applied on TabularResource Dialog");
if (trId != null) {
RuleApplyDialog raDialog = new RuleApplyDialog(
trId, eventBus);
raDialog.show();
} else {
Log.error("TRId is null");
UtilsGXT3.alert("Error",
"No current tabular resource present");
}
}
private void callDiscard() { private void callDiscard() {
HistoryDiscard historyDiscard = new HistoryDiscard(eventBus); HistoryDiscard historyDiscard = new HistoryDiscard(eventBus);

View File

@ -41,6 +41,7 @@ public class RuleToolBar {
private TextButton ruleOpenButton; private TextButton ruleOpenButton;
private TextButton ruleDeleteButton; private TextButton ruleDeleteButton;
private TextButton ruleApplyButton; private TextButton ruleApplyButton;
private TextButton ruleTabularResourceButton;
// private TextButton ruleShareButton; // private TextButton ruleShareButton;
@ -105,6 +106,22 @@ public class RuleToolBar {
ruleLayout.setWidget(0, 1, ruleDeleteButton); ruleLayout.setWidget(0, 1, ruleDeleteButton);
ruleLayout.getFlexCellFormatter().setRowSpan(0, 1, 2); ruleLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
ruleTabularResourceButton = new TextButton(msgs.ruleTabularResourceButton(),
TabularDataResources.INSTANCE.ruleTabularResource32());
ruleTabularResourceButton.disable();
ruleTabularResourceButton.setScale(ButtonScale.LARGE);
ruleTabularResourceButton.setIconAlign(IconAlign.TOP);
ruleTabularResourceButton.setToolTip(msgs.ruleTabularResourceButtonToolTip());
ruleTabularResourceButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
ruleTabularResourceButton.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new RibbonEvent(RibbonType.RULES_APPLIED_ON_TABULAR_RESOURCE));
}
});
ruleLayout.setWidget(0, 2, ruleTabularResourceButton);
ruleLayout.getFlexCellFormatter().setRowSpan(0, 2, 2);
/* /*
@ -204,6 +221,7 @@ public class RuleToolBar {
ruleNewButton.enable(); ruleNewButton.enable();
ruleDeleteButton.enable(); ruleDeleteButton.enable();
ruleApplyButton.disable(); ruleApplyButton.disable();
ruleTabularResourceButton.disable();
// ruleShareButton.enable(); // ruleShareButton.enable();
break; break;
case TR_CLOSE: case TR_CLOSE:
@ -212,6 +230,7 @@ public class RuleToolBar {
ruleNewButton.enable(); ruleNewButton.enable();
ruleDeleteButton.enable(); ruleDeleteButton.enable();
ruleApplyButton.disable(); ruleApplyButton.disable();
ruleTabularResourceButton.disable();
// ruleShareButton.enable(); // ruleShareButton.enable();
break; break;
case TR_OPEN: case TR_OPEN:
@ -221,6 +240,7 @@ public class RuleToolBar {
ruleNewButton.enable(); ruleNewButton.enable();
ruleDeleteButton.enable(); ruleDeleteButton.enable();
ruleApplyButton.enable(); ruleApplyButton.enable();
ruleTabularResourceButton.enable();
// ruleShareButton.enable(); // ruleShareButton.enable();
break; break;
case WIZARD_OPEN: case WIZARD_OPEN:
@ -228,6 +248,7 @@ public class RuleToolBar {
ruleNewButton.disable(); ruleNewButton.disable();
ruleDeleteButton.disable(); ruleDeleteButton.disable();
ruleApplyButton.disable(); ruleApplyButton.disable();
ruleTabularResourceButton.disable();
// ruleShareButton.disable(); // ruleShareButton.disable();
break; break;
default: default:

View File

@ -31,6 +31,12 @@ public interface RuleToolBarMessages extends Messages {
@DefaultMessage("Share") @DefaultMessage("Share")
String ruleShareButtonToolTip(); String ruleShareButtonToolTip();
@DefaultMessage("Applied")
String ruleTabularResourceButton();
@DefaultMessage("Applied")
String ruleTabularResourceButtonToolTip();
@DefaultMessage("On Column") @DefaultMessage("On Column")
String ruleOnColumnGroupHeadingText(); String ruleOnColumnGroupHeadingText();
@ -49,5 +55,7 @@ public interface RuleToolBarMessages extends Messages {
} }

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.td.client.rule; package org.gcube.portlets.user.td.client.rule;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import org.gcube.portlets.user.td.client.resource.TabularDataResources; import org.gcube.portlets.user.td.client.resource.TabularDataResources;
@ -11,6 +12,7 @@ import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
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.gwtservice.shared.rule.AppliedRulesResponseData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyColumnRulesSession; import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyColumnRulesSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData; import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3; import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
@ -87,8 +89,9 @@ public class RuleApplyPanel extends FramedPanel {
private TRId trId; private TRId trId;
private ArrayList<ColumnData> columns; private ArrayList<ColumnData> columns;
private ColumnData column; private ColumnData column;
private AppliedRulesResponseData appliedRuleResponseData;
private ArrayList<RuleDescriptionData> applicableRules; private ArrayList<RuleDescriptionData> applicableRules;
private ArrayList<RuleDescriptionData> appliesRules; private ArrayList<RuleDescriptionData> appliedRules;
private TextButton btnApply; private TextButton btnApply;
private TextButton btnClose; private TextButton btnClose;
@ -103,7 +106,6 @@ public class RuleApplyPanel extends FramedPanel {
this.parent = parent; this.parent = parent;
this.trId = trId; this.trId = trId;
applicableRules = new ArrayList<RuleDescriptionData>(); applicableRules = new ArrayList<RuleDescriptionData>();
appliesRules = new ArrayList<RuleDescriptionData>();
Log.debug("RuleApplyPanel"); Log.debug("RuleApplyPanel");
setWidth(WIDTH); setWidth(WIDTH);
@ -154,7 +156,8 @@ public class RuleApplyPanel extends FramedPanel {
"The requested columns is null"); "The requested columns is null");
} }
columns = result; columns = result;
create();
getAppliedBaseColumnRules();
} }
}); });
@ -212,8 +215,6 @@ public class RuleApplyPanel extends FramedPanel {
sb.append(ruleApplyTemplates.format(value)); sb.append(ruleApplyTemplates.format(value));
} }
}); });
ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, String>( ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, String>(
propsRules.description(), 120, "Description"); propsRules.description(), 120, "Description");
@ -400,6 +401,21 @@ public class RuleApplyPanel extends FramedPanel {
protected void updateRulesInGrids(ColumnData columnData) { protected void updateRulesInGrids(ColumnData columnData) {
column = columnData; column = columnData;
HashMap<String, ArrayList<RuleDescriptionData>> columnRuleMapping = appliedRuleResponseData
.getColumnRuleMapping();
if (columnRuleMapping != null) {
ArrayList<RuleDescriptionData> applied = columnRuleMapping
.get(columnData.getColumnId());
if (applied != null) {
appliedRules = applied;
appliesRulesStore.clear();
appliesRulesStore.addAll(new ArrayList<RuleDescriptionData>(
applied));
}
}
getApplicableBaseColumnRules(); getApplicableBaseColumnRules();
} }
@ -414,10 +430,10 @@ public class RuleApplyPanel extends FramedPanel {
eventBus.fireEvent(new SessionExpiredEvent( eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
Log.error("Error retrieving applicable rules:" Log.error(caught.getLocalizedMessage());
+ caught.getLocalizedMessage()); UtilsGXT3.alert(
UtilsGXT3.alert("Error retrieving rules", "Error retrieving applicable rules",
"Error retrieving applicable rules"); caught.getLocalizedMessage());
} }
} }
@ -425,18 +441,40 @@ public class RuleApplyPanel extends FramedPanel {
@Override @Override
public void onSuccess(ArrayList<RuleDescriptionData> result) { public void onSuccess(ArrayList<RuleDescriptionData> result) {
Log.trace("loaded " + result.size() + " Rules"); Log.trace("loaded " + result.size() + " Rules");
if (appliedRules != null && appliedRules.size() > 0) {
ArrayList<RuleDescriptionData> removableRules = new ArrayList<RuleDescriptionData>();
for (RuleDescriptionData ruleApplied : appliedRules) {
for (RuleDescriptionData ruleApplicable : result) {
if (ruleApplicable.equals(ruleApplied)) {
removableRules.add(ruleApplicable);
break;
}
}
}
result.removeAll(removableRules);
}
applicableRules = result; applicableRules = result;
getAppliesBaseColumnRules();
applicableRulesStore.clear();
applicableRulesStore
.addAll(new ArrayList<RuleDescriptionData>(
applicableRules));
forceLayout();
} }
}); });
} }
protected void getAppliesBaseColumnRules() { protected void getAppliedBaseColumnRules() {
ExpressionServiceAsync.INSTANCE.getApplicableBaseColumnRules(column, ExpressionServiceAsync.INSTANCE.getAppliedRulesByTabularResourceId(
new AsyncCallback<ArrayList<RuleDescriptionData>>() { trId, new AsyncCallback<AppliedRulesResponseData>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -444,28 +482,18 @@ public class RuleApplyPanel extends FramedPanel {
eventBus.fireEvent(new SessionExpiredEvent( eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
Log.error("Error retrieving applicable rules:" Log.error(caught.getLocalizedMessage());
+ caught.getLocalizedMessage()); UtilsGXT3.alert("Error retrieving applied rules",
UtilsGXT3.alert("Error retrieving rules", caught.getLocalizedMessage());
"Error retrieving applicable rules");
} }
} }
@Override @Override
public void onSuccess(ArrayList<RuleDescriptionData> result) { public void onSuccess(AppliedRulesResponseData result) {
Log.trace("loaded " + result.size() + " Rules"); Log.trace("AppliedRuleResponseData: " + result);
appliesRules = result; appliedRuleResponseData = result;
applicableRulesStore.clear(); create();
applicableRulesStore
.addAll(new ArrayList<RuleDescriptionData>(
applicableRules));
appliesRulesStore.clear();
appliesRulesStore
.addAll(new ArrayList<RuleDescriptionData>(
appliesRules));
forceLayout();
} }
}); });
@ -485,12 +513,27 @@ public class RuleApplyPanel extends FramedPanel {
ArrayList<RuleDescriptionData> rulesToBeApplied = new ArrayList<RuleDescriptionData>(); ArrayList<RuleDescriptionData> rulesToBeApplied = new ArrayList<RuleDescriptionData>();
for (RuleDescriptionData ruleSelected : selectedRules) { for (RuleDescriptionData ruleSelected : selectedRules) {
boolean ruleApplied = false; boolean ruleApplied = false;
for (RuleDescriptionData ruleAlreadyApplied : appliesRules) { HashMap<String, ArrayList<RuleDescriptionData>> columnRuleMapping = appliedRuleResponseData
if (ruleSelected.getId() == ruleAlreadyApplied.getId()) { .getColumnRuleMapping();
ruleApplied = true;
break; if (columnRuleMapping != null) {
ArrayList<RuleDescriptionData> applied = columnRuleMapping
.get(column.getColumnId());
if (applied != null) {
for (RuleDescriptionData ruleAlreadyApplied : applied) {
if (ruleSelected.getId() == ruleAlreadyApplied
.getId()) {
ruleApplied = true;
break;
}
}
} else {
} }
} else {
} }
if (ruleApplied == false) { if (ruleApplied == false) {
rulesToBeApplied.add(ruleSelected); rulesToBeApplied.add(ruleSelected);
} }

View File

@ -5,6 +5,8 @@ ruleDeleteButton = Delete
ruleDeleteButtonToolTip = Delete ruleDeleteButtonToolTip = Delete
ruleShareButton = Share ruleShareButton = Share
ruleShareButtonToolTip = Share ruleShareButtonToolTip = Share
ruleTabularResourceButton = Applied
ruleTabularResourceButtonToolTip = Applied
ruleOnColumnGroupHeadingText = On Column ruleOnColumnGroupHeadingText = On Column
ruleNewButton = New ruleNewButton = New
ruleNewButtonToolTip = New ruleNewButtonToolTip = New

View File

@ -5,6 +5,8 @@ ruleDeleteButton = Borrar
ruleDeleteButtonToolTip = Borrar ruleDeleteButtonToolTip = Borrar
ruleShareButton = Cuota ruleShareButton = Cuota
ruleShareButtonToolTip = Cuota ruleShareButtonToolTip = Cuota
ruleTabularResourceButton = Aplicado
ruleTabularResourceButtonToolTip = Aplicado
ruleOnColumnGroupHeadingText = On Columna ruleOnColumnGroupHeadingText = On Columna
ruleNewButton = Nuevo ruleNewButton = Nuevo
ruleNewButtonToolTip = Nuevo ruleNewButtonToolTip = Nuevo

View File

@ -5,6 +5,8 @@ ruleDeleteButton = Elimina
ruleDeleteButtonToolTip = Elimina ruleDeleteButtonToolTip = Elimina
ruleShareButton = Condividi ruleShareButton = Condividi
ruleShareButtonToolTip = Condividi ruleShareButtonToolTip = Condividi
ruleTabularResourceButton = Applicate
ruleTabularResourceButtonToolTip = Applicate
ruleOnColumnGroupHeadingText = Su Colonna ruleOnColumnGroupHeadingText = Su Colonna
ruleNewButton = Nuova ruleNewButton = Nuova
ruleNewButtonToolTip = Nuova ruleNewButtonToolTip = Nuova