Search in sources :

Example 1 with Criteria

use of org.sagebionetworks.bridge.models.Criteria in project BridgeServer2 by Sage-Bionetworks.

the class DynamoAppConfigDao method createAppConfig.

public AppConfig createAppConfig(AppConfig appConfig) {
    checkNotNull(appConfig);
    appConfig.setDeleted(false);
    Criteria criteria = persistCriteria(appConfig);
    appConfig.setCriteria(criteria);
    mapper.save(appConfig);
    return appConfig;
}
Also used : Criteria(org.sagebionetworks.bridge.models.Criteria)

Example 2 with Criteria

use of org.sagebionetworks.bridge.models.Criteria in project BridgeServer2 by Sage-Bionetworks.

the class DynamoAppConfigDao method loadCriteria.

private void loadCriteria(AppConfig config) {
    Criteria criteria = criteriaDao.getCriteria(getKey(config));
    if (criteria == null) {
        criteria = Criteria.create();
    }
    criteria.setKey(getKey(config));
    config.setCriteria(criteria);
}
Also used : Criteria(org.sagebionetworks.bridge.models.Criteria)

Example 3 with Criteria

use of org.sagebionetworks.bridge.models.Criteria in project BridgeServer2 by Sage-Bionetworks.

the class DynamoAppConfigDao method persistCriteria.

private Criteria persistCriteria(AppConfig config) {
    Criteria criteria = config.getCriteria();
    criteria.setKey(getKey(config));
    return criteriaDao.createOrUpdateCriteria(criteria);
}
Also used : Criteria(org.sagebionetworks.bridge.models.Criteria)

Example 4 with Criteria

use of org.sagebionetworks.bridge.models.Criteria in project BridgeServer2 by Sage-Bionetworks.

the class TestUtilsTest method newCriteria.

private Criteria newCriteria() {
    // Don't use an interface method, that's what we're testing here.
    Criteria criteria = new DynamoCriteria();
    criteria.setMinAppVersion(IOS, 5);
    criteria.setMaxAppVersion(IOS, 15);
    criteria.setMaxAppVersion(ANDROID, 12);
    criteria.setAllOfGroups(ALL_OF_GROUPS);
    criteria.setNoneOfGroups(NONE_OF_GROUPS);
    return criteria;
}
Also used : DynamoCriteria(org.sagebionetworks.bridge.dynamodb.DynamoCriteria) DynamoCriteria(org.sagebionetworks.bridge.dynamodb.DynamoCriteria) Criteria(org.sagebionetworks.bridge.models.Criteria)

Example 5 with Criteria

use of org.sagebionetworks.bridge.models.Criteria in project BridgeServer2 by Sage-Bionetworks.

the class DynamoAppConfigDaoTest method createAppConfig.

@Test
public void createAppConfig() {
    AppConfig config = AppConfig.create();
    // verify this cannot be created true
    config.setDeleted(true);
    // set in AppConfigService
    config.setGuid(GUID);
    Criteria criteria = Criteria.create();
    config.setCriteria(criteria);
    AppConfig result = dao.createAppConfig(config);
    assertSame(result, config);
    assertFalse(result.isDeleted());
    assertEquals(criteria.getKey(), CRITERIA_KEY);
    verify(mockMapper).save(config);
    verify(mockCriteriaDao).createOrUpdateCriteria(criteria);
}
Also used : AppConfig(org.sagebionetworks.bridge.models.appconfig.AppConfig) Criteria(org.sagebionetworks.bridge.models.Criteria) Test(org.testng.annotations.Test)

Aggregations

Criteria (org.sagebionetworks.bridge.models.Criteria)82 Test (org.testng.annotations.Test)51 Subpopulation (org.sagebionetworks.bridge.models.subpopulations.Subpopulation)19 CriteriaScheduleStrategy (org.sagebionetworks.bridge.models.schedules.CriteriaScheduleStrategy)10 ScheduleCriteria (org.sagebionetworks.bridge.models.schedules.ScheduleCriteria)10 Template (org.sagebionetworks.bridge.models.templates.Template)9 SchedulePlan (org.sagebionetworks.bridge.models.schedules.SchedulePlan)8 JsonNode (com.fasterxml.jackson.databind.JsonNode)7 GuidVersionHolder (org.sagebionetworks.bridge.models.GuidVersionHolder)5 DynamoCriteria (org.sagebionetworks.bridge.dynamodb.DynamoCriteria)4 AppConfig (org.sagebionetworks.bridge.models.appconfig.AppConfig)4 DynamoSubpopulation (org.sagebionetworks.bridge.dynamodb.DynamoSubpopulation)3 InvalidEntityException (org.sagebionetworks.bridge.exceptions.InvalidEntityException)3 NotificationTopic (org.sagebionetworks.bridge.models.notifications.NotificationTopic)3 Schedule (org.sagebionetworks.bridge.models.schedules.Schedule)3 TestUtils.getNotificationTopic (org.sagebionetworks.bridge.TestUtils.getNotificationTopic)2 EntityNotFoundException (org.sagebionetworks.bridge.exceptions.EntityNotFoundException)2 CriteriaContext (org.sagebionetworks.bridge.models.CriteriaContext)2 TemplateRevision (org.sagebionetworks.bridge.models.templates.TemplateRevision)2 Condition (com.amazonaws.services.dynamodbv2.model.Condition)1