Fixed TimeZone

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-sdmx-import-widget@115610 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-06-29 12:36:51 +00:00 committed by Giancarlo Panichi
parent a0242c2971
commit 5b5b56a612
1 changed files with 28 additions and 44 deletions

View File

@ -56,7 +56,7 @@ import com.sencha.gxt.widget.core.client.form.TextField;
*/ */
public class SDMXTableDetailCard extends WizardCard { public class SDMXTableDetailCard extends WizardCard {
protected DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd"); protected DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
protected final String TABLEDETAILPANELWIDTH = "100%"; protected final String TABLEDETAILPANELWIDTH = "100%";
protected final String TABLEDETAILPANELHEIGHT = "100%"; protected final String TABLEDETAILPANELHEIGHT = "100%";
protected final String FORMWIDTH = "538px"; protected final String FORMWIDTH = "538px";
@ -77,11 +77,10 @@ public class SDMXTableDetailCard extends WizardCard {
protected DateField validUntilTo; protected DateField validUntilTo;
protected TextButton checkButton; protected TextButton checkButton;
protected ListLoader<ListLoadConfig, ListLoadResult<LicenceData>> loader; protected ListLoader<ListLoadConfig, ListLoadResult<LicenceData>> loader;
protected ComboBox<LicenceData> comboLicences; protected ComboBox<LicenceData> comboLicences;
TabResource detail; TabResource detail;
public SDMXTableDetailCard(final SDMXImportSession importSession) { public SDMXTableDetailCard(final SDMXImportSession importSession) {
@ -143,7 +142,7 @@ public class SDMXTableDetailCard extends WizardCard {
validUntilTo = new DateField(); validUntilTo = new DateField();
p.add(new FieldLabel(validUntilTo, "Valid Until To"), p.add(new FieldLabel(validUntilTo, "Valid Until To"),
new VerticalLayoutData(1, -1)); new VerticalLayoutData(1, -1));
// Combo Licences // Combo Licences
LicenceDataPropertiesCombo propsLicenceData = GWT LicenceDataPropertiesCombo propsLicenceData = GWT
.create(LicenceDataPropertiesCombo.class); .create(LicenceDataPropertiesCombo.class);
@ -168,7 +167,7 @@ public class SDMXTableDetailCard extends WizardCard {
} }
}; };
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, LicenceData, ListLoadResult<LicenceData>>( loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, LicenceData, ListLoadResult<LicenceData>>(
storeCombo)); storeCombo));
Log.trace("LoaderCombo created"); Log.trace("LoaderCombo created");
@ -191,15 +190,15 @@ public class SDMXTableDetailCard extends WizardCard {
Log.trace("Combo Licence created"); Log.trace("Combo Licence created");
// / // /
p.add(new FieldLabel(comboLicences, "Licence"), p.add(new FieldLabel(comboLicences, "Licence"), new VerticalLayoutData(
new VerticalLayoutData(1, -1)); 1, -1));
tableDetailPanel.add(form); tableDetailPanel.add(form);
setContent(tableDetailPanel); setContent(tableDetailPanel);
} }
protected void loadData(ListLoadConfig loadConfig, protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<LicenceData>> callback) { final AsyncCallback<ListLoadResult<LicenceData>> callback) {
TDGWTServiceAsync.INSTANCE TDGWTServiceAsync.INSTANCE
@ -230,7 +229,7 @@ public class SDMXTableDetailCard extends WizardCard {
}); });
} }
@Override @Override
public void setup() { public void setup() {
Command sayNextCard = new Command() { Command sayNextCard = new Command() {
@ -320,39 +319,22 @@ public class SDMXTableDetailCard extends WizardCard {
protected void goNext() { protected void goNext() {
try { try {
detail= new TabResource(); detail = new TabResource();
detail.setName(name.getCurrentValue()); detail.setName(name.getCurrentValue());
detail.setAgency(agencyName.getCurrentValue()); detail.setAgency(agencyName.getCurrentValue());
detail.setDescription(description.getCurrentValue()); detail.setDescription(description.getCurrentValue());
detail.setRight(rights.getCurrentValue()); detail.setRight(rights.getCurrentValue());
Date vFrom = validFrom.getCurrentValue();
if (vFrom == null) {
Log.debug("Valid From is null");
} else {
try {
detail.setValidFrom(sdf.format(vFrom));
} catch (Throwable e) {
Log.error("Error parsing Valid From "
+ e.getLocalizedMessage());
}
}
Date vUntilTo = validUntilTo.getCurrentValue(); detail.setValidFrom(validFrom.getCurrentValue());
if (vUntilTo == null) { detail.setValidUntilTo(validUntilTo.getCurrentValue());
Log.debug("Valid Until To is null");
} else { if (validFrom.getCurrentValue() != null
try { && validUntilTo.getCurrentValue() != null
detail.setValidUntilTo(sdf.format(vUntilTo)); && validFrom.getCurrentValue().compareTo(
} catch (Throwable e) { validUntilTo.getCurrentValue()) > 0) {
Log.error("Error parsing Valid Until To " Log.debug("Attention Valid From field is higher than Valid Until To field");
+ e.getLocalizedMessage()); AlertMessageBox d = new AlertMessageBox("Attention!",
} "Valid From field is higher than Valid Until To field");
}
if(vFrom!=null && vUntilTo!=null && vFrom.compareTo(vUntilTo)>0){
Log.debug("Attention Valid From field is higher than Valid Until To field");
AlertMessageBox d = new AlertMessageBox("Attention!", "Valid From field is higher than Valid Until To field");
d.addHideHandler(new HideHandler() { d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) { public void onHide(HideEvent event) {
@ -363,13 +345,15 @@ public class SDMXTableDetailCard extends WizardCard {
}); });
d.show(); d.show();
} }
if (comboLicences.getCurrentValue() != null
if(comboLicences.getCurrentValue()!=null&& && comboLicences.getCurrentValue().getLicenceId() != null
comboLicences.getCurrentValue().getLicenceId()!=null && !comboLicences.getCurrentValue().getLicenceId().isEmpty()){ && !comboLicences.getCurrentValue().getLicenceId()
detail.setLicence(comboLicences.getCurrentValue().getLicenceId()); .isEmpty()) {
detail.setLicence(comboLicences.getCurrentValue()
.getLicenceId());
} }
importSession.setTabResource(detail); importSession.setTabResource(detail);
SDMXOperationInProgressCard sdmxOperationInProgressCard = new SDMXOperationInProgressCard( SDMXOperationInProgressCard sdmxOperationInProgressCard = new SDMXOperationInProgressCard(
importSession); importSession);