Search in sources :

Example 81 with ExternalID

use of org.orcid.jaxb.model.record_rc2.ExternalID in project ORCID-Source by ORCID.

the class ValidateV2RC3Identifiers method testWork.

/**
     * <common:external-ids>
                <common:external-id>
                        <common:external-id-type>agr</common:external-id-type>
                        <common:external-id-value>work:external-identifier-id</common:external-id-value>                        
                        <common:external-id-url>http://orcid.org</common:external-id-url>
                        <common:external-id-relationship>self</common:external-id-relationship>
                </common:external-id>
        </common:external-ids>
        
     * @throws SAXException
     * @throws IOException
     * @throws JAXBException
     * @throws ParserConfigurationException
     */
@Test
public void testWork() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    Work work = unmarshallFromPath("/record_2.0_rc3/samples/work-2.0_rc3.xml", Work.class);
    ExternalID id = work.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("agr", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    Validator validator = getValidator("work");
    validator.validate(marshall(Work.class, work));
    validator.validate(marshallToDOM(Work.class, work));
    work = unmarshallFromPath("/record_2.0_rc3/samples/work-full-2.0_rc3.xml", Work.class);
    id = work.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("agr", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    validator.validate(marshall(Work.class, work));
    validator.validate(marshallToDOM(Work.class, work));
}
Also used : ExternalID(org.orcid.jaxb.model.record_rc3.ExternalID) Work(org.orcid.jaxb.model.record_rc3.Work) Url(org.orcid.jaxb.model.common_rc3.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 82 with ExternalID

use of org.orcid.jaxb.model.record_rc2.ExternalID in project ORCID-Source by ORCID.

the class ValidateV2RC4Identifiers method testWork.

/**
     * <common:external-ids>
                <common:external-id>
                        <common:external-id-type>agr</common:external-id-type>
                        <common:external-id-value>work:external-identifier-id</common:external-id-value>                        
                        <common:external-id-url>http://orcid.org</common:external-id-url>
                        <common:external-id-relationship>self</common:external-id-relationship>
                </common:external-id>
        </common:external-ids>
        
     * @throws SAXException
     * @throws IOException
     * @throws JAXBException
     * @throws ParserConfigurationException
     */
@Test
public void testWork() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    Work work = unmarshallFromPath("/record_2.0_rc4/samples/work-2.0_rc4.xml", Work.class);
    ExternalID id = work.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("agr", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    Validator validator = getValidator("work");
    validator.validate(marshall(Work.class, work));
    validator.validate(marshallToDOM(Work.class, work));
    work = unmarshallFromPath("/record_2.0_rc4/samples/work-full-2.0_rc4.xml", Work.class);
    id = work.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("agr", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    validator.validate(marshall(Work.class, work));
    validator.validate(marshallToDOM(Work.class, work));
}
Also used : ExternalID(org.orcid.jaxb.model.record_rc4.ExternalID) Work(org.orcid.jaxb.model.record_rc4.Work) Url(org.orcid.jaxb.model.common_rc4.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 83 with ExternalID

use of org.orcid.jaxb.model.record_rc2.ExternalID in project ORCID-Source by ORCID.

the class ValidateV2RC4Identifiers method testPeerReview.

/** Test both types of identifier here
     * 
     * @throws SAXException
     * @throws IOException
     * @throws JAXBException
     * @throws ParserConfigurationException
     */
@Test
public void testPeerReview() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    PeerReview peerReview = unmarshallFromPath("/record_2.0_rc4/samples/peer-review-2.0_rc4.xml", PeerReview.class);
    ExternalID id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    ExternalID subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
    Validator validator = getValidator("peer-review");
    validator.validate(marshall(PeerReview.class, peerReview));
    validator.validate(marshallToDOM(PeerReview.class, peerReview));
    //do the full record too
    peerReview = unmarshallFromPath("/record_2.0_rc4/samples/peer-review-full-2.0_rc4.xml", PeerReview.class);
    id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
}
Also used : ExternalID(org.orcid.jaxb.model.record_rc4.ExternalID) PeerReview(org.orcid.jaxb.model.record_rc4.PeerReview) Url(org.orcid.jaxb.model.common_rc4.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 84 with ExternalID

use of org.orcid.jaxb.model.record_rc2.ExternalID in project ORCID-Source by ORCID.

the class WorkFormTest method getWork.

public static Work getWork() {
    Work work = new Work();
    work.setCountry(new Country(Iso3166Country.US));
    Date date = new Date();
    work.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(date)));
    work.setJournalTitle(new Title("Journal Title"));
    work.setLanguageCode("EN");
    work.setPublicationDate(new PublicationDate(new Year(2015), new Month(1), new Day(1)));
    work.setPutCode(Long.valueOf("12345"));
    work.setShortDescription("Short description");
    work.setUrl(new Url("http://test.com"));
    work.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.LIMITED);
    work.setWorkCitation(new org.orcid.jaxb.model.record_v2.Citation("Citation", CitationType.BIBTEX));
    WorkContributors contributors = new WorkContributors();
    org.orcid.jaxb.model.common_v2.Contributor contributor = new org.orcid.jaxb.model.common_v2.Contributor();
    contributor.setCreditName(new CreditName("Credit name"));
    contributor.setContributorOrcid(new ContributorOrcid("0000-0000-0000-0000"));
    ContributorAttributes att = new ContributorAttributes();
    att.setContributorRole(ContributorRole.ASSIGNEE);
    att.setContributorSequence(SequenceType.FIRST);
    contributor.setContributorAttributes(att);
    contributors.getContributor().add(contributor);
    work.setWorkContributors(contributors);
    ExternalIDs weis = new ExternalIDs();
    ExternalID wei = new ExternalID();
    wei.setRelationship(Relationship.SELF);
    wei.setUrl(new Url("http://test.com"));
    wei.setValue("ID");
    wei.setType(WorkExternalIdentifierType.AGR.value());
    weis.getExternalIdentifier().add(wei);
    work.setWorkExternalIdentifiers(weis);
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("Work Title"));
    workTitle.setSubtitle(new Subtitle("Subtitle"));
    TranslatedTitle translated = new TranslatedTitle("Translated", "US");
    workTitle.setTranslatedTitle(translated);
    work.setWorkTitle(workTitle);
    work.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
    return work;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) WorkContributors(org.orcid.jaxb.model.record_v2.WorkContributors) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Url(org.orcid.jaxb.model.common_v2.Url) Month(org.orcid.jaxb.model.common_v2.Month) Work(org.orcid.jaxb.model.record_v2.Work) PublicationDate(org.orcid.jaxb.model.common_v2.PublicationDate) ContributorAttributes(org.orcid.jaxb.model.common_v2.ContributorAttributes) CreditName(org.orcid.jaxb.model.common_v2.CreditName) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) Date(java.util.Date) CreatedDate(org.orcid.jaxb.model.common_v2.CreatedDate) PublicationDate(org.orcid.jaxb.model.common_v2.PublicationDate) Subtitle(org.orcid.jaxb.model.common_v2.Subtitle) Year(org.orcid.jaxb.model.common_v2.Year) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) CreatedDate(org.orcid.jaxb.model.common_v2.CreatedDate) Country(org.orcid.jaxb.model.common_v2.Country) Iso3166Country(org.orcid.jaxb.model.common_v2.Iso3166Country) ContributorOrcid(org.orcid.jaxb.model.common_v2.ContributorOrcid) Day(org.orcid.jaxb.model.common_v2.Day)

