use of org.openforis.collect.model.NameValueEntry in project collect by openforis.
the class DatabaseExternalCodeListProvider method addSurveyFilter.
protected NameValueEntry[] addSurveyFilter(CodeList list, NameValueEntry... filters) {
NameValueEntry surveyFilter = createSurveyFilter(list);
NameValueEntry[] newFilters = Arrays.copyOf(filters, filters.length + 1);
newFilters[filters.length] = surveyFilter;
return newFilters;
}
use of org.openforis.collect.model.NameValueEntry in project collect by openforis.
the class DatabaseExternalCodeListProvider method visitChildItems.
@Override
public void visitChildItems(final ExternalCodeListItem item, final Visitor<CodeListItem> visitor) {
final CodeList list = item.getCodeList();
int itemLevel = item.getLevel();
final int childrenLevel = itemLevel + 1;
if (childrenLevel > list.getHierarchy().size()) {
return;
}
List<NameValueEntry> filters = createChildItemsFilters(item);
String childrenKeyColName = getLevelKeyColumnName(list, childrenLevel);
String[] notNullColumns = new String[] { childrenKeyColName };
dynamicTableDao.visitRows(list.getLookupTable(), filters.toArray(new NameValueEntry[filters.size()]), notNullColumns, new Visitor<Map<String, String>>() {
public void visit(Map<String, String> row) {
ExternalCodeListItem item = parseRow(row, list, childrenLevel);
visitor.visit(item);
}
});
}
use of org.openforis.collect.model.NameValueEntry in project collect by openforis.
the class DatabaseExternalCodeListProvider method addSurveyFilter.
protected void addSurveyFilter(CodeList list, List<NameValueEntry> filters) {
NameValueEntry surveyFilter = createSurveyFilter(list);
filters.add(surveyFilter);
}
use of org.openforis.collect.model.NameValueEntry in project collect by openforis.
the class DatabaseExternalCodeListProvider method getItem.
@Override
public ExternalCodeListItem getItem(CodeAttribute attribute) {
CodeAttributeDefinition defn = attribute.getDefinition();
CodeList list = defn.getList();
List<NameValueEntry> filters = new ArrayList<NameValueEntry>();
addSurveyFilter(list, filters);
CodeAttribute codeParent = attribute.getCodeParent();
while (codeParent != null) {
String colName = getLevelKeyColumnName(codeParent);
String codeValue = getCodeValue(codeParent);
filters.add(new NameValueEntry(colName, codeValue));
codeParent = codeParent.getCodeParent();
}
String colName = getLevelKeyColumnName(attribute);
String codeValue = getCodeValue(attribute);
filters.add(new NameValueEntry(colName, codeValue));
int level = defn.getLevelPosition();
List<NameValueEntry> emptyNextLevelsFilters = createEmptyNextLevelFilters(list, level);
filters.addAll(emptyNextLevelsFilters);
Map<String, String> row = dynamicTableDao.loadRow(list.getLookupTable(), filters.toArray(new NameValueEntry[filters.size()]));
if (row == null) {
return null;
} else {
ExternalCodeListItem result = parseRow(row, list, level);
return result;
}
}
use of org.openforis.collect.model.NameValueEntry in project collect by openforis.
the class DatabaseExternalCodeListProvider method getRootItem.
public ExternalCodeListItem getRootItem(CodeList list, String code) {
List<NameValueEntry> filters = new ArrayList<NameValueEntry>();
addSurveyFilter(list, filters);
List<NameValueEntry> emptyNextLevelsFilters = createEmptyNextLevelFilters(list, 1);
filters.addAll(emptyNextLevelsFilters);
String firstLevelKeyColName = getLevelKeyColumnName(list, 1);
NameValueEntry itemFilter = new NameValueEntry(firstLevelKeyColName, code);
filters.add(itemFilter);
Map<String, String> row = dynamicTableDao.loadRow(list.getLookupTable(), filters.toArray(new NameValueEntry[0]));
return parseRow(row, list, 1);
}
Aggregations