Working on #18236
This commit is contained in:
parent
b7904782f8
commit
d68726721c
|
@ -1,18 +1,19 @@
|
|||
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.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.shared.CatalogueItem;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
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.ModalFooter;
|
||||
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.ClickHandler;
|
||||
import com.google.gwt.user.client.Window;
|
||||
|
@ -31,6 +32,7 @@ public class CkanToZendoPublisherWidget {
|
|||
.getInstance();
|
||||
|
||||
private Button buttonPublish = new Button("Publish on Zenodo");
|
||||
private Ckan2ZenodoViewManager manager = null;
|
||||
/**
|
||||
* Instantiates a new ckan to zendo publisher widget.
|
||||
*/
|
||||
|
@ -79,7 +81,7 @@ public class CkanToZendoPublisherWidget {
|
|||
public void onSuccess(ZenodoItem result) {
|
||||
loader.setVisible(false);
|
||||
modal.remove(loader);
|
||||
Ckan2ZenodoViewManager manager = new Ckan2ZenodoViewManager();
|
||||
manager = new Ckan2ZenodoViewManager();
|
||||
BasicTabPanel basicTabPanel = manager.viewForPublishing(result);
|
||||
modal.add(basicTabPanel);
|
||||
buttonPublish.setEnabled(true);
|
||||
|
@ -90,6 +92,14 @@ public class CkanToZendoPublisherWidget {
|
|||
|
||||
@Override
|
||||
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">
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
||||
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
|
||||
xmlns:citem="urn:import:org.gcube.portlets.widgets.ckan2zenodopublisher.client.ui.authors">
|
||||
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
|
||||
<ui:style>
|
||||
.noBorder {
|
||||
border: 0px;
|
||||
|
@ -15,7 +14,6 @@
|
|||
<g:VerticalPanel>
|
||||
<g:VerticalPanel styleName="{style.noBorder}"
|
||||
ui:field="fieldset_authors">
|
||||
<!-- <citem:CreatorView ui:field="field_authors"></citem:CreatorView> -->
|
||||
</g:VerticalPanel>
|
||||
<b:Button text="Add another Author"
|
||||
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 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.ZenodoMetadata;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.ControlGroup;
|
||||
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.TextArea;
|
||||
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.google.gwt.core.client.GWT;
|
||||
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
|
||||
*/
|
||||
public abstract class BasicInformationView extends Composite {
|
||||
public class BasicInformationView extends Composite implements FormValidator {
|
||||
|
||||
/** The ui binder. */
|
||||
private static BasicInformationViewUiBinder uiBinder = GWT.create(BasicInformationViewUiBinder.class);
|
||||
|
||||
|
||||
private CreatorsFormView creatorsView;
|
||||
|
||||
/**
|
||||
|
@ -44,59 +49,40 @@ public abstract class BasicInformationView extends Composite {
|
|||
|
||||
@UiField
|
||||
TextBox field_doi;
|
||||
|
||||
|
||||
@UiField
|
||||
Fieldset fieldset_basic_informations;
|
||||
|
||||
|
||||
@UiField
|
||||
TextArea field_description;
|
||||
|
||||
|
||||
@UiField
|
||||
ListBox field_upload_type;
|
||||
|
||||
|
||||
@UiField
|
||||
ListBox field_access_right;
|
||||
|
||||
|
||||
@UiField
|
||||
ListBox field_license;
|
||||
|
||||
|
||||
@UiField
|
||||
ListBox field_publication_type;
|
||||
|
||||
|
||||
@UiField
|
||||
DateBox field_publication_date;
|
||||
|
||||
@UiField
|
||||
Alert error_alert;
|
||||
|
||||
// @UiField
|
||||
// Pager pager;
|
||||
|
||||
//public final static HandlerManager eventBus = new HandlerManager(null);
|
||||
|
||||
// public final static HandlerManager eventBus = new HandlerManager(null);
|
||||
|
||||
private boolean isEditConfiguration;
|
||||
|
||||
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
|
||||
* 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.
|
||||
*
|
||||
* @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) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
|
@ -128,8 +115,7 @@ public abstract class BasicInformationView extends Composite {
|
|||
// this.isEditConfiguration = true;
|
||||
// this.editConfiguration = conf;
|
||||
|
||||
//bindEvents();
|
||||
|
||||
// bindEvents();
|
||||
|
||||
// if (isEditConfiguration) {
|
||||
// pager.getRight().setText("Update Configuration");
|
||||
|
@ -138,8 +124,7 @@ public abstract class BasicInformationView extends Composite {
|
|||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sets the visible fields for update.
|
||||
*
|
||||
|
@ -150,10 +135,10 @@ public abstract class BasicInformationView extends Composite {
|
|||
List<Widget> listWidgtes = new ArrayList<Widget>();
|
||||
listWidgtes.add(field_doi);
|
||||
listWidgtes.add(field_publication_date);
|
||||
|
||||
|
||||
for (Widget widget : listWidgtes) {
|
||||
Widget parent = widget.getParent().getParent(); //It should be the 'ControlGroup'
|
||||
if(parent instanceof ControlGroup) {
|
||||
Widget parent = widget.getParent().getParent(); // It should be the 'ControlGroup'
|
||||
if (parent instanceof ControlGroup) {
|
||||
parent.setVisible(isUpdate);
|
||||
}
|
||||
}
|
||||
|
@ -167,15 +152,15 @@ public abstract class BasicInformationView extends Composite {
|
|||
field_title.setValue(zenodoItem.getTitle());
|
||||
field_description.setValue(zenodoItem.getMetadata().getDescription());
|
||||
field_doi.setValue(zenodoItem.getDoi().toString());
|
||||
|
||||
|
||||
ZenodoMetadata zMeta = zenodoItem.getMetadata();
|
||||
if(zMeta!=null) {
|
||||
if (zMeta != null) {
|
||||
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());
|
||||
selectValueToListBox(field_publication_type,zMeta.getPublication_type().getSelectableValues());
|
||||
|
||||
//ADDING AUTHORS
|
||||
selectValueToListBox(field_publication_type, zMeta.getPublication_type().getSelectableValues());
|
||||
|
||||
// ADDING AUTHORS
|
||||
creatorsView = new CreatorsFormView(zenodoItem.getMetadata().getCreators());
|
||||
fieldset_basic_informations.add(creatorsView);
|
||||
}
|
||||
|
@ -187,44 +172,44 @@ public abstract class BasicInformationView extends Composite {
|
|||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the values to list box.
|
||||
*
|
||||
* @param list the list
|
||||
* @param list the list
|
||||
* @param listValues the list values
|
||||
*/
|
||||
private void addValuesToListBox(ListBox list, List<String> listValues) {
|
||||
if(listValues==null)
|
||||
if (listValues == null)
|
||||
return;
|
||||
|
||||
for (int i=0; i<listValues.size(); i++) {
|
||||
|
||||
for (int i = 0; i < listValues.size(); i++) {
|
||||
list.setValue(i, listValues.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Select value to list box.
|
||||
*
|
||||
* @param list the list
|
||||
* @param list the list
|
||||
* @param values the values
|
||||
*/
|
||||
private void selectValueToListBox(ListBox list, List<String> values) {
|
||||
String selectValue = null;
|
||||
if(values==null || values.isEmpty()) {
|
||||
if (values == null || values.isEmpty()) {
|
||||
selectValue = null;
|
||||
}else {
|
||||
} else {
|
||||
selectValue = values.get(0);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if(list.getItemCount()>0)
|
||||
if (list.getItemCount() > 0)
|
||||
list.setSelectedValue(selectValue);
|
||||
}catch(Exception e) {
|
||||
GWT.log("error: "+e);
|
||||
} catch (Exception e) {
|
||||
GWT.log("error: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// private void addFileForPublishing(ZenodoFile file) {
|
||||
// PublishFileView pv = new PublishFileView();
|
||||
// pv.getField_file_name().setValue(file.getFilename());
|
||||
|
@ -290,7 +275,6 @@ public abstract class BasicInformationView extends Composite {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is edits the configuration.
|
||||
*
|
||||
|
@ -301,4 +285,78 @@ public abstract class BasicInformationView extends Composite {
|
|||
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
|
||||
</small>
|
||||
</b:Legend>
|
||||
<!-- <b:Label type="INFO" -->
|
||||
<!-- addStyleNames="{style.margin-left-100}">Basic Information</b:Label> -->
|
||||
<b:Alert ui:field="error_alert" type="ERROR"
|
||||
visible="false" close="false"></b:Alert>
|
||||
<b:ControlGroup ui:field="cg_doi_url">
|
||||
<b:ControlLabel for="cl_doi_url">Digital Object Identifier</b:ControlLabel>
|
||||
<b:Controls>
|
||||
|
@ -130,7 +130,7 @@
|
|||
</b:Fieldset>
|
||||
</b:Form>
|
||||
</g:HTMLPanel>
|
||||
<!-- <b:Pager left="Back" right="Next" -->
|
||||
<!-- aligned="true" ui:field="pager" /> -->
|
||||
<!-- <b:Pager left="Back" right="Next" -->
|
||||
<!-- aligned="true" ui:field="pager" /> -->
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|
|
@ -1,5 +1,8 @@
|
|||
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.basicinformation.BasicInformationView;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoItem;
|
||||
|
@ -21,6 +24,8 @@ public class Ckan2ZenodoViewManager {
|
|||
|
||||
public final static HandlerManager eventBus = new HandlerManager(null);
|
||||
|
||||
private List<FormValidator> forms = new ArrayList<FormValidator>();
|
||||
|
||||
/**
|
||||
* Instantiates a new ckan 2 zenodo view manager.
|
||||
*/
|
||||
|
@ -32,7 +37,7 @@ public class Ckan2ZenodoViewManager {
|
|||
* View for publishing.
|
||||
*
|
||||
* @param zenodoItem the zenodo item
|
||||
* @return
|
||||
* @return the basic tab panel
|
||||
*/
|
||||
public BasicTabPanel viewForPublishing(final ZenodoItem zenodoItem){
|
||||
|
||||
|
@ -44,24 +49,9 @@ public class Ckan2ZenodoViewManager {
|
|||
}
|
||||
//Basic Information
|
||||
int tabIndex = 0;
|
||||
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) {
|
||||
}
|
||||
};
|
||||
|
||||
BasicInformationView basicForm = new BasicInformationView(zenodoItem, isUpdate, tabIndex);
|
||||
basicTabPanel.getAcc_basic_info().add(basicForm);
|
||||
basicTabPanel.getTabPanel().getSelectedTab();
|
||||
forms.add(basicForm);
|
||||
|
||||
//Files
|
||||
tabIndex = 1;
|
||||
|
@ -71,9 +61,16 @@ public class Ckan2ZenodoViewManager {
|
|||
return basicTabPanel;
|
||||
|
||||
//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;
|
||||
|
||||
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.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.portlets.widgets.ckan2zenodopublisher.client.CkanToZendoPublisherWidgetConstant;
|
||||
import org.gcube.portlets.widgets.ckan2zenodopublisher.client.CkanToZenodoPublisherService;
|
||||
|
@ -61,38 +50,38 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
|||
PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true);
|
||||
}
|
||||
|
||||
// Ckan2Zenodo client= Ckan2Zenodo.get();
|
||||
//
|
||||
// // Get the item representation
|
||||
// CkanItemDescriptor itemDescr=client.read(item.getItemName());
|
||||
//
|
||||
// //Get a preview of the deposition to be published
|
||||
// ZenodoDeposition zdPreview=client.translate(itemDescr);
|
||||
//
|
||||
// //Filter resources according to VRE policies
|
||||
// //List<CkanResource> toFilterFiles=client.filterResources(itemDescr);
|
||||
//
|
||||
// //zdPreview.setFiles(toFilterFiles);
|
||||
// return ItemToZenodoConverter.toZenodoItem(zdPreview);
|
||||
Ckan2Zenodo client= Ckan2Zenodo.get();
|
||||
|
||||
// Get the item representation
|
||||
CkanItemDescriptor itemDescr=client.read(item.getItemName());
|
||||
|
||||
//Get a preview of the deposition to be published
|
||||
ZenodoDeposition zdPreview=client.translate(itemDescr);
|
||||
|
||||
//Filter resources according to VRE policies
|
||||
//List<CkanResource> toFilterFiles=client.filterResources(itemDescr);
|
||||
|
||||
//zdPreview.setFiles(toFilterFiles);
|
||||
return ItemToZenodoConverter.toZenodoItem(zdPreview);
|
||||
|
||||
// //TO TEST
|
||||
ZenodoDeposition zd = new ZenodoDeposition();
|
||||
zd.setTitle("My beautiful title");
|
||||
ArrayList<FileDeposition> files = new ArrayList<FileDeposition>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
FileDeposition fd = new FileDeposition();
|
||||
int index = i+1;
|
||||
fd.setFilename("My file "+index);
|
||||
files.add(fd);
|
||||
}
|
||||
zd.setFiles(files);
|
||||
DepositionMetadata metadata = new DepositionMetadata(UploadType.dataset, new Date(), "My title", new ArrayList<Creator>(), "My desr", AccessRights.open);
|
||||
metadata.setDescription("My beautiful description");
|
||||
List<RelatedIdentifier> related_identifiers = new ArrayList<RelatedIdentifier>(1);
|
||||
related_identifiers.add(new RelatedIdentifier("12345", Relation.cites));
|
||||
metadata.setRelated_identifiers(related_identifiers);
|
||||
zd.setMetadata(metadata);
|
||||
return ItemToZenodoConverter.toZenodoItem(zd);
|
||||
// ZenodoDeposition zd = new ZenodoDeposition();
|
||||
// zd.setTitle("My beautiful title");
|
||||
// ArrayList<FileDeposition> files = new ArrayList<FileDeposition>();
|
||||
// for (int i = 0; i < 5; i++) {
|
||||
// FileDeposition fd = new FileDeposition();
|
||||
// int index = i+1;
|
||||
// fd.setFilename("My file "+index);
|
||||
// files.add(fd);
|
||||
// }
|
||||
// zd.setFiles(files);
|
||||
// DepositionMetadata metadata = new DepositionMetadata(UploadType.dataset, new Date(), "My title", new ArrayList<Creator>(), "My desr", AccessRights.open);
|
||||
// metadata.setDescription("My beautiful description");
|
||||
// List<RelatedIdentifier> related_identifiers = new ArrayList<RelatedIdentifier>(1);
|
||||
// related_identifiers.add(new RelatedIdentifier("12345", Relation.cites));
|
||||
// metadata.setRelated_identifiers(related_identifiers);
|
||||
// zd.setMetadata(metadata);
|
||||
// return ItemToZenodoConverter.toZenodoItem(zd);
|
||||
|
||||
} catch (Exception e) {
|
||||
String error = "Error on converting the catalogue item: "+item.getItemName();
|
||||
|
|
Loading…
Reference in New Issue