2019-12-10 16:31:06 +01:00
|
|
|
package org.gcube.portlets.widgets.ckan2zenodopublisher.server.converter;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Community;
|
|
|
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Contributor;
|
|
|
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Creator;
|
|
|
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DateInterval;
|
|
|
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata;
|
|
|
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata.AccessRights;
|
2020-01-13 17:48:41 +01:00
|
|
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata.PublicationType;
|
|
|
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.DepositionMetadata.UploadType;
|
2019-12-10 16:31:06 +01:00
|
|
|
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;
|
2019-12-10 17:39:12 +01:00
|
|
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.Subject;
|
2019-12-10 16:31:06 +01:00
|
|
|
import org.gcube.data.publishing.ckan2zenodo.model.zenodo.ZenodoDeposition;
|
|
|
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.server.CkanToZenodoUtil;
|
|
|
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.SerializableEnum;
|
2020-01-13 17:48:41 +01:00
|
|
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.LicenseBean;
|
2019-12-10 16:31:06 +01:00
|
|
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCommunity;
|
|
|
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoContributor;
|
|
|
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoCreator;
|
|
|
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoDateInterval;
|
|
|
|
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.ZenodoMetadata;
|
|
|
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoRelatedIdentifier;
|
2019-12-10 17:39:12 +01:00
|
|
|
import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoSubject;
|
2020-01-10 17:07:03 +01:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
2019-12-10 16:31:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Class ItemToZenodoConverter.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
*
|
|
|
|
* Dec 10, 2019
|
|
|
|
*/
|
|
|
|
public class ItemToZenodoConverter {
|
|
|
|
|
2020-01-10 17:07:03 +01:00
|
|
|
private static Logger LOG = LoggerFactory.getLogger(ItemToZenodoConverter.class);
|
|
|
|
/**
|
|
|
|
* **
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* TO CLIENT.
|
|
|
|
*
|
|
|
|
* @param zenodoDeposition the zenodo deposition
|
|
|
|
* @return the zenodo item
|
|
|
|
*/
|
|
|
|
|
2019-12-10 16:31:06 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* To zenodo item.
|
|
|
|
*
|
|
|
|
* @param zenodoDeposition the zenodo deposition
|
|
|
|
* @return the zenodo item
|
|
|
|
*/
|
|
|
|
public static ZenodoItem toZenodoItem(ZenodoDeposition zenodoDeposition) {
|
|
|
|
|
|
|
|
if(zenodoDeposition==null)
|
|
|
|
return null;
|
|
|
|
|
2020-01-13 17:48:41 +01:00
|
|
|
LOG.debug("Converting item: "+zenodoDeposition);
|
|
|
|
|
2019-12-10 16:31:06 +01:00
|
|
|
ZenodoItem zi = new ZenodoItem();
|
|
|
|
zi.setId(zenodoDeposition.getId());
|
|
|
|
zi.setDoi(zenodoDeposition.getDoi());
|
|
|
|
zi.setCreated(zenodoDeposition.getCreated());
|
|
|
|
|
|
|
|
if(zenodoDeposition.getFiles()!=null) {
|
|
|
|
List<ZenodoFile> listOfFiles = new ArrayList<ZenodoFile>(zenodoDeposition.getFiles().size());
|
|
|
|
for (FileDeposition fileDeposition : zenodoDeposition.getFiles()) {
|
|
|
|
listOfFiles.add(toZenodoFile(fileDeposition));
|
|
|
|
}
|
2019-12-12 18:32:30 +01:00
|
|
|
zi.setFiles(listOfFiles);
|
2019-12-10 16:31:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
zi.setModified(zenodoDeposition.getModified());
|
|
|
|
zi.setOwner(zenodoDeposition.getOwner());
|
|
|
|
zi.setRecord_id(zenodoDeposition.getRecord_id());
|
|
|
|
zi.setRecord_url(zenodoDeposition.getRecord_url()!=null?zenodoDeposition.getRecord_url().toString():null);
|
|
|
|
zi.setState(zenodoDeposition.getState());
|
|
|
|
zi.setSubmitted(zenodoDeposition.getSubmitted());
|
|
|
|
zi.setTitle(zenodoDeposition.getTitle());
|
2020-01-14 12:28:20 +01:00
|
|
|
|
2019-12-10 16:31:06 +01:00
|
|
|
zi.setMetadata(toZenodoMetadata(zenodoDeposition.getMetadata()));
|
|
|
|
|
2020-01-13 17:48:41 +01:00
|
|
|
LOG.debug("Converted item: "+zi);
|
|
|
|
|
2019-12-10 16:31:06 +01:00
|
|
|
return zi;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* To zenodo file.
|
|
|
|
*
|
|
|
|
* @param fileDeposition the file deposition
|
|
|
|
* @return the zenodo file
|
|
|
|
*/
|
|
|
|
public static ZenodoFile toZenodoFile(FileDeposition fileDeposition) {
|
|
|
|
|
|
|
|
if(fileDeposition==null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
ZenodoFile zf = new ZenodoFile();
|
|
|
|
zf.setId(fileDeposition.getId());
|
|
|
|
zf.setFilename(fileDeposition.getFilename());
|
|
|
|
zf.setFilesize(fileDeposition.getFilesize());
|
|
|
|
zf.setChecksum(fileDeposition.getChecksum());
|
|
|
|
return zf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* To zenodo metadata.
|
|
|
|
*
|
|
|
|
* @param depositionMetadata the deposition metadata
|
|
|
|
* @return the zenodo metadata
|
|
|
|
*/
|
|
|
|
public static ZenodoMetadata toZenodoMetadata(DepositionMetadata depositionMetadata){
|
|
|
|
|
|
|
|
if(depositionMetadata==null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
ZenodoMetadata zm = new ZenodoMetadata();
|
|
|
|
zm.setAccess_conditions(depositionMetadata.getAccess_conditions());
|
2019-12-12 18:32:30 +01:00
|
|
|
zm.setDescription(depositionMetadata.getDescription());
|
2019-12-10 17:39:12 +01:00
|
|
|
|
2020-01-13 17:48:41 +01:00
|
|
|
//Access Type
|
2019-12-10 16:31:06 +01:00
|
|
|
if(depositionMetadata.getAccess_right()!=null) {
|
|
|
|
AccessRights[] ar = { depositionMetadata.getAccess_right() };
|
|
|
|
SerializableEnum<String> sEnum = CkanToZenodoUtil.toSerializableEnum(ar, AccessRights.values());
|
|
|
|
zm.setAccess_right(sEnum);
|
|
|
|
}
|
2019-12-10 17:39:12 +01:00
|
|
|
|
2020-01-13 17:48:41 +01:00
|
|
|
//Upload Type
|
|
|
|
if(depositionMetadata.getUpload_type()!=null) {
|
|
|
|
UploadType[] upType = { depositionMetadata.getUpload_type() };
|
|
|
|
SerializableEnum<String> sEnum = CkanToZenodoUtil.toSerializableEnum(upType, UploadType.values());
|
|
|
|
zm.setUpload_type(sEnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Publication Type
|
|
|
|
if(depositionMetadata.getPublication_type()!=null) {
|
2020-01-14 12:28:20 +01:00
|
|
|
PublicationType[] publicationType = { depositionMetadata.getPublication_type() };
|
|
|
|
SerializableEnum<String> sEnum = CkanToZenodoUtil.toSerializableEnum(publicationType, PublicationType.values());
|
2020-01-13 17:48:41 +01:00
|
|
|
zm.setPublication_type(sEnum);
|
|
|
|
}
|
|
|
|
|
|
|
|
zm.setLicense(new LicenseBean(depositionMetadata.getLicense(),depositionMetadata.getLicense(),null)); //HAVE TO BE RIVISITED
|
|
|
|
zm.setKeywords(depositionMetadata.getKeywords());
|
2019-12-10 16:31:06 +01:00
|
|
|
zm.setCommunities(toZenodoCommunities(depositionMetadata.getCommunities()));
|
|
|
|
zm.setConference_acronym(depositionMetadata.getConference_acronym());
|
|
|
|
zm.setConference_dates(depositionMetadata.getConference_dates());
|
|
|
|
zm.setConference_place(depositionMetadata.getConference_place());
|
|
|
|
zm.setConference_session(depositionMetadata.getConference_session());
|
|
|
|
zm.setConference_session_part(depositionMetadata.getConference_session_part());
|
|
|
|
zm.setConference_title(depositionMetadata.getConference_title());
|
|
|
|
zm.setConference_url(depositionMetadata.getConference_url());
|
|
|
|
zm.setContributors(toZenodoContributors(depositionMetadata.getContributors()));
|
|
|
|
zm.setCreators(toZenodoCreators(depositionMetadata.getCreators()));
|
2020-01-10 17:07:03 +01:00
|
|
|
zm.setDates(toZenodoDateIntervals(depositionMetadata.getDates()));
|
2019-12-10 16:31:06 +01:00
|
|
|
zm.setRelated_identifiers(toRelatedIdentifiers(depositionMetadata.getRelated_identifiers()));
|
2019-12-10 17:39:12 +01:00
|
|
|
zm.setSubjects(toZenodoSubjects(depositionMetadata.getSubjects()));
|
|
|
|
zm.setThesis_supervisors(toZenodoCreators(depositionMetadata.getThesis_supervisors()));
|
|
|
|
zm.setThesis_university(depositionMetadata.getThesis_university());
|
|
|
|
zm.setTitle(depositionMetadata.getTitle());
|
|
|
|
zm.setVersion(depositionMetadata.getVersion());
|
2020-01-14 12:28:20 +01:00
|
|
|
zm.setNotes(depositionMetadata.getNotes());
|
2019-12-10 16:31:06 +01:00
|
|
|
return zm;
|
|
|
|
}
|
2019-12-10 17:39:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* To zenodo subjects.
|
|
|
|
*
|
|
|
|
* @param subjects the subjects
|
|
|
|
* @return the list
|
|
|
|
*/
|
|
|
|
private static List<ZenodoSubject> toZenodoSubjects(List<Subject> subjects) {
|
|
|
|
if(subjects==null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
List<ZenodoSubject> list = new ArrayList<ZenodoSubject>(subjects.size());
|
|
|
|
for (Subject sub : subjects) {
|
|
|
|
ZenodoSubject zs = new ZenodoSubject(sub.getTerm(), sub.getIdentifier(), sub.getScheme());
|
|
|
|
list.add(zs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2019-12-10 16:31:06 +01:00
|
|
|
/**
|
|
|
|
* To related identifiers.
|
|
|
|
*
|
|
|
|
* @param related_identifiers the related identifiers
|
|
|
|
* @return the list
|
|
|
|
*/
|
|
|
|
private static List<ZenodoRelatedIdentifier> toRelatedIdentifiers(List<RelatedIdentifier> related_identifiers) {
|
|
|
|
|
|
|
|
if(related_identifiers==null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
List<ZenodoRelatedIdentifier> list = new ArrayList<ZenodoRelatedIdentifier>(related_identifiers.size());
|
|
|
|
for (RelatedIdentifier relatedIdentifier : related_identifiers) {
|
|
|
|
Relation[] rel = { relatedIdentifier.getRelation() };
|
|
|
|
SerializableEnum<String> sEnum = CkanToZenodoUtil.toSerializableEnum(rel, Relation.values());
|
|
|
|
ZenodoRelatedIdentifier zdi = new ZenodoRelatedIdentifier(relatedIdentifier.getIdentifier(), sEnum);
|
|
|
|
list.add(zdi);
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2020-01-10 17:07:03 +01:00
|
|
|
|
2019-12-10 16:31:06 +01:00
|
|
|
/**
|
2020-01-10 17:07:03 +01:00
|
|
|
* To zenodo date intervals.
|
2019-12-10 16:31:06 +01:00
|
|
|
*
|
|
|
|
* @param dateIntervals the date intervals
|
|
|
|
* @return the list
|
|
|
|
*/
|
2020-01-10 17:07:03 +01:00
|
|
|
private static List<ZenodoDateInterval> toZenodoDateIntervals(List<DateInterval> dateIntervals) {
|
2019-12-10 16:31:06 +01:00
|
|
|
|
|
|
|
if(dateIntervals==null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
List<ZenodoDateInterval> list = new ArrayList<ZenodoDateInterval>(dateIntervals.size());
|
|
|
|
for (DateInterval dateInterval : dateIntervals) {
|
|
|
|
SerializableEnum<String> types = null;
|
|
|
|
if(dateInterval.getType()!=null) {
|
|
|
|
DateInterval.Type[] rel = { dateInterval.getType() };
|
|
|
|
types = CkanToZenodoUtil.toSerializableEnum(rel, DateInterval.Type.values());
|
|
|
|
}
|
|
|
|
|
2019-12-12 18:32:30 +01:00
|
|
|
list.add(new ZenodoDateInterval(dateInterval.getStart(), dateInterval.getEnd(), types, dateInterval.getDescription()));
|
2019-12-10 16:31:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* To zenodo communities.
|
|
|
|
*
|
|
|
|
* @param communities the communities
|
|
|
|
* @return the list
|
|
|
|
*/
|
|
|
|
public static List<ZenodoCommunity> toZenodoCommunities(List<Community> communities) {
|
|
|
|
|
|
|
|
if(communities==null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
List<ZenodoCommunity> list = new ArrayList<ZenodoCommunity>(communities.size());
|
|
|
|
for (Community community : communities) {
|
|
|
|
list.add(new ZenodoCommunity(community.getIdentifier()));
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* To zenodo contributors.
|
|
|
|
*
|
|
|
|
* @param contributors the contributors
|
|
|
|
* @return the list
|
|
|
|
*/
|
|
|
|
public static List<ZenodoContributor> toZenodoContributors(List<Contributor> contributors) {
|
|
|
|
|
|
|
|
if(contributors==null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
List<ZenodoContributor> list = new ArrayList<ZenodoContributor>(contributors.size());
|
|
|
|
for (Contributor contr : contributors) {
|
|
|
|
ZenodoContributor zc = new ZenodoContributor();
|
|
|
|
zc.setAffiliation(contr.getAffiliation());
|
|
|
|
zc.setGnd(contr.getGnd());
|
|
|
|
zc.setName(contr.getName());
|
|
|
|
zc.setOrcid(contr.getOrcid());
|
|
|
|
SerializableEnum<String> types = null;
|
|
|
|
if(contr.getType()!=null) {
|
|
|
|
Contributor.Type[] rel = { contr.getType() };
|
|
|
|
types = CkanToZenodoUtil.toSerializableEnum(rel, Contributor.Type.values());
|
|
|
|
}
|
|
|
|
zc.setType(types);
|
|
|
|
list.add(zc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* To zenodo creators.
|
|
|
|
*
|
|
|
|
* @param creators the creators
|
|
|
|
* @return the list
|
|
|
|
*/
|
|
|
|
public static List<ZenodoCreator> toZenodoCreators(List<Creator> creators) {
|
|
|
|
|
|
|
|
if(creators==null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
List<ZenodoCreator> list = new ArrayList<ZenodoCreator>(creators.size());
|
|
|
|
for (Creator contr : creators) {
|
|
|
|
ZenodoContributor zc = new ZenodoContributor();
|
|
|
|
zc.setAffiliation(contr.getAffiliation());
|
|
|
|
zc.setGnd(contr.getGnd());
|
|
|
|
zc.setName(contr.getName());
|
|
|
|
zc.setOrcid(contr.getOrcid());
|
|
|
|
list.add(zc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
2020-01-10 17:07:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
// * **
|
|
|
|
// *
|
|
|
|
// *
|
|
|
|
// * TO SERVICE.
|
|
|
|
// *
|
|
|
|
// * @param zenodoItem the zenodo item
|
|
|
|
// * @param zenodoDeposition the zenodo deposition
|
|
|
|
// * @return the zenodo deposition
|
|
|
|
// */
|
|
|
|
//
|
|
|
|
// /**
|
|
|
|
// * To service zenodo deposition.
|
|
|
|
// *
|
|
|
|
// * @param zenodoItem the zenodo item
|
|
|
|
// */
|
|
|
|
// public static ZenodoDeposition toServiceZenodoDeposition(ZenodoItem zenodoItem, ZenodoDeposition zenodoDeposition) {
|
|
|
|
//
|
|
|
|
// if(zenodoItem==null)
|
|
|
|
// return zenodoDeposition;
|
|
|
|
//
|
|
|
|
// //zenodoDeposition.setId(zenodoItem.getId());
|
|
|
|
// //zenodoDeposition.setDoi(zenodoItem.getDoi());
|
|
|
|
// //zenodoDeposition.setCreated(zenodoItem.getCreated());
|
|
|
|
//
|
|
|
|
// zenodoDeposition.setTitle(zenodoItem.getTitle());
|
|
|
|
//
|
|
|
|
// if(zenodoItem.getFiles()!=null) {
|
|
|
|
// ArrayList<FileDeposition> listOfFiles = new ArrayList<FileDeposition>(zenodoItem.getFiles().size());
|
|
|
|
// for (ZenodoFile zf : zenodoItem.getFiles()) {
|
|
|
|
// listOfFiles.add(toServiceZenodoDeposition(zf));
|
|
|
|
// }
|
|
|
|
// zenodoDeposition.setFiles(listOfFiles);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// //zenodoDeposition.setModified(zenodoItem.getModified());
|
|
|
|
// //zenodoDeposition.setOwner(zenodoItem.getOwner());
|
|
|
|
// //zenodoDeposition.setRecord_id(zenodoItem.getRecord_id());
|
|
|
|
//// try {
|
|
|
|
//// zenodoDeposition.setRecord_url(zenodoItem.getRecord_url()!=null?new URL(zenodoItem.getRecord_url()):null);
|
|
|
|
//// } catch (MalformedURLException e) {
|
|
|
|
//// LOG.warn(e.getMessage());
|
|
|
|
//// }
|
|
|
|
//
|
|
|
|
//// zenodoDeposition.setState(zenodoItem.getState());
|
|
|
|
//// zenodoDeposition.setSubmitted(zenodoItem.getSubmitted());
|
|
|
|
// //zenodoDeposition.setMetadata(toServiceZenodoMetadata(zenodoItem.getMetadata(),zenodoDeposition.getMetadata()));
|
|
|
|
//
|
|
|
|
// return zenodoDeposition;
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
|
|
|
|
// /**
|
|
|
|
// * To service zenodo metadata.
|
|
|
|
// *
|
|
|
|
// * @param zenodoMetadata the zenodo metadata
|
|
|
|
// * @param depositionMetadata the deposition metadata
|
|
|
|
// * @return the deposition metadata
|
|
|
|
// */
|
|
|
|
// public static DepositionMetadata toServiceZenodoMetadata(ZenodoMetadata zenodoMetadata, DepositionMetadata depositionMetadata){
|
|
|
|
//
|
|
|
|
// if(zenodoMetadata==null)
|
|
|
|
// return null;
|
|
|
|
//
|
|
|
|
// depositionMetadata.setAccess_conditions(depositionMetadata.getAccess_conditions());
|
|
|
|
// depositionMetadata.setDescription(depositionMetadata.getDescription());
|
|
|
|
//
|
|
|
|
// if(depositionMetadata.getAccess_right()!=null) {
|
|
|
|
// AccessRights[] ar = { depositionMetadata.getAccess_right() };
|
|
|
|
// SerializableEnum<String> sEnum = CkanToZenodoUtil.toSerializableEnum(ar, AccessRights.values());
|
|
|
|
// depositionMetadata.setAccess_right(sEnum);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// depositionMetadata.setCommunities(toZenodoCommunities(depositionMetadata.getCommunities()));
|
|
|
|
// depositionMetadata.setConference_acronym(depositionMetadata.getConference_acronym());
|
|
|
|
// depositionMetadata.setConference_dates(depositionMetadata.getConference_dates());
|
|
|
|
// depositionMetadata.setConference_place(depositionMetadata.getConference_place());
|
|
|
|
// depositionMetadata.setConference_session(depositionMetadata.getConference_session());
|
|
|
|
// depositionMetadata.setConference_session_part(depositionMetadata.getConference_session_part());
|
|
|
|
// depositionMetadata.setConference_title(depositionMetadata.getConference_title());
|
|
|
|
// depositionMetadata.setConference_url(depositionMetadata.getConference_url());
|
|
|
|
// depositionMetadata.setContributors(toZenodoContributors(depositionMetadata.getContributors()));
|
|
|
|
// depositionMetadata.setCreators(toZenodoCreators(depositionMetadata.getCreators()));
|
|
|
|
// depositionMetadata.setDates(toZenodDateIntervals(depositionMetadata.getDates()));
|
|
|
|
// depositionMetadata.setRelated_identifiers(toRelatedIdentifiers(depositionMetadata.getRelated_identifiers()));
|
|
|
|
// depositionMetadata.setSubjects(toZenodoSubjects(depositionMetadata.getSubjects()));
|
|
|
|
// depositionMetadata.setThesis_supervisors(toZenodoCreators(depositionMetadata.getThesis_supervisors()));
|
|
|
|
// depositionMetadata.setThesis_university(depositionMetadata.getThesis_university());
|
|
|
|
// depositionMetadata.setTitle(depositionMetadata.getTitle());
|
|
|
|
// depositionMetadata.setVersion(depositionMetadata.getVersion());
|
|
|
|
// return zm;
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* To service file deposition.
|
|
|
|
*
|
|
|
|
* @param zenodoFile the zenodo file
|
|
|
|
* @return the file deposition
|
|
|
|
*/
|
|
|
|
public static FileDeposition toServiceFileDeposition(ZenodoFile zenodoFile) {
|
|
|
|
|
|
|
|
if(zenodoFile==null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
FileDeposition fileDep = new FileDeposition();
|
|
|
|
fileDep.setId(zenodoFile.getId());
|
|
|
|
fileDep.setFilename(zenodoFile.getFilename());
|
|
|
|
fileDep.setFilesize(zenodoFile.getFilesize());
|
|
|
|
fileDep.setChecksum(zenodoFile.getChecksum());
|
|
|
|
return fileDep;
|
|
|
|
}
|
2020-01-13 17:48:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update metadata info of deposition metadata.
|
|
|
|
*
|
|
|
|
* @param metadata the metadata
|
|
|
|
* @param depositionMetadata the deposition metadata
|
|
|
|
* @return the deposition metadata
|
|
|
|
*/
|
|
|
|
public static DepositionMetadata updateMetadataInfoOfDepositionMetadata(ZenodoMetadata metadata, DepositionMetadata depositionMetadata) {
|
|
|
|
|
|
|
|
//upload type
|
|
|
|
SerializableEnum<String> uploadType = metadata.getUpload_type();
|
2020-01-14 12:28:20 +01:00
|
|
|
LOG.debug("Read upload type: "+uploadType);
|
|
|
|
if(uploadType!=null) {
|
|
|
|
String theUploadTypeValue = uploadType.getSelectedValues().get(0);
|
|
|
|
LOG.debug("Set upload type: "+theUploadTypeValue);
|
|
|
|
depositionMetadata.setUpload_type(UploadType.valueOf(theUploadTypeValue));
|
|
|
|
}
|
2020-01-13 17:48:41 +01:00
|
|
|
|
|
|
|
//access right
|
|
|
|
SerializableEnum<String> accessRight = metadata.getAccess_right();
|
2020-01-14 12:28:20 +01:00
|
|
|
LOG.debug("Read access type: "+accessRight);
|
|
|
|
if(accessRight!=null) {
|
|
|
|
String theAccessRightValue = accessRight.getSelectedValues().get(0);
|
|
|
|
LOG.debug("Set access right: "+theAccessRightValue);
|
|
|
|
depositionMetadata.setAccess_right(AccessRights.valueOf(theAccessRightValue));
|
|
|
|
}
|
2020-01-13 17:48:41 +01:00
|
|
|
|
|
|
|
//publication type
|
|
|
|
SerializableEnum<String> publicationType = metadata.getPublication_type();
|
2020-01-14 12:28:20 +01:00
|
|
|
LOG.debug("Read publication type: "+publicationType);
|
|
|
|
if(publicationType!=null) {
|
|
|
|
String thePublicationTypeValue = publicationType.getSelectedValues().get(0);
|
|
|
|
depositionMetadata.setPublication_type(PublicationType.valueOf(thePublicationTypeValue));
|
|
|
|
}
|
|
|
|
|
|
|
|
//keywords
|
|
|
|
depositionMetadata.setKeywords(metadata.getKeywords());
|
2020-01-13 17:48:41 +01:00
|
|
|
|
|
|
|
return depositionMetadata;
|
|
|
|
}
|
2019-12-10 16:31:06 +01:00
|
|
|
|
|
|
|
}
|