diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/CkanToZendoPublisherWidget.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/CkanToZendoPublisherWidget.java index 154d728..3b22efa 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/CkanToZendoPublisherWidget.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/CkanToZendoPublisherWidget.java @@ -31,7 +31,7 @@ public class CkanToZendoPublisherWidget { private CkanToZenodoPublisherServiceAsync ckanToZenodoService; - private Button buttonPublish = new Button("Publish on Zenodo"); + private Button buttonPublish = new Button("Upload to Zenodo"); private Ckan2ZenodoViewManager manager = null; private BasicTabPanel basicTabPanel; private ModalFooter modalFooter; @@ -91,7 +91,7 @@ public class CkanToZendoPublisherWidget { public void onClick(ClickEvent event) { if(manager==null) - Window.alert("Sorry, the zenodo publishing is not available at this point"); + Window.alert("Sorry, the upload to zenodo is not available at this point"); boolean allFormsAreValid = true; List forms = manager.getListForms(); @@ -104,7 +104,7 @@ public class CkanToZendoPublisherWidget { if(allFormsAreValid) { buttonPublish.setEnabled(false); basicTabPanel.getElement().getStyle().setOpacity(0.5); - final LoaderIcon loaderPublishing = new LoaderIcon("Trying to publish on Zenodo..."); + final LoaderIcon loaderPublishing = new LoaderIcon("Trying to upload on Zenodo..."); modalFooter.add(loaderPublishing); //Submit publish on zenodo. ZenodoItem zenodoItem = manager.getZenodoItemFromFieldsForm(); diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/basicinformation/BasicInformationView.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/basicinformation/BasicInformationView.java index e79c98d..d1942ab 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/basicinformation/BasicInformationView.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/basicinformation/BasicInformationView.java @@ -7,6 +7,7 @@ import java.util.List; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors.CreatorsFormView; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.tags.TagsPanel; +import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils.FieldDescription; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FieldUtil; import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoAuthor; @@ -169,6 +170,14 @@ public class BasicInformationView extends Composite implements FormValidator { ZenodoMetadata zMeta = zenodoItem.getMetadata(); if (zMeta != null) { String title = zenodoItem.getTitle()!=null?zenodoItem.getTitle():zMeta.getTitle(); + + String value = zenodoItem.getFieldsDescriptions().get("title"); + if(value!=null) { + Widget parent = field_title.getParent(); + FieldDescription fd = new FieldDescription(null, value); + parent.getElement().appendChild(fd.getElement()); + } + field_title.setValue(title); //Re.fill title to be sure //Upload type diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/publishfile/PublishFilesFormView.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/publishfile/PublishFilesFormView.ui.xml index 2f7c08e..7dce4a8 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/publishfile/PublishFilesFormView.ui.xml +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/publishfile/PublishFilesFormView.ui.xml @@ -15,7 +15,7 @@ - Choose the file/s to publish... + Select the file/s to upload... diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/utils/FieldDescription.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/utils/FieldDescription.java new file mode 100644 index 0000000..21d87ba --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/utils/FieldDescription.java @@ -0,0 +1,38 @@ +package org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.utils; + +import com.github.gwtbootstrap.client.ui.Icon; +import com.github.gwtbootstrap.client.ui.Popover; +import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Style.Cursor; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.Widget; + +public class FieldDescription extends Composite { + + private static FieldDescriptionUiBinder uiBinder = GWT.create(FieldDescriptionUiBinder.class); + + interface FieldDescriptionUiBinder extends UiBinder { + } + + @UiField + Popover popoverDescription; + + @UiField + Icon infoIconDescription; + + public FieldDescription(String captionText, String text) { + initWidget(uiBinder.createAndBindUi(this)); + + // prepare the popover + if(captionText!=null) + popoverDescription.setHeading(new HTML("" + captionText + "").getHTML()); + + popoverDescription.setText(new HTML("

" + text + "

").getHTML()); + + // set icon cursor + infoIconDescription.getElement().getStyle().setCursor(Cursor.HELP); + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/utils/FieldDescription.ui.xml b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/utils/FieldDescription.ui.xml new file mode 100644 index 0000000..6f49975 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/client/ui/utils/FieldDescription.ui.xml @@ -0,0 +1,24 @@ + + + + .important { + font-weight: bold; + } + .div-inline{ + display: inline; + } + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/public/CkanToZenodoPublisher.css b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/public/CkanToZenodoPublisher.css index c7c815a..90547c1 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/public/CkanToZenodoPublisher.css +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/public/CkanToZenodoPublisher.css @@ -41,7 +41,6 @@ margin-bottom: 0px; font-size: 18px; color: gray; - text-align: right; } .form-font-size .tabbable { diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoPublisherServiceImpl.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoPublisherServiceImpl.java index b5b1d15..2e68d40 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoPublisherServiceImpl.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/CkanToZenodoPublisherServiceImpl.java @@ -19,6 +19,7 @@ import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata; 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.server.configuration.ZenodoFieldsDescriptionsReader; import org.gcube.portlets.widgets.ckan2zenodopublisher.server.converter.ItemToZenodoConverter; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem; import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile; @@ -148,6 +149,8 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple zenodoItem.addFiles(resources); zenodoItem.setName(item.getItemName()); + + zenodoItem.setFieldsDescriptions(ZenodoFieldsDescriptionsReader.readProperties()); LOG.debug("Returning item: "+zenodoItem); return zenodoItem; diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/configuration/ZenodoFieldsDescriptionsReader.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/configuration/ZenodoFieldsDescriptionsReader.java new file mode 100644 index 0000000..5eb38e0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/configuration/ZenodoFieldsDescriptionsReader.java @@ -0,0 +1,40 @@ +package org.gcube.portlets.widgets.ckan2zenodopublisher.server.configuration; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ZenodoFieldsDescriptionsReader { + + private static final String ZENODO_FIELDS_SUGGESTIONS_PROPERTIES = "zenodo_fields_suggestions.properties"; + + private static Logger LOG = LoggerFactory.getLogger(ZenodoFieldsDescriptionsReader.class); + + public static Map readProperties() { + + Map map = null; + + try (InputStream in = ZenodoFieldsDescriptionsReader.class.getResourceAsStream(ZENODO_FIELDS_SUGGESTIONS_PROPERTIES)) { + // load a properties file + Properties prop = new Properties(); + prop.load(in); + map = new HashMap(prop.keySet().size()); + for (Object key : prop.keySet()) { + String value = (String) prop.get(key); + LOG.debug("Zenodo Field descriptor read (" + key + ", " + value +")"); + map.put((String) key, (String) prop.get(key)); + } + + } catch (IOException e) { + LOG.error("Error occurred on reading the property file: " + ZENODO_FIELDS_SUGGESTIONS_PROPERTIES, e); + } + + return map; + } + +} diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/configuration/zenodo_fields_suggestions.properties b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/configuration/zenodo_fields_suggestions.properties new file mode 100644 index 0000000..55e80c5 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/server/configuration/zenodo_fields_suggestions.properties @@ -0,0 +1,7 @@ +#Property file to read the fields descriptions to show on GUI side +title = Title of deposition. +description = Abstract or description for deposition. +creators = The creators/authors of the deposition. Name of creator (is required) in the format Family name, Given names +access_right = open: Open Access, embargoed: Embargoed Access, restricted: Restricted Access, closed: Closed Access Defaults to open. +license = The selected license applies to all files in this deposition, but not to the metadata which is licensed under Creative Commons Zero. Further information about licenses is available at Open Definition Licenses Service. Defaults to cc-by for non-datasets and cc-zero for datasets. +contributors = The contributors of the deposition (e.g. editors, data curators, etc.). Name of creator (is required) in the format Family name, Given names \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/ZenodoItem.java b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/ZenodoItem.java index fae5be1..f0d9864 100644 --- a/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/ZenodoItem.java +++ b/src/main/java/org/gcube/portlets/widgets/ckan2zenodopublisher/shared/wrapped/ZenodoItem.java @@ -2,7 +2,9 @@ package org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped; import java.io.Serializable; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * The Class ZenodoItem. @@ -32,6 +34,8 @@ public class ZenodoItem implements Serializable { private String title; private String name; //this is the dataset name + private Map fieldsDescriptions; + /** * Instantiates a new zenodo item. */ @@ -276,6 +280,30 @@ public class ZenodoItem implements Serializable { public void setName(String name) { this.name = name; } + + + /** + * Sets the fields descriptions. + * + * @param mapOfFieldsDescriptions the map of fields descriptions + */ + public void setFieldsDescriptions(Map mapOfFieldsDescriptions) { + this.fieldsDescriptions = mapOfFieldsDescriptions; + } + + + /** + * Gets the fields descriptions. + * + * @return the fields descriptions + */ + public Map getFieldsDescriptions() { + if(fieldsDescriptions == null) + return new HashMap(); + + return fieldsDescriptions; + } + /* (non-Javadoc) * @see java.lang.Object#toString() @@ -313,4 +341,5 @@ public class ZenodoItem implements Serializable { return builder.toString(); } + } diff --git a/src/main/webapp/CkanToZenodoPublisher.css b/src/main/webapp/CkanToZenodoPublisher.css deleted file mode 100644 index 87cb15b..0000000 --- a/src/main/webapp/CkanToZenodoPublisher.css +++ /dev/null @@ -1,10 +0,0 @@ -/** Add css rules here for your application. */ - -.ckan2zenodo-modal-style { - width: 800px !important; - left: -400px !important; -} - -.ckan2zenodo-modal-style input { - width: 400px -} \ No newline at end of file