use of org.openforis.collect.relational.data.Row in project collect by openforis.
the class CodeTableDataExtractor method next.
@Override
public Row next() {
Row row;
if (isDefaultCodeRowToBeCreated()) {
row = createDefaultCodeRow();
} else {
CodeListItem item = items.get(itemIndex);
row = extractRow(item);
itemIndex++;
}
count++;
return row;
}
use of org.openforis.collect.relational.data.Row in project collect by openforis.
the class CodeTableDataExtractor method extractRow.
public Row extractRow(CodeListItem source) {
Row row = new Row(table);
List<Column<?>> columns = table.getColumns();
for (int i = 0; i < columns.size(); i++) {
Column<?> col = columns.get(i);
Object val = extractValue(source, col);
row.setValue(i, val);
}
return row;
}
use of org.openforis.collect.relational.data.Row in project collect by openforis.
the class CodeTableDataExtractor method createDefaultCodeRow.
protected Row createDefaultCodeRow() {
Row row = new Row(table);
List<Column<?>> columns = table.getColumns();
for (int i = 0; i < columns.size(); i++) {
@SuppressWarnings("rawtypes") Column col = columns.get(i);
Object val;
if (col instanceof CodePrimaryKeyColumn) {
val = DEFAULT_CODE_ROW_ID;
} else if (col instanceof CodeListCodeColumn) {
val = table.getDefaultCode();
} else if (col instanceof CodeLabelColumn) {
val = table.getDefaultCodeLabel(((CodeLabelColumn) col).getLanguageCode());
} else {
val = null;
}
row.setValue(i, val);
}
return row;
}
use of org.openforis.collect.relational.data.Row in project collect by openforis.
the class DataTableDataExtractor method extractDataInternal.
private void extractDataInternal(DataTable table, Node<?> source, Dataset data) {
// Extract data from this node
Row row = extractRow(source);
data.addRow(row);
// Extract data from descendants
for (DataTable childTable : table.getChildTables()) {
Path path = childTable.getRelativePath();
List<Node<?>> children = path.evaluate(source);
for (Node<?> child : children) {
extractDataInternal(childTable, child, data);
}
}
}
use of org.openforis.collect.relational.data.Row in project collect by openforis.
the class DataTableDataExtractor method next.
@Override
public Row next() {
Node<?> source = nodes.get(nextIndex++);
Row row = extractRow(source);
return row;
}
Aggregations