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));
}
Aggregations