Search in sources :

Example 6 with Source

use of hex.glm.GLM2.Source in project ORCID-Source by ORCID.

the class AffiliationForm method valueOf.

public static AffiliationForm valueOf(Affiliation affiliation) {
    AffiliationForm form = new AffiliationForm();
    if (affiliation instanceof Education) {
        form.setAffiliationType(Text.valueOf(AffiliationType.EDUCATION.value()));
    } else {
        form.setAffiliationType(Text.valueOf(AffiliationType.EMPLOYMENT.value()));
    }
    form.setPutCode(Text.valueOf(affiliation.getPutCode()));
    form.setVisibility(Visibility.valueOf(affiliation.getVisibility()));
    Organization organization = affiliation.getOrganization();
    form.setDateSortString(PojoUtil.createDateSortString(affiliation.getStartDate(), affiliation.getEndDate()));
    form.setAffiliationName(Text.valueOf(organization.getName()));
    OrganizationAddress address = organization.getAddress();
    form.setCity(Text.valueOf(address.getCity()));
    if (organization.getDisambiguatedOrganization() != null) {
        if (organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier() != null) {
            form.setDisambiguatedAffiliationSourceId(Text.valueOf(organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier()));
            form.setDisambiguationSource(Text.valueOf(organization.getDisambiguatedOrganization().getDisambiguationSource()));
            form.setOrgDisambiguatedId(Text.valueOf(String.valueOf(organization.getDisambiguatedOrganization().getId())));
        }
    }
    if (address.getRegion() != null) {
        form.setRegion(Text.valueOf(address.getRegion()));
    } else {
        form.setRegion(new Text());
    }
    if (address.getCountry() != null) {
        form.setCountry(Text.valueOf(address.getCountry().value()));
    } else {
        form.setCountry(new Text());
    }
    if (affiliation.getDepartmentName() != null) {
        form.setDepartmentName(Text.valueOf(affiliation.getDepartmentName()));
    } else {
        form.setDepartmentName(new Text());
    }
    if (affiliation.getRoleTitle() != null) {
        form.setRoleTitle(Text.valueOf(affiliation.getRoleTitle()));
    } else {
        form.setRoleTitle(new Text());
    }
    if (affiliation.getStartDate() != null) {
        form.setStartDate(Date.valueOf(affiliation.getStartDate()));
    }
    if (affiliation.getEndDate() != null) {
        form.setEndDate(Date.valueOf(affiliation.getEndDate()));
    }
    Source source = affiliation.getSource();
    if (source != null) {
        form.setSource(source.retrieveSourcePath());
        if (source.getSourceName() != null) {
            form.setSourceName(source.getSourceName().getContent());
        }
    }
    form.setCreatedDate(Date.valueOf(affiliation.getCreatedDate()));
    form.setLastModified(Date.valueOf(affiliation.getLastModifiedDate()));
    return form;
}
Also used : Organization(org.orcid.jaxb.model.common_v2.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.common_v2.DisambiguatedOrganization) Education(org.orcid.jaxb.model.record_v2.Education) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) Source(org.orcid.jaxb.model.common_v2.Source)

Example 7 with Source

use of hex.glm.GLM2.Source in project ORCID-Source by ORCID.

the class KeywordForm method toKeyword.

public Keyword toKeyword() {
    Keyword keyword = new Keyword();
    if (!PojoUtil.isEmpty(putCode)) {
        keyword.setPutCode(Long.valueOf(putCode));
    }
    if (!PojoUtil.isEmpty(content)) {
        keyword.setContent(content);
    }
    if (visibility != null && visibility.getVisibility() != null) {
        keyword.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(visibility.getVisibility().value()));
    } else {
        keyword.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.KEYWORD_DEFAULT.getVisibility().value()));
    }
    if (createdDate != null) {
        keyword.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(createdDate.toCalendar())));
    }
    if (lastModified != null) {
        keyword.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(lastModified.toCalendar())));
    }
    if (displayIndex != null) {
        keyword.setDisplayIndex(displayIndex);
    } else {
        keyword.setDisplayIndex(0L);
    }
    keyword.setSource(new Source(source));
    return keyword;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Keyword(org.orcid.jaxb.model.record_v2.Keyword) CreatedDate(org.orcid.jaxb.model.common_v2.CreatedDate) Source(org.orcid.jaxb.model.common_v2.Source)

Example 8 with Source

use of hex.glm.GLM2.Source in project ORCID-Source by ORCID.

the class WebsiteForm method toResearcherUrl.

