Search in sources :

Example 6 with Deprecated

use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.

the class ValidateV2_1SamplesTest method unmarshallFromPath.

private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type, schemaPath);
        Object result = null;
        if (ResearcherUrls.class.equals(type)) {
            result = (ResearcherUrls) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        } else if (PersonExternalIdentifiers.class.equals(type)) {
            result = (PersonExternalIdentifiers) obj;
        } else if (Biography.class.equals(type)) {
            result = (Biography) obj;
        } else if (Name.class.equals(type)) {
            result = (Name) obj;
        } else if (CreditName.class.equals(type)) {
            result = (CreditName) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (OtherNames.class.equals(type)) {
            result = (OtherNames) obj;
        } else if (Keywords.class.equals(type)) {
            result = (Keywords) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Addresses.class.equals(type)) {
            result = (Addresses) obj;
        } else if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Emails.class.equals(type)) {
            result = (Emails) obj;
        } else if (Email.class.equals(type)) {
            result = (Email) obj;
        } else if (Person.class.equals(type)) {
            result = (Person) obj;
        } else if (Deprecated.class.equals(type)) {
            result = (Deprecated) obj;
        } else if (Preferences.class.equals(type)) {
            result = (Preferences) obj;
        } else if (History.class.equals(type)) {
            result = (History) obj;
        } else if (Record.class.equals(type)) {
            result = (Record) obj;
        } else if (ActivitiesSummary.class.equals(type)) {
            result = (ActivitiesSummary) obj;
        } else if (Works.class.equals(type)) {
            result = (Works) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Address(org.orcid.jaxb.model.record_v2.Address) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) CreditName(org.orcid.jaxb.model.record_v2.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) History(org.orcid.jaxb.model.record_v2.History) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Deprecated(org.orcid.jaxb.model.record_v2.Deprecated) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Example 7 with Deprecated

use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.

the class ValidateV2RC2SamplesTest method unmarshallFromPath.

private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type, schemaPath);
        Object result = null;
        if (ResearcherUrls.class.equals(type)) {
            result = (ResearcherUrls) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        } else if (PersonExternalIdentifiers.class.equals(type)) {
            result = (PersonExternalIdentifiers) obj;
        } else if (Biography.class.equals(type)) {
            result = (Biography) obj;
        } else if (Name.class.equals(type)) {
            result = (Name) obj;
        } else if (CreditName.class.equals(type)) {
            result = (CreditName) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (OtherNames.class.equals(type)) {
            result = (OtherNames) obj;
        } else if (Keywords.class.equals(type)) {
            result = (Keywords) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Addresses.class.equals(type)) {
            result = (Addresses) obj;
        } else if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Emails.class.equals(type)) {
            result = (Emails) obj;
        } else if (Email.class.equals(type)) {
            result = (Email) obj;
        } else if (Person.class.equals(type)) {
            result = (Person) obj;
        } else if (Deprecated.class.equals(type)) {
            result = (Deprecated) obj;
        } else if (Preferences.class.equals(type)) {
            result = (Preferences) obj;
        } else if (History.class.equals(type)) {
            result = (History) obj;
        } else if (Record.class.equals(type)) {
            result = (Record) obj;
        } else if (ActivitiesSummary.class.equals(type)) {
            result = (ActivitiesSummary) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.record_rc2.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.record_rc2.Keyword) Address(org.orcid.jaxb.model.record_rc2.Address) OtherNames(org.orcid.jaxb.model.record_rc2.OtherNames) CreditName(org.orcid.jaxb.model.record_rc2.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier) History(org.orcid.jaxb.model.record_rc2.History) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc2.ActivitiesSummary) Deprecated(org.orcid.jaxb.model.record_rc2.Deprecated) Biography(org.orcid.jaxb.model.record_rc2.Biography) ResearcherUrl(org.orcid.jaxb.model.record_rc2.ResearcherUrl)

Example 8 with Deprecated

use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.

the class ValidateV2RC2SamplesTest method testUnmarshallDeprecated.

@Test
public void testUnmarshallDeprecated() throws SAXException, URISyntaxException {
    Deprecated deprecated = (Deprecated) unmarshallFromPath("/record_2.0_rc2/samples/deprecated-2.0_rc2.xml", Deprecated.class, "/record_2.0_rc2/deprecated-2.0_rc2.xsd");
    assertNotNull(deprecated);
    assertNotNull(deprecated.getPrimaryRecord());
    assertNotNull(deprecated.getPrimaryRecord().getOrcidIdentifier());
    assertEquals("http://orcid.org/8888-8888-8888-8880", deprecated.getPrimaryRecord().getOrcidIdentifier().getUri());
    assertEquals("8888-8888-8888-8880", deprecated.getPrimaryRecord().getOrcidIdentifier().getPath());
    assertEquals("orcid.org", deprecated.getPrimaryRecord().getOrcidIdentifier().getHost());
    assertNotNull(deprecated.getDeprecatedDate());
    assertEquals(2001, deprecated.getDeprecatedDate().getValue().getYear());
    assertEquals(12, deprecated.getDeprecatedDate().getValue().getMonth());
    assertEquals(31, deprecated.getDeprecatedDate().getValue().getDay());
}
Also used : Deprecated(org.orcid.jaxb.model.record_rc2.Deprecated) Test(org.junit.Test)

