Search in sources :

Example 1 with Source

use of spold2.Source in project ORCID-Source by ORCID.

the class DigestEmail method addNotification.

public void addNotification(Notification notification) {
    Source source = notification.getSource();
    String sourceId = null;
    if (source == null) {
        sourceId = "ORCID";
    } else {
        sourceId = source.retrieveSourcePath();
    }
    DigestSourceNotifications digestSourceNotifications = notificationsBySourceId.get(sourceId);
    if (digestSourceNotifications == null) {
        digestSourceNotifications = new DigestSourceNotifications(source);
        notificationsBySourceId.put(sourceId, digestSourceNotifications);
    }
    digestSourceNotifications.addNotification(notification);
}
Also used : Source(org.orcid.jaxb.model.common_v2.Source)

Example 2 with Source

use of spold2.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)

Example 3 with Source

use of spold2.Source in project ORCID-Source by ORCID.

the class JpaJaxbNotificationAdapterTest method testToNotificationPermissionEntity.

@Test
public void testToNotificationPermissionEntity() {
    NotificationPermission notification = new NotificationPermission();
    notification.setNotificationType(NotificationType.PERMISSION);
    String authorizationUrlString = "https://orcid.org/oauth/authorize?client_id=APP-U4UKCNSSIM1OCVQY&response_type=code&scope=/orcid-works/create&redirect_uri=http://somethirdparty.com";
    AuthorizationUrl url = new AuthorizationUrl();
    notification.setAuthorizationUrl(url);
    notification.setNotificationIntro("This is the intro");
    notification.setNotificationSubject("This is the subject");
    Source source = new Source();
    notification.setSource(source);
    SourceClientId clientId = new SourceClientId();
    source.setSourceClientId(clientId);
    clientId.setPath("APP-5555-5555-5555-5555");
    url.setUri(authorizationUrlString);
    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 NotificationAddItemsEntity);
    NotificationAddItemsEntity addActivitiesEntity = (NotificationAddItemsEntity) notificationEntity;
    assertNotNull(notificationEntity);
    assertEquals(NotificationType.PERMISSION, notificationEntity.getNotificationType());
    assertEquals(authorizationUrlString, addActivitiesEntity.getAuthorizationUrl());
    assertEquals(notification.getNotificationIntro(), notificationEntity.getNotificationIntro());
    assertEquals(notification.getNotificationSubject(), notificationEntity.getNotificationSubject());
    // Source
    assertNull(notificationEntity.getSourceId());
    assertNull(notificationEntity.getClientSourceId());
    assertNull(notificationEntity.getElementSourceId());
    Set<NotificationItemEntity> activityEntities = addActivitiesEntity.getNotificationItems();
    assertNotNull(activityEntities);
    assertEquals(1, activityEntities.size());
    NotificationItemEntity activityEntity = activityEntities.iterator().next();
    assertEquals(ItemType.WORK, activityEntity.getItemType());
    assertEquals("Latest Research Article", activityEntity.getItemName());
    assertEquals("DOI", activityEntity.getExternalIdType());
    assertEquals("1234/abc123", activityEntity.getExternalIdValue());
}
Also used : AuthorizationUrl(org.orcid.jaxb.model.notification.permission_v2.AuthorizationUrl) NotificationAddItemsEntity(org.orcid.persistence.jpa.entities.NotificationAddItemsEntity) 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) NotificationPermission(org.orcid.jaxb.model.notification.permission_v2.NotificationPermission) Items(org.orcid.jaxb.model.notification.permission_v2.Items) NotificationItemEntity(org.orcid.persistence.jpa.entities.NotificationItemEntity) NotificationEntity(org.orcid.persistence.jpa.entities.NotificationEntity) Source(org.orcid.jaxb.model.common_v2.Source) Test(org.junit.Test)

Example 4 with Source

use of spold2.Source in project ORCID-Source by ORCID.

the class ActivityValidatorTest method validateDuplicatedExtIds_duplicatesFoundTest.

@SuppressWarnings("deprecation")
@Test(expected = OrcidDuplicatedActivityException.class)
public void validateDuplicatedExtIds_duplicatesFoundTest() {
    SourceEntity source1 = mock(SourceEntity.class);
    when(source1.getSourceName()).thenReturn("source name");
    when(source1.getSourceId()).thenReturn("APP-00000000000000");
    SourceClientId sourceClientId = new SourceClientId();
    sourceClientId.setPath("APP-00000000000000");
    Source source2 = mock(Source.class);
    when(source2.getSourceName()).thenReturn(new SourceName("source name"));
    when(source2.getSourceClientId()).thenReturn(sourceClientId);
    ExternalIDs extIds1 = getExternalIDs();
    ExternalIDs extIds2 = getExternalIDs();
    activityValidator.checkExternalIdentifiersForDuplicates(extIds1, extIds2, source2, source1);
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) SourceClientId(org.orcid.jaxb.model.common_v2.SourceClientId) SourceName(org.orcid.jaxb.model.common_v2.SourceName) Source(org.orcid.jaxb.model.common_v2.Source) Test(org.junit.Test)

