use of org.orcid.jaxb.model.message.WorkContributors in project ORCID-Source by ORCID.
the class JpaJaxbEntityAdapterToOrcidProfileTest method checkOrcidWorks.
private void checkOrcidWorks(OrcidWorks orcidWorks) {
assertNotNull(orcidWorks);
List<OrcidWork> orcidWorkList = orcidWorks.getOrcidWork();
assertEquals(3, orcidWorkList.size());
boolean putCode1Found = false;
boolean putCode4Found = false;
for (OrcidWork orcidWork : orcidWorkList) {
if (orcidWork.getPutCode().equals("1")) {
putCode1Found = true;
assertEquals("1", orcidWork.getPutCode());
Citation workCitation = orcidWork.getWorkCitation();
assertNotNull(workCitation);
assertEquals("Bobby Ewing, ", workCitation.getCitation());
assertEquals(CitationType.FORMATTED_IEEE, workCitation.getWorkCitationType());
WorkContributors contributors = orcidWork.getWorkContributors();
assertNotNull(contributors);
assertEquals(2, contributors.getContributor().size());
assertEquals("Jaylen Kessler", contributors.getContributor().get(0).getCreditName().getContent());
assertEquals(Visibility.PUBLIC, contributors.getContributor().get(0).getCreditName().getVisibility());
assertEquals(Visibility.PUBLIC, orcidWork.getVisibility());
assertNull(orcidWork.getJournalTitle());
} else if (orcidWork.getPutCode().equals("3")) {
WorkContributors contributors = orcidWork.getWorkContributors();
assertNotNull(contributors);
assertEquals(1, contributors.getContributor().size());
assertEquals("0000-0003-0172-7925", contributors.getContributor().get(0).getContributorOrcid().getPath());
} else if (orcidWork.getPutCode().equals("4")) {
putCode4Found = true;
assertNotNull(orcidWork.getWorkTitle());
assertNotNull(orcidWork.getWorkTitle().getTitle());
assertEquals("A book with a Journal Title", orcidWork.getWorkTitle().getTitle().getContent());
assertNotNull(orcidWork.getJournalTitle());
assertEquals("My Journal Title", orcidWork.getJournalTitle().getContent());
assertNotNull(orcidWork.getPublicationDate());
assertNotNull(orcidWork.getPublicationDate().getDay());
assertNotNull(orcidWork.getPublicationDate().getMonth());
assertNotNull(orcidWork.getPublicationDate().getYear());
assertEquals("01", orcidWork.getPublicationDate().getDay().getValue());
assertEquals("02", orcidWork.getPublicationDate().getMonth().getValue());
assertEquals("2011", orcidWork.getPublicationDate().getYear().getValue());
assertNotNull(orcidWork.getWorkCitation());
assertEquals("Sue Ellen ewing", orcidWork.getWorkCitation().getCitation());
assertEquals(CitationType.FORMATTED_IEEE, orcidWork.getWorkCitation().getWorkCitationType());
assertNotNull(orcidWork.getWorkType());
assertEquals(WorkType.BOOK, orcidWork.getWorkType());
}
}
assertTrue(putCode1Found);
assertTrue(putCode4Found);
}
use of org.orcid.jaxb.model.message.WorkContributors in project ORCID-Source by ORCID.
the class JsonUtilsTest method testJsonStringToWorkContributors.
@Test
public void testJsonStringToWorkContributors() {
String jsonString = "{\"contributor\":[{\"contributorOrcid\":null,\"creditName\":{\"content\":\"A Contributor\",\"visibility\":null},\"contributorEmail\":null,\"contributorAttributes\":null}]}";
WorkContributors workContributors = JsonUtils.<WorkContributors>readObjectFromJsonString(jsonString, WorkContributors.class);
assertEquals(1, workContributors.getContributor().size());
assertEquals("A Contributor", workContributors.getContributor().get(0).getCreditName().getContent());
}
use of org.orcid.jaxb.model.message.WorkContributors in project ORCID-Source by ORCID.
the class Publication method getOrcidWork.
public OrcidWork getOrcidWork() {
initCrossRefContext();
OrcidWork orcidWork = new OrcidWork();
if (StringUtils.isNotBlank(doi)) {
WorkExternalIdentifier doiExtId = new WorkExternalIdentifier();
doiExtId.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
doiExtId.setWorkExternalIdentifierId(new WorkExternalIdentifierId(doi));
WorkExternalIdentifiers workExtIds = new WorkExternalIdentifiers();
orcidWork.setWorkExternalIdentifiers(workExtIds);
workExtIds.getWorkExternalIdentifier().add(doiExtId);
}
if (StringUtils.isNotBlank(title)) {
WorkTitle workTitle = new WorkTitle();
orcidWork.setWorkTitle(workTitle);
workTitle.setTitle(new Title(title));
}
// Will throw an IllegalArgumentException if not valid
CitationType cType = CitationType.fromValue(citationType);
Citation citation = new Citation(fullCitation, cType);
orcidWork.setWorkCitation(citation);
String publicationDateString = crossRefContext.getDate();
if (StringUtils.isNotBlank(publicationDateString)) {
XMLGregorianCalendar publicationDateGregCal = DateUtils.convertToXMLGregorianCalendar(publicationDateString);
if (publicationDateGregCal != null) {
Year publicationyear = new Year(publicationDateGregCal.getYear());
Month publicationMonth = publicationDateGregCal.getMonth() == DatatypeConstants.FIELD_UNDEFINED ? null : new Month(publicationDateGregCal.getMonth());
Day publicationDay = publicationDateGregCal.getDay() == DatatypeConstants.FIELD_UNDEFINED ? null : new Day(publicationDateGregCal.getDay());
orcidWork.setPublicationDate(new PublicationDate(publicationyear, publicationMonth, publicationDay));
}
}
String author = crossRefContext.getAuthor();
if (StringUtils.isNotBlank(author)) {
WorkContributors workContributors = new WorkContributors();
orcidWork.setWorkContributors(workContributors);
Contributor contributor = new Contributor();
workContributors.getContributor().add(contributor);
contributor.setCreditName(new CreditName(author));
ContributorAttributes contributorAttributes = new ContributorAttributes();
contributor.setContributorAttributes(contributorAttributes);
contributorAttributes.setContributorRole(ContributorRole.AUTHOR);
contributorAttributes.setContributorSequence(SequenceType.FIRST);
}
return orcidWork;
}
use of org.orcid.jaxb.model.message.WorkContributors in project ORCID-Source by ORCID.
the class JsonUtilsTest method testWorkContributorsToJsonString.
@Test
public void testWorkContributorsToJsonString() {
WorkContributors workContributors = new WorkContributors();
Contributor contributor1 = new Contributor();
workContributors.getContributor().add(contributor1);
contributor1.setCreditName(new CreditName("A Contributor"));
String result = JsonUtils.convertToJsonString(workContributors);
assertEquals("{\"contributor\":[{\"contributorOrcid\":null,\"creditName\":{\"content\":\"A Contributor\",\"visibility\":null},\"contributorEmail\":null,\"contributorAttributes\":null}]}", result);
}
use of org.orcid.jaxb.model.message.WorkContributors in project ORCID-Source by ORCID.
the class CheckAndFixContributorNameVisibility method processOrcid.
private void processOrcid(final String orcid) {
LOG.info("Checking and fixing profile: {}", orcid);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
OrcidProfile orcidProfile = orcidProfileManager.retrieveOrcidProfile(orcid);
OrcidWorks orcidWorks = orcidProfile.retrieveOrcidWorks();
if (orcidWorks != null) {
for (OrcidWork orcidWork : orcidWorks.getOrcidWork()) {
WorkContributors workContributors = orcidWork.getWorkContributors();
if (workContributors != null) {
for (Contributor contributor : workContributors.getContributor()) {
ContributorOrcid contributorOrcid = contributor.getContributorOrcid();
if (contributorOrcid != null) {
String orcid = contributorOrcid.getPath();
ProfileEntity contributorProfile = profileDao.find(orcid);
if (contributorProfile.getRecordNameEntity() != null && contributorProfile.getRecordNameEntity().getVisibility() != null) {
if (!Visibility.PUBLIC.value().equals(contributorProfile.getRecordNameEntity().getVisibility().value())) {
contributor.setCreditName(null);
}
}
}
}
}
}
}
orcidProfileManager.updateOrcidProfile(orcidProfile);
}
});
}
Aggregations