use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testAddWorkToDeprecatedAccount.
@Test(expected = OrcidDeprecatedException.class)
public void testAddWorkToDeprecatedAccount() {
SecurityContextTestUtils.setUpSecurityContext();
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-444X"));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
OrcidWork work = new OrcidWork();
WorkTitle title = new WorkTitle();
title.setTitle(new Title("Title"));
work.setWorkTitle(title);
WorkExternalIdentifiers weis = new WorkExternalIdentifiers();
WorkExternalIdentifier wei = new WorkExternalIdentifier();
wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("00000001"));
wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
weis.getWorkExternalIdentifier().add(wei);
work.setWorkExternalIdentifiers(weis);
OrcidWorks orcidWorks = new OrcidWorks();
orcidActivities.setOrcidWorks(orcidWorks);
t2OrcidApiServiceDelegator.addWorks(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testUpdateWithNewWork.
@Test
@Transactional
public void testUpdateWithNewWork() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.ORCID_WORKS_UPDATE);
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4446"));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
OrcidWorks orcidWorks = new OrcidWorks();
orcidActivities.setOrcidWorks(orcidWorks);
OrcidWork orcidWork = new OrcidWork();
orcidWorks.getOrcidWork().add(orcidWork);
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("Added by works update"));
orcidWork.setWorkTitle(workTitle);
orcidWork.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
WorkExternalIdentifier wei = new WorkExternalIdentifier();
wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("abc123"));
workExternalIdentifiers.getWorkExternalIdentifier().add(wei);
orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
Response response = t2OrcidApiServiceDelegator.updateWorks(mockedUriInfo, "4444-4444-4444-4446", orcidMessage);
assertNotNull(response);
OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4446");
List<OrcidWork> retreivedWorksList = retrievedProfile.getOrcidActivities().getOrcidWorks().getOrcidWork();
boolean foundWorkFromAnotherSource = false;
boolean foundExisting = false;
boolean foundNew = false;
boolean foundExistingPrivate = false;
// another source
for (OrcidWork retrievedWork : retreivedWorksList) {
if ("6".equals(retrievedWork.getPutCode())) {
assertEquals("Journal article B", retrievedWork.getWorkTitle().getTitle().getContent());
assertEquals(Visibility.LIMITED, retrievedWork.getVisibility());
foundWorkFromAnotherSource = true;
} else if ("7".equals(retrievedWork.getPutCode())) {
// Existing private work
assertEquals("Journal article C", retrievedWork.getWorkTitle().getTitle().getContent());
assertEquals(Visibility.PRIVATE, retrievedWork.getVisibility());
foundExisting = true;
} else if ("8".equals(retrievedWork.getPutCode())) {
// Existing private work added by the user
assertEquals("Journal article D", retrievedWork.getWorkTitle().getTitle().getContent());
assertEquals(Visibility.PRIVATE, retrievedWork.getVisibility());
foundExistingPrivate = true;
} else {
// The added work
assertEquals("Added by works update", retrievedWork.getWorkTitle().getTitle().getContent());
foundNew = true;
}
}
assertTrue("Work from other source should be there", foundWorkFromAnotherSource);
assertTrue("New work should be there", foundNew);
assertTrue("Existing private work should be there", foundExisting);
assertTrue("Existing private work added by the user should be there", foundExistingPrivate);
assertEquals(4, retreivedWorksList.size());
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testUpdateWorkWhenNotSource.
@Test(expected = WrongSourceException.class)
@Transactional
public void testUpdateWorkWhenNotSource() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.ORCID_WORKS_UPDATE);
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4446"));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
OrcidWorks orcidWorks = new OrcidWorks();
orcidActivities.setOrcidWorks(orcidWorks);
OrcidWork orcidWork = new OrcidWork();
orcidWorks.getOrcidWork().add(orcidWork);
orcidWork.setPutCode("6");
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("Updated by works update"));
orcidWork.setWorkTitle(workTitle);
orcidWork.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
WorkExternalIdentifier wei = new WorkExternalIdentifier();
wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("abc123"));
workExternalIdentifiers.getWorkExternalIdentifier().add(wei);
orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
t2OrcidApiServiceDelegator.updateWorks(mockedUriInfo, "4444-4444-4444-4446", orcidMessage);
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class FindOrcidWorkDuplicates method deriveOrcidData.
private StringBuffer deriveOrcidData(String orcid, boolean definitive, List<OrcidWork> orcidWorks) {
StringBuffer duplicationString = new StringBuffer();
String definitiveIdentifier = definitive ? "Definitive" : "Duplicate";
for (OrcidWork duplicate : orcidWorks) {
String putCode = duplicate.getPutCode();
String title = duplicate.getWorkTitle() != null && duplicate.getWorkTitle().getTitle() != null && StringUtils.isNotBlank(duplicate.getWorkTitle().getTitle().getContent()) ? duplicate.getWorkTitle().getTitle().getContent() : MISSING_ENTRY;
String visibility = duplicate.getVisibility() != null ? duplicate.getVisibility().value() : MISSING_ENTRY;
duplicationString.append(orcid).append(SEPERATOR);
duplicationString.append(definitiveIdentifier).append(SEPERATOR);
duplicationString.append(putCode).append(SEPERATOR);
duplicationString.append(title).append(SEPERATOR);
duplicationString.append(visibility).append(SEPERATOR);
duplicationString.append(NEW_LINE);
}
return duplicationString;
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class FindOrcidWorkDuplicates method splitWorksIntoDuplicateSets.
private Map<OrcidWorkMatcher, List<OrcidWork>> splitWorksIntoDuplicateSets(OrcidWorks orcidWorks) {
// do any works match, bar the put code and visibility
Map<OrcidWorkMatcher, List<OrcidWork>> orcidWorksAsDupes = new HashMap<OrcidWorkMatcher, List<OrcidWork>>();
// for each work associated with a profile
for (OrcidWork orcidWork : orcidWorks.getOrcidWork()) {
OrcidWorkMatcher orcidMatcherKey = new OrcidWorkMatcher(orcidWork);
// does anything exist in the map for that key
if (orcidWorksAsDupes.containsKey(orcidMatcherKey)) {
// if so get the map and add
List<OrcidWork> existingDupesForWork = orcidWorksAsDupes.get(orcidMatcherKey);
existingDupesForWork.add(orcidWork);
orcidWorksAsDupes.put(orcidMatcherKey, existingDupesForWork);
} else {
// if not build a new list - may be adding duplicates for this work
List<OrcidWork> orcidWorksForKey = new ArrayList<OrcidWork>();
orcidWorksForKey.add(orcidWork);
orcidWorksAsDupes.put(orcidMatcherKey, orcidWorksForKey);
}
}
return orcidWorksAsDupes;
}
Aggregations