Example 5 with Source

use of spold2.Source in project h2o-2 by h2oai.

the class GLMTest2 method testProstate.

/**
   * Simple test for binomial family (no regularization, test both lsm solvers).
   * Runs the classical prostate, using dataset with race replaced by categoricals (probably as it's supposed to be?), in any case,
   * it gets to test correct processing of categoricals.
   *
   * Compare against the results from standard R glm implementation.
   * @throws ExecutionException
   * @throws InterruptedException
   */
@Test
public void testProstate() throws InterruptedException, ExecutionException {
    Key parsed = Key.make("prostate_parsed");
    Key modelKey = Key.make("prostate_model");
    GLMModel model = null;
    File f = TestUtil.find_test_file("smalldata/glm_test/prostate_cat_replaced.csv");
    Frame fr = getFrameForFile(parsed, "smalldata/glm_test/prostate_cat_replaced.csv", new String[] { "ID" }, "CAPSULE");
    try {
        // R results
        //      Coefficients:
        //        (Intercept)           ID          AGE       RACER2       RACER3        DPROS        DCAPS          PSA          VOL      GLEASON
        //          -8.894088     0.001588    -0.009589     0.231777    -0.459937     0.556231     0.556395     0.027854    -0.011355     1.010179
        String[] cfs1 = new String[] { "Intercept", "AGE", "RACE.R2", "RACE.R3", "DPROS", "DCAPS", "PSA", "VOL", "GLEASON" };
        double[] vals = new double[] { -8.14867, -0.01368, 0.32337, -0.38028, 0.55964, 0.49548, 0.02794, -0.01104, 0.97704 };
        new GLM2("GLM test on prostate.", Key.make(), modelKey, new Source(fr, fr.lastVec(), false), Family.binomial).setRegularization(new double[] { 0 }, new double[] { 0 }).doInit().fork().get();
        model = DKV.get(modelKey).get();
        //HEX-1817
        Assert.assertTrue(model.get_params().state == Job.JobState.DONE);
        testHTML(model);
        HashMap<String, Double> coefs = model.coefficients();
        for (int i = 0; i < cfs1.length; ++i) assertEquals(vals[i], coefs.get(cfs1[i]), 1e-4);
        GLMValidation val = model.validation();
        assertEquals(512.3, model.null_validation.residualDeviance(), 1e-1);
        assertEquals(378.3, val.residualDeviance(), 1e-1);
        assertEquals(396.3, val.aic(), 1e-1);
        double prior = 1e-5;
        // test the same data and model with prior, should get the same model except for the intercept
        new GLM2("GLM test on prostate.", Key.make(), modelKey, new Source(fr, fr.lastVec(), false), Family.binomial).setRegularization(new double[] { 0 }, new double[] { 0 }).setPrior(prior).doInit().fork().get();
        GLMModel model2 = DKV.get(modelKey).get();
        for (int i = 0; i < model2.beta().length - 1; ++i) assertEquals(model.beta()[i], model2.beta()[i], 1e-8);
        assertEquals(model.beta()[model.beta().length - 1] - Math.log(model.ymu * (1 - prior) / (prior * (1 - model.ymu))), model2.beta()[model.beta().length - 1], 1e-10);
    } finally {
        fr.delete();
        if (model != null)
            model.delete();
    }
}
Also used : Source(hex.glm.GLM2.Source) File(java.io.File) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)17 Source (hex.glm.GLM2.Source)11 Source (org.orcid.jaxb.model.common_v2.Source)10 Source (org.openstreetmap.osmosis.core.task.v0_6.Source)8 SourceClientId (org.orcid.jaxb.model.common_v2.SourceClientId)5 SecurityCenterClient (com.google.cloud.securitycenter.v1.SecurityCenterClient)4 Source (com.google.cloud.securitycenter.v1.Source)4 IOException (java.io.IOException)4 Sink (org.openstreetmap.osmosis.core.task.v0_6.Sink)3 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 Source (spold2.Source)3 File (java.io.File)2 Source (org.apache.skywalking.apm.network.event.v3.Source)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 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)2