refs #3483: TDM - improve the quality of the error messages for Rules

https://support.d4science.org/issues/3483

Fixed Rules share

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@128126 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-04-18 16:17:48 +00:00
parent c39202fa9d
commit cee9e25722
9 changed files with 216 additions and 62 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/tabular-data-manager-2.9.0-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/tabular-data-manager-2.10.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/tabular-data-manager-2.9.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="target/tabular-data-manager-2.10.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
@ -45,5 +45,5 @@
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/> <classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/> <classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
<classpathentry kind="output" path="target/tabular-data-manager-2.9.0-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/tabular-data-manager-2.10.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -1,7 +1,8 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.portlets-user.tabular-data-portlet.2-10-0" <Changeset component="org.gcube.portlets-user.tabular-data-portlet.2-10-0"
date="2016-05-01"> date="2016-05-01">
<Change>Fix back button behavior [issue #3249]</Change> <Change>Fixed back button behavior [issue #3249]</Change>
<Change>Fixed share of rules [Ticket #3483]</Change>
</Changeset> </Changeset>
<Changeset component="org.gcube.portlets-user.tabular-data-portlet.2-9-0" <Changeset component="org.gcube.portlets-user.tabular-data-portlet.2-9-0"
date="2015-10-15"> date="2015-10-15">

24
pom.xml
View File

@ -76,6 +76,17 @@
<version>1.0.1</version> <version>1.0.1</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<!--
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-authorization</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
<scope>runtime</scope>
</dependency> -->
<!-- Storage for CSV temp --> <!-- Storage for CSV temp -->
<dependency> <dependency>
<groupId>org.gcube.contentmanagement</groupId> <groupId>org.gcube.contentmanagement</groupId>
@ -169,6 +180,19 @@
</dependency> </dependency>
<!-- Authorization
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-authorization</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
<scope>provided</scope>
</dependency> -->
<!-- Social --> <!-- Social -->
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>

View File

@ -143,6 +143,10 @@ public class TabularDataController {
private TabularDataControllerMessages msgs; private TabularDataControllerMessages msgs;
private CommonMessages msgsCommon; private CommonMessages msgsCommon;
private enum CheckFor {
ApplyColumnRule, ApplyTableRule, ApplyTemplate;
}
public TabularDataController() { public TabularDataController() {
eventBus = new SimpleEventBus(); eventBus = new SimpleEventBus();
initMessages(); initMessages();
@ -795,7 +799,7 @@ public class TabularDataController {
eventBus.fireEvent(new UIStateEvent(UIStateType.WIZARD_OPEN)); eventBus.fireEvent(new UIStateEvent(UIStateType.WIZARD_OPEN));
} }
public void doRibbonCommand(RibbonEvent event) { private void doRibbonCommand(RibbonEvent event) {
RibbonType type = event.getRibbonType(); RibbonType type = event.getRibbonType();
Log.trace("doRibbonEvent ribbonType: " + type); Log.trace("doRibbonEvent ribbonType: " + type);
try { try {
@ -1084,8 +1088,8 @@ public class TabularDataController {
} }
// TODO
public void doBackgroundRequestCommand(BackgroundRequestEvent event) { private void doBackgroundRequestCommand(BackgroundRequestEvent event) {
BackgroundRequestType type = event.getBackgroundRequestType(); BackgroundRequestType type = event.getBackgroundRequestType();
Log.trace("doBackgroundRequestEvent BackgroundRequestType: " + type); Log.trace("doBackgroundRequestEvent BackgroundRequestType: " + type);
try { try {
@ -1746,9 +1750,8 @@ public class TabularDataController {
public void onSuccess() { public void onSuccess() {
Log.debug("Template Apply call"); Log.debug("Template Apply call");
if (trId != null) { if (trId != null) {
TemplateApplyDialog taDialog = new TemplateApplyDialog( retrieveTabResourceInformation(CheckFor.ApplyTemplate);
trId, eventBus);
taDialog.show();
} else { } else {
Log.error("TRId is null"); Log.error("TRId is null");
UtilsGXT3.alert(msgsCommon.error(), UtilsGXT3.alert(msgsCommon.error(),
@ -1763,11 +1766,33 @@ public class TabularDataController {
} }
private void openTemplateApplyIsOwner(final TabResource tabResource) {
if (userInfo.getUsername().compareTo(tabResource.getOwnerLogin()) == 0) {
GWT.runAsync(new RunAsyncCallback() {
public void onSuccess() {
TemplateApplyDialog taDialog = new TemplateApplyDialog(
trId, eventBus);
taDialog.show();
}
public void onFailure(Throwable reason) {
asyncCodeLoadingFailed(reason);
}
});
} else {
UtilsGXT3.info(msgsCommon.attention(),
msgs.attentionNotOwnerTemplateApply());
}
}
private void openTemplateShare() { private void openTemplateShare() {
GWT.runAsync(new RunAsyncCallback() { GWT.runAsync(new RunAsyncCallback() {
public void onSuccess() { public void onSuccess() {
Log.debug("Template Share call"); Log.debug("Template Share call");
TemplateShareDialog tsDialog = new TemplateShareDialog(eventBus); TemplateShareDialog tsDialog = new TemplateShareDialog(
userInfo, eventBus);
tsDialog.show(); tsDialog.show();
} }
@ -1784,7 +1809,7 @@ public class TabularDataController {
public void onSuccess() { public void onSuccess() {
Log.debug("Open Share Window"); Log.debug("Open Share Window");
@SuppressWarnings("unused") @SuppressWarnings("unused")
TRShare trShare = new TRShare(trId, eventBus); TRShare trShare = new TRShare(userInfo, trId, eventBus);
} }
public void onFailure(Throwable reason) { public void onFailure(Throwable reason) {
@ -1847,7 +1872,7 @@ public class TabularDataController {
GWT.runAsync(new RunAsyncCallback() { GWT.runAsync(new RunAsyncCallback() {
public void onSuccess() { public void onSuccess() {
Log.debug("Request Open Share Rule Dialog"); Log.debug("Request Open Share Rule Dialog");
RuleShareDialog cfDialog = new RuleShareDialog(eventBus); RuleShareDialog cfDialog = new RuleShareDialog(userInfo, eventBus);
cfDialog.show(); cfDialog.show();
} }
@ -1873,24 +1898,83 @@ public class TabularDataController {
} }
private void openOnColumnApplyRule() { private void openOnColumnApplyRule() {
GWT.runAsync(new RunAsyncCallback() { Log.debug("Request Open On Column Apply Rule Dialog");
public void onSuccess() { if (trId != null) {
Log.debug("Request Open On Column Apply Rule Dialog"); retrieveTabResourceInformation(CheckFor.ApplyColumnRule);
if (trId != null) { } else {
Log.error("TRId is null");
UtilsGXT3.alert(msgsCommon.error(),
msgs.noCurrentTabularResourcePresent());
}
}
private void retrieveTabResourceInformation(final CheckFor checkFor) {
TDGWTServiceAsync.INSTANCE.getTabResourceInformation(trId,
new AsyncCallback<TabResource>() {
public void onSuccess(TabResource tabResource) {
Log.info("Retrieved TR: " + tabResource);
if (checkFor == null) {
UtilsGXT3.alert(msgsCommon.error(),
"Error retrieving tabular resource informations!");
Log.error("CheckFor is null");
return;
}
switch (checkFor) {
case ApplyColumnRule:
openOnColumnApplyRuleIsOwner(tabResource);
break;
case ApplyTableRule:
openOnTableApplyRuleIsOwner(tabResource);
break;
case ApplyTemplate:
openTemplateApplyIsOwner(tabResource);
break;
default:
break;
}
}
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(msgsCommon.errorLocked(),
caught.getLocalizedMessage());
} else {
Log.error("Error retrienving properties: "
+ caught.getLocalizedMessage());
}
}
}
});
}
private void openOnColumnApplyRuleIsOwner(final TabResource tabResource) {
if (userInfo.getUsername().compareTo(tabResource.getOwnerLogin()) == 0) {
GWT.runAsync(new RunAsyncCallback() {
public void onSuccess() {
RuleOnColumnApplyDialog raDialog = new RuleOnColumnApplyDialog( RuleOnColumnApplyDialog raDialog = new RuleOnColumnApplyDialog(
trId, eventBus); trId, eventBus);
raDialog.show(); raDialog.show();
} else {
Log.error("TRId is null");
UtilsGXT3.alert(msgsCommon.error(),
msgs.noCurrentTabularResourcePresent());
} }
}
public void onFailure(Throwable reason) { public void onFailure(Throwable reason) {
asyncCodeLoadingFailed(reason); asyncCodeLoadingFailed(reason);
} }
});
});
} else {
UtilsGXT3.info(msgsCommon.attention(),
msgs.attentionNotOwnerRuleApply());
}
} }
private void openOnTableNewRule() { private void openOnTableNewRule() {
@ -1935,10 +2019,20 @@ public class TabularDataController {
} }
// TODO
private void openOnTableApplyRule() { private void openOnTableApplyRule() {
Log.debug("Request Open On Table Apply Rule Dialog"); Log.debug("Request Open On Table Apply Rule Dialog");
if (trId != null) { if (trId != null) {
retrieveTabResourceInformation(CheckFor.ApplyTableRule);
} else {
Log.error("TRId is null");
UtilsGXT3.alert(msgsCommon.error(),
msgs.noCurrentTabularResourcePresent());
}
}
private void openOnTableApplyRuleIsOwner(TabResource tabResource) {
if (userInfo.getUsername().compareTo(tabResource.getOwnerLogin()) == 0) {
GWT.runAsync(new RunAsyncCallback() { GWT.runAsync(new RunAsyncCallback() {
public void onSuccess() { public void onSuccess() {
openWizard(); openWizard();
@ -1975,11 +2069,9 @@ public class TabularDataController {
asyncCodeLoadingFailed(reason); asyncCodeLoadingFailed(reason);
} }
}); });
} else { } else {
Log.error("TRId is null"); UtilsGXT3.info(msgsCommon.attention(),
UtilsGXT3.alert(msgsCommon.error(), msgs.attentionNotOwnerRuleApply());
msgs.noCurrentTabularResourcePresent());
} }
} }

View File

@ -21,63 +21,70 @@ public interface TabularDataControllerMessages extends Messages {
@DefaultMessage("Error in close TR: {0}") @DefaultMessage("Error in close TR: {0}")
String errorInCloseTR(String localizedMessage); String errorInCloseTR(String localizedMessage);
@DefaultMessage("Error in set Active TR: {0}") @DefaultMessage("Error in set Active TR: {0}")
String errorInSetActiveTR(String localizedMessage); String errorInSetActiveTR(String localizedMessage);
@DefaultMessage("Confirm") @DefaultMessage("Confirm")
String confirm(); String confirm();
@DefaultMessage("Are you sure you want to delete the tabular resource?") @DefaultMessage("Are you sure you want to delete the tabular resource?")
String areYouSureYouWantToDeleteTheTabularResource(); String areYouSureYouWantToDeleteTheTabularResource();
@DefaultMessage("No tabular resource present") @DefaultMessage("No tabular resource present")
String noTabularResourcePresent(); String noTabularResourcePresent();
@DefaultMessage("No current tabular resource present!") @DefaultMessage("No current tabular resource present!")
String noCurrentTabularResourcePresent(); String noCurrentTabularResourcePresent();
@DefaultMessage("SDMX Import") @DefaultMessage("SDMX Import")
String sdmxImport(); String sdmxImport();
@DefaultMessage("CSV Export") @DefaultMessage("CSV Export")
String csvExport(); String csvExport();
@DefaultMessage("JSON Export") @DefaultMessage("JSON Export")
String jsonExport(); String jsonExport();
@DefaultMessage("SDMX Export") @DefaultMessage("SDMX Export")
String sdmxExport(); String sdmxExport();
@DefaultMessage("Extract Codelist") @DefaultMessage("Extract Codelist")
String extractCodelist(); String extractCodelist();
@DefaultMessage("Codelist Mapping Import") @DefaultMessage("Codelist Mapping Import")
String codelistMappingImport(); String codelistMappingImport();
@DefaultMessage("Union") @DefaultMessage("Union")
String union(); String union();
@DefaultMessage("Replace By External Columns") @DefaultMessage("Replace By External Columns")
String replaceByExternalColumns(); String replaceByExternalColumns();
@DefaultMessage("Charts Creation") @DefaultMessage("Charts Creation")
String chartsCreation(); String chartsCreation();
@DefaultMessage("Map Creation") @DefaultMessage("Map Creation")
String mapCreation(); String mapCreation();
@DefaultMessage("CSV Import") @DefaultMessage("CSV Import")
String csvImport(); String csvImport();
@DefaultMessage("Error on set Tabular Resource: {0}") @DefaultMessage("Error on set Tabular Resource: {0}")
String errorOnSetTabularResource(String localizedMessage); String errorOnSetTabularResource(String localizedMessage);
@DefaultMessage("No row selected!") @DefaultMessage("No row selected!")
String noRowSelected(); String noRowSelected();
@DefaultMessage("No cell selected!") @DefaultMessage("No cell selected!")
String noCellSelected(); String noCellSelected();
@DefaultMessage("In order to apply a template you must be the owner of the tabular resource. "
+ "You are not the owner of this tabular resource!")
String attentionNotOwnerTemplateApply();
@DefaultMessage("In order to apply a rule you must be the owner of the tabular resource."
+ "You are not the owner of this tabular resource!")
String attentionNotOwnerRuleApply();
} }

View File

@ -2,9 +2,13 @@ package org.gcube.portlets.user.td.client.template;
import org.gcube.portlets.user.td.client.resource.TabularDataResources; import org.gcube.portlets.user.td.client.resource.TabularDataResources;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData; import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.user.UserInfo;
import org.gcube.portlets.user.td.sharewidget.client.TemplateShare; import org.gcube.portlets.user.td.sharewidget.client.TemplateShare;
import org.gcube.portlets.user.td.widgetcommonevent.client.CommonMessages;
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.web.bindery.event.shared.EventBus; import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.widget.core.client.Window; import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.event.SelectEvent; import com.sencha.gxt.widget.core.client.event.SelectEvent;
@ -18,14 +22,17 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
*/ */
public class TemplateShareDialog extends Window { public class TemplateShareDialog extends Window {
private static final String WIDTH = "850px"; private static final String WIDTH = "850px";
private static final String HEIGHT = "530px"; private static final String HEIGHT = "530px";
private EventBus eventBus; private EventBus eventBus;
private UserInfo userInfo;
private CommonMessages msgsCommon;
public TemplateShareDialog(EventBus eventBus) { public TemplateShareDialog(UserInfo userInfo, EventBus eventBus) {
this.eventBus = eventBus; this.eventBus = eventBus;
this.userInfo = userInfo;
initMessages();
initWindow(); initWindow();
TemplateSharePanel templateDeletePanel = new TemplateSharePanel(this, TemplateSharePanel templateDeletePanel = new TemplateSharePanel(this,
eventBus); eventBus);
add(templateDeletePanel); add(templateDeletePanel);
@ -44,6 +51,11 @@ public class TemplateShareDialog extends Window {
} }
private void initMessages() {
//msgs = GWT.create(TabularDataControllerMessages.class);
msgsCommon = GWT.create(CommonMessages.class);
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
@ -64,13 +76,19 @@ public class TemplateShareDialog extends Window {
hide(); hide();
} }
public void templateShare(TemplateData templateData) { public void templateShare(TemplateData templateData) {
Log.debug("Share Window"); Log.debug("Share Window");
@SuppressWarnings("unused") if (userInfo.getUsername().compareTo(templateData.getOwnerLogin()) == 0) {
TemplateShare templateShare = new TemplateShare(templateData, eventBus); @SuppressWarnings("unused")
close(); TemplateShare templateShare = new TemplateShare(userInfo,
templateData, eventBus);
close();
} else {
UtilsGXT3
.info(msgsCommon.attention(),
"In order to share a template you must be the owner of the template. "
+ "You are not the owner of this template!");
}
} }
} }

View File

@ -21,3 +21,7 @@ mapCreation = Map Creation
errorOnSetTabularResource = Error on set Tabular Resource: {0} errorOnSetTabularResource = Error on set Tabular Resource: {0}
noRowSelected = No row selected! noRowSelected = No row selected!
noCellSelected = No cell selected! noCellSelected = No cell selected!
attentionNotOwnerTemplateApply = In order to apply a template you must be the owner of the Tabular Resource. \
You are not the owner of this Tabular Resource!
attentionNotOwnerRuleApply = In order to apply a rule you must be the owner of the Tabular Resource. \
You are not the owner of this Tabular Resource!

View File

@ -20,4 +20,8 @@ chartsCreation = Crea gráfico
mapCreation = Crea Mapa mapCreation = Crea Mapa
errorOnSetTabularResource = Error en poner la Tabular Resource: {0} errorOnSetTabularResource = Error en poner la Tabular Resource: {0}
noRowSelected = Ninguna línea seleccionada! noRowSelected = Ninguna línea seleccionada!
noCellSelected = Ninguna célula selezionata! noCellSelected = Ninguna célula selezionata!
attentionNotOwnerTemplateApply = Con el fin de aplicar una plantilla que debe ser el propietario de la Tabular Resource. \
Usted no es el propietario de este Tablurar Resource!
attentionNotOwnerRuleApply = Con el fin de aplicar una regla debe ser el propietario de la Tabular Resource. \
Usted no es el propietario de este Tabular Resource!

View File

@ -20,4 +20,8 @@ chartsCreation = Crea Grafico
mapCreation = Crea Mappa mapCreation = Crea Mappa
errorOnSetTabularResource = Errore nel settare la Tabular Resource: {0} errorOnSetTabularResource = Errore nel settare la Tabular Resource: {0}
noRowSelected = Nessuna riga selezionata! noRowSelected = Nessuna riga selezionata!
noCellSelected = Nessuna cella selezionata! noCellSelected = Nessuna cella selezionata!
attentionNotOwnerTemplateApply = Per poter applicare un template bisogna essere il proprietario della Tabular Resource. \
Non sei il proprietario di questa Tabular Resource!
attentionNotOwnerRuleApply = Per poter applicare una rule bisogna essere il proprietario della Tabular Resource. \
Non sei il proprietario di questa Tabular Resource!