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));
}
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));
}
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());
}
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;
}
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());
}
Aggregations