use of org.motechproject.mds.dto.UIDisplayFieldComparator in project motech by motech.
the class CsvImporterExporterTest method setUp.
@Before
public void setUp() {
MotechClassPool.registerServiceInterface(ENTITY_CLASSNAME, DATA_SERVICE_CLASSNAME);
when(bundleContext.getServiceReference(DATA_SERVICE_CLASSNAME)).thenReturn(serviceRef);
when(bundleContext.getService(serviceRef)).thenReturn(motechDataService);
when(motechDataService.getClassType()).thenReturn(Record2.class);
MotechClassPool.registerServiceInterface(RELATED_CLASSNAME, RELATED_SERVICE_CLASSNAME);
when(bundleContext.getServiceReference(RELATED_SERVICE_CLASSNAME)).thenReturn(relatedServiceRef);
when(bundleContext.getService(relatedServiceRef)).thenReturn(relatedDataService);
when(relatedDataService.getClassType()).thenReturn(RelatedClass.class);
when(relatedDataService.findById(0L)).thenReturn(new RelatedClass(0L));
when(relatedDataService.findById(1L)).thenReturn(new RelatedClass(1L));
when(entityInfoReader.getEntityInfo(ENTITY_CLASSNAME)).thenReturn(entityInfo);
when(entityInfoReader.getEntityInfo(ENTITY_ID)).thenReturn(entityInfo);
when(entityInfo.getEntity()).thenReturn(entityDto);
when(entityDto.getClassName()).thenReturn(ENTITY_CLASSNAME);
when(entityDto.getName()).thenReturn(ENTITY_NAME);
when(entityDto.getModule()).thenReturn(ENTITY_MODULE);
when(entityDto.getNamespace()).thenReturn(ENTITY_NAMESPACE);
when(csvExportCustomizer.columnOrderComparator(any(BrowsingSettingsDto.class))).thenReturn(new UIDisplayFieldComparator(new ArrayList<Number>()));
when(csvExportCustomizer.exportDisplayName(any(FieldDto.class))).thenCallRealMethod();
CsvTestHelper.mockRecord2Fields(entityInfo, advancedSettingsDto, browsingSettingsDto);
}
use of org.motechproject.mds.dto.UIDisplayFieldComparator in project motech by motech.
the class JarGeneratorServiceImpl method getFieldsInfo.
private List<FieldInfo> getFieldsInfo(EntityDto entity, List<FieldDto> fields, AdvancedSettingsDto advancedSettings) {
List<FieldInfo> fieldsInfo = new ArrayList<>();
Collections.sort(fields, new UIDisplayFieldComparator(advancedSettings.getBrowsing().getDisplayedFields()));
for (FieldDto field : fields) {
FieldInfo fieldInfo = new FieldInfo();
fieldInfo.setField(field);
boolean exposedByRest = advancedSettings.isFieldExposedByRest(field.getBasic().getName());
fieldInfo.setRestExposed(exposedByRest);
FieldInfo.TypeInfo typeInfo = fieldInfo.getTypeInfo();
typeInfo.setType(field.getType().getTypeClass());
typeInfo.setTaskType(ActionParameterTypeResolver.resolveType(entity, field));
// combobox values
typeInfo.setCombobox(field.getType().isCombobox());
if (field.getType().isCombobox()) {
ComboboxHolder cbHolder = new ComboboxHolder(entity, field);
String[] items = cbHolder.getValues();
if (ArrayUtils.isNotEmpty(items)) {
typeInfo.setItems(Arrays.asList(items));
}
typeInfo.setAllowsMultipleSelection(cbHolder.isCollection());
typeInfo.setAllowUserSupplied(cbHolder.isAllowUserSupplied());
}
fieldsInfo.add(fieldInfo);
}
return fieldsInfo;
}
Aggregations