use of org.orcid.jaxb.model.message.OrcidActivities 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.OrcidActivities in project ORCID-Source by ORCID.
the class T2OrcidApiServiceVersionedDelegatorTest method addAffiliationTest.
@Test
public void addAffiliationTest() {
setUpSecurityContext();
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4441"));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
Affiliation affiliation = new Affiliation();
affiliation.setStartDate(new FuzzyDate(2010, 01, 01));
affiliation.setEndDate(new FuzzyDate(2015, 01, 01));
affiliation.setDepartmentName("Dep Name");
affiliation.setRoleTitle("Role Title");
affiliation.setType(AffiliationType.EDUCATION);
Organization organization = new Organization();
organization.setName("My Org");
OrganizationAddress add = new OrganizationAddress();
add.setCity("My City");
add.setCountry(Iso3166Country.US);
organization.setAddress(add);
affiliation.setOrganization(organization);
affiliations.getAffiliation().add(affiliation);
orcidActivities.setAffiliations(affiliations);
Response response = t2OrcidApiServiceDelegatorLatest.addAffiliations(mockedUriInfo, "4444-4444-4444-4441", orcidMessage);
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
assertEquals(1, orgAffiliationRelationDao.getByUserAndType("4444-4444-4444-4441", org.orcid.jaxb.model.record_v2.AffiliationType.EDUCATION).size());
}
use of org.orcid.jaxb.model.message.OrcidActivities in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testAddWorks.
@Test
public void testAddWorks() {
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-4441"));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
OrcidWorks orcidWorks = new OrcidWorks();
orcidActivities.setOrcidWorks(orcidWorks);
Response response = t2OrcidApiServiceDelegator.addWorks(mockedUriInfo, "4444-4444-4444-4441", orcidMessage);
assertNotNull(response);
assertEquals(201, response.getStatus());
}
use of org.orcid.jaxb.model.message.OrcidActivities in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testAddAffiliationToDeprecatedAccount.
@Test(expected = OrcidDeprecatedException.class)
public void testAddAffiliationToDeprecatedAccount() {
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);
OrganizationAddress address = new OrganizationAddress();
address.setCity("City");
address.setCountry(Iso3166Country.US);
Organization org = new Organization();
org.setAddress(address);
org.setName("Testing org name");
Affiliations affiliations = new Affiliations();
Affiliation affiliation = new Affiliation();
affiliation.setDepartmentName("Dept name");
affiliation.setOrganization(org);
affiliation.setType(AffiliationType.EMPLOYMENT);
affiliations.getAffiliation().add(affiliation);
orcidActivities.setAffiliations(affiliations);
t2OrcidApiServiceDelegator.addAffiliations(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
use of org.orcid.jaxb.model.message.OrcidActivities in project ORCID-Source by ORCID.
the class T2OrcidApiServiceDelegatorTest method testUpdateExistingNonPrivateAffiliation.
@Test
@Transactional
public void testUpdateExistingNonPrivateAffiliation() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.AFFILIATIONS_UPDATE);
OrcidMessage orcidMessage = new OrcidMessage();
orcidMessage.setMessageVersion("1.2_rc6");
OrcidProfile orcidProfile = new OrcidProfile();
orcidMessage.setOrcidProfile(orcidProfile);
orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4443"));
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
orcidActivities.setAffiliations(affiliations);
Affiliation affiliation1 = new Affiliation();
affiliations.getAffiliation().add(affiliation1);
affiliation1.setPutCode("3");
affiliation1.setType(AffiliationType.EDUCATION);
Organization organization1 = new Organization();
affiliation1.setOrganization(organization1);
organization1.setName("Different org");
OrganizationAddress organizationAddress = new OrganizationAddress();
organization1.setAddress(organizationAddress);
organizationAddress.setCity("Edinburgh");
organizationAddress.setCountry(Iso3166Country.GB);
Response response = t2OrcidApiServiceDelegator.updateAffiliations(mockedUriInfo, "4444-4444-4444-4443", orcidMessage);
assertNotNull(response);
OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4443");
List<Affiliation> retreivedAffiliationsList = retrievedProfile.getOrcidActivities().getAffiliations().getAffiliation();
assertEquals(3, retreivedAffiliationsList.size());
Affiliation updatedAffiliation = retreivedAffiliationsList.get(0);
assertEquals("Different org", updatedAffiliation.getOrganization().getName());
assertEquals("APP-5555555555555555", updatedAffiliation.getSource().retrieveSourcePath());
Affiliation existingAffiliation = retreivedAffiliationsList.get(1);
assertEquals(Visibility.PRIVATE, existingAffiliation.getVisibility());
assertEquals("Eine Institution", existingAffiliation.getOrganization().getName());
}
Aggregations