Search in sources :

Example 1 with ComboboxValueService

use of org.motechproject.mds.service.ComboboxValueService in project motech by motech.

the class MdsBundleIT method verifyComboboxValueUpdate.

private void verifyComboboxValueUpdate() throws Exception {
    getLogger().info("Verifying combobox value update");
    Long entityId = entityService.getEntityByClassName(FOO_CLASS).getId();
    List<Object> allObjects = service.retrieveAll(QueryParams.ascOrder("someDateTime"));
    assertEquals(allObjects.size(), INSTANCE_COUNT);
    Object retrieved = allObjects.get(0);
    Class objClass = retrieved.getClass();
    updateInstance(retrieved, false, "anotherString", "anotherStringCp", new ArrayList(asList("0", "35")), YEAR_LATER, LD_YEAR_AGO, TEST_MAP2, NEW_PERIOD, BYTE_ARRAY_VALUE, DATE_TOMORROW, DOUBLE_VALUE_2, NIGHT_TIME, 3, toEnum(objClass, "two"), JAVA_LD_NOW.minusDays(1), JAVA_NOW.minusHours(1));
    service.update(retrieved);
    ComboboxValueService cbValueService = ServiceRetriever.getService(bundleContext, ComboboxValueService.class);
    assertEquals(asList("0", "2", "35", "4"), cbValueService.getAllValuesForCombobox(FOO_CLASS, "someList"));
}
Also used : ArrayList(java.util.ArrayList) TestClass(org.motechproject.mds.osgi.TestClass) ComboboxValueService(org.motechproject.mds.service.ComboboxValueService)

Example 2 with ComboboxValueService

use of org.motechproject.mds.service.ComboboxValueService in project motech by motech.

the class EntityServiceImpl method getAllComboboxValues.

private List<String> getAllComboboxValues(Entity entity, Field field) {
    ServiceReference<ComboboxValueService> ref = bundleContext.getServiceReference(ComboboxValueService.class);
    if (ref == null) {
        LOGGER.warn("Combobox value service unavailable, ignoring user supplied values");
        ComboboxHolder cbHolder = new ComboboxHolder(field);
        return Arrays.asList(cbHolder.getValues());
    } else {
        ComboboxValueService cbValueService = bundleContext.getService(ref);
        return cbValueService.getAllValuesForCombobox(entity.toDto(), field.toDto());
    }
}
Also used : ComboboxHolder(org.motechproject.mds.domain.ComboboxHolder) ComboboxValueService(org.motechproject.mds.service.ComboboxValueService)

Aggregations

ComboboxValueService (org.motechproject.mds.service.ComboboxValueService)2 ArrayList (java.util.ArrayList)1 ComboboxHolder (org.motechproject.mds.domain.ComboboxHolder)1 TestClass (org.motechproject.mds.osgi.TestClass)1