use of org.openforis.collect.io.data.csv.BasicColumnProvider in project collect by openforis.
the class DataCSVReader method calculateIgnoredColumns.
private List<String> calculateIgnoredColumns() {
final CSVDataExportParameters csvExportConfig = new CSVDataExportParameters();
csvExportConfig.setIncludeCodeItemLabelColumn(true);
csvExportConfig.setIncludeEnumeratedEntities(false);
CollectSurvey survey = (CollectSurvey) parentEntityDefinition.getSurvey();
ColumnProviderChain columnProvider = new CSVDataExportColumnProviderGenerator(survey, csvExportConfig).generateColumnProviderChain(parentEntityDefinition);
List<String> result = new ArrayList<String>();
List<String> colNames = getColumnNames();
for (final String colName : colNames) {
final MutableBoolean ignored = new MutableBoolean(false);
columnProvider.traverseProviders(new Visitor<ColumnProvider>() {
public void visit(ColumnProvider p) {
if (!(p instanceof ColumnProviderChain) && p instanceof BasicColumnProvider) {
List<String> finalColumnHeadings = ((BasicColumnProvider) p).generateFinalColumnHeadings();
if (finalColumnHeadings.contains(colName)) {
if (p instanceof CodeColumnProvider && colName.endsWith(csvExportConfig.getFieldHeadingSeparator() + CodeColumnProvider.ITEM_LABEL_SUFFIX)) {
ignored.setTrue();
}
}
}
}
});
if (ignored.booleanValue()) {
result.add(colName);
}
}
return result;
}
Aggregations