use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testCheckWorkExternalIdentifiersAreNotDuplicated3.
@Test
@Transactional
public void testCheckWorkExternalIdentifiersAreNotDuplicated3() {
List<OrcidWork> newOrcidWorksList = new ArrayList<OrcidWork>();
List<OrcidWork> existingWorkList = new ArrayList<OrcidWork>();
OrcidWork newWork1 = getOrcidWork("work1", false);
OrcidWork newWork2 = getOrcidWork("work2", false);
OrcidWork newWork3 = getOrcidWork("work3", false);
OrcidWork newWork3_fixed = getOrcidWork("work3", false);
WorkTitle updatedTitle = new WorkTitle();
updatedTitle.setTitle(new Title("updated title"));
newWork3_fixed.setWorkTitle(updatedTitle);
//Check #3: Check duplicates in new works
newOrcidWorksList.add(newWork1);
newOrcidWorksList.add(newWork2);
newOrcidWorksList.add(newWork3);
newOrcidWorksList.add(newWork3_fixed);
try {
orcidProfileManager.checkWorkExternalIdentifiersAreNotDuplicated(newOrcidWorksList, existingWorkList);
fail();
} catch (IllegalArgumentException iae) {
assertEquals("Works \"Title for work3->updated\" and \"updated title\" have the same external id \"doi-work3\"", iae.getMessage());
}
}
use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.
the class Api12Helper method addWork.
protected static void addWork(String userOrcid, String token, String title, T2OAuthAPIService<ClientResponse> oauthT2Client) {
String id = String.valueOf(System.currentTimeMillis());
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
OrcidWorks orcidWorks = new OrcidWorks();
orcidActivities.setOrcidWorks(orcidWorks);
OrcidWork orcidWork = new OrcidWork();
orcidWorks.getOrcidWork().add(orcidWork);
orcidWork.setWorkType(WorkType.JOURNAL_ARTICLE);
orcidWork.setVisibility(Visibility.LIMITED);
WorkTitle workTitle = new WorkTitle();
orcidWork.setWorkTitle(workTitle);
WorkExternalIdentifier wei = new WorkExternalIdentifier();
wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId(id));
wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
WorkExternalIdentifiers extIds = new WorkExternalIdentifiers();
extIds.getWorkExternalIdentifier().add(wei);
orcidWork.setWorkExternalIdentifiers(extIds);
workTitle.setTitle(new Title(title));
ClientResponse clientResponse = oauthT2Client.addWorksXml(userOrcid, orcidMessage, token);
assertEquals(201, clientResponse.getStatus());
}
use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.
the class Jaxb2JpaAdapterImpl method getWorkEntity.
public WorkEntity getWorkEntity(OrcidWork orcidWork, WorkEntity workEntity) {
if (orcidWork != null) {
if (workEntity == null) {
String putCode = orcidWork.getPutCode();
if (StringUtils.isNotBlank(putCode) && !"-1".equals(putCode)) {
throw new IllegalArgumentException("Invalid put-code was supplied: " + putCode);
}
workEntity = new WorkEntity();
} else {
workEntity.clean();
}
Citation workCitation = orcidWork.getWorkCitation();
if (workCitation != null && StringUtils.isNotBlank(workCitation.getCitation()) && workCitation.getWorkCitationType() != null) {
workEntity.setCitation(workCitation.getCitation());
workEntity.setCitationType(CitationType.fromValue(workCitation.getWorkCitationType().value()));
}
// New way of doing work contributors
workEntity.setContributorsJson(getWorkContributorsJson(orcidWork.getWorkContributors()));
workEntity.setDescription(orcidWork.getShortDescription() != null ? orcidWork.getShortDescription() : null);
// New way of doing work external ids
workEntity.setExternalIdentifiersJson(getWorkExternalIdsJson(orcidWork));
workEntity.setPublicationDate(getWorkPublicationDate(orcidWork));
WorkTitle workTitle = orcidWork.getWorkTitle();
if (workTitle != null) {
workEntity.setSubtitle(workTitle.getSubtitle() != null ? workTitle.getSubtitle().getContent() : null);
workEntity.setTitle(workTitle.getTitle() != null ? workTitle.getTitle().getContent().trim() : null);
TranslatedTitle translatedTitle = workTitle.getTranslatedTitle();
if (translatedTitle != null) {
workEntity.setTranslatedTitle(StringUtils.isEmpty(translatedTitle.getContent()) ? null : translatedTitle.getContent());
workEntity.setTranslatedTitleLanguageCode(StringUtils.isEmpty(translatedTitle.getLanguageCode()) ? null : translatedTitle.getLanguageCode());
}
}
workEntity.setJournalTitle(orcidWork.getJournalTitle() != null ? orcidWork.getJournalTitle().getContent() : null);
workEntity.setLanguageCode(orcidWork.getLanguageCode() != null ? orcidWork.getLanguageCode() : null);
if (orcidWork.getCountry() != null && orcidWork.getCountry().getValue() != null) {
workEntity.setIso2Country(org.orcid.jaxb.model.common_v2.Iso3166Country.fromValue(orcidWork.getCountry().getValue().value()));
}
workEntity.setWorkUrl(orcidWork.getUrl() != null ? orcidWork.getUrl().getValue() : null);
if (orcidWork.getWorkType() != null) {
workEntity.setWorkType(org.orcid.jaxb.model.record_v2.WorkType.fromValue(orcidWork.getWorkType().value()));
}
if (orcidWork.getVisibility() != null) {
workEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(orcidWork.getVisibility().value()));
} else {
workEntity.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE);
}
workEntity.setAddedToProfileDate(new Date());
//Set source
setSource(orcidWork.getSource(), workEntity);
if (workEntity.getDisplayIndex() == null) {
workEntity.setDisplayIndex(0L);
}
return workEntity;
}
return null;
}
use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method getStandardOrcid.
private OrcidProfile getStandardOrcid() {
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setOrcidIdentifier("1234");
OrcidBio orcidBio = new OrcidBio();
ContactDetails contactDetails = new ContactDetails();
Email email = new Email("email");
email.setVisibility(Visibility.PUBLIC);
contactDetails.addOrReplacePrimaryEmail(email);
orcidBio.setContactDetails(contactDetails);
Keywords bioKeywords = new Keywords();
bioKeywords.getKeyword().add(new Keyword("Pavement Studies", Visibility.PUBLIC));
bioKeywords.getKeyword().add(new Keyword("Advanced Tea Making", Visibility.PUBLIC));
bioKeywords.setVisibility(Visibility.PUBLIC);
orcidBio.setKeywords(bioKeywords);
PersonalDetails personalDetails = new PersonalDetails();
CreditName creditName = new CreditName("credit name");
creditName.setVisibility(Visibility.PUBLIC);
personalDetails.setCreditName(creditName);
FamilyName familyName = new FamilyName("familyName");
familyName.setVisibility(Visibility.PUBLIC);
personalDetails.setFamilyName(familyName);
OtherNames otherNames = new OtherNames();
otherNames.setVisibility(Visibility.PUBLIC);
otherNames.getOtherName().add(new OtherName("Other 1", Visibility.PUBLIC));
otherNames.getOtherName().add(new OtherName("Other 2", Visibility.PUBLIC));
personalDetails.setOtherNames(otherNames);
GivenNames givenNames = new GivenNames("givenNames");
givenNames.setVisibility(Visibility.PUBLIC);
personalDetails.setGivenNames(givenNames);
orcidBio.setPersonalDetails(personalDetails);
ExternalIdentifiers externalIdentifiers = new ExternalIdentifiers();
externalIdentifiers.setVisibility(Visibility.PUBLIC);
orcidBio.setExternalIdentifiers(externalIdentifiers);
ExternalIdentifier externalIdentifier1 = createExternalIdentifier("45678", "defghi");
externalIdentifiers.getExternalIdentifier().add(externalIdentifier1);
ExternalIdentifier externalIdentifier2 = createExternalIdentifier("54321", "abc123");
externalIdentifiers.getExternalIdentifier().add(externalIdentifier2);
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
orcidActivities.setAffiliations(affiliations);
FundingList fundings = new FundingList();
orcidActivities.setFundings(fundings);
OrcidWorks orcidWorks = new OrcidWorks();
OrcidWork orcidWork1 = new OrcidWork();
orcidWork1.setVisibility(Visibility.PUBLIC);
OrcidWork orcidWork2 = new OrcidWork();
orcidWork2.setVisibility(Visibility.PUBLIC);
OrcidWork orcidWork3 = new OrcidWork();
orcidWork3.setVisibility(Visibility.LIMITED);
WorkTitle workTitle1 = new WorkTitle();
Title title1 = new Title("Work title 1");
workTitle1.setTitle(title1);
workTitle1.setSubtitle(null);
orcidWork1.setWorkTitle(workTitle1);
WorkExternalIdentifier wei = new WorkExternalIdentifier();
wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work1-pmid"));
wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.PMID);
orcidWork1.setWorkExternalIdentifiers(new WorkExternalIdentifiers(Arrays.asList(wei)));
WorkTitle workTitle2 = new WorkTitle();
Title title2 = new Title("Work title 2");
workTitle2.setSubtitle(null);
workTitle2.setTitle(title2);
orcidWork2.setWorkTitle(workTitle2);
WorkTitle workTitle3 = new WorkTitle();
Title title3 = new Title("Work Title 3");
workTitle3.setSubtitle(null);
workTitle3.setTitle(title3);
orcidWork3.setWorkTitle(workTitle3);
orcidWorks.setOrcidWork(new ArrayList<OrcidWork>(Arrays.asList(new OrcidWork[] { orcidWork1, orcidWork2, orcidWork3 })));
orcidProfile.setOrcidWorks(orcidWorks);
orcidProfile.setOrcidBio(orcidBio);
return orcidProfile;
}
use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAddOrcidWorksWhenDefaultVisibilityIsPublic.
@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorksWhenDefaultVisibilityIsPublic() {
OrcidProfile profile1 = createBasicProfile();
OrcidHistory history = new OrcidHistory();
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile1.setOrcidHistory(history);
history.setClaimed(new Claimed(true));
profile1.getOrcidInternal().getPreferences().setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.PUBLIC));
orcidProfileManager.createOrcidProfile(profile1, false, false);
OrcidProfile profile2 = new OrcidProfile();
profile2.setOrcidIdentifier(TEST_ORCID);
OrcidWorks orcidWorks = new OrcidWorks();
profile2.setOrcidWorks(orcidWorks);
WorkTitle workTitle1 = new WorkTitle();
workTitle1.setTitle(new Title("Another Title"));
workTitle1.setSubtitle(new Subtitle("Journal of Cloud Spotting"));
OrcidWork work1 = createWork1(workTitle1);
Source source = new Source(TEST_ORCID);
work1.setSource(source);
orcidWorks.getOrcidWork().add(work1);
WorkTitle workTitle2 = new WorkTitle();
workTitle2.setTitle(new Title("New Title"));
workTitle2.setSubtitle(new Subtitle("Another New subtitle"));
OrcidWork work2 = createWork2(workTitle2);
orcidWorks.getOrcidWork().add(work2);
// Try to add a duplicate
WorkTitle workTitle3 = new WorkTitle();
workTitle3.setTitle(new Title("Further Title"));
workTitle3.setSubtitle(new Subtitle("Further subtitle"));
OrcidWork work3 = createWork3(workTitle3);
work3.setVisibility(Visibility.LIMITED);
orcidWorks.getOrcidWork().add(work3);
orcidProfileManager.addOrcidWorks(profile2);
OrcidProfile resultProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertEquals("Will", resultProfile.getOrcidBio().getPersonalDetails().getGivenNames().getContent());
List<OrcidWork> works = resultProfile.retrieveOrcidWorks().getOrcidWork();
assertEquals(4, works.size());
assertEquals("Another Title", works.get(0).getWorkTitle().getTitle().getContent());
assertEquals("Journal of Cloud Spotting", works.get(0).getWorkTitle().getSubtitle().getContent());
for (OrcidWork work : works) {
if ("Test Title".equals(work.getWorkTitle().getTitle().getContent()))
assertEquals(Visibility.PRIVATE, work.getVisibility());
else
assertEquals(Visibility.PUBLIC, work.getVisibility());
}
}
Aggregations