ref 9056:TabMan - Improve resource management in TabMan

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

Improve resources management

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-export-widget@151398 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-07-27 15:43:10 +00:00 committed by Giancarlo Panichi
parent 19010a25a9
commit 3323ff92fa
5 changed files with 185 additions and 155 deletions

View File

@ -29,8 +29,10 @@ public class SDMXExportWizardTD extends WizardWindow {
/**
*
*
* @param title Title
* @param eventBus Event bus
* @param title
* Title
* @param eventBus
* Event bus
*/
public SDMXExportWizardTD(String title, final EventBus eventBus) {
super(title, eventBus);
@ -39,52 +41,47 @@ public class SDMXExportWizardTD extends WizardWindow {
exportSession = new SDMXExportSession();
final AutoProgressMessageBox box = new AutoProgressMessageBox("Wait",
"Retrive Tabular Resource Information, please wait...");
final AutoProgressMessageBox box = new AutoProgressMessageBox("Wait", "Retrieving Information, please wait...");
box.setProgressText("Retrieving...");
box.auto();
box.show();
TDGWTServiceAsync.INSTANCE
.getTabResourceInformation(new AsyncCallback<TabResource>() {
retrieveTabularDataInfo(box);
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Locked",
caught.getLocalizedMessage(), "",
caught);
} else {
Log.error("No Tabular Resource Information retrived from server "
+ caught.getLocalizedMessage());
box.hide();
showErrorAndHide(
"Error",
"Error retrieving tabular resource information: ",
caught.getLocalizedMessage(), caught);
}
}
}
public void onSuccess(TabResource result) {
Log.debug("Tabular Resource Information retrived");
exportSession.setTabResource(result);
exportSession.setExportType(TableType
.getColumnDataTypeFromId(result
.getTableTypeName()));
box.hide();
}
});
SDMXRegistrySelectionCard sdmxRegistrySelectionCard = new SDMXRegistrySelectionCard(
exportSession);
SDMXRegistrySelectionCard sdmxRegistrySelectionCard = new SDMXRegistrySelectionCard(exportSession);
addCard(sdmxRegistrySelectionCard);
sdmxRegistrySelectionCard.setup();
}
private void retrieveTabularDataInfo(final AutoProgressMessageBox box) {
TDGWTServiceAsync.INSTANCE.getTabResourceInformation(new AsyncCallback<TabResource>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
} else {
if (caught instanceof TDGWTIsLockedException) {
Log.error(caught.getLocalizedMessage());
showErrorAndHide("Error Locked", caught.getLocalizedMessage(), "", caught);
} else {
Log.error(
"No Tabular Resource Information retrived from server " + caught.getLocalizedMessage());
box.hide();
showErrorAndHide("Error", "Error retrieving tabular resource information: ",
caught.getLocalizedMessage(), caught);
}
}
}
public void onSuccess(TabResource result) {
Log.debug("Tabular Resource Information retrived");
exportSession.setTabResource(result);
exportSession.setExportType(TableType.getColumnDataTypeFromId(result.getTableTypeName()));
box.hide();
}
});
}
}

View File