public ResearcherUrl toResearcherUrl() {
    ResearcherUrl researcherUrl = new ResearcherUrl();
    if (!PojoUtil.isEmpty(this.getUrl())) {
        researcherUrl.setUrl(new Url(this.getUrl()));
    }
    if (!PojoUtil.isEmpty(this.getUrlName())) {
        researcherUrl.setUrlName(this.getUrlName());
    }
    if (this.visibility != null && this.visibility.getVisibility() != null) {
        researcherUrl.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(this.getVisibility().getVisibility().value()));
    }
    if (!PojoUtil.isEmpty(this.getPutCode())) {
        researcherUrl.setPutCode(Long.valueOf(this.getPutCode()));
    }
    if (displayIndex != null) {
        researcherUrl.setDisplayIndex(displayIndex);
    } else {
        researcherUrl.setDisplayIndex(0L);
    }
    researcherUrl.setSource(new Source(source));
    return researcherUrl;
}
Also used : ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Source(org.orcid.jaxb.model.common_v2.Source)

Example 9 with Source

use of hex.glm.GLM2.Source in project ORCID-Source by ORCID.

the class NotificationManagerTest method filterActionedNotificationAlertsTest.

@Test
public void filterActionedNotificationAlertsTest() {
    TargetProxyHelper.injectIntoProxy(notificationManager, "notificationDao", mockNotificationDao);
    when(mockNotificationDao.findByOricdAndId(Matchers.anyString(), Matchers.anyLong())).thenReturn(null);
    List<Notification> notifications = IntStream.range(0, 10).mapToObj(new IntFunction<Notification>() {

        @Override
        public Notification apply(int value) {
            if (value % 3 == 0) {
                NotificationInstitutionalConnection n = new NotificationInstitutionalConnection();
                n.setSource(new Source("0000-0000-0000-0000"));
                n.setPutCode(Long.valueOf(value));
                return n;
            } else {
                NotificationPermission n = new NotificationPermission();
                n.setPutCode(Long.valueOf(value));
                return n;
            }
        }
    }).collect(Collectors.toList());
    assertEquals(10, notifications.size());
    notifications = notificationManager.filterActionedNotificationAlerts(notifications, "some-orcid");
    assertEquals(6, notifications.size());
    for (Notification n : notifications) {
        assertEquals(NotificationType.PERMISSION, n.getNotificationType());
        assertNotNull(n.getPutCode());
        assertThat(n.getPutCode(), not(anyOf(is(Long.valueOf(0)), is(Long.valueOf(3)), is(Long.valueOf(6)), is(Long.valueOf(9)))));
    }
}
Also used : NotificationInstitutionalConnection(org.orcid.model.notification.institutional_sign_in_v2.NotificationInstitutionalConnection) IntFunction(java.util.function.IntFunction) NotificationPermission(org.orcid.jaxb.model.notification.permission_v2.NotificationPermission) Source(org.orcid.jaxb.model.common_v2.Source) Notification(org.orcid.jaxb.model.notification_v2.Notification) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 10 with Source

use of hex.glm.GLM2.Source 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(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.notification.permission_v2.Item) SourceClientId(org.orcid.jaxb.model.common_v2.SourceClientId) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Items(org.orcid.jaxb.model.notification.permission_v2.Items) NotificationEntity(org.orcid.persistence.jpa.entities.NotificationEntity) Source(org.orcid.jaxb.model.common_v2.Source) NotificationAmended(org.orcid.jaxb.model.notification.amended_v2.NotificationAmended) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)17 Source (org.orcid.jaxb.model.common_v2.Source)16 Source (hex.glm.GLM2.Source)11 SourceClientId (org.orcid.jaxb.model.common_v2.SourceClientId)5 SourceName (org.orcid.jaxb.model.common_v2.SourceName)3 Items (org.orcid.jaxb.model.notification.permission_v2.Items)3 NotificationPermission (org.orcid.jaxb.model.notification.permission_v2.NotificationPermission)3 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 DisambiguatedOrganization (org.orcid.jaxb.model.common_v2.DisambiguatedOrganization)2 LastModifiedDate (org.orcid.jaxb.model.common_v2.LastModifiedDate)2 Organization (org.orcid.jaxb.model.common_v2.Organization)2 OrganizationAddress (org.orcid.jaxb.model.common_v2.OrganizationAddress)2 NotificationAmended (org.orcid.jaxb.model.notification.amended_v2.NotificationAmended)2 AuthorizationUrl (org.orcid.jaxb.model.notification.permission_v2.AuthorizationUrl)2 Item (org.orcid.jaxb.model.notification.permission_v2.Item)2 Notification (org.orcid.jaxb.model.notification_v2.Notification)2 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)2 NotificationEntity (org.orcid.persistence.jpa.entities.NotificationEntity)2