Updated Codelist Mapping Import

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-codelistmapping-import-widget@96576 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-06-04 13:11:21 +00:00
parent 66dd1352cb
commit 2f3cc1f239
9 changed files with 262 additions and 119 deletions

View File

@ -3,11 +3,11 @@
*/ */
package org.gcube.portlets.user.td.codelistmappingimportwidget.client; package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.FileUploadProgressBarUpdater; import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.FileUploadProgressBarUpdater;
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.FileUploadProgressListener; import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.FileUploadProgressListener;
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.FileUploadProgressUpdater; import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.FileUploadProgressUpdater;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
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.gwt.core.client.GWT;
@ -51,7 +51,7 @@ public class CodelistMappingFileUploadPanel extends FormPanel {
protected TextButton cancelButton; protected TextButton cancelButton;
public CodelistMappingFileUploadPanel(ResourceBundle res, final CodelistMappingUploadFileCard card, public CodelistMappingFileUploadPanel(ResourceBundle res, final CodelistMappingUploadFileCard card,
final CSVImportSession importSession) { final CodelistMappingSession codelistMappingSession) {
this.res = res; this.res = res;
setId("CodelistMappingUploadPanel"); setId("CodelistMappingUploadPanel");
@ -111,7 +111,7 @@ public class CodelistMappingFileUploadPanel extends FormPanel {
} }
importSession.setLocalFileName(filename); codelistMappingSession.setLocalFileName(filename);
} }
}); });
@ -134,7 +134,7 @@ public class CodelistMappingFileUploadPanel extends FormPanel {
|| fileUploadField.getValue().equals("")) { || fileUploadField.getValue().equals("")) {
Log.info("fileUploadField is null or empty"); Log.info("fileUploadField is null or empty");
AlertMessageBox alertMessageBox = new AlertMessageBox( AlertMessageBox alertMessageBox = new AlertMessageBox(
"CSV file missing", "Please specify a CSV file."); "XML file missing", "Please specify a XML file.");
alertMessageBox.show(); alertMessageBox.show();
return; return;
} else { } else {
@ -162,7 +162,7 @@ public class CodelistMappingFileUploadPanel extends FormPanel {
public void operationFailed(Throwable caught, String reason, public void operationFailed(Throwable caught, String reason,
String failureDetails) { String failureDetails) {
card.showErrorAndHide("Error uploading the csv file", reason, card.showErrorAndHide("Error uploading the xml file", reason,
failureDetails, caught); failureDetails, caught);
} }

View File

@ -1,8 +1,9 @@
package org.gcube.portlets.user.td.codelistmappingimportwidget.client; package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow; import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import com.google.web.bindery.event.shared.EventBus; import com.google.web.bindery.event.shared.EventBus;
/** /**
@ -12,8 +13,7 @@ import com.google.web.bindery.event.shared.EventBus;
*/ */
public class CodelistMappingImportWizardTD extends WizardWindow { public class CodelistMappingImportWizardTD extends WizardWindow {
protected CSVImportSession importSession; protected CodelistMappingSession codelistMappingSession;
//private CSVImportWizardTD wizard;
/** /**
* The id of the {@link CSVTarget} to use. * The id of the {@link CSVTarget} to use.
@ -23,10 +23,9 @@ public class CodelistMappingImportWizardTD extends WizardWindow {
public CodelistMappingImportWizardTD(TRId trId, String title, EventBus eventBus) { public CodelistMappingImportWizardTD(TRId trId, String title, EventBus eventBus) {
super(title,eventBus); super(title,eventBus);
importSession= new CSVImportSession(); codelistMappingSession= new CodelistMappingSession();
//this.wizard=this;
SourceSelectionCard sourceSelection= new SourceSelectionCard(importSession); SourceSelectionCard sourceSelection= new SourceSelectionCard(codelistMappingSession);
addCard(sourceSelection); addCard(sourceSelection);
sourceSelection.setup(); sourceSelection.setup();

View File

@ -3,16 +3,16 @@
*/ */
package org.gcube.portlets.user.td.codelistmappingimportwidget.client; package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.CodelistMappingImportProgressBarUpdater; import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.CodelistMappingImportProgressBarUpdater;
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.CodelistMappingImportProgressListener; import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.CodelistMappingImportProgressListener;
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.CodelistMappingImportProgressUpdater; import org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress.CodelistMappingImportProgressUpdater;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Command;
@ -28,8 +28,7 @@ import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayou
import com.sencha.gxt.widget.core.client.event.HideEvent; import com.sencha.gxt.widget.core.client.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
//import com.allen_sauer.gwt.log.client.Log;
//import com.google.gwt.user.client.Command;
/** /**
* *
@ -42,35 +41,33 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
public static final int STATUS_POLLING_DELAY = 1000; public static final int STATUS_POLLING_DELAY = 1000;
protected CodelistMappingOperationInProgressCard thisCard; protected CodelistMappingOperationInProgressCard thisCard;
protected CSVImportSession importSession; protected CodelistMappingSession codelistMappingSession;
protected CodelistMappingImportProgressUpdater progressUpdater; protected CodelistMappingImportProgressUpdater progressUpdater;
public CodelistMappingOperationInProgressCard(final CSVImportSession importSession) { public CodelistMappingOperationInProgressCard(final CodelistMappingSession codelistMappingSession) {
super("Operation In Progress", ""); super("Operation In Progress", "");
this.importSession = importSession; this.codelistMappingSession = codelistMappingSession;
thisCard = this; thisCard = this;
VBoxLayoutContainer operationInProgressPanel = new VBoxLayoutContainer(); VBoxLayoutContainer operationInProgressPanel = new VBoxLayoutContainer();
operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER); operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
final FlexTable description = new FlexTable(); final FlexTable description = new FlexTable();
// FlexCellFormatter cellFormatter = description.getFlexCellFormatter();
description.setCellSpacing(10); description.setCellSpacing(10);
description.setCellPadding(4); description.setCellPadding(4);
description.setBorderWidth(0); description.setBorderWidth(0);
// display:block;vertical-align:text-top;
description.setHTML(0, 0, description.setHTML(0, 0,
"<span style=\"font-weight:bold;\";>Document: </span>"); "<span style=\"font-weight:bold;\";>Document: </span>");
description.setText(0, 1, "CSV File"); description.setText(0, 1, "Codelist Mapping");
description.setHTML(1, 0, description.setHTML(1, 0,
"<span style=\"font-weight:bold;\";>Source: </span>"); "<span style=\"font-weight:bold;\";>Source: </span>");
description.setText(1, 1, importSession.getSource().getName()); description.setText(1, 1, codelistMappingSession.getSource().getName());
description.setHTML(2, 0, description.setHTML(2, 0,
"<span style=\"font-weight:bold;\";>File: </span>"); "<span style=\"font-weight:bold;\";>Name: </span>");
description.setText(2, 1, importSession.getTabResource().getName()); description.setText(2, 1, codelistMappingSession.getResourceTD().getName());
FramedPanel summary = new FramedPanel(); FramedPanel summary = new FramedPanel();
summary.setHeadingText("Import Summary"); summary.setHeadingText("Import Summary");
@ -93,10 +90,9 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
} }
// columnToImportMask
public void importCodelistMapping() {
public void importCSV() { TDGWTServiceAsync.INSTANCE.startCodelistMappingImport(codelistMappingSession,
TDGWTServiceAsync.INSTANCE.startCSVImport(importSession,
new AsyncCallback<Void>() { new AsyncCallback<Void>() {
public void onSuccess(Void result) { public void onSuccess(Void result) {
@ -111,8 +107,8 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
showErrorAndHide( showErrorAndHide(
"Error in importCSV", "Error in import codelist mapping",
"An error occured in importCSV: " "An error occured in import codelist mapping: "
+ caught.getLocalizedMessage(), + caught.getLocalizedMessage(),
caught.getStackTrace().toString(), caught); caught.getStackTrace().toString(), caught);
} }
@ -127,7 +123,7 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
setNextButtonVisible(false); setNextButtonVisible(false);
getWizardWindow().setEnableNextButton(false); getWizardWindow().setEnableNextButton(false);
getWizardWindow().setNextButtonToFinish(); getWizardWindow().setNextButtonToFinish();
importCSV(); importCodelistMapping();
} }
public void operationInitializing() { public void operationInitializing() {
@ -139,15 +135,13 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
} }
public void operationComplete(final TRId trId) { public void operationComplete(final TRId trId) {
// final String tableId,final String tableResourceId) {
Command sayComplete = new Command() { Command sayComplete = new Command() {
public void execute() { public void execute() {
try { try {
getWizardWindow().close(false); getWizardWindow().close(false);
Log.info("fire Complete: tabular resource " + trId.getId()); Log.info("fire Complete: "+ trId);
Log.info("fire Complete: tableId " + trId.getTableId());
getWizardWindow().fireCompleted(trId); getWizardWindow().fireCompleted(trId);
} catch (Exception e) { } catch (Exception e) {
@ -170,7 +164,7 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
new SessionExpiredEvent( new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
AlertMessageBox d = new AlertMessageBox("Error in CSV Import", AlertMessageBox d = new AlertMessageBox("Error in Codelist Mapping Import",
reason); reason);
d.addHideHandler(new HideHandler() { d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) { public void onHide(HideEvent event) {
@ -182,8 +176,7 @@ public class CodelistMappingOperationInProgressCard extends WizardCard implement
@Override @Override
public void operationStopped(final TRId trId, String reason, String details) { public void operationStopped(final TRId trId, String reason, String details) {
// final String tableId,final String tableResourceId) {
Command sayComplete = new Command() { Command sayComplete = new Command() {
public void execute() { public void execute() {
try { try {

View File

@ -3,8 +3,8 @@
*/ */
package org.gcube.portlets.user.td.codelistmappingimportwidget.client; package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.gwtservice.shared.resource.ResourceTD;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
@ -33,7 +33,7 @@ public class CodelistMappingTableDetailCard extends WizardCard {
protected final String TABLEDETAILPANELHEIGHT = "100%"; protected final String TABLEDETAILPANELHEIGHT = "100%";
protected final String FORMWIDTH = "538px"; protected final String FORMWIDTH = "538px";
protected CSVImportSession importSession; protected CodelistMappingSession codelistMappingSession;
protected CodelistMappingTableDetailCard thisCard; protected CodelistMappingTableDetailCard thisCard;
protected VerticalLayoutContainer p; protected VerticalLayoutContainer p;
@ -43,12 +43,13 @@ public class CodelistMappingTableDetailCard extends WizardCard {
protected TextArea description; protected TextArea description;
protected TextArea rights; protected TextArea rights;
protected TabResource detail = new TabResource(); protected ResourceTD resourceDetails = new ResourceTD();
public CodelistMappingTableDetailCard(final CSVImportSession importSession) { public CodelistMappingTableDetailCard(
final CodelistMappingSession codelistMappingSession) {
super("Codelist Mapping Detail", ""); super("Codelist Mapping Detail", "");
this.importSession = importSession; this.codelistMappingSession = codelistMappingSession;
thisCard = this; thisCard = this;
tableDetailPanel = new VerticalPanel(); tableDetailPanel = new VerticalPanel();
@ -72,7 +73,7 @@ public class CodelistMappingTableDetailCard extends WizardCard {
name = new TextField(); name = new TextField();
name.setAllowBlank(false); name.setAllowBlank(false);
name.setEmptyText("Enter a name..."); name.setEmptyText("Enter a name...");
name.setValue(importSession.getLocalFileName()); name.setValue(codelistMappingSession.getLocalFileName());
name.setAllowBlank(false); name.setAllowBlank(false);
p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1)); p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1));
@ -84,19 +85,16 @@ public class CodelistMappingTableDetailCard extends WizardCard {
p.add(new FieldLabel(description, "Description"), p.add(new FieldLabel(description, "Description"),
new VerticalLayoutData(1, -1)); new VerticalLayoutData(1, -1));
tableDetailPanel.add(form); tableDetailPanel.add(form);
setContent(tableDetailPanel); setContent(tableDetailPanel);
} }
@Override @Override
public void setup() { public void setup() {
Command sayNextCard = new Command() { Command sayNextCard = new Command() {
public void execute() { public void execute() {
checkData(); checkData();
} }
@ -137,8 +135,7 @@ public class CodelistMappingTableDetailCard extends WizardCard {
if (name.getValue() == null || name.getValue().isEmpty() if (name.getValue() == null || name.getValue().isEmpty()
|| !name.isValid() || description.getValue() == null || !name.isValid() || description.getValue() == null
|| description.getValue().isEmpty() || !description.isValid() || description.getValue().isEmpty() || !description.isValid()) {
) {
d = new AlertMessageBox("Attention!", "Fill in all fields"); d = new AlertMessageBox("Attention!", "Fill in all fields");
d.addHideHandler(hideHandler); d.addHideHandler(hideHandler);
d.show(); d.show();
@ -152,15 +149,14 @@ public class CodelistMappingTableDetailCard extends WizardCard {
protected void goNext() { protected void goNext() {
try { try {
detail.setName(name.getCurrentValue()); resourceDetails.setName(name.getCurrentValue());
detail.setDescription(description.getCurrentValue()); resourceDetails.setDescription(description.getCurrentValue());
detail.setRight(rights.getCurrentValue());
importSession.setTabResource(detail); codelistMappingSession.setResourceTD(resourceDetails);
CodelistMappingOperationInProgressCard csvOperationInProgressCard = new CodelistMappingOperationInProgressCard( CodelistMappingOperationInProgressCard codelistMappingOperationInProgressCard = new CodelistMappingOperationInProgressCard(
importSession); codelistMappingSession);
getWizardWindow().addCard(csvOperationInProgressCard); getWizardWindow().addCard(codelistMappingOperationInProgressCard);
Log.info("NextCard CodelistMappingOperationInProgressCard"); Log.info("NextCard CodelistMappingOperationInProgressCard");
getWizardWindow().nextCard(); getWizardWindow().nextCard();
} catch (Exception e) { } catch (Exception e) {

View File

@ -3,8 +3,8 @@
*/ */
package org.gcube.portlets.user.td.codelistmappingimportwidget.client; package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Command; import com.google.gwt.user.client.Command;
@ -16,16 +16,16 @@ import com.google.gwt.user.client.Command;
* *
*/ */
public class CodelistMappingUploadFileCard extends WizardCard { public class CodelistMappingUploadFileCard extends WizardCard {
protected CSVImportSession importSession; protected CodelistMappingSession codelistMappingSession;
protected CodelistMappingFileUploadPanel fileUploadPanel; protected CodelistMappingFileUploadPanel fileUploadPanel;
protected CodelistMappingUploadFileCard thisCard; protected CodelistMappingUploadFileCard thisCard;
public CodelistMappingUploadFileCard(final CSVImportSession importSession) { public CodelistMappingUploadFileCard(final CodelistMappingSession codelistMappingSession) {
super("Codelist Mapping Import File Upload", ""); super("Codelist Mapping Import File Upload", "");
this.thisCard = this; this.thisCard = this;
this.importSession = importSession; this.codelistMappingSession = codelistMappingSession;
this.fileUploadPanel = new CodelistMappingFileUploadPanel(res, thisCard,importSession); this.fileUploadPanel = new CodelistMappingFileUploadPanel(res, thisCard,codelistMappingSession);
setContent(fileUploadPanel); setContent(fileUploadPanel);
@ -36,7 +36,7 @@ public class CodelistMappingUploadFileCard extends WizardCard {
Command sayNextCard = new Command() { Command sayNextCard = new Command() {
public void execute() { public void execute() {
CodelistMappingTableDetailCard detailsCard = new CodelistMappingTableDetailCard(importSession); CodelistMappingTableDetailCard detailsCard = new CodelistMappingTableDetailCard(codelistMappingSession);
getWizardWindow().addCard(detailsCard); getWizardWindow().addCard(detailsCard);
Log.info("NextCard CodelistMappingTableDetailCard"); Log.info("NextCard CodelistMappingTableDetailCard");
getWizardWindow().nextCard(); getWizardWindow().nextCard();
@ -51,7 +51,7 @@ public class CodelistMappingUploadFileCard extends WizardCard {
try { try {
getWizardWindow().previousCard(); getWizardWindow().previousCard();
getWizardWindow().removeCard(thisCard); getWizardWindow().removeCard(thisCard);
Log.info("Remove CSVUploadFileCard"); Log.info("Remove CodelistMappingUploadFileCard");
} catch (Exception e) { } catch (Exception e) {
Log.error("sayPreviousCard :" + e.getLocalizedMessage()); Log.error("sayPreviousCard :" + e.getLocalizedMessage());
} }

View File

@ -0,0 +1,146 @@
/**
*
*/
package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.resource.ResourceTD;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.Command;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.event.HideEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.FieldSet;
import com.sencha.gxt.widget.core.client.form.TextArea;
import com.sencha.gxt.widget.core.client.form.TextField;
/**
*
* @author "Giancarlo Panichi" <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class CodelistMappingUrlSelectionCard extends WizardCard {
protected final String FORMWIDTH = "538px";
protected CodelistMappingSession codelistMappingSession;
protected CodelistMappingUrlSelectionCard thisCard;
protected TextField name;
protected TextArea description;
public CodelistMappingUrlSelectionCard(
final CodelistMappingSession codelistMappingSession) {
super("Codelist Mapping Url Selection", "");
this.thisCard = this;
this.codelistMappingSession = codelistMappingSession;
FramedPanel form = new FramedPanel();
form.setHeadingText("Url Selection");
form.setWidth(FORMWIDTH);
FieldSet fieldSet = new FieldSet();
fieldSet.setHeadingText("");
fieldSet.setCollapsible(false);
form.add(fieldSet);
VerticalLayoutContainer v = new VerticalLayoutContainer();
fieldSet.add(v);
name = new TextField();
name.setAllowBlank(false);
name.setEmptyText("Enter a name...");
name.setValue(codelistMappingSession.getLocalFileName());
name.setAllowBlank(false);
v.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1));
description = new TextArea();
description.setAllowBlank(false);
description.setEmptyText("Enter a description...");
description.setValue("XML codelist mapping");
description.setAllowBlank(false);
v.add(new FieldLabel(description, "Description"),
new VerticalLayoutData(1, -1));
setContent(form);
}
protected void checkUrl() {
getWizardWindow().setEnableNextButton(false);
getWizardWindow().setEnableBackButton(false);
AlertMessageBox d;
HideHandler hideHandler = new HideHandler() {
public void onHide(HideEvent event) {
getWizardWindow().setEnableNextButton(true);
getWizardWindow().setEnableBackButton(false);
}
};
if (name.getValue() == null || name.getValue().isEmpty()
|| !name.isValid() || description.getValue() == null
|| description.getValue().isEmpty() || !description.isValid()) {
d = new AlertMessageBox("Attention!", "Fill in all fields");
d.addHideHandler(hideHandler);
d.show();
} else {
name.setReadOnly(true);
description.setReadOnly(true);
goNext();
}
}
protected void goNext() {
try {
ResourceTD resourceTD=new ResourceTD();
resourceTD.setName(name.getCurrentValue());
resourceTD.setDescription(description.getCurrentValue());
codelistMappingSession.setResourceTD(resourceTD);
CodelistMappingTableDetailCard detailsCard = new CodelistMappingTableDetailCard(
codelistMappingSession);
getWizardWindow().addCard(detailsCard);
Log.info("NextCard CodelistMappingTableDetailCard");
getWizardWindow().nextCard();
} catch (Throwable e) {
Log.error("sayNextCard :" + e.getLocalizedMessage());
}
}
@Override
public void setup() {
Command sayNextCard = new Command() {
public void execute() {
checkUrl();
}
};
getWizardWindow().setNextButtonCommand(sayNextCard);
Command sayPreviousCard = new Command() {
public void execute() {
try {
getWizardWindow().previousCard();
getWizardWindow().removeCard(thisCard);
Log.info("Remove CodelistMappingUrlSelectionCard");
} catch (Exception e) {
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
}
}
};
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
getWizardWindow().setEnableNextButton(false);
}
}

View File

@ -3,13 +3,13 @@
*/ */
package org.gcube.portlets.user.td.codelistmappingimportwidget.client; package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.workspace.WorkspacePanel;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import org.gcube.portlets.user.td.codelistmappingimportwidget.client.workspace.WorkspacePanel;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.widgets.lighttree.client.Item; import org.gcube.portlets.widgets.lighttree.client.Item;
import org.gcube.portlets.widgets.lighttree.client.ItemType; import org.gcube.portlets.widgets.lighttree.client.ItemType;
import org.gcube.portlets.widgets.lighttree.client.event.ItemSelectionEvent; import org.gcube.portlets.widgets.lighttree.client.event.ItemSelectionEvent;
@ -28,7 +28,7 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
*/ */
public class CodelistMappingWorkSpaceSelectionCard extends WizardCard { public class CodelistMappingWorkSpaceSelectionCard extends WizardCard {
protected CSVImportSession importSession; protected CodelistMappingSession codelistMappingSession;
protected CodelistMappingWorkSpaceSelectionCard thisCard; protected CodelistMappingWorkSpaceSelectionCard thisCard;
protected Item item; protected Item item;
@ -36,10 +36,10 @@ public class CodelistMappingWorkSpaceSelectionCard extends WizardCard {
protected WorkspacePanel wpanel; protected WorkspacePanel wpanel;
public CodelistMappingWorkSpaceSelectionCard( public CodelistMappingWorkSpaceSelectionCard(
final CSVImportSession importSession) { final CodelistMappingSession codelistMappingSession) {
super("CSV Import From Workspace", ""); super("CSV Import From Workspace", "");
this.importSession = importSession; this.codelistMappingSession = codelistMappingSession;
thisCard = this; thisCard = this;
p = new VerticalLayoutContainer(); p = new VerticalLayoutContainer();
@ -52,7 +52,7 @@ public class CodelistMappingWorkSpaceSelectionCard extends WizardCard {
wpanel.setSelectableTypes(ItemType.EXTERNAL_FILE); wpanel.setSelectableTypes(ItemType.EXTERNAL_FILE);
wpanel.getSelectableTypes().remove(ItemType.ROOT); wpanel.getSelectableTypes().remove(ItemType.ROOT);
wpanel.getSelectableTypes().remove(ItemType.FOLDER); wpanel.getSelectableTypes().remove(ItemType.FOLDER);
wpanel.setAllowedMimeTypes("text/csv", "application/zip", wpanel.setAllowedMimeTypes("application/xml", "application/zip",
"application/x-zip", "application/x-zip-compressed", "application/x-zip", "application/x-zip-compressed",
"application/octet", "application/octet-stream"); "application/octet", "application/octet-stream");
wpanel.addSelectionHandler(new ItemSelectionHandler() { wpanel.addSelectionHandler(new ItemSelectionHandler() {
@ -66,7 +66,7 @@ public class CodelistMappingWorkSpaceSelectionCard extends WizardCard {
Log.debug("Item name: " + filename); Log.debug("Item name: " + filename);
Log.debug("Item path: " + item.getPath()); Log.debug("Item path: " + item.getPath());
importSession.setItemId(item.getId()); codelistMappingSession.setItemId(item.getId());
getWizardWindow().setEnableNextButton(true); getWizardWindow().setEnableNextButton(true);
} else { } else {
@ -88,11 +88,11 @@ public class CodelistMappingWorkSpaceSelectionCard extends WizardCard {
@Override @Override
public void setup() { public void setup() {
Log.debug("CSVWorkSpaceSelectionCard Call Setup "); Log.debug("CodelistMappingWorkSpaceSelectionCard Call Setup ");
Command sayNextCard = new Command() { Command sayNextCard = new Command() {
public void execute() { public void execute() {
Log.debug("CSVWorkSpaceSelectionCard Call sayNextCard wpanel:" Log.debug("CodelistMappingWorkSpaceSelectionCard Call sayNextCard wpanel:"
+ wpanel); + wpanel);
wpanel.disable(); wpanel.disable();
wpanel.startWaiting(); wpanel.startWaiting();
@ -110,7 +110,7 @@ public class CodelistMappingWorkSpaceSelectionCard extends WizardCard {
try { try {
getWizardWindow().previousCard(); getWizardWindow().previousCard();
getWizardWindow().removeCard(thisCard); getWizardWindow().removeCard(thisCard);
Log.debug("Remove CSVWorkSpaceSelectionCard"); Log.debug("Remove CodelistMappingWorkSpaceSelectionCard");
} catch (Exception e) { } catch (Exception e) {
Log.error("sayPreviousCard :" + e.getLocalizedMessage()); Log.error("sayPreviousCard :" + e.getLocalizedMessage());
} }
@ -124,7 +124,7 @@ public class CodelistMappingWorkSpaceSelectionCard extends WizardCard {
protected void getFileFromWorkspace() { protected void getFileFromWorkspace() {
TDGWTServiceAsync tdGwtServiceAsync = TDGWTServiceAsync.INSTANCE; TDGWTServiceAsync tdGwtServiceAsync = TDGWTServiceAsync.INSTANCE;
tdGwtServiceAsync.getFileFromWorkspace(importSession, tdGwtServiceAsync.getFileFromWorkspace(codelistMappingSession,
new AsyncCallback<Void>() { new AsyncCallback<Void>() {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -144,7 +144,7 @@ public class CodelistMappingWorkSpaceSelectionCard extends WizardCard {
public void onSuccess(Void result) { public void onSuccess(Void result) {
wpanel.endWaiting(); wpanel.endWaiting();
goForward(); goNext();
} }
@ -152,9 +152,9 @@ public class CodelistMappingWorkSpaceSelectionCard extends WizardCard {
} }
protected void goForward() { protected void goNext() {
CodelistMappingTableDetailCard detailsCard = new CodelistMappingTableDetailCard( CodelistMappingTableDetailCard detailsCard = new CodelistMappingTableDetailCard(
importSession); codelistMappingSession);
getWizardWindow().addCard(detailsCard); getWizardWindow().addCard(detailsCard);
Log.info("NextCard CodelistMappingTableDetailCard"); Log.info("NextCard CodelistMappingTableDetailCard");
getWizardWindow().nextCard(); getWizardWindow().nextCard();

View File

@ -3,12 +3,12 @@
*/ */
package org.gcube.portlets.user.td.codelistmappingimportwidget.client; package org.gcube.portlets.user.td.codelistmappingimportwidget.client;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession;
import org.gcube.portlets.user.td.gwtservice.shared.source.FileSource; import org.gcube.portlets.user.td.gwtservice.shared.source.FileSource;
import org.gcube.portlets.user.td.gwtservice.shared.source.SourceType;
import org.gcube.portlets.user.td.gwtservice.shared.source.UrlSource; import org.gcube.portlets.user.td.gwtservice.shared.source.UrlSource;
import org.gcube.portlets.user.td.gwtservice.shared.source.WorkspaceSource; import org.gcube.portlets.user.td.gwtservice.shared.source.WorkspaceSource;
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.logical.shared.ValueChangeEvent; import com.google.gwt.event.logical.shared.ValueChangeEvent;
@ -27,18 +27,18 @@ import com.sencha.gxt.widget.core.client.form.Radio;
*/ */
public class SourceSelectionCard extends WizardCard { public class SourceSelectionCard extends WizardCard {
protected final CSVImportSession importSession; protected final CodelistMappingSession codelistMappingSession;
final UrlSource urlSource = UrlSource.INSTANCE; final UrlSource urlSource = UrlSource.INSTANCE;
final FileSource fileSource = FileSource.INSTANCE; final FileSource fileSource = FileSource.INSTANCE;
final WorkspaceSource workspaceSource = WorkspaceSource.INSTANCE; final WorkspaceSource workspaceSource = WorkspaceSource.INSTANCE;
public SourceSelectionCard(final CSVImportSession importSession) { public SourceSelectionCard(final CodelistMappingSession codelistMappingSession) {
super("Codelist Mapping source selection", ""); super("Codelist Mapping source selection", "");
this.importSession = importSession; this.codelistMappingSession = codelistMappingSession;
// Default // Default
importSession.setSource(urlSource); codelistMappingSession.setSource(urlSource);
VerticalPanel sourceSelectionPanel = new VerticalPanel(); VerticalPanel sourceSelectionPanel = new VerticalPanel();
sourceSelectionPanel.setStylePrimaryName(res.wizardCSS() sourceSelectionPanel.setStylePrimaryName(res.wizardCSS()
@ -88,15 +88,15 @@ public class SourceSelectionCard extends WizardCard {
Radio radio = (Radio) group.getValue(); Radio radio = (Radio) group.getValue();
Log.info("Source Selected:" + radio.getName()); Log.info("Source Selected:" + radio.getName());
if (radio.getName().compareTo(urlSource.getName()) == 0) { if (radio.getName().compareTo(urlSource.getName()) == 0) {
importSession.setSource(urlSource); codelistMappingSession.setSource(urlSource);
} else { } else {
if (radio.getName() if (radio.getName()
.compareTo(workspaceSource.getName()) == 0) { .compareTo(workspaceSource.getName()) == 0) {
importSession.setSource(workspaceSource); codelistMappingSession.setSource(workspaceSource);
} else { } else {
if (radio.getName().compareTo(fileSource.getName()) == 0) { if (radio.getName().compareTo(fileSource.getName()) == 0) {
importSession.setSource(fileSource); codelistMappingSession.setSource(fileSource);
} else { } else {
} }
@ -122,26 +122,35 @@ public class SourceSelectionCard extends WizardCard {
Command sayNextCard = new Command() { Command sayNextCard = new Command() {
public void execute() { public void execute() {
try { try {
String sourceId = importSession.getSource().getId(); String sourceId = codelistMappingSession.getSource().getId();
if (sourceId == null || sourceId.isEmpty()) { if (sourceId == null || sourceId.isEmpty()) {
Log.error("CSV Import Source Id: " + sourceId); Log.error("Codelist Mapping Import Source Id: " + sourceId);
} else { } else {
if (sourceId.compareTo("File") == 0) { if (sourceId.compareTo(SourceType.FILE.toString()) == 0) {
Log.info("NextCard CSVUploadFileCard"); Log.info("NextCard CodelistMappingUploadFileCard");
CodelistMappingUploadFileCard csvUploadFileCard = new CodelistMappingUploadFileCard( CodelistMappingUploadFileCard codelistMappingUploadFileCard = new CodelistMappingUploadFileCard(
importSession); codelistMappingSession);
getWizardWindow().addCard(csvUploadFileCard); getWizardWindow().addCard(codelistMappingUploadFileCard);
getWizardWindow().nextCard(); getWizardWindow().nextCard();
} else { } else {
if (sourceId.compareTo("Workspace") == 0) { if (sourceId.compareTo(SourceType.WORKSPACE.toString()) == 0) {
Log.info("NextCard CSVWorkspaceSelectionCard"); Log.info("NextCard CSVWorkspaceSelectionCard");
CodelistMappingWorkSpaceSelectionCard csvWorkspaceSelectionCard = new CodelistMappingWorkSpaceSelectionCard( CodelistMappingWorkSpaceSelectionCard codelistMappingWorkspaceSelectionCard = new CodelistMappingWorkSpaceSelectionCard(
importSession); codelistMappingSession);
getWizardWindow().addCard( getWizardWindow().addCard(
csvWorkspaceSelectionCard); codelistMappingWorkspaceSelectionCard);
getWizardWindow().nextCard(); getWizardWindow().nextCard();
} else { } else {
Log.debug("No source selected and no card loaded"); if (sourceId.compareTo(SourceType.URL.toString()) == 0) {
Log.info("NextCard CodelistMappingURLSelectionCard");
CodelistMappingUrlSelectionCard codelistMappingUrlSelectionCard = new CodelistMappingUrlSelectionCard(
codelistMappingSession);
getWizardWindow().addCard(
codelistMappingUrlSelectionCard);
getWizardWindow().nextCard();
} else {
Log.debug("No source selected and no card loaded");
}
} }
} }
} }

View File

@ -6,7 +6,7 @@ package org.gcube.portlets.user.td.codelistmappingimportwidget.client.progress;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingMonitor;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
@ -33,7 +33,7 @@ public class CodelistMappingImportProgressUpdater extends Timer {
public void run() { public void run() {
Log.debug("requesting operation progress"); Log.debug("requesting operation progress");
TDGWTServiceAsync.INSTANCE TDGWTServiceAsync.INSTANCE
.getCSVImportMonitor(new AsyncCallback<CSVImportMonitor>() { .getCodelistMappingMonitor(new AsyncCallback<CodelistMappingMonitor>() {
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -45,7 +45,7 @@ public class CodelistMappingImportProgressUpdater extends Timer {
"Failed getting operation updates", message); "Failed getting operation updates", message);
} }
public void onSuccess(CSVImportMonitor result) { public void onSuccess(CodelistMappingMonitor result) {
Log.info("retrieved CSVImportMonitor: " Log.info("retrieved CSVImportMonitor: "
+ result.getStatus()); + result.getStatus());
switch (result.getStatus()) { switch (result.getStatus()) {
@ -77,7 +77,7 @@ public class CodelistMappingImportProgressUpdater extends Timer {
break; break;
case SUCCEDED: case SUCCEDED:
cancel(); cancel();
Log.info("Import fisnish TableId :" Log.info("Import fisnish:"
+ result.getTrId()); + result.getTrId());
fireOperationComplete(result.getTrId()); fireOperationComplete(result.getTrId());
break; break;
@ -92,26 +92,26 @@ public class CodelistMappingImportProgressUpdater extends Timer {
} }
protected void errorMessage(CSVImportMonitor result) { protected void errorMessage(CodelistMappingMonitor result) {
Log.info("CSV Import Failed"); Log.info("Codelist Mapping Import Failed");
Throwable th = null; Throwable th = null;
String failure = null; String failure = null;
String details = null; String details = null;
if (result.getError() != null) { if (result.getError() != null) {
th = result.getError(); th = result.getError();
failure = "Failed Client Library Import"; failure = "Failed Client Library Codelist Mapping Import";
details = result.getError().getLocalizedMessage(); details = result.getError().getLocalizedMessage();
} else { } else {
th = new Throwable("Failed"); th = new Throwable("Failed");
failure = "Failed Client Library Import"; failure = "Failed Client Library Codelist Mapping Import";
details = "Error in import"; details = "Error in codelist mapping import";
} }
fireOperationFailed(th, failure, details); fireOperationFailed(th, failure, details);
} }
protected void stopMessage(CSVImportMonitor result) { protected void stopMessage(CodelistMappingMonitor result) {
Log.info("CSV Import Stopped"); Log.info("Codelist Mapping Import Stopped");
String failure = null; String failure = null;
String details = null; String details = null;
if (result.getError() != null) { if (result.getError() != null) {
@ -119,7 +119,7 @@ public class CodelistMappingImportProgressUpdater extends Timer {
details = result.getError().getLocalizedMessage(); details = result.getError().getLocalizedMessage();
} else { } else {
failure = "Stopped"; failure = "Stopped";
details = "Stopped import CSV"; details = "Stopped codelist mapping import";
} }
fireOperationStopped(result.getTrId(),failure, details); fireOperationStopped(result.getTrId(),failure, details);