Fixing `publication_date` issue [#26166]
This commit is contained in:
parent
6dbc1d8e4c
commit
4eb65dc4ed
|
@ -4,6 +4,10 @@
|
|||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v1.1.4-SNAPSHOT] - 2023-12-05
|
||||
|
||||
- Fixing `publication_date` issue [#26166]
|
||||
|
||||
## [v1.1.3] - 2023-07-25
|
||||
|
||||
- Fixing `null` issue, recompiling this component [#25275]
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -14,7 +14,7 @@
|
|||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>ckan2zenodo-publisher-widget</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.1.3</version>
|
||||
<version>1.1.4-SNAPSHOT</version>
|
||||
|
||||
<description>
|
||||
gCube Ckan2Zenodo Publisher widget allows to publish D4Science catalogue's items on Zenodo
|
||||
|
|
|
@ -35,18 +35,17 @@ import org.gcube.portlets.widgets.ckan2zenodopublisher.shared.wrapped.ZenodoSubj
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class ItemToZenodoConverter.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Dec 10, 2019
|
||||
* Dec 10, 2019
|
||||
*/
|
||||
public class ItemToZenodoConverter {
|
||||
|
||||
|
||||
private static Logger LOG = LoggerFactory.getLogger(ItemToZenodoConverter.class);
|
||||
|
||||
/**
|
||||
* **
|
||||
*
|
||||
|
@ -56,8 +55,7 @@ public class ItemToZenodoConverter {
|
|||
* @param zenodoDeposition the zenodo deposition
|
||||
* @return the zenodo item
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To zenodo item.
|
||||
*
|
||||
|
@ -65,112 +63,108 @@ public class ItemToZenodoConverter {
|
|||
* @return the zenodo item
|
||||
*/
|
||||
public static ZenodoItem toZenodoItem(ZenodoDeposition zenodoDeposition) {
|
||||
|
||||
if(zenodoDeposition==null)
|
||||
|
||||
if (zenodoDeposition == null)
|
||||
return null;
|
||||
|
||||
LOG.debug("Converting item: "+zenodoDeposition);
|
||||
|
||||
|
||||
LOG.debug("Converting item: " + zenodoDeposition);
|
||||
|
||||
ZenodoItem zi = new ZenodoItem();
|
||||
zi.setId(zenodoDeposition.getId());
|
||||
zi.setDoi(zenodoDeposition.getDoi());
|
||||
zi.setCreated(zenodoDeposition.getCreated());
|
||||
|
||||
//Add files already published in the deposition
|
||||
List<ZenodoFile> files = toZenodoFiles(zenodoDeposition.getFiles(),true);
|
||||
|
||||
// Add files already published in the deposition
|
||||
List<ZenodoFile> files = toZenodoFiles(zenodoDeposition.getFiles(), true);
|
||||
zi.addFiles(files);
|
||||
|
||||
|
||||
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.setRecord_url(zenodoDeposition.getRecord_url() != null ? zenodoDeposition.getRecord_url().toString() : null);
|
||||
zi.setState(zenodoDeposition.getState());
|
||||
zi.setSubmitted(zenodoDeposition.getSubmitted());
|
||||
zi.setTitle(zenodoDeposition.getTitle());
|
||||
|
||||
zi.setMetadata(toZenodoMetadata(zenodoDeposition.getMetadata()));
|
||||
|
||||
LOG.debug("Converted item: "+zi);
|
||||
|
||||
|
||||
LOG.debug("Converted item: " + zi);
|
||||
|
||||
return zi;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds the files.
|
||||
*
|
||||
* @param files the files
|
||||
* @param files the files
|
||||
* @param filesAlreadyPublished the files already published
|
||||
* @return the list
|
||||
*/
|
||||
private static List<ZenodoFile> toZenodoFiles(ArrayList<FileDeposition> files, boolean filesAlreadyPublished) {
|
||||
|
||||
if(files==null)
|
||||
|
||||
if (files == null)
|
||||
return null;
|
||||
|
||||
|
||||
List<ZenodoFile> listOfFiles = new ArrayList<ZenodoFile>(files.size());
|
||||
for (FileDeposition fileDeposition : files) {
|
||||
listOfFiles.add(toZenodoFile(fileDeposition, filesAlreadyPublished));
|
||||
}
|
||||
|
||||
|
||||
return listOfFiles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To zenodo files.
|
||||
*
|
||||
* @param filteredResources the filtered resources
|
||||
* @param filteredResources the filtered resources
|
||||
* @param filesAlreadyPublished the files already published
|
||||
* @return the list
|
||||
*/
|
||||
public static List<ZenodoFile> toZenodoFiles(List<CkanResource> filteredResources, boolean filesAlreadyPublished) {
|
||||
if(filteredResources==null)
|
||||
if (filteredResources == null)
|
||||
return null;
|
||||
|
||||
|
||||
List<ZenodoFile> listOfFiles = new ArrayList<ZenodoFile>(filteredResources.size());
|
||||
for (CkanResource ckanResource : filteredResources) {
|
||||
listOfFiles.add(toZenodoFile(ckanResource,filesAlreadyPublished));
|
||||
listOfFiles.add(toZenodoFile(ckanResource, filesAlreadyPublished));
|
||||
}
|
||||
|
||||
|
||||
return listOfFiles;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To zenodo file.
|
||||
*
|
||||
* @param fileDeposition the file deposition
|
||||
* @param fileDeposition the file deposition
|
||||
* @param fileAlreadyPublished the file already published
|
||||
* @return the zenodo file
|
||||
*/
|
||||
public static ZenodoFile toZenodoFile(FileDeposition fileDeposition, boolean fileAlreadyPublished) {
|
||||
|
||||
if(fileDeposition==null)
|
||||
|
||||
if (fileDeposition == null)
|
||||
return null;
|
||||
|
||||
|
||||
ZenodoFile zf = new ZenodoFile();
|
||||
zf.setId(fileDeposition.getId());
|
||||
zf.setFilename(fileDeposition.getFilename());
|
||||
zf.setFilesize(fileDeposition.getFilesize()+"");
|
||||
zf.setFilesize(fileDeposition.getFilesize() + "");
|
||||
zf.setChecksum(fileDeposition.getChecksum());
|
||||
zf.setIsAlreadyPublished(fileAlreadyPublished);
|
||||
return zf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To zenodo file.
|
||||
*
|
||||
* @param ckanResource the ckan resource
|
||||
* @param ckanResource the ckan resource
|
||||
* @param fileAlreadyPublished the file already published
|
||||
* @return the zenodo file
|
||||
*/
|
||||
public static ZenodoFile toZenodoFile(CkanResource ckanResource, boolean fileAlreadyPublished) {
|
||||
|
||||
if(ckanResource==null)
|
||||
|
||||
if (ckanResource == null)
|
||||
return null;
|
||||
|
||||
|
||||
ZenodoFile zf = new ZenodoFile();
|
||||
zf.setId(ckanResource.getId());
|
||||
zf.setFilename(ckanResource.getName());
|
||||
|
@ -182,70 +176,72 @@ public class ItemToZenodoConverter {
|
|||
zf.setIsAlreadyPublished(fileAlreadyPublished);
|
||||
return zf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To zenodo metadata.
|
||||
*
|
||||
* @param depositionMetadata the deposition metadata
|
||||
* @return the zenodo metadata
|
||||
*/
|
||||
public static ZenodoMetadata toZenodoMetadata(DepositionMetadata depositionMetadata){
|
||||
|
||||
if(depositionMetadata==null)
|
||||
public static ZenodoMetadata toZenodoMetadata(DepositionMetadata depositionMetadata) {
|
||||
|
||||
if (depositionMetadata == null)
|
||||
return null;
|
||||
|
||||
|
||||
ZenodoMetadata zm = new ZenodoMetadata();
|
||||
zm.setAccess_conditions(depositionMetadata.getAccess_conditions());
|
||||
zm.setDescription(depositionMetadata.getDescription());
|
||||
|
||||
//Access Type
|
||||
|
||||
// fixing bug #26165 on publication_date = null
|
||||
zm.setPublication_date(depositionMetadata.getPublication_date());
|
||||
|
||||
// Access Type
|
||||
AccessRights[] accessRight = null;
|
||||
if(depositionMetadata.getAccess_right()!=null) {
|
||||
if (depositionMetadata.getAccess_right() != null) {
|
||||
AccessRights[] theAccessRight = { depositionMetadata.getAccess_right() };
|
||||
accessRight = theAccessRight;
|
||||
}
|
||||
zm.setAccess_right(CkanToZenodoUtil.toSerializableEnum(accessRight, AccessRights.values()));
|
||||
|
||||
//Upload Type
|
||||
|
||||
// Upload Type
|
||||
UploadType[] uploadType = null;
|
||||
if(depositionMetadata.getUpload_type()!=null) {
|
||||
if (depositionMetadata.getUpload_type() != null) {
|
||||
UploadType[] theUploadType = { depositionMetadata.getUpload_type() };
|
||||
uploadType = theUploadType;
|
||||
|
||||
|
||||
}
|
||||
zm.setUpload_type(CkanToZenodoUtil.toSerializableEnum(uploadType, UploadType.values()));
|
||||
|
||||
//Publication Type
|
||||
|
||||
// Publication Type
|
||||
PublicationType[] publicationType = null;
|
||||
if(depositionMetadata.getPublication_type()!=null) {
|
||||
if (depositionMetadata.getPublication_type() != null) {
|
||||
PublicationType[] thepublicationType = { depositionMetadata.getPublication_type() };
|
||||
publicationType = thepublicationType;
|
||||
}
|
||||
zm.setPublication_type(CkanToZenodoUtil.toSerializableEnum(publicationType, PublicationType.values()));
|
||||
|
||||
//Image Type
|
||||
|
||||
// Image Type
|
||||
ImageType[] imageType = null;
|
||||
if(depositionMetadata.getImage_type()!=null) {
|
||||
if (depositionMetadata.getImage_type() != null) {
|
||||
ImageType[] theImageType = { depositionMetadata.getImage_type() };
|
||||
imageType = theImageType;
|
||||
}
|
||||
zm.setImage_type(CkanToZenodoUtil.toSerializableEnum(imageType, ImageType.values()));
|
||||
|
||||
//Licenses
|
||||
|
||||
// Licenses
|
||||
List<String> selectedLicenses = null;
|
||||
if(depositionMetadata.getLicense()!=null) {
|
||||
if (depositionMetadata.getLicense() != null) {
|
||||
selectedLicenses = new ArrayList<String>();
|
||||
selectedLicenses.add(depositionMetadata.getLicense()); //NEED TO ADD ALL LICENSES
|
||||
selectedLicenses.add(depositionMetadata.getLicense()); // NEED TO ADD ALL LICENSES
|
||||
}
|
||||
if(selectedLicenses!=null) {
|
||||
if (selectedLicenses != null) {
|
||||
zm.setLicenseIDs(selectedLicenses);
|
||||
}
|
||||
|
||||
if(depositionMetadata.getEmbargo_date()!=null) {
|
||||
|
||||
|
||||
if (depositionMetadata.getEmbargo_date() != null) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
zm.setKeywords(depositionMetadata.getKeywords());
|
||||
zm.setCommunities(toZenodoCommunities(depositionMetadata.getCommunities()));
|
||||
zm.setConference_acronym(depositionMetadata.getConference_acronym());
|
||||
|
@ -255,12 +251,12 @@ public class ItemToZenodoConverter {
|
|||
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()));
|
||||
|
||||
//to manage empty or null contributors from mapping
|
||||
|
||||
// to manage empty or null contributors from mapping
|
||||
zm.setContributorsTypes(CkanToZenodoUtil.toSerializableEnum(null, Contributor.Type.values()));
|
||||
|
||||
|
||||
zm.setCreators(toZenodoCreators(depositionMetadata.getCreators()));
|
||||
zm.setDates(toZenodoDateIntervals(depositionMetadata.getDates()));
|
||||
zm.setEmbargo_date(depositionMetadata.getEmbargo_date());
|
||||
|
@ -271,11 +267,10 @@ public class ItemToZenodoConverter {
|
|||
zm.setTitle(depositionMetadata.getTitle());
|
||||
zm.setVersion(depositionMetadata.getVersion());
|
||||
zm.setNotes(depositionMetadata.getNotes());
|
||||
|
||||
|
||||
return zm;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To zenodo subjects.
|
||||
*
|
||||
|
@ -283,15 +278,15 @@ public class ItemToZenodoConverter {
|
|||
* @return the list
|
||||
*/
|
||||
private static List<ZenodoSubject> toZenodoSubjects(List<Subject> subjects) {
|
||||
if(subjects==null)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -302,22 +297,21 @@ public class ItemToZenodoConverter {
|
|||
* @return the list
|
||||
*/
|
||||
private static List<ZenodoRelatedIdentifier> toRelatedIdentifiers(List<RelatedIdentifier> related_identifiers) {
|
||||
|
||||
if(related_identifiers==null)
|
||||
|
||||
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());
|
||||
SerializableEnum<String> sEnum = CkanToZenodoUtil.toSerializableEnum(rel, Relation.values());
|
||||
ZenodoRelatedIdentifier zdi = new ZenodoRelatedIdentifier(relatedIdentifier.getIdentifier(), sEnum);
|
||||
list.add(zdi);
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To zenodo date intervals.
|
||||
*
|
||||
|
@ -325,21 +319,22 @@ public class ItemToZenodoConverter {
|
|||
* @return the list
|
||||
*/
|
||||
private static List<ZenodoDateInterval> toZenodoDateIntervals(List<DateInterval> dateIntervals) {
|
||||
|
||||
if(dateIntervals==null)
|
||||
|
||||
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) {
|
||||
if (dateInterval.getType() != null) {
|
||||
DateInterval.Type[] rel = { dateInterval.getType() };
|
||||
types = CkanToZenodoUtil.toSerializableEnum(rel, DateInterval.Type.values());
|
||||
}
|
||||
|
||||
list.add(new ZenodoDateInterval(dateInterval.getStart(), dateInterval.getEnd(), types, dateInterval.getDescription()));
|
||||
|
||||
list.add(new ZenodoDateInterval(dateInterval.getStart(), dateInterval.getEnd(), types,
|
||||
dateInterval.getDescription()));
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -350,18 +345,18 @@ public class ItemToZenodoConverter {
|
|||
* @return the list
|
||||
*/
|
||||
public static List<ZenodoCommunity> toZenodoCommunities(List<Community> communities) {
|
||||
|
||||
if(communities==null)
|
||||
|
||||
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.
|
||||
*
|
||||
|
@ -369,10 +364,10 @@ public class ItemToZenodoConverter {
|
|||
* @return the list
|
||||
*/
|
||||
public static List<ZenodoContributor> toZenodoContributors(List<Contributor> contributors) {
|
||||
|
||||
if(contributors==null)
|
||||
|
||||
if (contributors == null)
|
||||
return null;
|
||||
|
||||
|
||||
List<ZenodoContributor> list = new ArrayList<ZenodoContributor>(contributors.size());
|
||||
for (Contributor contr : contributors) {
|
||||
ZenodoContributor zc = new ZenodoContributor();
|
||||
|
@ -381,17 +376,17 @@ public class ItemToZenodoConverter {
|
|||
zc.setName(contr.getName());
|
||||
zc.setOrcid(contr.getOrcid());
|
||||
SerializableEnum<String> types = null;
|
||||
if(contr.getType()!=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.
|
||||
*
|
||||
|
@ -399,10 +394,10 @@ public class ItemToZenodoConverter {
|
|||
* @return the list
|
||||
*/
|
||||
public static List<ZenodoCreator> toZenodoCreators(List<Creator> creators) {
|
||||
|
||||
if(creators==null)
|
||||
|
||||
if (creators == null)
|
||||
return null;
|
||||
|
||||
|
||||
List<ZenodoCreator> list = new ArrayList<ZenodoCreator>(creators.size());
|
||||
for (Creator contr : creators) {
|
||||
ZenodoCreator zc = new ZenodoCreator();
|
||||
|
@ -412,11 +407,10 @@ public class ItemToZenodoConverter {
|
|||
zc.setOrcid(contr.getOrcid());
|
||||
list.add(zc);
|
||||
}
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To service file deposition.
|
||||
*
|
||||
|
@ -424,204 +418,203 @@ public class ItemToZenodoConverter {
|
|||
* @return the file deposition
|
||||
*/
|
||||
public static FileDeposition toServiceFileDeposition(ZenodoFile zenodoFile) {
|
||||
|
||||
if(zenodoFile==null)
|
||||
|
||||
if (zenodoFile == null)
|
||||
return null;
|
||||
|
||||
|
||||
FileDeposition fileDep = new FileDeposition();
|
||||
fileDep.setId(zenodoFile.getId());
|
||||
fileDep.setFilename(zenodoFile.getFilename());
|
||||
try {
|
||||
fileDep.setFilesize(Integer.parseInt(zenodoFile.getFilesize()));
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
fileDep.setChecksum(zenodoFile.getChecksum());
|
||||
return fileDep;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update metadata info of deposition metadata.
|
||||
*
|
||||
* @param metadata the metadata
|
||||
* @param metadata the metadata
|
||||
* @param depositionMetadata the deposition metadata
|
||||
* @return the deposition metadata
|
||||
*/
|
||||
public static DepositionMetadata updateMetadataInfoOfDepositionMetadata(ZenodoMetadata metadata, DepositionMetadata depositionMetadata) {
|
||||
|
||||
//description
|
||||
public static DepositionMetadata updateMetadataInfoOfDepositionMetadata(ZenodoMetadata metadata,
|
||||
DepositionMetadata depositionMetadata) {
|
||||
|
||||
// description
|
||||
String description = metadata.getDescription();
|
||||
LOG.debug("Read description: "+description);
|
||||
if(description!=null) {
|
||||
LOG.debug("Read description: " + description);
|
||||
if (description != null) {
|
||||
depositionMetadata.setDescription(description);
|
||||
}
|
||||
|
||||
//upload type
|
||||
|
||||
// upload type
|
||||
SerializableEnum<String> uploadType = metadata.getUpload_type();
|
||||
LOG.debug("Read upload type: "+uploadType);
|
||||
if(uploadType!=null && uploadType.getSelectedValues()!=null) {
|
||||
LOG.debug("Read upload type: " + uploadType);
|
||||
if (uploadType != null && uploadType.getSelectedValues() != null) {
|
||||
String theUploadTypeValue = uploadType.getSelectedValues().get(0);
|
||||
LOG.debug("Set upload type: "+theUploadTypeValue);
|
||||
LOG.debug("Set upload type: " + theUploadTypeValue);
|
||||
depositionMetadata.setUpload_type(UploadType.valueOf(theUploadTypeValue));
|
||||
}
|
||||
|
||||
//access right
|
||||
|
||||
// access right
|
||||
SerializableEnum<String> accessRight = metadata.getAccess_right();
|
||||
LOG.debug("Read access type: "+accessRight);
|
||||
if(accessRight!=null && accessRight.getSelectedValues()!=null) {
|
||||
LOG.debug("Read access type: " + accessRight);
|
||||
if (accessRight != null && accessRight.getSelectedValues() != null) {
|
||||
try {
|
||||
String theAccessRightValue = accessRight.getSelectedValues().get(0);
|
||||
LOG.debug("Set access right: "+theAccessRightValue);
|
||||
LOG.debug("Set access right: " + theAccessRightValue);
|
||||
depositionMetadata.setAccess_right(AccessRights.valueOf(theAccessRightValue));
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Set access right error: ",e);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Set access right error: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
//publication type
|
||||
|
||||
// publication type
|
||||
SerializableEnum<String> publicationType = metadata.getPublication_type();
|
||||
LOG.debug("Read publication type: "+publicationType);
|
||||
if(publicationType!=null && publicationType.getSelectedValues()!=null) {
|
||||
LOG.debug("Read publication type: " + publicationType);
|
||||
if (publicationType != null && publicationType.getSelectedValues() != null) {
|
||||
try {
|
||||
String thePublicationTypeValue = publicationType.getSelectedValues().get(0);
|
||||
LOG.debug("Set publication type: "+thePublicationTypeValue);
|
||||
LOG.debug("Set publication type: " + thePublicationTypeValue);
|
||||
depositionMetadata.setPublication_type(PublicationType.valueOf(thePublicationTypeValue));
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Set publication type error: ",e);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Set publication type error: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
//image type
|
||||
|
||||
// image type
|
||||
SerializableEnum<String> imageType = metadata.getImage_type();
|
||||
LOG.debug("Read image type: "+imageType);
|
||||
if(imageType!=null && imageType.getSelectedValues()!=null) {
|
||||
LOG.debug("Read image type: " + imageType);
|
||||
if (imageType != null && imageType.getSelectedValues() != null) {
|
||||
try {
|
||||
String imageTypeValue = imageType.getSelectedValues().get(0);
|
||||
LOG.debug("Set image type: "+imageTypeValue);
|
||||
LOG.debug("Set image type: " + imageTypeValue);
|
||||
depositionMetadata.setImage_type(ImageType.valueOf(imageTypeValue));
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Set image type error: ",e);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Set image type error: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
//embargo_date
|
||||
|
||||
// embargo_date
|
||||
Date embargoDate = metadata.getEmbargo_date();
|
||||
LOG.debug("Read embargo date: "+imageType);
|
||||
if(embargoDate!=null) {
|
||||
LOG.debug("Read embargo date: " + imageType);
|
||||
if (embargoDate != null) {
|
||||
try {
|
||||
LOG.debug("Set embargo date: "+embargoDate);
|
||||
LOG.debug("Set embargo date: " + embargoDate);
|
||||
depositionMetadata.setEmbargo_date(embargoDate);
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Set embargo date error: ",e);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Set embargo date error: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
//access conditions
|
||||
|
||||
// access conditions
|
||||
String accessConditions = metadata.getAccess_conditions();
|
||||
LOG.debug("Read access conditions: "+accessConditions);
|
||||
if(accessConditions!=null) {
|
||||
LOG.debug("Set access conditions: "+accessConditions);
|
||||
LOG.debug("Read access conditions: " + accessConditions);
|
||||
if (accessConditions != null) {
|
||||
LOG.debug("Set access conditions: " + accessConditions);
|
||||
depositionMetadata.setAccess_conditions(accessConditions);
|
||||
}
|
||||
|
||||
//license
|
||||
|
||||
// license
|
||||
List<String> licenses = metadata.getLicenseIDs();
|
||||
LOG.debug("Read licenses: "+licenses);
|
||||
if(licenses!=null && licenses.size()>0) {
|
||||
LOG.debug("Read licenses: " + licenses);
|
||||
if (licenses != null && licenses.size() > 0) {
|
||||
try {
|
||||
String lB = licenses.get(0);
|
||||
LOG.debug("Set license: "+lB);
|
||||
LOG.debug("Set license: " + lB);
|
||||
depositionMetadata.setLicense(lB);
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Set license error: ",e);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Set license error: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
//creators
|
||||
|
||||
// creators
|
||||
List<Creator> creators = null;
|
||||
List<? extends ZenodoAuthor> zenodoCreators = metadata.getCreators();
|
||||
LOG.debug("Read Creators: "+zenodoCreators);
|
||||
if(zenodoCreators!=null) {
|
||||
LOG.debug("Read Creators: " + zenodoCreators);
|
||||
if (zenodoCreators != null) {
|
||||
creators = toCreators(zenodoCreators);
|
||||
}
|
||||
LOG.debug("Set Creators: "+creators);
|
||||
LOG.debug("Set Creators: " + creators);
|
||||
depositionMetadata.setCreators(creators);
|
||||
|
||||
//contributors
|
||||
|
||||
// contributors
|
||||
List<Contributor> contributors = null;
|
||||
List<? extends ZenodoAuthor> zenodoContributors = metadata.getContributors();
|
||||
LOG.debug("Read Contributors: "+zenodoContributors);
|
||||
if(zenodoContributors!=null) {
|
||||
LOG.debug("Read Contributors: " + zenodoContributors);
|
||||
if (zenodoContributors != null) {
|
||||
contributors = toContributors(zenodoContributors);
|
||||
}
|
||||
|
||||
if(LOG.isDebugEnabled()) {
|
||||
|
||||
if (LOG.isDebugEnabled()) {
|
||||
for (Contributor contributor : contributors) {
|
||||
LOG.debug("Set contributor: name "+contributor.getName() + " type "+contributor.getType());
|
||||
LOG.debug("Set contributor: name " + contributor.getName() + " type " + contributor.getType());
|
||||
}
|
||||
}
|
||||
depositionMetadata.setContributors(contributors);
|
||||
|
||||
//keywords
|
||||
|
||||
// keywords
|
||||
depositionMetadata.setKeywords(metadata.getKeywords());
|
||||
|
||||
|
||||
return depositionMetadata;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* To creators.
|
||||
*
|
||||
* @param zenodoCreators the zenodo creators
|
||||
* @return the list
|
||||
*/
|
||||
public static List<Creator> toCreators(List<? extends ZenodoAuthor> zenodoCreators){
|
||||
|
||||
if(zenodoCreators==null)
|
||||
public static List<Creator> toCreators(List<? extends ZenodoAuthor> zenodoCreators) {
|
||||
|
||||
if (zenodoCreators == null)
|
||||
return null;
|
||||
|
||||
|
||||
List<Creator> listOfCreators = new ArrayList<>(zenodoCreators.size());
|
||||
for (ZenodoAuthor zenodoAuthor : zenodoCreators) {
|
||||
Creator creator = new Creator();
|
||||
creator.setName(zenodoAuthor.getName());
|
||||
if(CkanToZenodoUtil.isNotEmpty(zenodoAuthor.getAffiliation())) {
|
||||
if (CkanToZenodoUtil.isNotEmpty(zenodoAuthor.getAffiliation())) {
|
||||
creator.setAffiliation(zenodoAuthor.getAffiliation());
|
||||
}
|
||||
if(CkanToZenodoUtil.isNotEmpty(zenodoAuthor.getGnd())) {
|
||||
if (CkanToZenodoUtil.isNotEmpty(zenodoAuthor.getGnd())) {
|
||||
creator.setGnd(zenodoAuthor.getGnd());
|
||||
}
|
||||
if(CkanToZenodoUtil.isNotEmpty(zenodoAuthor.getOrcid())) {
|
||||
if (CkanToZenodoUtil.isNotEmpty(zenodoAuthor.getOrcid())) {
|
||||
creator.setOrcid(zenodoAuthor.getOrcid());
|
||||
}
|
||||
listOfCreators.add(creator);
|
||||
}
|
||||
|
||||
|
||||
return listOfCreators;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To contributors.
|
||||
*
|
||||
* @param zenodoContributors the zenodo contributors
|
||||
* @return the list
|
||||
*/
|
||||
public static List<Contributor> toContributors(List<? extends ZenodoAuthor> zenodoContributors){
|
||||
|
||||
if(zenodoContributors==null)
|
||||
public static List<Contributor> toContributors(List<? extends ZenodoAuthor> zenodoContributors) {
|
||||
|
||||
if (zenodoContributors == null)
|
||||
return null;
|
||||
|
||||
|
||||
List<Contributor> listOfContributors = new ArrayList<Contributor>(zenodoContributors.size());
|
||||
for (ZenodoAuthor zenodoAuthor : zenodoContributors) {
|
||||
Contributor contributor = new Contributor();
|
||||
contributor.setName(zenodoAuthor.getName());
|
||||
if(CkanToZenodoUtil.isNotEmpty(zenodoAuthor.getAffiliation())) {
|
||||
if (CkanToZenodoUtil.isNotEmpty(zenodoAuthor.getAffiliation())) {
|
||||
contributor.setAffiliation(zenodoAuthor.getAffiliation());
|
||||
}
|
||||
if(CkanToZenodoUtil.isNotEmpty(zenodoAuthor.getGnd())) {
|
||||
if (CkanToZenodoUtil.isNotEmpty(zenodoAuthor.getGnd())) {
|
||||
contributor.setGnd(zenodoAuthor.getGnd());
|
||||
}
|
||||
if(CkanToZenodoUtil.isNotEmpty(zenodoAuthor.getOrcid())) {
|
||||
if (CkanToZenodoUtil.isNotEmpty(zenodoAuthor.getOrcid())) {
|
||||
contributor.setOrcid(zenodoAuthor.getOrcid());
|
||||
}
|
||||
Type type = null;
|
||||
|
@ -629,16 +622,14 @@ public class ItemToZenodoConverter {
|
|||
try {
|
||||
theType = zenodoAuthor.getType().getSelectedValues().get(0);
|
||||
type = Type.valueOf(theType);
|
||||
}catch (Exception e) {
|
||||
LOG.error("I'm not able to convert "+theType + " as value of "+Type.class.getName());
|
||||
} catch (Exception e) {
|
||||
LOG.error("I'm not able to convert " + theType + " as value of " + Type.class.getName());
|
||||
}
|
||||
contributor.setType(type);
|
||||
listOfContributors.add(contributor);
|
||||
}
|
||||
|
||||
|
||||
return listOfContributors;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue