Search in sources :

Example 16 with OrcidHistory

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

the class OrcidClientGroupManagerImpl method createGroupProfile.

private OrcidProfile createGroupProfile(OrcidClientGroup orcidClientGroup) {
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setType(OrcidType.GROUP);
    orcidProfile.setGroupType(orcidClientGroup.getType());
    OrcidHistory orcidHistory = new OrcidHistory();
    orcidProfile.setOrcidHistory(orcidHistory);
    orcidHistory.setClaimed(new Claimed(true));
    orcidHistory.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    OrcidBio orcidBio = new OrcidBio();
    orcidProfile.setOrcidBio(orcidBio);
    PersonalDetails personalDetails = new PersonalDetails();
    orcidBio.setPersonalDetails(personalDetails);
    personalDetails.setCreditName(new CreditName(orcidClientGroup.getGroupName()));
    ContactDetails contactDetails = new ContactDetails();
    orcidBio.setContactDetails(contactDetails);
    Email primaryEmail = new Email(orcidClientGroup.getEmail());
    primaryEmail.setVisibility(Visibility.PRIVATE);
    primaryEmail.setVerified(true);
    contactDetails.addOrReplacePrimaryEmail(primaryEmail);
    if (!PojoUtil.isEmpty(orcidClientGroup.getSalesforceId())) {
        OrcidInternal orcidInternal = new OrcidInternal();
        orcidInternal.setSalesforceId(new SalesforceId(orcidClientGroup.getSalesforceId()));
        orcidProfile.setOrcidInternal(orcidInternal);
    }
    return orcidProfile;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) SalesforceId(org.orcid.jaxb.model.message.SalesforceId) CreditName(org.orcid.jaxb.model.message.CreditName) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Claimed(org.orcid.jaxb.model.message.Claimed) Date(java.util.Date) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate)

Example 17 with OrcidHistory

use of org.orcid.jaxb.model.message.OrcidHistory 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());
    }
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) 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) Source(org.orcid.jaxb.model.message.Source) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Subtitle(org.orcid.jaxb.model.message.Subtitle) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with OrcidHistory

use of org.orcid.jaxb.model.message.OrcidHistory 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 19 with OrcidHistory

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

the class OrcidProfileManagerImplTest method testAddOrcidWorksWhenDefaultVisibilityIsPrivate.

@Test
@Transactional
public void testAddOrcidWorksWhenDefaultVisibilityIsPrivate() {
    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.PRIVATE));
    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.PRIVATE, work.getVisibility());
    }
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) 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) Source(org.orcid.jaxb.model.message.Source) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Subtitle(org.orcid.jaxb.model.message.Subtitle) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 20 with OrcidHistory

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

the class OrcidProfileManagerImplTest method testAddOrcidWorksWhenDefaultVisibilityIsLimited.

@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorksWhenDefaultVisibilityIsLimited() {
    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.LIMITED));
    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.LIMITED, work.getVisibility());
    }
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) 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) Source(org.orcid.jaxb.model.message.Source) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Subtitle(org.orcid.jaxb.model.message.Subtitle) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)27 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)20 Date (java.util.Date)17 SubmissionDate (org.orcid.jaxb.model.message.SubmissionDate)17 Claimed (org.orcid.jaxb.model.message.Claimed)15 Test (org.junit.Test)10 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)10 ActivitiesVisibilityDefault (org.orcid.jaxb.model.message.ActivitiesVisibilityDefault)9 Transactional (org.springframework.transaction.annotation.Transactional)9 ApprovalDate (org.orcid.jaxb.model.message.ApprovalDate)8 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)8 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)8 Source (org.orcid.jaxb.model.message.Source)8 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)7 OrcidInternal (org.orcid.jaxb.model.message.OrcidInternal)7 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)7 Email (org.orcid.jaxb.model.message.Email)6 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)6 Rollback (org.springframework.test.annotation.Rollback)6 ArrayList (java.util.ArrayList)5