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"?>
<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>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</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>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -45,5 +45,5 @@
</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-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>

View File

@ -1,7 +1,8 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-user.tabular-data-portlet.2-10-0"
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 component="org.gcube.portlets-user.tabular-data-portlet.2-9-0"
date="2015-10-15">

24
pom.xml
View File

@ -76,6 +76,17 @@
<version>1.0.1</version>
<scope>runtime</scope>
</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 -->
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
@ -169,6 +180,19 @@
</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 -->
<dependency>
<groupId>org.gcube.portal</groupId>

View File

@ -143,6 +143,10 @@ public class TabularDataController {
private TabularDataControllerMessages msgs;
private CommonMessages msgsCommon;
private enum CheckFor {
ApplyColumnRule, ApplyTableRule, ApplyTemplate;
}
public TabularDataController() {
eventBus = new SimpleEventBus();
initMessages();
@ -795,7 +799,7 @@ public class TabularDataController {
eventBus.fireEvent(new UIStateEvent(UIStateType.WIZARD_OPEN));
}
public void doRibbonCommand(RibbonEvent event) {
private void doRibbonCommand(RibbonEvent event) {
RibbonType type = event.getRibbonType();
Log.trace("doRibbonEvent ribbonType: " + type);
try {
@ -1084,8 +1088,8 @@ public class TabularDataController {
}
// TODO
public void doBackgroundRequestCommand(BackgroundRequestEvent event) {
private void doBackgroundRequestCommand(BackgroundRequestEvent event) {
BackgroundRequestType type = event.getBackgroundRequestType();
Log.trace("doBackgroundRequestEvent BackgroundRequestType: " + type);
try {
@ -1746,9 +1750,8 @@ public class TabularDataController {
public void onSuccess() {
Log.debug("Template Apply call");
if (trId != null) {
TemplateApplyDialog taDialog = new TemplateApplyDialog(
trId, eventBus);
taDialog.show();
retrieveTabResourceInformation(CheckFor.ApplyTemplate);
} else {
Log.error("TRId is null");
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() {
GWT.runAsync(new RunAsyncCallback() {
public void onSuccess() {
Log.debug("Template Share call");
TemplateShareDialog tsDialog = new TemplateShareDialog(eventBus);
TemplateShareDialog tsDialog = new TemplateShareDialog(
userInfo, eventBus);
tsDialog.show();
}
@ -1784,7 +1809,7 @@ public class TabularDataController {
public void onSuccess() {
Log.debug("Open Share Window");
@SuppressWarnings("unused")
TRShare trShare = new TRShare(trId, eventBus);
TRShare trShare = new TRShare(userInfo, trId, eventBus);
}
public void onFailure(Throwable reason) {
@ -1847,7 +1872,7 @@ public class TabularDataController {
GWT.runAsync(new RunAsyncCallback() {
public void onSuccess() {
Log.debug("Request Open Share Rule Dialog");
RuleShareDialog cfDialog = new RuleShareDialog(eventBus);
RuleShareDialog cfDialog = new RuleShareDialog(userInfo, eventBus);
cfDialog.show();
}
@ -1873,24 +1898,83 @@ public class TabularDataController {
}
private void openOnColumnApplyRule() {
GWT.runAsync(new RunAsyncCallback() {
public void onSuccess() {
Log.debug("Request Open On Column Apply Rule Dialog");
if (trId != null) {
Log.debug("Request Open On Column Apply Rule Dialog");
if (trId != null) {
retrieveTabResourceInformation(CheckFor.ApplyColumnRule);
} 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(
trId, eventBus);
raDialog.show();
} else {
Log.error("TRId is null");
UtilsGXT3.alert(msgsCommon.error(),
msgs.noCurrentTabularResourcePresent());
}
}
public void onFailure(Throwable reason) {
asyncCodeLoadingFailed(reason);
}
});
public void onFailure(Throwable reason) {
asyncCodeLoadingFailed(reason);
}
});
} else {
UtilsGXT3.info(msgsCommon.attention(),
msgs.attentionNotOwnerRuleApply());
}
}
private void openOnTableNewRule() {
@ -1935,10 +2019,20 @@ public class TabularDataController {
}
// TODO
private void openOnTableApplyRule() {
Log.debug("Request Open On Table Apply Rule Dialog");
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() {
public void onSuccess() {
openWizard();
@ -1975,11 +2069,9 @@ public class TabularDataController {
asyncCodeLoadingFailed(reason);
}
});
} else {
Log.error("TRId is null");
UtilsGXT3.alert(msgsCommon.error(),
msgs.noCurrentTabularResourcePresent());
UtilsGXT3.info(msgsCommon.attention(),
msgs.attentionNotOwnerRuleApply());
}
}

View File

@ -21,63 +21,70 @@ public interface TabularDataControllerMessages extends Messages {
@DefaultMessage("Error in close TR: {0}")
String errorInCloseTR(String localizedMessage);
@DefaultMessage("Error in set Active TR: {0}")
String errorInSetActiveTR(String localizedMessage);
@DefaultMessage("Confirm")
String confirm();
@DefaultMessage("Are you sure you want to delete the tabular resource?")
String areYouSureYouWantToDeleteTheTabularResource();
@DefaultMessage("No tabular resource present")
String noTabularResourcePresent();
@DefaultMessage("No current tabular resource present!")
String noCurrentTabularResourcePresent();
@DefaultMessage("SDMX Import")
String sdmxImport();
@DefaultMessage("CSV Export")
String csvExport();
@DefaultMessage("JSON Export")
String jsonExport();
@DefaultMessage("SDMX Export")
String sdmxExport();
@DefaultMessage("Extract Codelist")
String extractCodelist();
@DefaultMessage("Codelist Mapping Import")
String codelistMappingImport();
@DefaultMessage("Union")
String union();
@DefaultMessage("Replace By External Columns")
String replaceByExternalColumns();
@DefaultMessage("Charts Creation")
String chartsCreation();
@DefaultMessage("Map Creation")
String mapCreation();
@DefaultMessage("CSV Import")
String csvImport();
@DefaultMessage("Error on set Tabular Resource: {0}")
String errorOnSetTabularResource(String localizedMessage);
@DefaultMessage("No row selected!")
String noRowSelected();
@DefaultMessage("No cell selected!")
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.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.widgetcommonevent.client.CommonMessages;
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
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.sencha.gxt.widget.core.client.Window;
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 {
private static final String WIDTH = "850px";
private static final String HEIGHT = "530px";
private static final String HEIGHT = "530px";
private EventBus eventBus;
private UserInfo userInfo;
private CommonMessages msgsCommon;
public TemplateShareDialog(EventBus eventBus) {
public TemplateShareDialog(UserInfo userInfo, EventBus eventBus) {
this.eventBus = eventBus;
this.userInfo = userInfo;
initMessages();
initWindow();
TemplateSharePanel templateDeletePanel = new TemplateSharePanel(this,
eventBus);
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}
*/
@ -64,13 +76,19 @@ public class TemplateShareDialog extends Window {
hide();
}
public void templateShare(TemplateData templateData) {
Log.debug("Share Window");
@SuppressWarnings("unused")
TemplateShare templateShare = new TemplateShare(templateData, eventBus);
close();
if (userInfo.getUsername().compareTo(templateData.getOwnerLogin()) == 0) {
@SuppressWarnings("unused")
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}
noRowSelected = No row 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
errorOnSetTabularResource = Error en poner la Tabular Resource: {0}
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
errorOnSetTabularResource = Errore nel settare la Tabular Resource: {0}
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!