diff --git a/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXExportWizardTD.java b/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXExportWizardTD.java index efcc824..f88d45f 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXExportWizardTD.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXExportWizardTD.java @@ -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() { + 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() { + + 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(); + + } + }); + } + } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXOperationInProgressCard.java b/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXOperationInProgressCard.java index cd1ba52..d9e620b 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXOperationInProgressCard.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXOperationInProgressCard.java @@ -156,7 +156,7 @@ public class SDMXOperationInProgressCard extends WizardCard implements newTrId = operationResult.getTrId(); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); safeHtmlBuilder - .appendHtmlConstant("
Operation Completed
"); + .appendHtmlConstant("
Operation Completed
Check The Resources
"); resultField.setHTML(safeHtmlBuilder.toSafeHtml()); resultField.setVisible(true); Command sayComplete = new Command() { diff --git a/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXRegistrySelectionCard.java b/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXRegistrySelectionCard.java index 24b1f9b..365d7d6 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXRegistrySelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/SDMXRegistrySelectionCard.java @@ -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("

Internal SDMX Registry" - + "
Select this if you want use the Internal Registry

"); + if (defaultRegistryUrl == null || defaultRegistryUrl.isEmpty()) { + radioStandardRegistry.setBoxLabel("

Internal SDMX Registry" + + "
Select this if you want use the Internal Registry" + "

"); + } else { + radioStandardRegistry.setBoxLabel("

Internal SDMX Registry" + + "
Select this if you want use the Internal Registry" + + "

"); + } radioStandardRegistry.setValue(true); radioStandardRegistry.setName("Default"); - radioStandardRegistry.setStylePrimaryName(res.wizardCSS() - .getImportSelectionSource()); + radioStandardRegistry.setStylePrimaryName(res.wizardCSS().getImportSelectionSource()); Radio radioUrlRegistry = new Radio(); - radioUrlRegistry - .setBoxLabel("

Another SDMX Registry

"); + radioUrlRegistry.setBoxLabel( + "

Another SDMX Registry

"); 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 nodel = radioUrlRegistry.getElement() - .getElementsByTagName("SPAN"); + NodeList 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>() { - public void onValueChange(ValueChangeEvent> 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 nodel = radio.getElement() - .getElementsByTagName("SPAN"); + NodeList 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() { + + @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() { + ((SDMXRegistrySource) exportSession.getSource()), new AsyncCallback() { 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 { } } - - } diff --git a/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/template/SDMXTemplateExportOperationInProgressCard.java b/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/template/SDMXTemplateExportOperationInProgressCard.java index c3ecc31..aba4fbe 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/template/SDMXTemplateExportOperationInProgressCard.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/template/SDMXTemplateExportOperationInProgressCard.java @@ -156,7 +156,7 @@ public class SDMXTemplateExportOperationInProgressCard extends WizardCard implem newTrId = operationResult.getTrId(); SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder(); safeHtmlBuilder - .appendHtmlConstant("
Operation Completed
"); + .appendHtmlConstant("
Operation Completed
Check The Resources
"); resultField.setHTML(safeHtmlBuilder.toSafeHtml()); resultField.setVisible(true); Command sayComplete = new Command() { diff --git a/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/template/SDMXTemplateExportRegistrySelectionCard.java b/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/template/SDMXTemplateExportRegistrySelectionCard.java index f09054e..5fb476d 100644 --- a/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/template/SDMXTemplateExportRegistrySelectionCard.java +++ b/src/main/java/org/gcube/portlets/user/td/sdmxexportwidget/client/template/SDMXTemplateExportRegistrySelectionCard.java @@ -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("

Internal SDMX Registry" - + "
Select this if you want use the Internal Registry

"); + + if (defaultRegistryUrl == null || defaultRegistryUrl.isEmpty()) { + radioStandardRegistry.setBoxLabel("

Internal SDMX Registry" + + "
Select this if you want use the Internal Registry" + "

"); + } else { + radioStandardRegistry.setBoxLabel("

Internal SDMX Registry" + + "
Select this if you want use the Internal Registry" + + "

"); + } radioStandardRegistry.setValue(true); radioStandardRegistry.setName("Default"); - radioStandardRegistry.setStylePrimaryName(res.wizardCSS() - .getImportSelectionSource()); + radioStandardRegistry.setStylePrimaryName(res.wizardCSS().getImportSelectionSource()); Radio radioUrlRegistry = new Radio(); - radioUrlRegistry - .setBoxLabel("

Another SDMX Registry

"); + radioUrlRegistry.setBoxLabel( + "

Another SDMX Registry

"); 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 nodel = radioUrlRegistry.getElement() - .getElementsByTagName("SPAN"); + NodeList 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>() { - public void onValueChange(ValueChangeEvent> 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 nodel = radio.getElement() - .getElementsByTagName("SPAN"); + NodeList 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() { + + @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() { + ((SDMXRegistrySource) sdmxTemplateExportSession.getSource()), + new AsyncCallback() { 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 { } } - - }