Search in sources :

Example 11 with OrcidProfile

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

the class T2OrcidApiServiceDelegatorTest method testReadPrivacyOnBioAsPublic.

@Test
public void testReadPrivacyOnBioAsPublic() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4497", ScopePathType.READ_PUBLIC);
    /*Example A List on 4444-4444-4444-4497:
        Item 1 Private (client is source)
        Item 2 Private (other source)
        Item 3 Limited
        Item 4 Public 
        */
    OrcidProfile p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4497").getEntity()).getOrcidProfile();
    assertEquals(1, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("type4", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getVisibility());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 12 with OrcidProfile

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

the class T2OrcidApiServiceDelegatorTest method testReadPrivacyOnBio3.

@Test
public void testReadPrivacyOnBio3() {
    /*Example C List:
        Item 1 Public
         */
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_LIMITED);
    OrcidProfile p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4443").getEntity()).getOrcidProfile();
    System.out.println(p.toString());
    assertEquals(1, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("Facebook", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getVisibility());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getVisibility());
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4443", ScopePathType.READ_PUBLIC);
    p = ((OrcidMessage) t2OrcidApiServiceDelegator.findBioDetails("4444-4444-4444-4443").getEntity()).getOrcidProfile();
    System.out.println(p.toString());
    assertEquals(1, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("Facebook", p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getVisibility());
    assertEquals(Visibility.PUBLIC, p.getOrcidBio().getExternalIdentifiers().getVisibility());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 13 with OrcidProfile

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

the class MigrateEmails method migrateProfiles.

private void migrateProfiles() {
    long startTime = System.currentTimeMillis();
    @SuppressWarnings("unchecked") List<String> orcids = Collections.EMPTY_LIST;
    int doneCount = 0;
    do {
        orcids = profileDao.findOrcidsNeedingEmailMigration(CHUNK_SIZE);
        for (final String orcid : orcids) {
            LOG.info("Migrating emails for profile: {}", orcid);
            transactionTemplate.execute(new TransactionCallbackWithoutResult() {

                @Override
                protected void doInTransactionWithoutResult(TransactionStatus status) {
                    OrcidProfile orcidProfile = orcidProfileManager.retrieveOrcidProfile(orcid);
                    // Save it straight back - it will be saved back in the
                    // new DB table automatically
                    orcidProfileManager.updateOrcidProfile(orcidProfile);
                }
            });
            doneCount++;
        }
    } while (!orcids.isEmpty());
    long endTime = System.currentTimeMillis();
    String timeTaken = DurationFormatUtils.formatDurationHMS(endTime - startTime);
    LOG.info("Finished migrating emails: doneCount={}, timeTaken={} (H:m:s.S)", doneCount, timeTaken);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) TransactionStatus(org.springframework.transaction.TransactionStatus) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult)

Example 14 with OrcidProfile

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

the class IndexProfiles method processOrcid.

private void processOrcid(final String orcid) {
    LOG.info("Indexing profile: {}", orcid);
    try {
        OrcidProfile orcidProfile = orcidProfileManager.retrievePublicOrcidProfile(orcid);
        orcidIndexManager.persistProfileInformationForIndexing(orcidProfile);
        profileDao.updateIndexingStatus(orcid, IndexingStatus.DONE);
    } catch (RuntimeException e) {
        errorCount++;
        if (continueOnError) {
            LOG.error("Error indexing profile: orcid={}", orcid, e);
            return;
        } else {
            throw e;
        }
    }
    doneCount++;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile)

Example 15 with OrcidProfile

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

the class OrcidClientGroupManagerImpl method createGroup.

/**
     * Creates a group profile. If the OrcidClientGroup provided already
     * contains a groupOrcid, it will just return it, if it doesnt, it will
     * create the profile and update the parameter.
     * 
     * @param orcidClientGroup
     *            the group to be created
     * @return the group updated with his orcid id.
     */
public OrcidClientGroup createGroup(OrcidClientGroup orcidClientGroup) {
    String groupOrcid = orcidClientGroup.getGroupOrcid();
    if (PojoUtil.isEmpty(groupOrcid)) {
        OrcidProfile groupProfile = createGroupProfile(orcidClientGroup);
        groupProfile = orcidProfileManager.createOrcidProfile(groupProfile, false, false);
        groupOrcid = groupProfile.getOrcidIdentifier().getPath();
        orcidClientGroup.setGroupOrcid(groupOrcid);
    }
    return orcidClientGroup;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile)

Aggregations

OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)241 Test (org.junit.Test)118 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)77 Transactional (org.springframework.transaction.annotation.Transactional)50 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)45 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)43 DBUnitTest (org.orcid.test.DBUnitTest)43 Rollback (org.springframework.test.annotation.Rollback)40 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)36 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)35 Date (java.util.Date)27 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)27 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)25 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)23 Affiliations (org.orcid.jaxb.model.message.Affiliations)22 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)22 Title (org.orcid.jaxb.model.message.Title)22 Email (org.orcid.jaxb.model.message.Email)21 GivenNames (org.orcid.jaxb.model.message.GivenNames)21 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)21