Working on #18236
This commit is contained in:
parent
b7904782f8
commit
d68726721c
|
@ -1,18 +1,19 @@
|
||||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.client;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.Ckan2ZenodoViewManager;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.Ckan2ZenodoViewManager;
|
||||||
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.LoaderIcon;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.LoaderIcon;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.CatalogueItem;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.Alert;
|
import com.github.gwtbootstrap.client.ui.Alert;
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
import com.github.gwtbootstrap.client.ui.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.Label;
|
|
||||||
import com.github.gwtbootstrap.client.ui.Modal;
|
import com.github.gwtbootstrap.client.ui.Modal;
|
||||||
import com.github.gwtbootstrap.client.ui.ModalFooter;
|
import com.github.gwtbootstrap.client.ui.ModalFooter;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.LabelType;
|
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
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;
|
||||||
|
@ -31,6 +32,7 @@ public class CkanToZendoPublisherWidget {
|
||||||
.getInstance();
|
.getInstance();
|
||||||
|
|
||||||
private Button buttonPublish = new Button("Publish on Zenodo");
|
private Button buttonPublish = new Button("Publish on Zenodo");
|
||||||
|
private Ckan2ZenodoViewManager manager = null;
|
||||||
/**
|
/**
|
||||||
* Instantiates a new ckan to zendo publisher widget.
|
* Instantiates a new ckan to zendo publisher widget.
|
||||||
*/
|
*/
|
||||||
|
@ -79,7 +81,7 @@ public class CkanToZendoPublisherWidget {
|
||||||
public void onSuccess(ZenodoItem result) {
|
public void onSuccess(ZenodoItem result) {
|
||||||
loader.setVisible(false);
|
loader.setVisible(false);
|
||||||
modal.remove(loader);
|
modal.remove(loader);
|
||||||
Ckan2ZenodoViewManager manager = new Ckan2ZenodoViewManager();
|
manager = new Ckan2ZenodoViewManager();
|
||||||
BasicTabPanel basicTabPanel = manager.viewForPublishing(result);
|
BasicTabPanel basicTabPanel = manager.viewForPublishing(result);
|
||||||
modal.add(basicTabPanel);
|
modal.add(basicTabPanel);
|
||||||
buttonPublish.setEnabled(true);
|
buttonPublish.setEnabled(true);
|
||||||
|
@ -90,6 +92,14 @@ public class CkanToZendoPublisherWidget {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
|
|
||||||
|
if(manager==null)
|
||||||
|
Window.alert("Sorry, the zenodo publishing is not available at this point");
|
||||||
|
|
||||||
|
List<FormValidator> forms = manager.getListForms();
|
||||||
|
for (FormValidator formValidator : forms) {
|
||||||
|
formValidator.validateFormFields();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||||
xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
||||||
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
|
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
|
||||||
xmlns:citem="urn:import:org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors">
|
|
||||||
<ui:style>
|
<ui:style>
|
||||||
.noBorder {
|
.noBorder {
|
||||||
border: 0px;
|
border: 0px;
|
||||||
|
@ -15,7 +14,6 @@
|
||||||
<g:VerticalPanel>
|
<g:VerticalPanel>
|
||||||
<g:VerticalPanel styleName="{style.noBorder}"
|
<g:VerticalPanel styleName="{style.noBorder}"
|
||||||
ui:field="fieldset_authors">
|
ui:field="fieldset_authors">
|
||||||
<!-- <citem:CreatorView ui:field="field_authors"></citem:CreatorView> -->
|
|
||||||
</g:VerticalPanel>
|
</g:VerticalPanel>
|
||||||
<b:Button text="Add another Author"
|
<b:Button text="Add another Author"
|
||||||
ui:field="button_add_author" type="LINK" icon="PLUS" addStyleNames="{style.float-right}"></b:Button>
|
ui:field="button_add_author" type="LINK" icon="PLUS" addStyleNames="{style.float-right}"></b:Button>
|
||||||
|
|
|
@ -4,14 +4,19 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors.CreatorsFormView;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors.CreatorsFormView;
|
||||||
|
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.ZenodoItem;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoMetadata;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoMetadata;
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.Alert;
|
||||||
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||||
import com.github.gwtbootstrap.client.ui.Fieldset;
|
import com.github.gwtbootstrap.client.ui.Fieldset;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Label;
|
||||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||||
import com.github.gwtbootstrap.client.ui.TextArea;
|
import com.github.gwtbootstrap.client.ui.TextArea;
|
||||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||||
|
import com.github.gwtbootstrap.client.ui.constants.ControlGroupType;
|
||||||
import com.github.gwtbootstrap.datepicker.client.ui.DateBox;
|
import com.github.gwtbootstrap.datepicker.client.ui.DateBox;
|
||||||
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;
|
||||||
|
@ -24,11 +29,11 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it May 4, 2018
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it May 4, 2018
|
||||||
*/
|
*/
|
||||||
public abstract class BasicInformationView extends Composite {
|
public class BasicInformationView extends Composite implements FormValidator {
|
||||||
|
|
||||||
/** The ui binder. */
|
/** The ui binder. */
|
||||||
private static BasicInformationViewUiBinder uiBinder = GWT.create(BasicInformationViewUiBinder.class);
|
private static BasicInformationViewUiBinder uiBinder = GWT.create(BasicInformationViewUiBinder.class);
|
||||||
|
|
||||||
private CreatorsFormView creatorsView;
|
private CreatorsFormView creatorsView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,59 +49,40 @@ public abstract class BasicInformationView extends Composite {
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
TextBox field_doi;
|
TextBox field_doi;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
Fieldset fieldset_basic_informations;
|
Fieldset fieldset_basic_informations;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
TextArea field_description;
|
TextArea field_description;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
ListBox field_upload_type;
|
ListBox field_upload_type;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
ListBox field_access_right;
|
ListBox field_access_right;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
ListBox field_license;
|
ListBox field_license;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
ListBox field_publication_type;
|
ListBox field_publication_type;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
DateBox field_publication_date;
|
DateBox field_publication_date;
|
||||||
|
|
||||||
|
@UiField
|
||||||
|
Alert error_alert;
|
||||||
|
|
||||||
// @UiField
|
// @UiField
|
||||||
// Pager pager;
|
// Pager pager;
|
||||||
|
|
||||||
//public final static HandlerManager eventBus = new HandlerManager(null);
|
// public final static HandlerManager eventBus = new HandlerManager(null);
|
||||||
|
|
||||||
|
|
||||||
private boolean isEditConfiguration;
|
private boolean isEditConfiguration;
|
||||||
|
|
||||||
private ZenodoItem zenodoItem;
|
private ZenodoItem zenodoItem;
|
||||||
|
|
||||||
/**
|
|
||||||
* Submit handler.
|
|
||||||
*/
|
|
||||||
public abstract void submitHandler();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the error.
|
|
||||||
*
|
|
||||||
* @param visible the visible
|
|
||||||
* @param error the error
|
|
||||||
*/
|
|
||||||
public abstract void setError(boolean visible, String error);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the confirm.
|
|
||||||
*
|
|
||||||
* @param visible the visible
|
|
||||||
* @param msg the msg
|
|
||||||
*/
|
|
||||||
public abstract void setConfirm(boolean visible, String msg);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Because this class has a default constructor, it can be used as a binder
|
* Because this class has a default constructor, it can be used as a binder
|
||||||
* template. In other words, it can be used in other *.ui.xml files as follows:
|
* template. In other words, it can be used in other *.ui.xml files as follows:
|
||||||
|
@ -107,7 +93,8 @@ public abstract class BasicInformationView extends Composite {
|
||||||
* HasHTML instead of HasText.
|
* HasHTML instead of HasText.
|
||||||
*
|
*
|
||||||
* @param zenodoItem the zenodo item
|
* @param zenodoItem the zenodo item
|
||||||
* @param isUpdate the is update
|
* @param isUpdate the is update
|
||||||
|
* @param tabIndex the tab index
|
||||||
*/
|
*/
|
||||||
public BasicInformationView(final ZenodoItem zenodoItem, boolean isUpdate, final int tabIndex) {
|
public BasicInformationView(final ZenodoItem zenodoItem, boolean isUpdate, final int tabIndex) {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
@ -128,8 +115,7 @@ public abstract class BasicInformationView extends Composite {
|
||||||
// this.isEditConfiguration = true;
|
// this.isEditConfiguration = true;
|
||||||
// this.editConfiguration = conf;
|
// this.editConfiguration = conf;
|
||||||
|
|
||||||
//bindEvents();
|
// bindEvents();
|
||||||
|
|
||||||
|
|
||||||
// if (isEditConfiguration) {
|
// if (isEditConfiguration) {
|
||||||
// pager.getRight().setText("Update Configuration");
|
// pager.getRight().setText("Update Configuration");
|
||||||
|
@ -138,8 +124,7 @@ public abstract class BasicInformationView extends Composite {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the visible fields for update.
|
* Sets the visible fields for update.
|
||||||
*
|
*
|
||||||
|
@ -150,10 +135,10 @@ public abstract class BasicInformationView extends Composite {
|
||||||
List<Widget> listWidgtes = new ArrayList<Widget>();
|
List<Widget> listWidgtes = new ArrayList<Widget>();
|
||||||
listWidgtes.add(field_doi);
|
listWidgtes.add(field_doi);
|
||||||
listWidgtes.add(field_publication_date);
|
listWidgtes.add(field_publication_date);
|
||||||
|
|
||||||
for (Widget widget : listWidgtes) {
|
for (Widget widget : listWidgtes) {
|
||||||
Widget parent = widget.getParent().getParent(); //It should be the 'ControlGroup'
|
Widget parent = widget.getParent().getParent(); // It should be the 'ControlGroup'
|
||||||
if(parent instanceof ControlGroup) {
|
if (parent instanceof ControlGroup) {
|
||||||
parent.setVisible(isUpdate);
|
parent.setVisible(isUpdate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,15 +152,15 @@ public abstract class BasicInformationView extends Composite {
|
||||||
field_title.setValue(zenodoItem.getTitle());
|
field_title.setValue(zenodoItem.getTitle());
|
||||||
field_description.setValue(zenodoItem.getMetadata().getDescription());
|
field_description.setValue(zenodoItem.getMetadata().getDescription());
|
||||||
field_doi.setValue(zenodoItem.getDoi().toString());
|
field_doi.setValue(zenodoItem.getDoi().toString());
|
||||||
|
|
||||||
ZenodoMetadata zMeta = zenodoItem.getMetadata();
|
ZenodoMetadata zMeta = zenodoItem.getMetadata();
|
||||||
if(zMeta!=null) {
|
if (zMeta != null) {
|
||||||
addValuesToListBox(field_upload_type, zMeta.getUpload_type().getSelectableValues());
|
addValuesToListBox(field_upload_type, zMeta.getUpload_type().getSelectableValues());
|
||||||
selectValueToListBox(field_upload_type,zMeta.getUpload_type().getSelectableValues());
|
selectValueToListBox(field_upload_type, zMeta.getUpload_type().getSelectableValues());
|
||||||
addValuesToListBox(field_publication_type, zMeta.getPublication_type().getSelectableValues());
|
addValuesToListBox(field_publication_type, zMeta.getPublication_type().getSelectableValues());
|
||||||
selectValueToListBox(field_publication_type,zMeta.getPublication_type().getSelectableValues());
|
selectValueToListBox(field_publication_type, zMeta.getPublication_type().getSelectableValues());
|
||||||
|
|
||||||
//ADDING AUTHORS
|
// ADDING AUTHORS
|
||||||
creatorsView = new CreatorsFormView(zenodoItem.getMetadata().getCreators());
|
creatorsView = new CreatorsFormView(zenodoItem.getMetadata().getCreators());
|
||||||
fieldset_basic_informations.add(creatorsView);
|
fieldset_basic_informations.add(creatorsView);
|
||||||
}
|
}
|
||||||
|
@ -187,44 +172,44 @@ public abstract class BasicInformationView extends Composite {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the values to list box.
|
* Adds the values to list box.
|
||||||
*
|
*
|
||||||
* @param list the list
|
* @param list the list
|
||||||
* @param listValues the list values
|
* @param listValues the list values
|
||||||
*/
|
*/
|
||||||
private void addValuesToListBox(ListBox list, List<String> listValues) {
|
private void addValuesToListBox(ListBox list, List<String> listValues) {
|
||||||
if(listValues==null)
|
if (listValues == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i=0; i<listValues.size(); i++) {
|
for (int i = 0; i < listValues.size(); i++) {
|
||||||
list.setValue(i, listValues.get(i));
|
list.setValue(i, listValues.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Select value to list box.
|
* Select value to list box.
|
||||||
*
|
*
|
||||||
* @param list the list
|
* @param list the list
|
||||||
* @param values the values
|
* @param values the values
|
||||||
*/
|
*/
|
||||||
private void selectValueToListBox(ListBox list, List<String> values) {
|
private void selectValueToListBox(ListBox list, List<String> values) {
|
||||||
String selectValue = null;
|
String selectValue = null;
|
||||||
if(values==null || values.isEmpty()) {
|
if (values == null || values.isEmpty()) {
|
||||||
selectValue = null;
|
selectValue = null;
|
||||||
}else {
|
} else {
|
||||||
selectValue = values.get(0);
|
selectValue = values.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(list.getItemCount()>0)
|
if (list.getItemCount() > 0)
|
||||||
list.setSelectedValue(selectValue);
|
list.setSelectedValue(selectValue);
|
||||||
}catch(Exception e) {
|
} catch (Exception e) {
|
||||||
GWT.log("error: "+e);
|
GWT.log("error: " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void addFileForPublishing(ZenodoFile file) {
|
// private void addFileForPublishing(ZenodoFile file) {
|
||||||
// PublishFileView pv = new PublishFileView();
|
// PublishFileView pv = new PublishFileView();
|
||||||
// pv.getField_file_name().setValue(file.getFilename());
|
// pv.getField_file_name().setValue(file.getFilename());
|
||||||
|
@ -290,7 +275,6 @@ public abstract class BasicInformationView extends Composite {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is edits the configuration.
|
* Checks if is edits the configuration.
|
||||||
*
|
*
|
||||||
|
@ -301,4 +285,78 @@ public abstract class BasicInformationView extends Composite {
|
||||||
return isEditConfiguration;
|
return isEditConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator#
|
||||||
|
* validateForm()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String validateFormFields() {
|
||||||
|
|
||||||
|
error_alert.setVisible(false);
|
||||||
|
|
||||||
|
setControlGroup(field_doi, ControlGroupType.NONE);
|
||||||
|
setControlGroup(field_title, ControlGroupType.NONE);
|
||||||
|
if (field_doi.isVisible()) {
|
||||||
|
String value = getTextValue(field_doi);
|
||||||
|
boolean isValid = FieldUtil.isValidValue(value);
|
||||||
|
if(!isValid) {
|
||||||
|
setControlGroup(field_doi, ControlGroupType.ERROR);
|
||||||
|
error_alert.setVisible(true);
|
||||||
|
error_alert.setText("This field is required");
|
||||||
|
return "This field is required";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field_title.isVisible()) {
|
||||||
|
String value = getTextValue(field_title);
|
||||||
|
boolean isValid = FieldUtil.isValidValue(value);
|
||||||
|
if(!isValid) {
|
||||||
|
setControlGroup(field_title, ControlGroupType.ERROR);
|
||||||
|
error_alert.setVisible(true);
|
||||||
|
error_alert.setText("This field is required");
|
||||||
|
return "This field is required";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.widgets.ckan2zenodopublisher.client.view.FormValidator#isValidForm()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean isValidForm() {
|
||||||
|
return validateFormFields()==null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the control group.
|
||||||
|
*
|
||||||
|
* @param box the box
|
||||||
|
* @param type the type
|
||||||
|
*/
|
||||||
|
private void setControlGroup(TextBox box, ControlGroupType type) {
|
||||||
|
try {
|
||||||
|
ControlGroup controlGroup = (ControlGroup) field_doi.getParent().getParent();
|
||||||
|
controlGroup.setType(type);
|
||||||
|
|
||||||
|
}catch (Exception e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the text value.
|
||||||
|
*
|
||||||
|
* @param box the box
|
||||||
|
* @return the text value
|
||||||
|
*/
|
||||||
|
private String getTextValue(TextBox box) {
|
||||||
|
|
||||||
|
return box.getText();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
is required
|
is required
|
||||||
</small>
|
</small>
|
||||||
</b:Legend>
|
</b:Legend>
|
||||||
<!-- <b:Label type="INFO" -->
|
<b:Alert ui:field="error_alert" type="ERROR"
|
||||||
<!-- addStyleNames="{style.margin-left-100}">Basic Information</b:Label> -->
|
visible="false" close="false"></b:Alert>
|
||||||
<b:ControlGroup ui:field="cg_doi_url">
|
<b:ControlGroup ui:field="cg_doi_url">
|
||||||
<b:ControlLabel for="cl_doi_url">Digital Object Identifier</b:ControlLabel>
|
<b:ControlLabel for="cl_doi_url">Digital Object Identifier</b:ControlLabel>
|
||||||
<b:Controls>
|
<b:Controls>
|
||||||
|
@ -130,7 +130,7 @@
|
||||||
</b:Fieldset>
|
</b:Fieldset>
|
||||||
</b:Form>
|
</b:Form>
|
||||||
</g:HTMLPanel>
|
</g:HTMLPanel>
|
||||||
<!-- <b:Pager left="Back" right="Next" -->
|
<!-- <b:Pager left="Back" right="Next" -->
|
||||||
<!-- aligned="true" ui:field="pager" /> -->
|
<!-- aligned="true" ui:field="pager" /> -->
|
||||||
</g:HTMLPanel>
|
</g:HTMLPanel>
|
||||||
</ui:UiBinder>
|
</ui:UiBinder>
|
|
@ -1,5 +1,8 @@
|
||||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.BasicTabPanel;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformation.BasicInformationView;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.basicinformation.BasicInformationView;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||||
|
@ -21,6 +24,8 @@ public class Ckan2ZenodoViewManager {
|
||||||
|
|
||||||
public final static HandlerManager eventBus = new HandlerManager(null);
|
public final static HandlerManager eventBus = new HandlerManager(null);
|
||||||
|
|
||||||
|
private List<FormValidator> forms = new ArrayList<FormValidator>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new ckan 2 zenodo view manager.
|
* Instantiates a new ckan 2 zenodo view manager.
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +37,7 @@ public class Ckan2ZenodoViewManager {
|
||||||
* View for publishing.
|
* View for publishing.
|
||||||
*
|
*
|
||||||
* @param zenodoItem the zenodo item
|
* @param zenodoItem the zenodo item
|
||||||
* @return
|
* @return the basic tab panel
|
||||||
*/
|
*/
|
||||||
public BasicTabPanel viewForPublishing(final ZenodoItem zenodoItem){
|
public BasicTabPanel viewForPublishing(final ZenodoItem zenodoItem){
|
||||||
|
|
||||||
|
@ -44,24 +49,9 @@ public class Ckan2ZenodoViewManager {
|
||||||
}
|
}
|
||||||
//Basic Information
|
//Basic Information
|
||||||
int tabIndex = 0;
|
int tabIndex = 0;
|
||||||
BasicInformationView basicForm = new BasicInformationView(zenodoItem, isUpdate, tabIndex) {
|
BasicInformationView basicForm = new BasicInformationView(zenodoItem, isUpdate, tabIndex);
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void submitHandler() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setError(boolean visible, String error) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setConfirm(boolean visible, String msg) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
basicTabPanel.getAcc_basic_info().add(basicForm);
|
basicTabPanel.getAcc_basic_info().add(basicForm);
|
||||||
basicTabPanel.getTabPanel().getSelectedTab();
|
forms.add(basicForm);
|
||||||
|
|
||||||
//Files
|
//Files
|
||||||
tabIndex = 1;
|
tabIndex = 1;
|
||||||
|
@ -71,9 +61,16 @@ public class Ckan2ZenodoViewManager {
|
||||||
return basicTabPanel;
|
return basicTabPanel;
|
||||||
|
|
||||||
//return basePanel;
|
//return basePanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the list forms.
|
||||||
|
*
|
||||||
|
* @return the list forms
|
||||||
|
*/
|
||||||
|
public List<FormValidator> getListForms(){
|
||||||
|
return forms;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
|
||||||
|
|
||||||
|
public class FieldUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is valid value.
|
||||||
|
*
|
||||||
|
* @param value the value
|
||||||
|
* @return true, if is valid value
|
||||||
|
*/
|
||||||
|
public static boolean isValidValue(String value){
|
||||||
|
return value!=null && !value.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.client.view;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface FormValidator.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Jan 9, 2020
|
||||||
|
*/
|
||||||
|
public interface FormValidator {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate form fields.
|
||||||
|
*
|
||||||
|
* @return the error in case of field not valid. Null otherwise
|
||||||
|
*/
|
||||||
|
String validateFormFields();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is valid form.
|
||||||
|
*
|
||||||
|
* @return true, if is valid form
|
||||||
|
*/
|
||||||
|
boolean isValidForm();
|
||||||
|
|
||||||
|
}
|
|
@ -1,18 +1,7 @@
|
||||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.server;
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gcube.data.publishing.ckan2zenodo.Ckan2Zenodo;
|
import org.gcube.data.publishing.ckan2zenodo.Ckan2Zenodo;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.CkanItemDescriptor;
|
import org.gcube.data.publishing.ckan2zenodo.model.CkanItemDescriptor;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Creator;
|
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
|
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata.AccessRights;
|
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata.UploadType;
|
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.FileDeposition;
|
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.RelatedIdentifier;
|
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.RelatedIdentifier.Relation;
|
|
||||||
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.CkanToZendoPublisherWidgetConstant;
|
||||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService;
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService;
|
||||||
|
@ -61,38 +50,38 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true);
|
PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ckan2Zenodo client= Ckan2Zenodo.get();
|
Ckan2Zenodo client= Ckan2Zenodo.get();
|
||||||
//
|
|
||||||
// // Get the item representation
|
// Get the item representation
|
||||||
// CkanItemDescriptor itemDescr=client.read(item.getItemName());
|
CkanItemDescriptor itemDescr=client.read(item.getItemName());
|
||||||
//
|
|
||||||
// //Get a preview of the deposition to be published
|
//Get a preview of the deposition to be published
|
||||||
// ZenodoDeposition zdPreview=client.translate(itemDescr);
|
ZenodoDeposition zdPreview=client.translate(itemDescr);
|
||||||
//
|
|
||||||
// //Filter resources according to VRE policies
|
//Filter resources according to VRE policies
|
||||||
// //List<CkanResource> toFilterFiles=client.filterResources(itemDescr);
|
//List<CkanResource> toFilterFiles=client.filterResources(itemDescr);
|
||||||
//
|
|
||||||
// //zdPreview.setFiles(toFilterFiles);
|
//zdPreview.setFiles(toFilterFiles);
|
||||||
// return ItemToZenodoConverter.toZenodoItem(zdPreview);
|
return ItemToZenodoConverter.toZenodoItem(zdPreview);
|
||||||
|
|
||||||
// //TO TEST
|
// //TO TEST
|
||||||
ZenodoDeposition zd = new ZenodoDeposition();
|
// ZenodoDeposition zd = new ZenodoDeposition();
|
||||||
zd.setTitle("My beautiful title");
|
// zd.setTitle("My beautiful title");
|
||||||
ArrayList<FileDeposition> files = new ArrayList<FileDeposition>();
|
// ArrayList<FileDeposition> files = new ArrayList<FileDeposition>();
|
||||||
for (int i = 0; i < 5; i++) {
|
// for (int i = 0; i < 5; i++) {
|
||||||
FileDeposition fd = new FileDeposition();
|
// FileDeposition fd = new FileDeposition();
|
||||||
int index = i+1;
|
// int index = i+1;
|
||||||
fd.setFilename("My file "+index);
|
// fd.setFilename("My file "+index);
|
||||||
files.add(fd);
|
// files.add(fd);
|
||||||
}
|
// }
|
||||||
zd.setFiles(files);
|
// zd.setFiles(files);
|
||||||
DepositionMetadata metadata = new DepositionMetadata(UploadType.dataset, new Date(), "My title", new ArrayList<Creator>(), "My desr", AccessRights.open);
|
// DepositionMetadata metadata = new DepositionMetadata(UploadType.dataset, new Date(), "My title", new ArrayList<Creator>(), "My desr", AccessRights.open);
|
||||||
metadata.setDescription("My beautiful description");
|
// metadata.setDescription("My beautiful description");
|
||||||
List<RelatedIdentifier> related_identifiers = new ArrayList<RelatedIdentifier>(1);
|
// List<RelatedIdentifier> related_identifiers = new ArrayList<RelatedIdentifier>(1);
|
||||||
related_identifiers.add(new RelatedIdentifier("12345", Relation.cites));
|
// related_identifiers.add(new RelatedIdentifier("12345", Relation.cites));
|
||||||
metadata.setRelated_identifiers(related_identifiers);
|
// metadata.setRelated_identifiers(related_identifiers);
|
||||||
zd.setMetadata(metadata);
|
// zd.setMetadata(metadata);
|
||||||
return ItemToZenodoConverter.toZenodoItem(zd);
|
// return ItemToZenodoConverter.toZenodoItem(zd);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String error = "Error on converting the catalogue item: "+item.getItemName();
|
String error = "Error on converting the catalogue item: "+item.getItemName();
|
||||||
|
|
Loading…
Reference in New Issue