Managed files already published
This commit is contained in:
parent
3450eda4f2
commit
1f720a786b
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -24,13 +25,16 @@ import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CkanToZendoPublisherWidget.
|
* The Class CkanToZendoPublisherWidget.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
*
|
*
|
||||||
* Dec 9, 2019
|
* Jan 28, 2020
|
||||||
*/
|
*/
|
||||||
public class CkanToZendoPublisherWidget {
|
public class CkanToZendoPublisherWidget {
|
||||||
|
|
||||||
|
@ -41,16 +45,24 @@ public class CkanToZendoPublisherWidget {
|
||||||
private BasicTabPanel basicTabPanel;
|
private BasicTabPanel basicTabPanel;
|
||||||
private ModalFooter modalFooter;
|
private ModalFooter modalFooter;
|
||||||
public static Map<String, String> mapOfFieldsDescriptions = new HashMap<String, String>();
|
public static Map<String, String> mapOfFieldsDescriptions = new HashMap<String, String>();
|
||||||
|
private final Modal modal = new Modal(true);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new ckan to zendo publisher widget.
|
||||||
|
*/
|
||||||
public CkanToZendoPublisherWidget() {
|
public CkanToZendoPublisherWidget() {
|
||||||
ckanToZenodoService = CkanToZenodoPublisherServiceAsync.Util.getInstance();
|
ckanToZenodoService = CkanToZenodoPublisherServiceAsync.Util.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Publish on zenodo.
|
||||||
|
*
|
||||||
|
* @param item the item
|
||||||
|
*/
|
||||||
public void publishOnZenodo(final CatalogueItem item) {
|
public void publishOnZenodo(final CatalogueItem item) {
|
||||||
|
|
||||||
final Modal modal = new Modal(true);
|
|
||||||
modal.setTitle("Upload to Zenodo...");
|
modal.setTitle("Upload to Zenodo...");
|
||||||
modal.addStyleName("ckan2zenodo-modal-style");
|
modal.addStyleName("ckan2zenodo-modal-style");
|
||||||
modal.setCloseVisible(true);
|
modal.setCloseVisible(true);
|
||||||
|
@ -71,20 +83,10 @@ public class CkanToZendoPublisherWidget {
|
||||||
loader.setVisible(false);
|
loader.setVisible(false);
|
||||||
modal.remove(loader);
|
modal.remove(loader);
|
||||||
Alert erroLabel = new Alert();
|
Alert erroLabel = new Alert();
|
||||||
erroLabel.setClose(false);
|
//erroLabel.setClose(false);
|
||||||
erroLabel.setType(AlertType.ERROR);
|
erroLabel.setType(AlertType.ERROR);
|
||||||
erroLabel.setText(caught.getLocalizedMessage());
|
erroLabel.setText(caught.getLocalizedMessage());
|
||||||
modal.add(erroLabel);
|
showResults(Arrays.asList(erroLabel.asWidget()));
|
||||||
Button close = new Button("Close");
|
|
||||||
close.addClickHandler(new ClickHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
modal.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
modal.add(close);
|
|
||||||
//Window.alert(caught.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -143,21 +145,11 @@ public class CkanToZendoPublisherWidget {
|
||||||
buttonPublish.setEnabled(true);
|
buttonPublish.setEnabled(true);
|
||||||
basicTabPanel.getElement().getStyle().setOpacity(1.0);
|
basicTabPanel.getElement().getStyle().setOpacity(1.0);
|
||||||
modalFooter.remove(loaderPublishing);
|
modalFooter.remove(loaderPublishing);
|
||||||
//modal.clear();
|
|
||||||
Alert erroLabel = new Alert();
|
Alert erroLabel = new Alert();
|
||||||
erroLabel.setClose(false);
|
//erroLabel.setClose(false);
|
||||||
erroLabel.setType(AlertType.ERROR);
|
erroLabel.setType(AlertType.ERROR);
|
||||||
erroLabel.setText(caught.getLocalizedMessage());
|
erroLabel.setText(caught.getLocalizedMessage());
|
||||||
modalFooter.add(erroLabel);
|
showResults(Arrays.asList(erroLabel.asWidget()));
|
||||||
Button close = new Button("Close");
|
|
||||||
close.addClickHandler(new ClickHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
modal.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
modal.add(close);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -175,26 +167,14 @@ public class CkanToZendoPublisherWidget {
|
||||||
infoLabel.setClose(false);
|
infoLabel.setClose(false);
|
||||||
infoLabel.setType(AlertType.INFO);
|
infoLabel.setType(AlertType.INFO);
|
||||||
infoLabel.setText(msg);
|
infoLabel.setText(msg);
|
||||||
modalFooter.add(infoLabel);
|
|
||||||
|
showResults(Arrays.asList(infoLabel.asWidget()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
basicTabPanel.managePager(PAGER.BACK); //TO SHOW THE FIELD MISSING
|
basicTabPanel.managePager(PAGER.BACK); //TO SHOW THE FIELD/s MISSING
|
||||||
// Alert infoLabel = new Alert(true);
|
|
||||||
// infoLabel.setAnimation(true);
|
|
||||||
// infoLabel.set
|
|
||||||
// infoLabel.setType(AlertType.WARNING);
|
|
||||||
// infoLabel.setText("Please, check your inputs, a required field is missing...");
|
|
||||||
// modalFooter.add(infoLabel);
|
|
||||||
}
|
}
|
||||||
// else {
|
|
||||||
// Alert infoLabel = new Alert();
|
|
||||||
// infoLabel.setClose(false);
|
|
||||||
// infoLabel.setType(AlertType.WARNING);
|
|
||||||
// infoLabel.setText("Please, check your inputs, a required field is missing...");
|
|
||||||
// modalFooter.add(infoLabel);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -203,4 +183,20 @@ public class CkanToZendoPublisherWidget {
|
||||||
modal.show();
|
modal.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show results.
|
||||||
|
*
|
||||||
|
* @param listWidget the list widget
|
||||||
|
*/
|
||||||
|
private void showResults(List<Widget> listWidget) {
|
||||||
|
VerticalPanel vp = new VerticalPanel();
|
||||||
|
for (Widget widget : listWidget) {
|
||||||
|
widget.getElement().getStyle().setMarginBottom(5.0, com.google.gwt.dom.client.Style.Unit.PX);
|
||||||
|
vp.add(widget);
|
||||||
|
}
|
||||||
|
modal.insert(vp, 1);
|
||||||
|
vp.getElement().focus();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,69 +3,109 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.publishfile;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.Fieldset;
|
import com.github.gwtbootstrap.client.ui.Fieldset;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
|
import com.google.gwt.user.client.ui.Label;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class PublishFilesFormView.
|
* The Class PublishFilesFormView.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
*
|
*
|
||||||
* Dec 17, 2019
|
* Jan 28, 2020
|
||||||
*/
|
*/
|
||||||
public class PublishFilesFormView extends Composite {
|
public class PublishFilesFormView extends Composite {
|
||||||
|
|
||||||
private static PublishFilesFormViewUiBinder uiBinder = GWT.create(PublishFilesFormViewUiBinder.class);
|
private static PublishFilesFormViewUiBinder uiBinder = GWT.create(PublishFilesFormViewUiBinder.class);
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
Fieldset field_form_files;
|
Fieldset field_form_files;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
Fieldset field_form_files_already_published;
|
||||||
|
|
||||||
// @UiField
|
@UiField
|
||||||
// Pager pager;
|
HorizontalPanel panelOfFilesPublished;
|
||||||
|
|
||||||
private List<PublishFileView> lstPFV = new ArrayList<PublishFileView>();
|
private List<PublishFileView> lstPFV = new ArrayList<PublishFileView>();
|
||||||
|
|
||||||
|
private List<ZenodoFile> alreadyPublished = new ArrayList<ZenodoFile>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Interface PublishFilesFormViewUiBinder.
|
* The Interface PublishFilesFormViewUiBinder.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
*
|
*
|
||||||
* Dec 17, 2019
|
* Dec 17, 2019
|
||||||
*/
|
*/
|
||||||
interface PublishFilesFormViewUiBinder extends UiBinder<Widget, PublishFilesFormView> {
|
interface PublishFilesFormViewUiBinder extends UiBinder<Widget, PublishFilesFormView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new publish files form view.
|
* Instantiates a new publish files form view.
|
||||||
* @param tabIndex
|
*
|
||||||
|
* @param tabIndex the tab index
|
||||||
*/
|
*/
|
||||||
public PublishFilesFormView(int tabIndex) {
|
public PublishFilesFormView(int tabIndex) {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the file.
|
|
||||||
*
|
|
||||||
* @param fileVP the file VP
|
|
||||||
*/
|
|
||||||
public void addFile(PublishFileView fileVP) {
|
|
||||||
lstPFV.add(fileVP);
|
|
||||||
field_form_files.add(fileVP);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list of publishing file view.
|
* Gets the list of publishing file view.
|
||||||
*
|
*
|
||||||
* @return the list of publishing file view
|
* @return the list of publishing file view
|
||||||
*/
|
*/
|
||||||
public List<PublishFileView> getListOfPublishingFileView(){
|
public List<PublishFileView> getListOfPublishingFileView() {
|
||||||
return lstPFV;
|
return lstPFV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the file.
|
||||||
|
*
|
||||||
|
* @param file the file
|
||||||
|
* @return the publish file view if is a file to publish
|
||||||
|
*/
|
||||||
|
public PublishFileView addFile(ZenodoFile file) {
|
||||||
|
|
||||||
|
PublishFileView pv = null;
|
||||||
|
if (file.getIsAlreadyPublished()) {
|
||||||
|
|
||||||
|
Label alert = new Label();
|
||||||
|
alert.setText(file.getFilename());
|
||||||
|
panelOfFilesPublished.add(alert);
|
||||||
|
field_form_files_already_published.setVisible(true);
|
||||||
|
alreadyPublished.add(file);
|
||||||
|
|
||||||
|
}else {
|
||||||
|
pv = new PublishFileView(file);
|
||||||
|
pv.getField_file_name().setValue(file.getFilename());
|
||||||
|
pv.getSwitchButton().setValue(true);
|
||||||
|
lstPFV.add(pv);
|
||||||
|
field_form_files.add(pv);
|
||||||
|
}
|
||||||
|
return pv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the already published.
|
||||||
|
*
|
||||||
|
* @return the already published
|
||||||
|
*/
|
||||||
|
public List<ZenodoFile> getAlreadyPublished() {
|
||||||
|
return alreadyPublished;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Fieldset getField_form_files_already_published() {
|
||||||
|
return field_form_files_already_published;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,16 +10,31 @@
|
||||||
.noBorder {
|
.noBorder {
|
||||||
border: 0px;
|
border: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.maring-top-high {
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.margin-left-files-published {
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
</ui:style>
|
</ui:style>
|
||||||
<g:HTMLPanel>
|
<g:HTMLPanel>
|
||||||
<b:Form type="HORIZONTAL">
|
<b:Form type="HORIZONTAL">
|
||||||
|
<b:Fieldset styleName="{style.noBorder}"
|
||||||
|
ui:field="field_form_files_already_published" visible="false">
|
||||||
|
<b:Legend addStyleNames="legend-style">
|
||||||
|
File/s already published on Zenodo
|
||||||
|
<g:HorizontalPanel
|
||||||
|
ui:field="panelOfFilesPublished"
|
||||||
|
addStyleNames="{style.margin-left-files-published}"></g:HorizontalPanel>
|
||||||
|
</b:Legend>
|
||||||
|
</b:Fieldset>
|
||||||
<b:Fieldset styleName="{style.noBorder}"
|
<b:Fieldset styleName="{style.noBorder}"
|
||||||
ui:field="field_form_files">
|
ui:field="field_form_files">
|
||||||
<b:Legend addStyleNames="legend-style"> Select the file/s to upload...
|
<b:Legend addStyleNames="legend-style"> Select the file/s to upload
|
||||||
</b:Legend>
|
</b:Legend>
|
||||||
</b:Fieldset>
|
</b:Fieldset>
|
||||||
</b:Form>
|
</b:Form>
|
||||||
<!-- <b:Pager left="Back" right="Next" aligned="true" -->
|
|
||||||
<!-- ui:field="pager" /> -->
|
|
||||||
</g:HTMLPanel>
|
</g:HTMLPanel>
|
||||||
</ui:UiBinder>
|
</ui:UiBinder>
|
|
@ -8,6 +8,7 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.publishfile.Pub
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile;
|
||||||
|
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
|
||||||
public class PublishFileViewManager {
|
public class PublishFileViewManager {
|
||||||
|
|
||||||
|
@ -25,23 +26,15 @@ public class PublishFileViewManager {
|
||||||
|
|
||||||
if (listFiles != null) {
|
if (listFiles != null) {
|
||||||
for (ZenodoFile file : listFiles) {
|
for (ZenodoFile file : listFiles) {
|
||||||
PublishFileView pfv = addFileForPublishing(file);
|
publishFileFormView.addFile(file);
|
||||||
publishFileFormView.addFile(pfv);
|
}
|
||||||
|
|
||||||
|
if(publishFileFormView.getAlreadyPublished().size()>0) {
|
||||||
|
publishFileFormView.getField_form_files_already_published().add(new HTML("<hr>"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PublishFileView addFileForPublishing(ZenodoFile file) {
|
|
||||||
PublishFileView pv = new PublishFileView(file);
|
|
||||||
pv.getField_file_name().setValue(file.getFilename());
|
|
||||||
pv.getSwitchButton().setValue(true);
|
|
||||||
|
|
||||||
if(file.getIsAlreadyPublished()) {
|
|
||||||
pv.hideSwitchButton(true, "File already published on Zenodo");
|
|
||||||
}
|
|
||||||
return pv;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Composite getView(){
|
public Composite getView(){
|
||||||
return publishFileFormView;
|
return publishFileFormView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.gcube.data.publishing.ckan2zenodo.model.faults.TransformationExceptio
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.faults.ZenodoException;
|
import org.gcube.data.publishing.ckan2zenodo.model.faults.ZenodoException;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition;
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZendoPublisherWidgetConstant;
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.server.configuration.ZenodoFieldsDescriptionsReader;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.server.configuration.ZenodoFieldsDescriptionsReader;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.server.converter.ItemToZenodoConverter;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.server.converter.ItemToZenodoConverter;
|
||||||
|
|
Loading…
Reference in New Issue