Search in sources :

Example 11 with OrganizationAddress

use of org.orcid.jaxb.model.message.OrganizationAddress 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);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Organization(org.orcid.jaxb.model.message.Organization) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 12 with OrganizationAddress

use of org.orcid.jaxb.model.message.OrganizationAddress 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());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Response(javax.ws.rs.core.Response) Organization(org.orcid.jaxb.model.message.Organization) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Affiliation(org.orcid.jaxb.model.message.Affiliation) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with OrganizationAddress

use of org.orcid.jaxb.model.message.OrganizationAddress in project ORCID-Source by ORCID.

the class Api12Helper method addAffiliation.

protected static void addAffiliation(String userOrcid, String token, String orgName, T2OAuthAPIService<ClientResponse> oauthT2Client) {
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion(OrcidMessage.DEFAULT_VERSION);
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    Affiliations affiliations = new Affiliations();
    orcidActivities.setAffiliations(affiliations);
    Affiliation affiliation = new Affiliation();
    affiliation.setVisibility(Visibility.LIMITED);
    affiliations.getAffiliation().add(affiliation);
    affiliation.setType(AffiliationType.EDUCATION);
    Organization organization = new Organization();
    affiliation.setOrganization(organization);
    organization.setName(orgName);
    OrganizationAddress organizationAddress = new OrganizationAddress();
    organization.setAddress(organizationAddress);
    organizationAddress.setCity("Edinburgh");
    organizationAddress.setCountry(Iso3166Country.GB);
    ClientResponse clientResponse = oauthT2Client.addAffiliationsXml(userOrcid, orcidMessage, token);
    assertEquals(201, clientResponse.getStatus());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ClientResponse(com.sun.jersey.api.client.ClientResponse) Organization(org.orcid.jaxb.model.message.Organization) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) Affiliation(org.orcid.jaxb.model.message.Affiliation)

Example 14 with OrganizationAddress

use of org.orcid.jaxb.model.message.OrganizationAddress in project ORCID-Source by ORCID.

the class OrcidProfileManagerImplTest method testOrgReuse.

@Test
@Transactional
@Rollback(true)
public void testOrgReuse() {
    OrcidProfile profile1 = createBasicProfile();
    OrcidHistory history = new OrcidHistory();
    history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    profile1.setOrcidHistory(history);
    history.setClaimed(new Claimed(true));
    OrcidActivities orcidActivities = profile1.getOrcidActivities();
    Affiliations affiliations = new Affiliations();
    orcidActivities.setAffiliations(affiliations);
    Affiliation affiliation = new Affiliation();
    affiliations.getAffiliation().add(affiliation);
    Organization organization = new Organization();
    affiliation.setOrganization(organization);
    organization.setName("New College");
    OrganizationAddress organizationAddress = new OrganizationAddress();
    organization.setAddress(organizationAddress);
    organizationAddress.setCity("Edinburgh");
    organizationAddress.setCountry(Iso3166Country.GB);
    orcidProfileManager.createOrcidProfile(profile1, false, false);
    ProfileEntity profileEntity = profileDao.find(TEST_ORCID);
    assertEquals(1, profileEntity.getOrgAffiliationRelations().size());
    OrgEntity orgEntity = profileEntity.getOrgAffiliationRelations().iterator().next().getOrg();
    assertNotNull(orgEntity);
    // Now create another profile with the same affiliation and check that
    // the org is reused;
    String otherOrcid = "4444-4444-4444-4448";
    OrcidProfile profile2 = createBasicProfile();
    profile2.setOrcidIdentifier(otherOrcid);
    List<Email> emailList2 = profile2.getOrcidBio().getContactDetails().getEmail();
    emailList2.clear();
    emailList2.add(new Email("another@semantico.com"));
    profile2.getOrcidActivities().setAffiliations(affiliations);
    orcidProfileManager.createOrcidProfile(profile2, false, false);
    ProfileEntity profileEntity2 = profileDao.find(otherOrcid);
    assertEquals(1, profileEntity2.getOrgAffiliationRelations().size());
    OrgEntity orgEntity2 = profileEntity2.getOrgAffiliationRelations().iterator().next().getOrg();
    assertNotNull(orgEntity);
    assertEquals(orgEntity.getId(), orgEntity2.getId());
}
Also used : Organization(org.orcid.jaxb.model.message.Organization) Email(org.orcid.jaxb.model.message.Email) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Date(java.util.Date) ApprovalDate(org.orcid.jaxb.model.message.ApprovalDate) Claimed(org.orcid.jaxb.model.message.Claimed) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Affiliations(org.orcid.jaxb.model.message.Affiliations) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) Affiliation(org.orcid.jaxb.model.message.Affiliation) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with OrganizationAddress

use of org.orcid.jaxb.model.message.OrganizationAddress in project ORCID-Source by ORCID.

the class OrcidProfileManagerBaseTest method getAffiliation.

public Affiliation getAffiliation() throws DatatypeConfigurationException {
    GregorianCalendar cal = new GregorianCalendar();
    XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
    Affiliation affiliation = new Affiliation();
    affiliation.setStartDate(new FuzzyDate(calendar.getYear(), calendar.getMonth(), calendar.getDay()));
    affiliation.setEndDate(new FuzzyDate(calendar.getYear(), calendar.getMonth(), calendar.getDay()));
    affiliation.setType(AffiliationType.EDUCATION);
    affiliation.setRoleTitle("A Role");
    affiliation.setDepartmentName("A Department");
    Organization organization = new Organization();
    affiliation.setOrganization(organization);
    organization.setName("Past Institution");
    OrganizationAddress address = new OrganizationAddress();
    address.setCountry(Iso3166Country.GB);
    organization.setAddress(address);
    return affiliation;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Organization(org.orcid.jaxb.model.message.Organization) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) FuzzyDate(org.orcid.jaxb.model.message.FuzzyDate) Affiliation(org.orcid.jaxb.model.message.Affiliation)

Aggregations

Organization (org.orcid.jaxb.model.message.Organization)16 OrganizationAddress (org.orcid.jaxb.model.message.OrganizationAddress)16 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)12 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)11 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)11 Affiliation (org.orcid.jaxb.model.message.Affiliation)10 Test (org.junit.Test)9 Affiliations (org.orcid.jaxb.model.message.Affiliations)9 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)8 DBUnitTest (org.orcid.test.DBUnitTest)8 Response (javax.ws.rs.core.Response)5 FuzzyDate (org.orcid.jaxb.model.message.FuzzyDate)4 Transactional (org.springframework.transaction.annotation.Transactional)4 DisambiguatedOrganization (org.orcid.jaxb.model.message.DisambiguatedOrganization)3 Funding (org.orcid.jaxb.model.message.Funding)3 FundingExternalIdentifier (org.orcid.jaxb.model.message.FundingExternalIdentifier)3 FundingExternalIdentifiers (org.orcid.jaxb.model.message.FundingExternalIdentifiers)3 FundingList (org.orcid.jaxb.model.message.FundingList)3 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)3 Title (org.orcid.jaxb.model.message.Title)3