use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method getWorkInsideOrcidProfile.
private OrcidProfile getWorkInsideOrcidProfile(String defaultTitle, String orcid) {
OrcidWork orcidWork = new OrcidWork();
// Set title
WorkTitle title = new WorkTitle();
if (defaultTitle != null)
title.setTitle(new Title(defaultTitle));
else
title.setTitle(new Title("Title"));
orcidWork.setWorkTitle(title);
// Set external identifiers
WorkExternalIdentifier extId1 = new WorkExternalIdentifier();
extId1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("doi-" + defaultTitle));
extId1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
WorkExternalIdentifier extId2 = new WorkExternalIdentifier();
if (defaultTitle != null)
extId2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("issn-" + defaultTitle));
else
extId2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("issn-" + System.currentTimeMillis()));
extId2.setWorkExternalIdentifierType(WorkExternalIdentifierType.ISSN);
WorkExternalIdentifiers extIds = new WorkExternalIdentifiers();
extIds.getWorkExternalIdentifier().add(extId1);
extIds.getWorkExternalIdentifier().add(extId2);
orcidWork.setWorkExternalIdentifiers(extIds);
orcidWork.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
OrcidProfile profile = new OrcidProfile();
profile.setOrcidIdentifier(orcid);
List<OrcidWork> workList = new ArrayList<OrcidWork>();
workList.add(orcidWork);
OrcidWorks orcidWorks = new OrcidWorks();
orcidWorks.setOrcidWork(workList);
profile.setOrcidWorks(orcidWorks);
return profile;
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testCheckWorkExternalIdentifiersAreNotDuplicated2.
@Test
@Transactional
public void testCheckWorkExternalIdentifiersAreNotDuplicated2() {
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 existingWork3 = getOrcidWork("work3", true);
OrcidWork existingWork4 = getOrcidWork("work4", true);
OrcidWork existingWork5 = getOrcidWork("work5", true);
// Check duplicates in new works and existing works
newOrcidWorksList.add(newWork1);
newOrcidWorksList.add(newWork2);
existingWorkList.add(existingWork4);
existingWorkList.add(existingWork5);
newOrcidWorksList.add(newWork3);
existingWorkList.add(existingWork3);
try {
orcidProfileManager.checkWorkExternalIdentifiersAreNotDuplicated(newOrcidWorksList, existingWorkList);
fail();
} catch (IllegalArgumentException iae) {
assertEquals("Works \"Title for work3->updated\" and \"Title for work3\"(put-code '" + existingWork3.getPutCode() + "') have the same external id \"doi-work3\"", iae.getMessage());
}
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl_NonTransactionalTest method testCreateRecordWithClient1AddTryToAddADuplicate.
@Test(expected = IllegalArgumentException.class)
public void testCreateRecordWithClient1AddTryToAddADuplicate() {
OrcidProfile profile1 = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertEquals(1, profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().size());
OrcidWork dupWork = createWork1();
dupWork.getWorkTitle().getTitle().setContent("Updated title");
profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().add(dupWork);
orcidProfileManager.addOrcidWorks(profile1);
fail();
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl_NonTransactionalTest method testCreateRecordWithClient1AddDuplicateWithClient2.
@Test
public void testCreateRecordWithClient1AddDuplicateWithClient2() {
OrcidProfile profile1 = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertEquals(1, profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().size());
assertEquals(CLIENT_1, profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getSource().retrieveSourcePath());
String work1PutCode = profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getPutCode();
// Change the source entity
TargetProxyHelper.injectIntoProxy(jaxb2JpaAdapter, "sourceManager", anotherMockSourceManager);
TargetProxyHelper.injectIntoProxy(orcidProfileManager, "sourceManager", anotherMockSourceManager);
OrcidWork dupWork = createWork1();
profile1 = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().clear();
profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().add(dupWork);
orcidProfileManager.addOrcidWorks(profile1);
OrcidProfile profileWithWork1FromTwoDifferentSources = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
assertEquals(2, profileWithWork1FromTwoDifferentSources.getOrcidActivities().getOrcidWorks().getOrcidWork().size());
profileWithWork1FromTwoDifferentSources.getOrcidActivities().getOrcidWorks().getOrcidWork().forEach(work -> {
if (work.getPutCode().equals(work1PutCode)) {
assertEquals(CLIENT_1, work.retrieveSourcePath());
} else {
assertEquals(CLIENT_2, work.retrieveSourcePath());
}
});
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl_NonTransactionalTest method addDataToTestRecord.
private void addDataToTestRecord() {
OrcidProfile profile1 = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
OrcidWork work1 = createWork1();
profile1.setOrcidActivities(new OrcidActivities());
profile1.getOrcidActivities().setOrcidWorks(new OrcidWorks());
profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work1);
orcidProfileManager.updateOrcidProfile(profile1);
}
Aggregations