Search in sources :

Example 31 with Source

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

the class ValidateV2IdentifiersTest 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/samples/read_samples/peer-review-2.0.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/samples/read_samples/peer-review-full-2.0.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_v2.ExternalID) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Url(org.orcid.jaxb.model.common_v2.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 32 with Source

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

the class AddressForm method toAddress.

public Address toAddress() {
    Address address = new Address();
    if (this.iso2Country != null && this.iso2Country.getValue() != null) {
        Country country = new Country();
        country.setValue(this.iso2Country.getValue().value());
        address.setCountry(country);
    }
    if (this.visibility != null && this.visibility.getVisibility() != null) {
        address.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(this.getVisibility().getVisibility().value()));
    }
    if (!PojoUtil.isEmpty(this.getPutCode())) {
        address.setPutCode(Long.valueOf(this.getPutCode()));
    }
    if (displayIndex != null) {
        address.setDisplayIndex(displayIndex);
    } else {
        address.setDisplayIndex(0L);
    }
    address.setSource(new Source(source));
    return address;
}
Also used : Address(org.orcid.jaxb.model.record_v2.Address) Country(org.orcid.jaxb.model.common_v2.Country) Source(org.orcid.jaxb.model.common_v2.Source)

Example 33 with Source

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

the class ExternalIDValidatorTest method testEmptyRelationshipOnNotificationItemExternalIds_flagOff.

@Test
public void testEmptyRelationshipOnNotificationItemExternalIds_flagOff() {
    Item i = new Item();
    Item i2 = new Item();
    Items items = new Items();
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("doi");
    id1.setValue("value1");
    id1.setUrl(new Url("http://value1.com"));
    ExternalID id2 = new ExternalID();
    id2.setRelationship(null);
    id2.setType("source-work-id");
    id2.setValue("value2");
    id2.setUrl(new Url("http://value1.com"));
    i.setExternalIdentifier(id1);
    i2.setExternalIdentifier(id2);
    items.getItems().add(i);
    items.getItems().add(i2);
    //both valid
    validator.validateNotificationItems(items);
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Items(org.orcid.jaxb.model.notification.permission_v2.Items) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Example 34 with Source

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

the class WorkExternalIdentifiersConversionsTest method testConvertFromExternalIDs.

@Test
public void testConvertFromExternalIDs() {
    WorkExternalIDsConverter conv = new WorkExternalIDsConverter();
    ExternalID id = new ExternalID();
    id.setRelationship(Relationship.SELF);
    id.setType("doi");
    id.setUrl(new Url("http://what.com"));
    id.setValue("value");
    ExternalID id2 = new ExternalID();
    id2.setRelationship(Relationship.PART_OF);
    id2.setType("source-work-id");
    id2.setUrl(new Url("http://whatnow.com"));
    id2.setValue("value2");
    ExternalIDs ids = new ExternalIDs();
    ids.getExternalIdentifier().add(id);
    ids.getExternalIdentifier().add(id2);
    String externalIdentifiersAsString = conv.convertTo(ids, null);
    assertEquals(expectedIDs, externalIdentifiersAsString);
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) WorkExternalIDsConverter(org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIDsConverter) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Example 35 with Source

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

the class ExternalIDValidatorTest method testEmptyRelationshipOnNotificationItemExternalIds_flagOn.

@Test(expected = ActivityIdentifierValidationException.class)
public void testEmptyRelationshipOnNotificationItemExternalIds_flagOn() {
    validator.setRequireRelationshipOnExternalIdentifier(true);
    Item i = new Item();
    Item i2 = new Item();
    Items items = new Items();
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("doi");
    id1.setValue("value1");
    id1.setUrl(new Url("http://value1.com"));
    ExternalID id2 = new ExternalID();
    id2.setRelationship(null);
    id2.setType("source-work-id");
    id2.setValue("value2");
    id2.setUrl(new Url("http://value1.com"));
    i.setExternalIdentifier(id1);
    i2.setExternalIdentifier(id2);
    items.getItems().add(i);
    items.getItems().add(i2);
    //both valid
    validator.validateNotificationItems(items);
    fail("no exception thrown for invalid type");
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Items(org.orcid.jaxb.model.notification.permission_v2.Items) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)25 Source (org.orcid.jaxb.model.common_v2.Source)16 Source (hex.glm.GLM2.Source)11 Url (org.orcid.jaxb.model.common_v2.Url)11 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)11 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)11 Visibility (org.orcid.jaxb.model.common_v2.Visibility)10 SourceClientId (org.orcid.jaxb.model.common_v2.SourceClientId)7 Items (org.orcid.jaxb.model.notification.permission_v2.Items)6 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)6 Date (java.util.Date)5 HashMap (java.util.HashMap)5 OrcidDuplicatedElementException (org.orcid.core.exception.OrcidDuplicatedElementException)5 Item (org.orcid.jaxb.model.notification.permission_v2.Item)5 CreatedDate (org.orcid.jaxb.model.common_v2.CreatedDate)4 LastModifiedDate (org.orcid.jaxb.model.common_v2.LastModifiedDate)4 SourceName (org.orcid.jaxb.model.common_v2.SourceName)4 OrgEntity (org.orcid.persistence.jpa.entities.OrgEntity)4 SourceOrcid (org.orcid.jaxb.model.common_v2.SourceOrcid)3 NotificationPermission (org.orcid.jaxb.model.notification.permission_v2.NotificationPermission)3