Search in sources :

Example 36 with LookupFieldDto

use of org.motechproject.mds.dto.LookupFieldDto in project motech by motech.

the class MdsRestBundleIT method prepareEntity.

private void prepareEntity() throws IOException {
    EntityDto entityDto = new EntityDto(ENTITY_NAME);
    entityDto = entityService.createEntity(entityDto);
    FieldDto strField = new FieldDto(null, entityDto.getId(), TypeDto.STRING, new FieldBasicDto("strFieldDisp", "strField", true, false), false, null);
    FieldDto intField = new FieldDto(null, entityDto.getId(), TypeDto.INTEGER, new FieldBasicDto("intFieldDisp", "intField"), false, null);
    entityService.addFields(entityDto, asList(strField, intField));
    RestOptionsDto restOptions = new RestOptionsDto(true, true, true, true, false);
    restOptions.setFieldNames(prepareAllRestFieldNames(entityService.getEntityFields(entityDto.getId())));
    entityService.updateRestOptions(entityDto.getId(), restOptions);
    // a set based lookup for our convenience
    LookupFieldDto intSetLookupField = new LookupFieldDto(null, "intField", LookupFieldType.SET);
    LookupDto setLookup = new LookupDto("byIntSet", false, true, asList(intSetLookupField), false);
    // list return REST lookup
    LookupFieldDto intLookupField = new LookupFieldDto(null, "intField", LookupFieldType.VALUE);
    LookupDto listLookup = new LookupDto("byInt", false, true, asList(intLookupField), false);
    // single return REST lookup
    LookupFieldDto strLookupField = new LookupFieldDto(null, "strField", LookupFieldType.VALUE);
    LookupDto singleLookup = new LookupDto("byStr", true, true, asList(strLookupField), false);
    entityService.addLookups(entityDto.getId(), asList(setLookup, listLookup, singleLookup));
}
Also used : EntityDto(org.motechproject.mds.dto.EntityDto) FieldBasicDto(org.motechproject.mds.dto.FieldBasicDto) LookupDto(org.motechproject.mds.dto.LookupDto) RestOptionsDto(org.motechproject.mds.dto.RestOptionsDto) LookupFieldDto(org.motechproject.mds.dto.LookupFieldDto) FieldDto(org.motechproject.mds.dto.FieldDto) LookupFieldDto(org.motechproject.mds.dto.LookupFieldDto)

Aggregations

LookupFieldDto (org.motechproject.mds.dto.LookupFieldDto)36 LookupDto (org.motechproject.mds.dto.LookupDto)25 FieldDto (org.motechproject.mds.dto.FieldDto)24 EntityDto (org.motechproject.mds.dto.EntityDto)18 ArrayList (java.util.ArrayList)16 Test (org.junit.Test)13 Method (java.lang.reflect.Method)5 TypeDto (org.motechproject.mds.dto.TypeDto)5 Arrays.asList (java.util.Arrays.asList)4 HashMap (java.util.HashMap)4 List (java.util.List)4 RelationshipHolder (org.motechproject.mds.domain.RelationshipHolder)4 FieldBasicDto (org.motechproject.mds.dto.FieldBasicDto)4 FieldTestHelper.lookupFieldDto (org.motechproject.mds.testutil.FieldTestHelper.lookupFieldDto)4 Before (org.junit.Before)3 ComboboxHolder (org.motechproject.mds.domain.ComboboxHolder)3 LinkedList (java.util.LinkedList)2 Field (org.motechproject.mds.domain.Field)2 AdvancedSettingsDto (org.motechproject.mds.dto.AdvancedSettingsDto)2 LookupFieldType (org.motechproject.mds.dto.LookupFieldType)2