use of org.motechproject.mds.dto.SettingDto in project motech by motech.
the class MdsBundleIT method prepareTestEntities.
private void prepareTestEntities() throws IOException {
getLogger().info("Preparing entities for testing");
EntityDto entityDto = new EntityDto(9999L, FOO);
entityDto = entityService.createEntity(entityDto);
SchemaHolder schemaHolder = entityService.getSchema();
generator.regenerateMdsDataBundle(schemaHolder);
List<FieldDto> fields = new ArrayList<>();
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.BOOLEAN, new FieldBasicDto("Some Boolean", "someBoolean"), false, null));
// this field is unique
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.STRING, new FieldBasicDto("Some String", "someString", false, true), false, null, null, asList(new SettingDto("mds.form.label.textarea", false, BOOLEAN)), null));
// test with capitalized name
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.STRING, new FieldBasicDto("Capital Name", "CapitalName"), false, null, null, asList(new SettingDto("mds.form.label.textarea", false, BOOLEAN)), null));
fields.add(new FieldDto(null, entityDto.getId(), COLLECTION, new FieldBasicDto("Some List", "someList"), false, null, null, asList(new SettingDto(Constants.Settings.COMBOBOX_VALUES, new LinkedList<>(), COLLECTION, REQUIRE), new SettingDto(Constants.Settings.ALLOW_USER_SUPPLIED, true, BOOLEAN), new SettingDto(Constants.Settings.ALLOW_MULTIPLE_SELECTIONS, true, BOOLEAN)), null));
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.DATETIME, new FieldBasicDto("dateTime", "someDateTime"), false, null));
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.DATETIME8, new FieldBasicDto("someJavaDateTime", "someJavaDateTime"), false, null));
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.MAP, new FieldBasicDto("someMap", "someMap"), false, Arrays.asList(new MetadataDto(MAP_KEY_TYPE, String.class.getName()), new MetadataDto(MAP_VALUE_TYPE, TestClass.class.getName())), null, null, null));
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.PERIOD, new FieldBasicDto("somePeriod", "somePeriod"), false, null));
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.BLOB, new FieldBasicDto("someBlob", "someBlob"), false, null));
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.LOCAL_DATE, new FieldBasicDto("someLocalDate", "someLocalDate"), false, null));
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.LOCAL_DATE8, new FieldBasicDto("someJavaDate", "someJavaDate"), false, null));
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.DATE, new FieldBasicDto("someDate", "someDate"), false, null));
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.TIME, new FieldBasicDto("someTime", "someTime"), false, null));
List<SettingDto> decimalSettings = asList(new SettingDto("mds.form.label.precision", 10), new SettingDto("mds.form.label.scale", 5));
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.DOUBLE, new FieldBasicDto("Some Decimal", "someDecimal"), false, null, null, decimalSettings, null));
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.INTEGER, new FieldBasicDto("someInteger", "someInt"), false, null));
fields.add(new FieldDto(null, entityDto.getId(), TypeDto.COLLECTION, new FieldBasicDto("Some Enum", "someEnum"), false, null, null, asList(new SettingDto(Constants.Settings.COMBOBOX_VALUES, asList("one", "two", "three"), COLLECTION, REQUIRE), new SettingDto(Constants.Settings.ALLOW_USER_SUPPLIED, false, BOOLEAN), new SettingDto(Constants.Settings.ALLOW_MULTIPLE_SELECTIONS, false, BOOLEAN)), null));
entityService.addFields(entityDto, fields);
List<LookupDto> lookups = new ArrayList<>();
List<LookupFieldDto> lookupFields = new ArrayList<>();
lookupFields.add(new LookupFieldDto(null, "someBoolean", LookupFieldType.VALUE));
lookups.add(new LookupDto("By boolean", false, false, lookupFields, true, "byBool", asList("someBoolean")));
lookupFields = new ArrayList<>();
lookupFields.add(new LookupFieldDto(null, "someString", LookupFieldType.VALUE));
lookups.add(new LookupDto("By unique String", true, false, lookupFields, true, "byUniqueString", asList("someString")));
lookupFields = new ArrayList<>();
lookupFields.add(new LookupFieldDto(null, "someBoolean", LookupFieldType.VALUE));
lookupFields.add(new LookupFieldDto(null, "someDateTime", LookupFieldType.RANGE));
lookupFields.add(new LookupFieldDto(null, "someString", LookupFieldType.SET));
lookupFields.add(new LookupFieldDto(null, "someList", LookupFieldType.VALUE));
lookups.add(new LookupDto("Combined", false, false, lookupFields, true));
lookupFields = new ArrayList<>();
lookupFields.add(new LookupFieldDto(null, "someInt", LookupFieldType.VALUE, "<="));
lookups.add(new LookupDto("With custom operator", false, false, lookupFields, true, "customOperator", asList("someInt")));
lookupFields = new ArrayList<>();
lookupFields.add(new LookupFieldDto(null, "someString", LookupFieldType.VALUE, "matches()"));
lookups.add(new LookupDto("With matches", false, false, lookupFields, true, "matchesOperator", asList("someString")));
lookupFields = new ArrayList<>();
lookupFields.add(new LookupFieldDto(null, "someString", LookupFieldType.VALUE, Constants.Operators.MATCHES_CASE_INSENSITIVE));
lookups.add(new LookupDto("With matches case insensitive", false, false, lookupFields, true, "matchesOperatorCI", singletonList("someString")));
entityService.addLookups(entityDto.getId(), lookups);
schemaHolder = entityService.getSchema();
generator.regenerateMdsDataBundle(schemaHolder);
getLogger().info("Entities ready for testing");
}
use of org.motechproject.mds.dto.SettingDto in project motech by motech.
the class FieldTestHelper method comboboxFieldDto.
public static FieldDto comboboxFieldDto(Long id, String name, String dispName, boolean allowMultiSelect, boolean allowUserSupplied, String values) {
FieldDto field = fieldDto(id, name, Collection.class.getName(), dispName, null);
field.addSetting(new SettingDto(Constants.Settings.ALLOW_MULTIPLE_SELECTIONS, allowMultiSelect, TypeDto.BOOLEAN));
field.addSetting(new SettingDto(Constants.Settings.ALLOW_USER_SUPPLIED, allowUserSupplied, TypeDto.BOOLEAN));
field.addSetting(new SettingDto(Constants.Settings.COMBOBOX_VALUES, values));
return field;
}
use of org.motechproject.mds.dto.SettingDto in project motech by motech.
the class ComboboxValueRepositoryContextIT method getEntityFields.
@Override
protected List<FieldDto> getEntityFields() {
// combobox with multiple selection - string collection field
FieldDto cbFieldMulti = new FieldDto(CB_FIELD_MULTI_NAME, CB_FIELD_MULTI_NAME, TypeDto.COLLECTION, false, false, null, "tooltip", "placeholder");
cbFieldMulti.addSetting(new SettingDto(Constants.Settings.ALLOW_USER_SUPPLIED, Constants.Util.TRUE));
cbFieldMulti.addSetting(new SettingDto(Constants.Settings.ALLOW_MULTIPLE_SELECTIONS, Constants.Util.TRUE));
// combobox without multiple selection - string field
FieldDto cbFieldSingle = new FieldDto(CB_FIELD_SINGLE_NAME, CB_FIELD_SINGLE_NAME, TypeDto.COLLECTION, false, false, null, "tooltip2", "placeholder2");
cbFieldSingle.addSetting(new SettingDto(Constants.Settings.ALLOW_USER_SUPPLIED, Constants.Util.TRUE));
cbFieldSingle.addSetting(new SettingDto(Constants.Settings.ALLOW_MULTIPLE_SELECTIONS, Constants.Util.FALSE));
return asList(cbFieldMulti, cbFieldSingle);
}
use of org.motechproject.mds.dto.SettingDto in project motech by motech.
the class CsvTestHelper method comboboxField.
private static FieldDto comboboxField(Long id, String name, boolean isList) {
FieldDto fieldDto = new FieldDto(name, name + " Disp", TypeDto.COLLECTION);
fieldDto.setId(id);
fieldDto.addMetadata(new MetadataDto(Constants.MetadataKeys.ENUM_CLASS_NAME, RecordEnum.class.getName()));
SettingDto settingDto = new SettingDto(Constants.Settings.ALLOW_MULTIPLE_SELECTIONS, String.valueOf(isList), TypeDto.BOOLEAN);
fieldDto.addSetting(settingDto);
return fieldDto;
}
use of org.motechproject.mds.dto.SettingDto in project motech by motech.
the class Field method updateSettings.
private void updateSettings(List<SettingDto> settingsList) {
if (settingsList != null) {
for (SettingDto settingDto : settingsList) {
FieldSetting setting = getSettingByName(settingDto.getName());
if (setting != null) {
Object value = settingDto.getValue();
setting.setValue(TypeHelper.format(value));
}
}
}
}
Aggregations