use of org.motechproject.mds.dto.BrowsingSettingsDto 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.BrowsingSettingsDto in project motech by motech.
the class Entity method updateBrowsingSettings.
protected void updateBrowsingSettings(AdvancedSettingsDto advancedSettings, boolean shouldSetUiChanged) {
BrowsingSettingsDto dto = advancedSettings.getBrowsing();
if (null == dto) {
dto = new BrowsingSettingsDto();
}
for (Field field : getFields()) {
Long fieldId = field.getId();
boolean isDisplayed = dto.containsDisplayedField(fieldId) && !field.isNonDisplayable();
boolean isFilterable = dto.containsFilterableField(fieldId);
field.setUIDisplayable(isDisplayed);
if ((field.isUIFilterable() != isFilterable) && shouldSetUiChanged) {
field.setUIFilterable(isFilterable);
field.setUiChanged(true);
}
if (isDisplayed) {
long position = dto.indexOfDisplayedField(fieldId);
field.setUIDisplayPosition(position);
}
}
}
Aggregations