Example 85 with ExternalID

use of org.orcid.jaxb.model.record_rc2.ExternalID in project ORCID-Source by ORCID.

the class JpaJaxbWorkAdapterTest method fromProfileWorkEntityToWorkTest.

@Test
public void fromProfileWorkEntityToWorkTest() {
    // Set base url to https to ensure source URI is converted to http
    orcidUrlManager.setBaseUrl("https://testserver.orcid.org");
    WorkEntity work = getWorkEntity();
    assertNotNull(work);
    Work w = jpaJaxbWorkAdapter.toWork(work);
    assertNotNull(w);
    assertNotNull(w.getCreatedDate());
    assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(w.getCreatedDate().getValue()));
    assertNotNull(w.getLastModifiedDate());
    assertEquals(DateUtils.convertToDate("2015-06-05T10:15:20"), DateUtils.convertToDate(w.getLastModifiedDate().getValue()));
    assertEquals(org.orcid.jaxb.model.common_v2.Iso3166Country.CR.value(), w.getCountry().getValue().value());
    assertEquals("work:citation", w.getWorkCitation().getCitation());
    assertEquals("work:description", w.getShortDescription());
    assertEquals("work:journalTitle", w.getJournalTitle().getContent());
    assertEquals(CitationType.BIBTEX.value(), w.getWorkCitation().getWorkCitationType().value());
    assertEquals(Long.valueOf(12345), w.getPutCode());
    assertEquals(Visibility.LIMITED.value(), w.getVisibility().value());
    assertEquals("work:title", w.getWorkTitle().getTitle().getContent());
    assertEquals("work:subtitle", w.getWorkTitle().getSubtitle().getContent());
    assertEquals("work:translatedTitle", w.getWorkTitle().getTranslatedTitle().getContent());
    assertEquals("ES", w.getWorkTitle().getTranslatedTitle().getLanguageCode());
    assertEquals(WorkType.ARTISTIC_PERFORMANCE.value(), w.getWorkType().value());
    assertNotNull(w.getWorkExternalIdentifiers());
    assertNotNull(w.getWorkExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, w.getWorkExternalIdentifiers().getExternalIdentifier().size());
    ExternalID workExtId = w.getWorkExternalIdentifiers().getExternalIdentifier().get(0);
    assertNotNull(workExtId.getValue());
    assertEquals("123", workExtId.getValue());
    assertNotNull(workExtId.getType());
    assertEquals(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value(), workExtId.getType());
    String sourcePath = w.getSource().retrieveSourcePath();
    assertNotNull(sourcePath);
    assertEquals("APP-5555555555555555", sourcePath);
    // Identifier URIs should always be http, event if base url is https
    assertEquals("http://testserver.orcid.org/client/APP-5555555555555555", w.getSource().retriveSourceUri());
}
Also used : WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Aggregations

ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)110 Test (org.junit.Test)97 Url (org.orcid.jaxb.model.common_v2.Url)55 ClientResponse (com.sun.jersey.api.client.ClientResponse)52 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)50 Work (org.orcid.jaxb.model.record_v2.Work)32 Title (org.orcid.jaxb.model.common_v2.Title)28 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)22 Funding (org.orcid.jaxb.model.record_v2.Funding)16 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)16 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)14 ArrayList (java.util.ArrayList)13 ExternalID (org.orcid.jaxb.model.record_rc3.ExternalID)13 ExternalID (org.orcid.jaxb.model.record_rc4.ExternalID)13 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)11 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)9 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)8 ExternalID (org.orcid.jaxb.model.record_rc2.ExternalID)8 List (java.util.List)7 Validator (javax.xml.validation.Validator)7