on going on #18226
This commit is contained in:
parent
371e5c8874
commit
1341b7b853
|
@ -106,7 +106,36 @@ public class CkanToZendoPublisherWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(allFormsAreValid) {
|
if(allFormsAreValid) {
|
||||||
submitPublishOnZenodo();
|
//Submit publish on zenodo.
|
||||||
|
ZenodoItem zenodoItem = manager.getZenodoItemFromFieldsForm();
|
||||||
|
GWT.log("Publishing file: "+zenodoItem.getFiles());
|
||||||
|
ckanToZenodoService.publishOnZenodo(zenodoItem, new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
//modal.clear();
|
||||||
|
Alert erroLabel = new Alert();
|
||||||
|
erroLabel.setClose(false);
|
||||||
|
erroLabel.setType(AlertType.ERROR);
|
||||||
|
erroLabel.setText(caught.getLocalizedMessage());
|
||||||
|
modal.add(erroLabel);
|
||||||
|
Button close = new Button("Close");
|
||||||
|
close.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
modal.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
modal.add(close);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String result) {
|
||||||
|
String msg = "Publishing: \n\n"+result+"\n\nIs it right?";
|
||||||
|
Window.alert(msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -115,27 +144,6 @@ public class CkanToZendoPublisherWidget {
|
||||||
modal.add(modalFooter);
|
modal.add(modalFooter);
|
||||||
modal.show();
|
modal.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To zenodo item.
|
|
||||||
*
|
|
||||||
* @param item the item
|
|
||||||
*/
|
|
||||||
private void toZenodoItem(CatalogueItem item) {
|
|
||||||
|
|
||||||
ckanToZenodoService.convertToZenodoItem(item, new AsyncCallback<ZenodoItem>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(ZenodoItem result) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit publish on zenodo.
|
* Submit publish on zenodo.
|
||||||
|
@ -150,10 +158,12 @@ public class CkanToZendoPublisherWidget {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
Window.alert(caught.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String result) {
|
public void onSuccess(String result) {
|
||||||
|
Window.alert(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,4 +138,11 @@ public class BasicTabPanel extends Composite {
|
||||||
pager.getRight().setVisible(false);
|
pager.getRight().setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void enableAddFileTab(boolean bool) {
|
||||||
|
//acc_files.setActive(bool);
|
||||||
|
acc_files.setEnabled(bool);
|
||||||
|
pager.getRight().setVisible(bool);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,22 +171,24 @@ public class CreatorsFormView extends Composite implements FormValidator{
|
||||||
boolean isValid = FieldUtil.isValidValue(value);
|
boolean isValid = FieldUtil.isValidValue(value);
|
||||||
if(!isValid) {
|
if(!isValid) {
|
||||||
FieldUtil.setControlGroup(cgAuthor, ControlGroupType.ERROR);
|
FieldUtil.setControlGroup(cgAuthor, ControlGroupType.ERROR);
|
||||||
return "The author name is required";
|
return "The Author Name is required";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
String affiliation = FieldUtil.getTextValue(creatorView.getField_affiliation());
|
String affiliation = FieldUtil.getTextValue(creatorView.getField_affiliation());
|
||||||
isValid = FieldUtil.isValidValue(affiliation);
|
isValid = FieldUtil.isValidValue(affiliation);
|
||||||
if(!isValid) {
|
if(!isValid) {
|
||||||
FieldUtil.setControlGroup(cgAuthor, ControlGroupType.ERROR);
|
FieldUtil.setControlGroup(cgAuthor, ControlGroupType.ERROR);
|
||||||
return "The author affiliation is required";
|
return "The field affiliation is required";
|
||||||
}
|
}
|
||||||
|
|
||||||
String orcid = FieldUtil.getTextValue(creatorView.getField_orcid());
|
String orcid = FieldUtil.getTextValue(creatorView.getField_orcid());
|
||||||
isValid = FieldUtil.isValidValue(orcid);
|
isValid = FieldUtil.isValidValue(orcid);
|
||||||
if(!isValid) {
|
if(!isValid) {
|
||||||
FieldUtil.setControlGroup(cgAuthor, ControlGroupType.ERROR);
|
FieldUtil.setControlGroup(cgAuthor, ControlGroupType.ERROR);
|
||||||
return "The author ORCID is required";
|
return "The field ORCID is required";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -165,20 +165,37 @@ public class BasicInformationView extends Composite implements FormValidator {
|
||||||
String title = zenodoItem.getTitle()!=null?zenodoItem.getTitle():zMeta.getTitle();
|
String title = zenodoItem.getTitle()!=null?zenodoItem.getTitle():zMeta.getTitle();
|
||||||
field_title.setValue(title); //Re.fill title to be sure
|
field_title.setValue(title); //Re.fill title to be sure
|
||||||
|
|
||||||
addValuesToListBox(field_upload_type, zMeta.getUpload_type().getSelectableValues());
|
//Upload type
|
||||||
selectValueToListBox(field_upload_type, zMeta.getUpload_type().getSelectedValues());
|
if(zMeta.getUpload_type()!=null) {
|
||||||
|
addValuesToListBox(field_upload_type, zMeta.getUpload_type().getSelectableValues());
|
||||||
|
selectValueToListBox(field_upload_type, zMeta.getUpload_type().getSelectedValues());
|
||||||
|
}else
|
||||||
|
field_upload_type.setEnabled(false);
|
||||||
|
|
||||||
|
//Publication Type
|
||||||
if(zMeta.getPublication_type()!=null) {
|
if(zMeta.getPublication_type()!=null) {
|
||||||
addValuesToListBox(field_publication_type, zMeta.getPublication_type().getSelectableValues());
|
addValuesToListBox(field_publication_type, zMeta.getPublication_type().getSelectableValues());
|
||||||
selectValueToListBox(field_publication_type, zMeta.getPublication_type().getSelectedValues());
|
selectValueToListBox(field_publication_type, zMeta.getPublication_type().getSelectedValues());
|
||||||
}else
|
}else
|
||||||
field_publication_type.setEnabled(false);
|
field_publication_type.setEnabled(false);
|
||||||
|
|
||||||
addValuesToListBox(field_access_right, zMeta.getAccess_right().getSelectableValues());
|
if(zMeta.getAccess_right()!=null) {
|
||||||
selectValueToListBox(field_access_right, zMeta.getAccess_right().getSelectedValues());
|
addValuesToListBox(field_access_right, zMeta.getAccess_right().getSelectableValues());
|
||||||
|
selectValueToListBox(field_access_right, zMeta.getAccess_right().getSelectedValues());
|
||||||
|
}else
|
||||||
|
field_access_right.setEnabled(false);
|
||||||
|
|
||||||
addValuesToListBox(field_license, Arrays.asList(zMeta.getLicense().getId()));
|
if(zMeta.getLicense()!=null) {
|
||||||
selectValueToListBox(field_license, Arrays.asList(zMeta.getLicense().getId()));
|
addValuesToListBox(field_license, Arrays.asList(zMeta.getLicense().getId()));
|
||||||
|
selectValueToListBox(field_license, Arrays.asList(zMeta.getLicense().getId()));
|
||||||
|
}
|
||||||
|
field_license.setEnabled(false); //because is not changeable
|
||||||
|
|
||||||
|
if(zMeta.getKeywords()!=null && zMeta.getKeywords().size()>0) {
|
||||||
|
for (String keyword : zMeta.getKeywords()) {
|
||||||
|
the_tags_panel.addTagElement(keyword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ADDING AUTHORS
|
// ADDING AUTHORS
|
||||||
creatorsView = new CreatorsFormView(zenodoItem.getMetadata().getCreators());
|
creatorsView = new CreatorsFormView(zenodoItem.getMetadata().getCreators());
|
||||||
|
@ -443,5 +460,15 @@ public class BasicInformationView extends Composite implements FormValidator {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the list of keywords.
|
||||||
|
*
|
||||||
|
* @return the list of keywords
|
||||||
|
*/
|
||||||
|
public List<String> getListOfKeywords(){
|
||||||
|
return the_tags_panel.getTags();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<g:HTMLPanel>
|
<g:HTMLPanel>
|
||||||
<b:ControlGroup ui:field="tagsInsertGroup">
|
<b:ControlGroup ui:field="tagsInsertGroup">
|
||||||
<b:ControlLabel for="tags" title="Item tag">
|
<b:ControlLabel for="tags" title="Item tag">
|
||||||
<font color="red">*</font>
|
<!-- <font color="red">*</font> -->
|
||||||
Keywords
|
Keywords
|
||||||
</b:ControlLabel>
|
</b:ControlLabel>
|
||||||
<b:Controls ui:field="controlAsTextBox">
|
<b:Controls ui:field="controlAsTextBox">
|
||||||
|
|
|
@ -13,6 +13,9 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoFile
|
||||||
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.google.gwt.core.client.Scheduler;
|
||||||
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||||
|
import com.google.gwt.core.shared.GWT;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,117 +23,130 @@ import com.google.gwt.event.shared.HandlerManager;
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
*
|
*
|
||||||
* Dec 19, 2019
|
* Dec 19, 2019
|
||||||
*/
|
*/
|
||||||
public class Ckan2ZenodoViewManager {
|
public class Ckan2ZenodoViewManager {
|
||||||
|
|
||||||
|
|
||||||
private BasicTabPanel basicTabPanel;
|
private BasicTabPanel basicTabPanel;
|
||||||
|
|
||||||
|
|
||||||
public final static HandlerManager eventBus = new HandlerManager(null);
|
public final static HandlerManager eventBus = new HandlerManager(null);
|
||||||
|
|
||||||
private List<FormValidator> forms = new ArrayList<FormValidator>();
|
private List<FormValidator> forms = new ArrayList<FormValidator>();
|
||||||
private BasicInformationView basicForm;
|
private BasicInformationView basicForm;
|
||||||
private PublishFileViewManager publishFileVM;
|
private PublishFileViewManager publishFileVM;
|
||||||
|
|
||||||
|
|
||||||
private ZenodoItem zenodoItem;
|
private ZenodoItem zenodoItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new ckan 2 zenodo view manager.
|
* Instantiates a new ckan 2 zenodo view manager.
|
||||||
*/
|
*/
|
||||||
public Ckan2ZenodoViewManager() {
|
public Ckan2ZenodoViewManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View for publishing.
|
* View for publishing.
|
||||||
*
|
*
|
||||||
* @param zenodoItem the zenodo item
|
* @param zenodoItem the zenodo item
|
||||||
* @return the basic tab panel
|
* @return the basic tab panel
|
||||||
*/
|
*/
|
||||||
public BasicTabPanel viewForPublishing(final ZenodoItem zenodoItem){
|
public BasicTabPanel viewForPublishing(final ZenodoItem zenodoItem) {
|
||||||
this.zenodoItem = zenodoItem;
|
this.zenodoItem = zenodoItem;
|
||||||
basicTabPanel = new BasicTabPanel();
|
basicTabPanel = new BasicTabPanel();
|
||||||
|
|
||||||
boolean isUpdate = false;
|
boolean isUpdate = false;
|
||||||
if(zenodoItem.getMetadata()!=null) {
|
if (zenodoItem.getMetadata() != null) {
|
||||||
isUpdate = zenodoItem.getMetadata().getDoi()!=null?true:false;
|
isUpdate = zenodoItem.getMetadata().getDoi() != null ? true : false;
|
||||||
}
|
}
|
||||||
//Basic Information
|
// Basic Information
|
||||||
int tabIndex = 0;
|
int tabIndex = 0;
|
||||||
basicForm = new BasicInformationView(zenodoItem, isUpdate, tabIndex);
|
basicForm = new BasicInformationView(zenodoItem, isUpdate, tabIndex);
|
||||||
basicTabPanel.getAcc_basic_info().add(basicForm);
|
basicTabPanel.getAcc_basic_info().add(basicForm);
|
||||||
forms.add(basicForm);
|
forms.add(basicForm);
|
||||||
|
|
||||||
//Files
|
// Files
|
||||||
tabIndex = 1;
|
if (zenodoItem.getFiles() != null && zenodoItem.getFiles().size() > 0) {
|
||||||
publishFileVM = new PublishFileViewManager(zenodoItem.getFiles(), tabIndex);
|
tabIndex = 1;
|
||||||
basicTabPanel.getAcc_files().add(publishFileVM.getView());
|
publishFileVM = new PublishFileViewManager(zenodoItem.getFiles(), tabIndex);
|
||||||
|
basicTabPanel.getAcc_files().add(publishFileVM.getView());
|
||||||
|
} else {
|
||||||
|
GWT.log("Hiding add files tab");
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
basicTabPanel.enableAddFileTab(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return basicTabPanel;
|
return basicTabPanel;
|
||||||
|
|
||||||
//return basePanel;
|
// return basePanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list forms.
|
* Gets the list forms.
|
||||||
*
|
*
|
||||||
* @return the list forms
|
* @return the list forms
|
||||||
*/
|
*/
|
||||||
public List<FormValidator> getListForms(){
|
public List<FormValidator> getListForms() {
|
||||||
return forms;
|
return forms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list file to publish.
|
* Gets the list file to publish.
|
||||||
*
|
*
|
||||||
* @return the list file to publish
|
* @return the list file to publish
|
||||||
*/
|
*/
|
||||||
public List<ZenodoFile> getListFileToPublish(){
|
public List<ZenodoFile> getListFileToPublish() {
|
||||||
return publishFileVM.getSelectedFileToZenodoPublishing();
|
if(publishFileVM!=null) {
|
||||||
|
return publishFileVM.getSelectedFileToZenodoPublishing();
|
||||||
|
}
|
||||||
|
return null; //Is null if any resource was attached to dataset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the zenodo item from form.
|
* Gets the zenodo item from form.
|
||||||
*
|
*
|
||||||
* @return the zenodo item from form
|
* @return the zenodo item from form
|
||||||
*/
|
*/
|
||||||
public ZenodoItem getZenodoItemFromFieldsForm(){
|
public ZenodoItem getZenodoItemFromFieldsForm() {
|
||||||
|
|
||||||
//Updating Basic Information
|
// Updating Basic Information
|
||||||
zenodoItem.setTitle(basicForm.getField_title().getValue());
|
zenodoItem.setTitle(basicForm.getField_title().getValue());
|
||||||
zenodoItem.setDoi(basicForm.getField_doi().getValue());
|
zenodoItem.setDoi(basicForm.getField_doi().getValue());
|
||||||
|
|
||||||
//Updating Metadata
|
// Updating Metadata
|
||||||
ZenodoMetadata meta = zenodoItem.getMetadata();
|
ZenodoMetadata meta = zenodoItem.getMetadata();
|
||||||
meta.setDescription(basicForm.getField_description().getValue());
|
meta.setDescription(basicForm.getField_description().getValue());
|
||||||
meta.setKeywords(basicForm.getTags()); //these are the keywords
|
meta.setKeywords(basicForm.getTags()); // these are the keywords
|
||||||
List<ZenodoCreator> creators = basicForm.getListOfCreators();
|
List<ZenodoCreator> creators = basicForm.getListOfCreators();
|
||||||
meta.setCreators(creators);
|
meta.setCreators(creators);
|
||||||
|
|
||||||
//upload type
|
// upload type
|
||||||
String uploadType = basicForm.getField_upload_type().getSelectedValue();
|
String uploadType = basicForm.getField_upload_type().getSelectedValue();
|
||||||
meta.setUpload_type(new SerializableEnum<>(Arrays.asList(uploadType), meta.getUpload_type().getSelectableValues()));
|
if(uploadType!=null)
|
||||||
//publication type
|
meta.setUpload_type(new SerializableEnum<>(Arrays.asList(uploadType), meta.getUpload_type().getSelectableValues()));
|
||||||
|
// publication type
|
||||||
String publicationType = basicForm.getField_publication_type().getSelectedValue();
|
String publicationType = basicForm.getField_publication_type().getSelectedValue();
|
||||||
meta.setPublication_type(new SerializableEnum<>(Arrays.asList(publicationType), meta.getPublication_type().getSelectableValues()));
|
if(publicationType!=null)
|
||||||
//access right
|
meta.setPublication_type(new SerializableEnum<>(Arrays.asList(publicationType), meta.getPublication_type().getSelectableValues()));
|
||||||
|
// access right
|
||||||
String accessRight = basicForm.getField_access_right().getSelectedValue();
|
String accessRight = basicForm.getField_access_right().getSelectedValue();
|
||||||
meta.setAccess_right(new SerializableEnum<>(Arrays.asList(accessRight), meta.getAccess_right().getSelectableValues()));
|
if(accessRight!=null)
|
||||||
|
meta.setAccess_right(new SerializableEnum<>(Arrays.asList(accessRight), meta.getAccess_right().getSelectableValues()));
|
||||||
|
//keywords
|
||||||
|
meta.setKeywords(basicForm.getTags());
|
||||||
|
|
||||||
zenodoItem.setMetadata(meta);
|
zenodoItem.setMetadata(meta);
|
||||||
|
|
||||||
//Updating list of file for publishing
|
// Updating list of file for publishing
|
||||||
List<ZenodoFile> publishingFile = getListFileToPublish();
|
List<ZenodoFile> publishingFile = getListFileToPublish();
|
||||||
zenodoItem.setFiles(publishingFile);
|
zenodoItem.setFiles(publishingFile);
|
||||||
|
|
||||||
return zenodoItem;
|
return zenodoItem;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package org.gcube.portlets.widgets.ckan2zenodopublisher.server;
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.server;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
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.CkanResource;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.faults.ConfigurationException;
|
import org.gcube.data.publishing.ckan2zenodo.model.faults.ConfigurationException;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.faults.GcatException;
|
import org.gcube.data.publishing.ckan2zenodo.model.faults.GcatException;
|
||||||
import org.gcube.data.publishing.ckan2zenodo.model.faults.InvalidItemException;
|
import org.gcube.data.publishing.ckan2zenodo.model.faults.InvalidItemException;
|
||||||
|
@ -39,6 +41,11 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
if(isOutFromPortal()) {
|
||||||
|
PortalUtils.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||||
|
PortalUtils.getCurrentToken(this.getThreadLocalRequest(), true);
|
||||||
|
}
|
||||||
|
|
||||||
ZenodoDeposition zdPreview=loadItemPreviewFromService(zenodoItem.getName());
|
ZenodoDeposition zdPreview=loadItemPreviewFromService(zenodoItem.getName());
|
||||||
|
|
||||||
//(EVENTUALLY) UPDATING INFO CHANGED BY FORM ON CLIENT-SIDE
|
//(EVENTUALLY) UPDATING INFO CHANGED BY FORM ON CLIENT-SIDE
|
||||||
|
@ -53,7 +60,8 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
}
|
}
|
||||||
zdPreview.setFiles(listOfFiles);
|
zdPreview.setFiles(listOfFiles);
|
||||||
}
|
}
|
||||||
//Updating Deposition Metadata
|
|
||||||
|
//Updating Deposition Metadata potentially changed on client-side
|
||||||
ZenodoMetadata metadata = zenodoItem.getMetadata();
|
ZenodoMetadata metadata = zenodoItem.getMetadata();
|
||||||
DepositionMetadata depositionMetadata = zdPreview.getMetadata();
|
DepositionMetadata depositionMetadata = zdPreview.getMetadata();
|
||||||
depositionMetadata = ItemToZenodoConverter.updateMetadataInfoOfDepositionMetadata(metadata, depositionMetadata);
|
depositionMetadata = ItemToZenodoConverter.updateMetadataInfoOfDepositionMetadata(metadata, depositionMetadata);
|
||||||
|
@ -65,9 +73,9 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
|
|
||||||
//Actually publish to zenodo :
|
//Actually publish to zenodo :
|
||||||
// Step 1 : metadata
|
// Step 1 : metadata
|
||||||
Ckan2Zenodo client= Ckan2Zenodo.get();
|
// Ckan2Zenodo client= Ckan2Zenodo.get();
|
||||||
CkanItemDescriptor item=client.read(zenodoItem.getName());
|
// CkanItemDescriptor item=client.read(zenodoItem.getName());
|
||||||
zdPreview = client.updatedMetadata(zdPreview);
|
// zdPreview = client.updatedMetadata(zdPreview);
|
||||||
|
|
||||||
//Step 2 : publish Resources
|
//Step 2 : publish Resources
|
||||||
// Future<ZenodoDeposition> future_Dep=client.uploadFiles(Collections.singleton(toFilter.get(0)), zdPreview);
|
// Future<ZenodoDeposition> future_Dep=client.uploadFiles(Collections.singleton(toFilter.get(0)), zdPreview);
|
||||||
|
@ -76,12 +84,12 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
//Finalize
|
//Finalize
|
||||||
// Get the item representation
|
// Get the item representation
|
||||||
|
|
||||||
client.publish(zdPreview, item);
|
//client.publish(zdPreview, item);
|
||||||
|
|
||||||
return "OK";
|
return zdPreview.toString();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String error = "Error on publishing on Zenodo the catalogue item: "+zenodoItem.getName();
|
String error = "Error when publishing on Zenodo the catalogue item: "+zenodoItem.getName();
|
||||||
LOG.error(error, e);
|
LOG.error(error, e);
|
||||||
String clientError = String.format("%s. %s", error, CkanToZendoPublisherWidgetConstant.MSG_OF_ERROR_REFRESH_AND_TRY_AGAIN_OR_CONTACT_THE_SUPPORT);
|
String clientError = String.format("%s. %s", error, CkanToZendoPublisherWidgetConstant.MSG_OF_ERROR_REFRESH_AND_TRY_AGAIN_OR_CONTACT_THE_SUPPORT);
|
||||||
throw new Exception(clientError);
|
throw new Exception(clientError);
|
||||||
|
@ -159,7 +167,12 @@ public class CkanToZenodoPublisherServiceImpl extends RemoteServiceServlet imple
|
||||||
CkanItemDescriptor itemDescr=client.read(itemName);
|
CkanItemDescriptor itemDescr=client.read(itemName);
|
||||||
|
|
||||||
//Get a preview of the deposition to be published
|
//Get a preview of the deposition to be published
|
||||||
return client.translate(itemDescr);
|
ZenodoDeposition zenodoDeposition = client.translate(itemDescr);
|
||||||
|
|
||||||
|
//Filter resources according to VRE policies
|
||||||
|
List<CkanResource> toFilter=client.filterResources(itemDescr);
|
||||||
|
|
||||||
|
return zenodoDeposition;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class ItemToZenodoConverter {
|
||||||
zi.setState(zenodoDeposition.getState());
|
zi.setState(zenodoDeposition.getState());
|
||||||
zi.setSubmitted(zenodoDeposition.getSubmitted());
|
zi.setSubmitted(zenodoDeposition.getSubmitted());
|
||||||
zi.setTitle(zenodoDeposition.getTitle());
|
zi.setTitle(zenodoDeposition.getTitle());
|
||||||
|
|
||||||
zi.setMetadata(toZenodoMetadata(zenodoDeposition.getMetadata()));
|
zi.setMetadata(toZenodoMetadata(zenodoDeposition.getMetadata()));
|
||||||
|
|
||||||
LOG.debug("Converted item: "+zi);
|
LOG.debug("Converted item: "+zi);
|
||||||
|
@ -145,8 +145,8 @@ public class ItemToZenodoConverter {
|
||||||
|
|
||||||
//Publication Type
|
//Publication Type
|
||||||
if(depositionMetadata.getPublication_type()!=null) {
|
if(depositionMetadata.getPublication_type()!=null) {
|
||||||
PublicationType[] upType = { depositionMetadata.getPublication_type() };
|
PublicationType[] publicationType = { depositionMetadata.getPublication_type() };
|
||||||
SerializableEnum<String> sEnum = CkanToZenodoUtil.toSerializableEnum(upType, PublicationType.values());
|
SerializableEnum<String> sEnum = CkanToZenodoUtil.toSerializableEnum(publicationType, PublicationType.values());
|
||||||
zm.setPublication_type(sEnum);
|
zm.setPublication_type(sEnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,6 +169,7 @@ public class ItemToZenodoConverter {
|
||||||
zm.setThesis_university(depositionMetadata.getThesis_university());
|
zm.setThesis_university(depositionMetadata.getThesis_university());
|
||||||
zm.setTitle(depositionMetadata.getTitle());
|
zm.setTitle(depositionMetadata.getTitle());
|
||||||
zm.setVersion(depositionMetadata.getVersion());
|
zm.setVersion(depositionMetadata.getVersion());
|
||||||
|
zm.setNotes(depositionMetadata.getNotes());
|
||||||
return zm;
|
return zm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,21 +442,32 @@ public class ItemToZenodoConverter {
|
||||||
|
|
||||||
//upload type
|
//upload type
|
||||||
SerializableEnum<String> uploadType = metadata.getUpload_type();
|
SerializableEnum<String> uploadType = metadata.getUpload_type();
|
||||||
String theUploadTypeValue = uploadType.getSelectedValues().get(0);
|
LOG.debug("Read upload type: "+uploadType);
|
||||||
LOG.debug("Set upload type: "+theUploadTypeValue);
|
if(uploadType!=null) {
|
||||||
depositionMetadata.setUpload_type(UploadType.valueOf(theUploadTypeValue));
|
String theUploadTypeValue = uploadType.getSelectedValues().get(0);
|
||||||
|
LOG.debug("Set upload type: "+theUploadTypeValue);
|
||||||
|
depositionMetadata.setUpload_type(UploadType.valueOf(theUploadTypeValue));
|
||||||
|
}
|
||||||
|
|
||||||
//access right
|
//access right
|
||||||
SerializableEnum<String> accessRight = metadata.getAccess_right();
|
SerializableEnum<String> accessRight = metadata.getAccess_right();
|
||||||
String theAccessRightValue = accessRight.getSelectedValues().get(0);
|
LOG.debug("Read access type: "+accessRight);
|
||||||
LOG.debug("Set access right: "+theAccessRightValue);
|
if(accessRight!=null) {
|
||||||
depositionMetadata.setAccess_right(AccessRights.valueOf(theAccessRightValue));
|
String theAccessRightValue = accessRight.getSelectedValues().get(0);
|
||||||
|
LOG.debug("Set access right: "+theAccessRightValue);
|
||||||
|
depositionMetadata.setAccess_right(AccessRights.valueOf(theAccessRightValue));
|
||||||
|
}
|
||||||
|
|
||||||
//publication type
|
//publication type
|
||||||
SerializableEnum<String> publicationType = metadata.getPublication_type();
|
SerializableEnum<String> publicationType = metadata.getPublication_type();
|
||||||
String thePublicationTypeValue = publicationType.getSelectedValues().get(0);
|
LOG.debug("Read publication type: "+publicationType);
|
||||||
LOG.debug("Set publication type: "+thePublicationTypeValue);
|
if(publicationType!=null) {
|
||||||
depositionMetadata.setPublication_type(PublicationType.valueOf(thePublicationTypeValue));
|
String thePublicationTypeValue = publicationType.getSelectedValues().get(0);
|
||||||
|
depositionMetadata.setPublication_type(PublicationType.valueOf(thePublicationTypeValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
//keywords
|
||||||
|
depositionMetadata.setKeywords(metadata.getKeywords());
|
||||||
|
|
||||||
return depositionMetadata;
|
return depositionMetadata;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,6 @@ public class ZenodoMetadata implements Serializable{
|
||||||
|
|
||||||
|
|
||||||
public SerializableEnum<String> getPublication_type() {
|
public SerializableEnum<String> getPublication_type() {
|
||||||
if(publication_type==null)
|
|
||||||
return new SerializableEnum<>();
|
|
||||||
return publication_type;
|
return publication_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue