Search in sources :

Example 6 with Claimed

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

the class T2OrcidApiServiceVersionedDelegatorTest method testCreateProfileWithInvalidHistoryElements.

@Test
public void testCreateProfileWithInvalidHistoryElements() {
    OrcidMessage orcidMessage = createStubOrcidMessage();
    orcidMessage.setMessageVersion("1.2");
    //Claimed should be null
    try {
        OrcidHistory history = new OrcidHistory();
        history.setClaimed(new Claimed(false));
        orcidMessage.getOrcidProfile().setOrcidHistory(history);
        t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
    } catch (OrcidValidationException obe) {
        assertTrue(obe.getMessage().contains("Claimed status should not be specified when creating a profile"));
    }
    //Creation method should be null
    try {
        OrcidHistory history = new OrcidHistory();
        history.setCreationMethod(CreationMethod.API);
        orcidMessage.getOrcidProfile().setOrcidHistory(history);
        t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
    } catch (OrcidValidationException obe) {
        assertTrue(obe.getMessage().contains("Creation method should not be specified when creating a profile"));
    }
    //Completion date should be null
    try {
        OrcidHistory history = new OrcidHistory();
        history.setCompletionDate(new CompletionDate());
        orcidMessage.getOrcidProfile().setOrcidHistory(history);
        t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
    } catch (OrcidValidationException obe) {
        assertTrue(obe.getMessage().contains("Completion date should not be specified when creating a profile"));
    }
    //Submission date should be null
    try {
        OrcidHistory history = new OrcidHistory();
        history.setSubmissionDate(new SubmissionDate());
        orcidMessage.getOrcidProfile().setOrcidHistory(history);
        t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
    } catch (OrcidValidationException obe) {
        assertTrue(obe.getMessage().contains("Submission date should not be specified when creating a profile"));
    }
    //Last modified date should be null
    try {
        OrcidHistory history = new OrcidHistory();
        history.setLastModifiedDate(new LastModifiedDate());
        orcidMessage.getOrcidProfile().setOrcidHistory(history);
        t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
    } catch (OrcidValidationException obe) {
        assertTrue(obe.getMessage().contains("Last modified date should not be specified when creating a profile"));
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.message.LastModifiedDate) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) CompletionDate(org.orcid.jaxb.model.message.CompletionDate) Claimed(org.orcid.jaxb.model.message.Claimed) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 7 with Claimed

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

the class OrcidProfileManagerReadOnlyImpl method createReservedForClaimOrcidProfile.

protected OrcidProfile createReservedForClaimOrcidProfile(String orcid, OrcidDeprecated deprecatedInfo, LastModifiedDate lastModifiedDate) {
    OrcidProfile op = new OrcidProfile();
    if (jpaJaxbAdapter != null) {
        op.setOrcidIdentifier(new OrcidIdentifier(jpaJaxbAdapter.getOrcidIdBase(orcid)));
    } else {
        op.setOrcidIdentifier(orcid);
    }
    if (deprecatedInfo != null)
        op.setOrcidDeprecated(deprecatedInfo);
    OrcidHistory oh = new OrcidHistory();
    oh.setClaimed(new Claimed(false));
    oh.setLastModifiedDate(lastModifiedDate);
    op.setOrcidHistory(oh);
    GivenNames gn = new GivenNames();
    PersonalDetails pd = new PersonalDetails();
    gn.setContent(localeManager.resolveMessage("orcid.reserved_for_claim"));
    gn.setVisibility(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility());
    pd.setGivenNames(gn);
    OrcidBio ob = new OrcidBio();
    ob.setPersonalDetails(pd);
    op.setOrcidBio(ob);
    return op;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) GivenNames(org.orcid.jaxb.model.message.GivenNames) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Claimed(org.orcid.jaxb.model.message.Claimed)

Example 8 with Claimed

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

the class SetUpClientsAndUsers method createUser.

private void createUser(Map<String, String> params) throws Exception {
    // Create it
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier(params.get(ORCID)));
    orcidProfile.setType(OrcidType.fromValue(params.get(ORCID_TYPE)));
    if (params.get(MEMBER_TYPE) != null) {
        orcidProfile.setGroupType(MemberType.fromValue(params.get(MEMBER_TYPE)));
    }
    orcidProfile.setPassword(params.get(PASSWORD));
    OrcidInternal internal = new OrcidInternal();
    Preferences preferences = new Preferences();
    ActivitiesVisibilityDefault visibilityDefaults = new ActivitiesVisibilityDefault();
    visibilityDefaults.setValue(Visibility.PUBLIC);
    preferences.setActivitiesVisibilityDefault(visibilityDefaults);
    internal.setPreferences(preferences);
    orcidProfile.setOrcidInternal(internal);
    Email email = new Email(params.get(EMAIL));
    email.setCurrent(true);
    email.setPrimary(true);
    email.setVerified(true);
    email.setVisibility(Visibility.PUBLIC);
    List<Email> emails = new ArrayList<Email>();
    emails.add(email);
    ContactDetails contactDetails = new ContactDetails();
    contactDetails.setEmail(emails);
    org.orcid.jaxb.model.message.PersonalDetails personalDetails = new org.orcid.jaxb.model.message.PersonalDetails();
    org.orcid.jaxb.model.message.CreditName creditName = new org.orcid.jaxb.model.message.CreditName(params.get(CREDIT_NAME));
    creditName.setVisibility(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility());
    personalDetails.setCreditName(creditName);
    personalDetails.setFamilyName(new org.orcid.jaxb.model.message.FamilyName(params.get(FAMILY_NAMES)));
    personalDetails.setGivenNames(new org.orcid.jaxb.model.message.GivenNames(params.get(GIVEN_NAMES)));
    OrcidBio bio = new OrcidBio();
    bio.setContactDetails(contactDetails);
    bio.setPersonalDetails(personalDetails);
    bio.setBiography(new Biography(params.get(BIO), OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility()));
    orcidProfile.setOrcidBio(bio);
    OrcidHistory history = new OrcidHistory();
    history.setClaimed(new Claimed(true));
    history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    history.setCreationMethod(CreationMethod.DIRECT);
    orcidProfile.setOrcidHistory(history);
    orcidProfileManager.createOrcidProfile(orcidProfile, false, false);
    if (params.containsKey(LOCKED)) {
        orcidProfileManager.lockProfile(params.get(ORCID), LockReason.SPAM.getLabel(), null);
    }
    if (params.containsKey(DEVELOPER_TOOLS)) {
        profileEntityManager.enableDeveloperTools(orcidProfile);
    }
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) ArrayList(java.util.ArrayList) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) Biography(org.orcid.jaxb.model.message.Biography) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) Preferences(org.orcid.jaxb.model.message.Preferences) CreditName(org.orcid.jaxb.model.common_v2.CreditName) Claimed(org.orcid.jaxb.model.message.Claimed) Date(java.util.Date) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory)

Example 9 with Claimed

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

use of org.orcid.jaxb.model.message.Claimed 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)

Aggregations

Claimed (org.orcid.jaxb.model.message.Claimed)15 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)14 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)13 SubmissionDate (org.orcid.jaxb.model.message.SubmissionDate)13 Date (java.util.Date)12 Test (org.junit.Test)9 ActivitiesVisibilityDefault (org.orcid.jaxb.model.message.ActivitiesVisibilityDefault)8 ApprovalDate (org.orcid.jaxb.model.message.ApprovalDate)8 Transactional (org.springframework.transaction.annotation.Transactional)8 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)6 OrcidInternal (org.orcid.jaxb.model.message.OrcidInternal)6 Rollback (org.springframework.test.annotation.Rollback)6 Preferences (org.orcid.jaxb.model.message.Preferences)5 Source (org.orcid.jaxb.model.message.Source)5 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)4 Email (org.orcid.jaxb.model.message.Email)4 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)4 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)4 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)4 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)4