Search in sources :

Example 76 with ExternalID

use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.

the class WorkForm method populateExternalIdentifiers.

public static void populateExternalIdentifiers(ExternalIDs extIds, WorkForm workForm, WorkType workType) {
    if (extIds != null) {
        List<WorkExternalIdentifier> workExternalIdentifiersList = new ArrayList<WorkExternalIdentifier>();
        for (ExternalID extId : extIds.getExternalIdentifier()) {
            if (extId.getRelationship() == null) {
                if (org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.equals(extId.getType())) {
                    if (WorkType.BOOK.equals(workType)) {
                        extId.setRelationship(Relationship.PART_OF);
                    } else {
                        extId.setRelationship(Relationship.SELF);
                    }
                } else if (org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISBN.equals(extId.getType())) {
                    if (WorkType.BOOK_CHAPTER.equals(workType) || WorkType.CONFERENCE_PAPER.equals(workType)) {
                        extId.setRelationship(Relationship.PART_OF);
                    } else {
                        extId.setRelationship(Relationship.SELF);
                    }
                } else {
                    extId.setRelationship(Relationship.SELF);
                }
            }
            workExternalIdentifiersList.add(WorkExternalIdentifier.valueOf(extId));
        }
        workForm.setWorkExternalIdentifiers(workExternalIdentifiersList);
    }
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) ArrayList(java.util.ArrayList)

Example 77 with ExternalID

use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.

the class JpaJaxbWorkAdapterTest method fromProfileWorkEntityToWorkSummaryTest.

@Test
public void fromProfileWorkEntityToWorkSummaryTest() {
    WorkEntity work = getWorkEntity();
    assertNotNull(work);
    WorkSummary ws = jpaJaxbWorkAdapter.toWorkSummary(work);
    assertNotNull(ws);
    assertEquals(Long.valueOf(12345), ws.getPutCode());
    assertEquals(Visibility.LIMITED.value(), ws.getVisibility().value());
    assertEquals("1234567890", ws.getDisplayIndex());
    assertNotNull(ws.getExternalIdentifiers());
    assertNotNull(ws.getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, ws.getExternalIdentifiers().getExternalIdentifier().size());
    ExternalID workExtId = ws.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertNotNull(workExtId.getValue());
    assertEquals("123", workExtId.getValue());
    assertNotNull(workExtId.getType());
    assertEquals(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value(), workExtId.getType());
    assertEquals("work:journalTitle", ws.getJournalTitle().getContent());
}
Also used : WorkEntity(org.orcid.persistence.jpa.entities.WorkEntity) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Test(org.junit.Test)

Example 78 with ExternalID

use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.

the class JpaJaxbNotificationAdapterTest method testToNotificationAmendedEntity.

@Test
public void testToNotificationAmendedEntity() {
    NotificationAmended notification = new NotificationAmended();
    notification.setNotificationType(NotificationType.AMENDED);
    Source source = new Source();
    notification.setSource(source);
    SourceClientId clientId = new SourceClientId();
    source.setSourceClientId(clientId);
    clientId.setPath("APP-5555-5555-5555-5555");
    Items activities = new Items();
    notification.setItems(activities);
    Item activity = new Item();
    activities.getItems().add(activity);
    activity.setItemType(ItemType.WORK);
    activity.setItemName("Latest Research Article");
    ExternalID extId = new ExternalID();
    activity.setExternalIdentifier(extId);
    extId.setType("doi");
    extId.setValue("1234/abc123");
    NotificationEntity notificationEntity = jpaJaxbNotificationAdapter.toNotificationEntity(notification);
    assertTrue(notificationEntity instanceof NotificationAmendedEntity);
    NotificationAmendedEntity notificationAmendedEntity = (NotificationAmendedEntity) notificationEntity;
    assertNotNull(notificationEntity);
    assertEquals(org.orcid.jaxb.model.notification_v2.NotificationType.AMENDED, notificationEntity.getNotificationType());
    // Source
    assertNull(notificationAmendedEntity.getSourceId());
    assertNull(notificationAmendedEntity.getClientSourceId());
    assertNull(notificationAmendedEntity.getElementSourceId());
}
Also used : NotificationAmendedEntity(org.orcid.persistence.jpa.entities.NotificationAmendedEntity) Item(org.orcid.jaxb.model.v3.dev1.notification.permission.Item) SourceClientId(org.orcid.jaxb.model.v3.dev1.common.SourceClientId) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Items(org.orcid.jaxb.model.v3.dev1.notification.permission.Items) NotificationEntity(org.orcid.persistence.jpa.entities.NotificationEntity) Source(org.orcid.jaxb.model.v3.dev1.common.Source) NotificationAmended(org.orcid.jaxb.model.v3.dev1.notification.amended.NotificationAmended) Test(org.junit.Test)

Example 79 with ExternalID

use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.

the class JSONExternalIdentifiersConverterV3Test method testConvertFrom.

@Test
public void testConvertFrom() {
    ExternalIDs externalIDs = converter.convertFrom("{\"externalIdentifier\":[{\"type\":\"GRANT_NUMBER\",\"value\":\"external-identifier-value\",\"url\":{\"value\":\"http://tempuri.org\"},\"relationship\":\"SELF\"},{\"type\":\"GRANT_NUMBER\",\"value\":\"external-identifier-value2\",\"url\":{\"value\":\"http://tempuri.org/2\"},\"relationship\":\"SELF\"}]}", null);
    assertNotNull(externalIDs);
    assertEquals(2, externalIDs.getExternalIdentifier().size());
    ExternalID externalID = externalIDs.getExternalIdentifier().get(0);
    assertEquals("grant_number", externalID.getType());
    assertEquals("external-identifier-value", externalID.getValue());
    assertEquals("http://tempuri.org", externalID.getUrl().getValue());
    externalID = externalIDs.getExternalIdentifier().get(1);
    assertEquals("grant_number", externalID.getType());
    assertEquals("external-identifier-value2", externalID.getValue());
    assertEquals("http://tempuri.org/2", externalID.getUrl().getValue());
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Test(org.junit.Test)

Example 80 with ExternalID

use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.

the class JSONPeerReviewWorkExternalIdentifierConverterV3Test method testConvertFrom.

@Test
public void testConvertFrom() {
    PeerReviewEntity peerReview = getPeerReviewEntity();
    ExternalID externalID = converter.convertFrom(peerReview.getSubjectExternalIdentifiersJson(), null);
    assertNotNull(externalID);
    assertEquals("source-work-id", externalID.getType());
    assertEquals("peer-review:subject-external-identifier-id", externalID.getValue());
    assertEquals("http://orcid.org", externalID.getUrl().getValue());
}
Also used : PeerReviewEntity(org.orcid.persistence.jpa.entities.PeerReviewEntity) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Test(org.junit.Test)

Aggregations

ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)120 Test (org.junit.Test)73 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)66 Url (org.orcid.jaxb.model.v3.dev1.common.Url)64 Title (org.orcid.jaxb.model.v3.dev1.common.Title)25 Work (org.orcid.jaxb.model.v3.dev1.record.Work)23 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)22 Response (javax.ws.rs.core.Response)20 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)20 DBUnitTest (org.orcid.test.DBUnitTest)20 List (java.util.List)16 TransientNonEmptyString (org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)14 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)13 ClientResponse (com.sun.jersey.api.client.ClientResponse)12 BaseTest (org.orcid.core.BaseTest)9 OrcidError (org.orcid.jaxb.model.v3.dev1.error.OrcidError)9 ArrayList (java.util.ArrayList)8 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)8 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)8 JSONUrl (org.orcid.core.adapter.jsonidentifier.JSONUrl)7