@ -156,7 +156,7 @@ public class SDMXOperationInProgressCard extends WizardCard implements
newTrId = operationResult.getTrId();
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
safeHtmlBuilder
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold; color:#009900;'>Operation Completed</div>");
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold; color:#009900;'>Operation Completed<br>Check The Resources</div>");
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
resultField.setVisible(true);
Command sayComplete = new Command() {

View File

@ -44,48 +44,50 @@ public class SDMXRegistrySelectionCard extends WizardCard {
public SDMXRegistrySelectionCard(final SDMXExportSession exportSession) {
super("SDMX Registry selection", "");
thisCard = this;
SDMXRegistrySource sdmxRegistrySource=new SDMXRegistrySource();
SDMXRegistrySource sdmxRegistrySource = new SDMXRegistrySource();
exportSession.setSource(sdmxRegistrySource);
this.exportSession = exportSession;
retrieveDefaultRegistryURL();
}
private void create(String defaultRegistryUrl) {
VerticalPanel registrySelectionPanel = new VerticalPanel();
registrySelectionPanel.setStylePrimaryName(res.wizardCSS()
.getImportSelectionSources());
registrySelectionPanel.setStylePrimaryName(res.wizardCSS().getImportSelectionSources());
Radio radioStandardRegistry = new Radio();
radioStandardRegistry
.setBoxLabel("<p style='display:inline-table;'><b>Internal SDMX Registry</b>"
+ "<br>Select this if you want use the Internal Registry</p>");
if (defaultRegistryUrl == null || defaultRegistryUrl.isEmpty()) {
radioStandardRegistry.setBoxLabel("<p style='display:inline-table;'><b>Internal SDMX Registry</b>"
+ "<br>Select this if you want use the Internal Registry" + "</p>");
} else {
radioStandardRegistry.setBoxLabel("<p style='display:inline-table;'><b>Internal SDMX Registry</b>"
+ "<br>Select this if you want use the <a href='" + defaultRegistryUrl + "'>Internal Registry</a>"
+ "</p>");
}
radioStandardRegistry.setValue(true);
radioStandardRegistry.setName("Default");
radioStandardRegistry.setStylePrimaryName(res.wizardCSS()
.getImportSelectionSource());
radioStandardRegistry.setStylePrimaryName(res.wizardCSS().getImportSelectionSource());
Radio radioUrlRegistry = new Radio();
radioUrlRegistry
.setBoxLabel("<p style='display:inline-table;'><b>Another SDMX Registry</b><br><SPAN id='SDMXRegistryUrl'></SPAN></p>");
radioUrlRegistry.setBoxLabel(
"<p style='display:inline-table;'><b>Another SDMX Registry</b><br><SPAN id='SDMXRegistryUrl'></SPAN></p>");
radioUrlRegistry.setName("Url");
radioUrlRegistry.setStylePrimaryName(res.wizardCSS()
.getImportSelectionSource());
radioUrlRegistry.setStylePrimaryName(res.wizardCSS().getImportSelectionSource());
radioUrlRegistry.disable();
radioUrlRegistry.setVisible(false);
url.setName("sdmxRegistryUrlInpuntField");
url.setId("sdmxRegistryUrlInputFieldId");
url.setStylePrimaryName(res.wizardCSS()
.getSDMXRegistryUrlInputStyle());
url.setStylePrimaryName(res.wizardCSS().getSDMXRegistryUrlInputStyle());
final VerticalLayoutContainer vcontainer = new VerticalLayoutContainer();
vcontainer.add(new FieldLabel(url, "URL"), new VerticalLayoutData(-1,
-1));
vcontainer.setStylePrimaryName(res.wizardCSS()
.getSDMXRegistryUrlStyle());
vcontainer.add(new FieldLabel(url, "URL"), new VerticalLayoutData(-1, -1));
vcontainer.setStylePrimaryName(res.wizardCSS().getSDMXRegistryUrlStyle());
vcontainer.setVisible(false);
NodeList<Element> nodel = radioUrlRegistry.getElement()
.getElementsByTagName("SPAN");
NodeList<Element> nodel = radioUrlRegistry.getElement().getElementsByTagName("SPAN");
Element span = nodel.getItem(0);
span.appendChild(vcontainer.getElement());
@ -99,7 +101,6 @@ public class SDMXRegistrySelectionCard extends WizardCard {
toggle.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
public void onValueChange(ValueChangeEvent<HasValue<Boolean>> event) {
try {
ToggleGroup group = (ToggleGroup) event.getSource();
@ -107,36 +108,58 @@ public class SDMXRegistrySelectionCard extends WizardCard {
Log.info("Registry Selected:" + radio.getName());
if (radio.getName().compareTo("Url") == 0) {
vcontainer.setVisible(true);
NodeList<Element> nodel = radio.getElement()
.getElementsByTagName("SPAN");
NodeList<Element> nodel = radio.getElement().getElementsByTagName("SPAN");
Element span = nodel.getItem(0);
span.appendChild(vcontainer.getElement());
Log.info("SDMXRegistry Url");
Log.info("Input value: " + url.getCurrentValue());
SDMXRegistrySource r = ((SDMXRegistrySource) exportSession
.getSource());
SDMXRegistrySource r = ((SDMXRegistrySource) exportSession.getSource());
//TODO r.setUrl(url.getCurrentValue());
r.setUrl(null);
Log.info("" + exportSession.getSource());
} else {
vcontainer.setVisible(false);
Log.info("SDMXRegistry Default");
SDMXRegistrySource r = ((SDMXRegistrySource) exportSession
.getSource());
SDMXRegistrySource r = ((SDMXRegistrySource) exportSession.getSource());
r.setUrl(null);
Log.info("Input value: " + url.getCurrentValue());
Log.info("" + exportSession.getSource());
}
} catch (Exception e) {
Log.error("ToggleGroup: onValueChange "
+ e.getLocalizedMessage());
Log.error("ToggleGroup: onValueChange " + e.getLocalizedMessage());
}
}
});
setCenterWidget(registrySelectionPanel, new MarginData(0));
forceLayout();
}
private void retrieveDefaultRegistryURL() {
mask("Please Wait...");
TDGWTServiceAsync.INSTANCE.getDefaultSDMXRegistryURL(new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
unmask();
if (caught instanceof TDGWTSessionExpiredException) {
getEventBus().fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error retrieving URL of default SDMX Registry " + caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(String defaultURLRegistry) {
unmask();
create(defaultURLRegistry);
}
});
}
@Override
@ -146,30 +169,27 @@ public class SDMXRegistrySelectionCard extends WizardCard {
try {
Log.info("Input value: " + url.getCurrentValue());
if (exportSession.getSource() instanceof SDMXRegistrySource) {
((SDMXRegistrySource) exportSession.getSource())
.setUrl(url.getCurrentValue());
((SDMXRegistrySource) exportSession.getSource()).setUrl(url.getCurrentValue());
TDGWTServiceAsync.INSTANCE.setSDMXRegistrySource(
((SDMXRegistrySource)exportSession.getSource()), new AsyncCallback<Void>() {
((SDMXRegistrySource) exportSession.getSource()), new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
getEventBus()
.fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("SDMXRegistrySource do not stored "
+ caught.getLocalizedMessage());
showErrorAndHide("Error", "SDMXRegistrySource do not stored."
,caught.getLocalizedMessage(), caught);
getEventBus().fireEvent(
new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error(
"SDMXRegistrySource do not stored " + caught.getLocalizedMessage());
showErrorAndHide("Error", "SDMXRegistrySource do not stored.",
caught.getLocalizedMessage(), caught);
}
}
public void onSuccess(Void result) {
Log.info("SDMXRegistrySource stored");
goNext();
}
});
} else {
@ -184,8 +204,7 @@ public class SDMXRegistrySelectionCard extends WizardCard {
};
getWizardWindow().setNextButtonCommand(sayNextCard);
Command sayPreviousCard = new Command() {
public void execute() {
try {
@ -196,20 +215,19 @@ public class SDMXRegistrySelectionCard extends WizardCard {
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
}
}
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
setEnableBackButton(false);
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
setEnableBackButton(false);
setEnableNextButton(true);
setBackButtonVisible(false);
}
protected void goNext() {
try {
SDMXAgenciesSelectionCard sdmxAgencyTypeCard = new SDMXAgenciesSelectionCard(
exportSession);
SDMXAgenciesSelectionCard sdmxAgencyTypeCard = new SDMXAgenciesSelectionCard(exportSession);
getWizardWindow().addCard(sdmxAgencyTypeCard);
Log.info("NextCard SDMXAgenciesSelectionCard ");
getWizardWindow().nextCard();
@ -218,6 +236,4 @@ public class SDMXRegistrySelectionCard extends WizardCard {
}
}
}

View File

@ -156,7 +156,7 @@ public class SDMXTemplateExportOperationInProgressCard extends WizardCard implem
newTrId = operationResult.getTrId();
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
safeHtmlBuilder
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold; color:#009900;'>Operation Completed</div>");
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold; color:#009900;'>Operation Completed<br>Check The Resources</div>");
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
resultField.setVisible(true);
Command sayComplete = new Command() {

View File

@ -47,45 +47,46 @@ public class SDMXTemplateExportRegistrySelectionCard extends WizardCard {
SDMXRegistrySource sdmxRegistrySource=new SDMXRegistrySource();
sdmxTemplateExportSession.setSource(sdmxRegistrySource);
this.sdmxTemplateExportSession = sdmxTemplateExportSession;
retrieveDefaultRegistryURL();
}
private void create(String defaultRegistryUrl) {
VerticalPanel registrySelectionPanel = new VerticalPanel();
registrySelectionPanel.setStylePrimaryName(res.wizardCSS()
.getImportSelectionSources());
registrySelectionPanel.setStylePrimaryName(res.wizardCSS().getImportSelectionSources());
Radio radioStandardRegistry = new Radio();
radioStandardRegistry
.setBoxLabel("<p style='display:inline-table;'><b>Internal SDMX Registry</b>"
+ "<br>Select this if you want use the Internal Registry</p>");
if (defaultRegistryUrl == null || defaultRegistryUrl.isEmpty()) {
radioStandardRegistry.setBoxLabel("<p style='display:inline-table;'><b>Internal SDMX Registry</b>"
+ "<br>Select this if you want use the Internal Registry" + "</p>");
} else {
radioStandardRegistry.setBoxLabel("<p style='display:inline-table;'><b>Internal SDMX Registry</b>"
+ "<br>Select this if you want use the <a href='" + defaultRegistryUrl + "'>Internal Registry</a>"
+ "</p>");
}
radioStandardRegistry.setValue(true);
radioStandardRegistry.setName("Default");
radioStandardRegistry.setStylePrimaryName(res.wizardCSS()
.getImportSelectionSource());
radioStandardRegistry.setStylePrimaryName(res.wizardCSS().getImportSelectionSource());
Radio radioUrlRegistry = new Radio();
radioUrlRegistry
.setBoxLabel("<p style='display:inline-table;'><b>Another SDMX Registry</b><br><SPAN id='SDMXRegistryUrl'></SPAN></p>");
radioUrlRegistry.setBoxLabel(
"<p style='display:inline-table;'><b>Another SDMX Registry</b><br><SPAN id='SDMXRegistryUrl'></SPAN></p>");
radioUrlRegistry.setName("Url");
radioUrlRegistry.setStylePrimaryName(res.wizardCSS()
.getImportSelectionSource());
radioUrlRegistry.setStylePrimaryName(res.wizardCSS().getImportSelectionSource());
radioUrlRegistry.disable();
radioUrlRegistry.setVisible(false);
url.setName("sdmxRegistryUrlInpuntField");
url.setId("sdmxRegistryUrlInputFieldId");
url.setStylePrimaryName(res.wizardCSS()
.getSDMXRegistryUrlInputStyle());
url.setStylePrimaryName(res.wizardCSS().getSDMXRegistryUrlInputStyle());
final VerticalLayoutContainer vcontainer = new VerticalLayoutContainer();
vcontainer.add(new FieldLabel(url, "URL"), new VerticalLayoutData(-1,
-1));
vcontainer.setStylePrimaryName(res.wizardCSS()
.getSDMXRegistryUrlStyle());
vcontainer.add(new FieldLabel(url, "URL"), new VerticalLayoutData(-1, -1));
vcontainer.setStylePrimaryName(res.wizardCSS().getSDMXRegistryUrlStyle());
vcontainer.setVisible(false);
NodeList<Element> nodel = radioUrlRegistry.getElement()
.getElementsByTagName("SPAN");
NodeList<Element> nodel = radioUrlRegistry.getElement().getElementsByTagName("SPAN");
Element span = nodel.getItem(0);
span.appendChild(vcontainer.getElement());
@ -99,7 +100,6 @@ public class SDMXTemplateExportRegistrySelectionCard extends WizardCard {
toggle.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
public void onValueChange(ValueChangeEvent<HasValue<Boolean>> event) {
try {
ToggleGroup group = (ToggleGroup) event.getSource();
@ -107,29 +107,25 @@ public class SDMXTemplateExportRegistrySelectionCard extends WizardCard {
Log.info("Registry Selected:" + radio.getName());
if (radio.getName().compareTo("Url") == 0) {
vcontainer.setVisible(true);
NodeList<Element> nodel = radio.getElement()
.getElementsByTagName("SPAN");
NodeList<Element> nodel = radio.getElement().getElementsByTagName("SPAN");
Element span = nodel.getItem(0);
span.appendChild(vcontainer.getElement());
Log.info("SDMXRegistry Url");
Log.info("Input value: " + url.getCurrentValue());
SDMXRegistrySource r = ((SDMXRegistrySource) sdmxTemplateExportSession
.getSource());
SDMXRegistrySource r = ((SDMXRegistrySource) sdmxTemplateExportSession.getSource());
r.setUrl(null);
Log.info("" + sdmxTemplateExportSession.getSource());
} else {
vcontainer.setVisible(false);
Log.info("SDMXRegistry Default");
SDMXRegistrySource r = ((SDMXRegistrySource) sdmxTemplateExportSession
.getSource());
SDMXRegistrySource r = ((SDMXRegistrySource) sdmxTemplateExportSession.getSource());
r.setUrl(null);
Log.info("Input value: " + url.getCurrentValue());
Log.info("" + sdmxTemplateExportSession.getSource());
}
} catch (Exception e) {
Log.error("ToggleGroup: onValueChange "
+ e.getLocalizedMessage());
Log.error("ToggleGroup: onValueChange " + e.getLocalizedMessage());
}
}
@ -139,6 +135,32 @@ public class SDMXTemplateExportRegistrySelectionCard extends WizardCard {
}
private void retrieveDefaultRegistryURL() {
mask("Please Wait...");
TDGWTServiceAsync.INSTANCE.getDefaultSDMXRegistryURL(new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
unmask();
if (caught instanceof TDGWTSessionExpiredException) {
getEventBus().fireEvent(new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error retrieving URL of default SDMX Registry " + caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(String defaultURLRegistry) {
unmask();
create(defaultURLRegistry);
}
});
}
@Override
public void setup() {
Command sayNextCard = new Command() {
@ -146,30 +168,28 @@ public class SDMXTemplateExportRegistrySelectionCard extends WizardCard {
try {
Log.info("Input value: " + url.getCurrentValue());
if (sdmxTemplateExportSession.getSource() instanceof SDMXRegistrySource) {
((SDMXRegistrySource) sdmxTemplateExportSession.getSource())
.setUrl(url.getCurrentValue());
((SDMXRegistrySource) sdmxTemplateExportSession.getSource()).setUrl(url.getCurrentValue());
TDGWTServiceAsync.INSTANCE.setSDMXRegistrySource(
((SDMXRegistrySource)sdmxTemplateExportSession.getSource()), new AsyncCallback<Void>() {
((SDMXRegistrySource) sdmxTemplateExportSession.getSource()),
new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
getEventBus()
.fireEvent(
new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("SDMXRegistrySource do not stored "
+ caught.getLocalizedMessage());
showErrorAndHide("Error", "SDMXRegistrySource do not stored."
,caught.getLocalizedMessage(), caught);
getEventBus().fireEvent(
new SessionExpiredEvent(SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error(
"SDMXRegistrySource do not stored " + caught.getLocalizedMessage());
showErrorAndHide("Error", "SDMXRegistrySource do not stored.",
caught.getLocalizedMessage(), caught);
}
}
public void onSuccess(Void result) {
Log.info("SDMXRegistrySource stored");
goNext();
}
});
} else {
@ -184,8 +204,7 @@ public class SDMXTemplateExportRegistrySelectionCard extends WizardCard {
};
getWizardWindow().setNextButtonCommand(sayNextCard);
Command sayPreviousCard = new Command() {
public void execute() {
try {
@ -196,16 +215,16 @@ public class SDMXTemplateExportRegistrySelectionCard extends WizardCard {
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
}
}
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
setEnableBackButton(false);
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
setEnableBackButton(false);
setEnableNextButton(true);
setBackButtonVisible(false);
}
protected void goNext() {
try {
SDMXTemplateExportAgenciesSelectionCard sdmxAgencyTypeCard = new SDMXTemplateExportAgenciesSelectionCard(
@ -218,6 +237,4 @@ public class SDMXTemplateExportRegistrySelectionCard extends WizardCard {
}
}
}