Example 9 with Deprecated

use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.

the class ValidateV2RC2SamplesTest method testMarshallDeprecated.

@Test
public void testMarshallDeprecated() throws JAXBException, SAXException, URISyntaxException {
    Deprecated object = (Deprecated) unmarshallFromPath("/record_2.0_rc2/samples/deprecated-2.0_rc2.xml", Deprecated.class);
    marshall(object, "/record_2.0_rc2/deprecated-2.0_rc2.xsd");
}
Also used : Deprecated(org.orcid.jaxb.model.record_rc2.Deprecated) Test(org.junit.Test)

Example 10 with Deprecated

use of org.orcid.jaxb.model.record_v2.Deprecated in project ORCID-Source by ORCID.

the class SolrMessageProcessor method updateSolrIndex.

private void updateSolrIndex(BaseMessage message) {
    String orcid = message.getOrcid();
    LOG.info("Updating using Record " + orcid + " in SOLR index");
    if (!isSolrIndexingEnabled) {
        LOG.info("Solr indexing is disabled");
        return;
    }
    try {
        org.orcid.jaxb.model.record_v2.Record record = orcid20ApiClient.fetchPublicRecord(message);
        // Remove deactivated records from SOLR index
        if (record.getHistory() != null && record.getHistory().getDeactivationDate() != null && record.getHistory().getDeactivationDate().getValue() != null) {
            solrUpdater.processInvalidRecord(orcid);
            recordStatusManager.markAsSent(orcid, AvailableBroker.SOLR);
            return;
        }
        // get detailed funding so we can discover org name and id
        List<Funding> fundings = new ArrayList<Funding>();
        if (record.getActivitiesSummary() != null && record.getActivitiesSummary().getFundings() != null && record.getActivitiesSummary().getFundings().getFundingGroup() != null) {
            for (FundingGroup group : record.getActivitiesSummary().getFundings().getFundingGroup()) {
                if (group.getFundingSummary() != null) {
                    for (FundingSummary f : group.getFundingSummary()) {
                        fundings.add(orcid20ApiClient.fetchFunding(record.getOrcidIdentifier().getPath(), f.getPutCode()));
                    }
                }
            }
        }
        solrUpdater.persist(recordConv.convert(record, fundings));
        recordStatusManager.markAsSent(orcid, AvailableBroker.SOLR);
    } catch (LockedRecordException lre) {
        LOG.error("Record " + orcid + " is locked");
        solrUpdater.processInvalidRecord(orcid);
        recordStatusManager.markAsSent(orcid, AvailableBroker.SOLR);
    } catch (DeprecatedRecordException dre) {
        LOG.error("Record " + orcid + " is deprecated");
        solrUpdater.processInvalidRecord(orcid);
        recordStatusManager.markAsSent(orcid, AvailableBroker.SOLR);
    } catch (Exception e) {
        LOG.error("Unable to fetch record " + orcid + " for SOLR");
        LOG.error(e.getMessage(), e);
        recordStatusManager.markAsFailed(orcid, AvailableBroker.SOLR);
    }
}
Also used : LockedRecordException(org.orcid.listener.exception.LockedRecordException) Funding(org.orcid.jaxb.model.record_v2.Funding) DeprecatedRecordException(org.orcid.listener.exception.DeprecatedRecordException) ArrayList(java.util.ArrayList) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) LockedRecordException(org.orcid.listener.exception.LockedRecordException) DeprecatedRecordException(org.orcid.listener.exception.DeprecatedRecordException) JAXBException(javax.xml.bind.JAXBException) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary)

Aggregations

IOException (java.io.IOException)7 DeprecatedRecordException (org.orcid.listener.exception.DeprecatedRecordException)6 InputStreamReader (java.io.InputStreamReader)5 Reader (java.io.Reader)5 Test (org.junit.Test)5 LockedRecordException (org.orcid.listener.exception.LockedRecordException)5 Biography (org.orcid.jaxb.model.record_v2.Biography)4 ArrayList (java.util.ArrayList)3 JAXBException (javax.xml.bind.JAXBException)3 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)3 Deprecated (org.orcid.jaxb.model.record_rc2.Deprecated)3 Address (org.orcid.jaxb.model.record_v2.Address)3 CreditName (org.orcid.jaxb.model.record_v2.CreditName)3 Funding (org.orcid.jaxb.model.record_v2.Funding)3 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)3 AmazonClientException (com.amazonaws.AmazonClientException)2 List (java.util.List)2 Document (org.bson.Document)2 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)2 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)2