use of org.openforis.collect.model.NameValueEntry in project collect by openforis.
the class DatabaseExternalCodeListProvider method getParentKeys.
protected Collection<NameValueEntry> getParentKeys(ExternalCodeListItem item) {
Set<NameValueEntry> result = new HashSet<NameValueEntry>();
Map<String, String> parentKeyByLevel = item.getParentKeyByLevel();
Set<Entry<String, String>> entrySet = parentKeyByLevel.entrySet();
for (Entry<String, String> entry : entrySet) {
NameValueEntry keyValuePair = new NameValueEntry(entry);
result.add(keyValuePair);
}
return result;
}
use of org.openforis.collect.model.NameValueEntry in project collect by openforis.
the class DatabaseExternalCodeListProvider method getChildItems.
@Override
public List<ExternalCodeListItem> getChildItems(ExternalCodeListItem item) {
CodeList list = item.getCodeList();
int itemLevel = item.getLevel();
int childrenLevel = itemLevel + 1;
if (childrenLevel > list.getHierarchy().size()) {
return Collections.emptyList();
}
List<NameValueEntry> filters = createChildItemsFilters(item);
String childrenKeyColName = getLevelKeyColumnName(list, childrenLevel);
String[] notNullColumns = new String[] { childrenKeyColName };
List<Map<String, String>> rows = dynamicTableDao.loadRows(list.getLookupTable(), filters.toArray(new NameValueEntry[filters.size()]), notNullColumns);
List<ExternalCodeListItem> result = new ArrayList<ExternalCodeListItem>();
for (Map<String, String> row : rows) {
ExternalCodeListItem child = parseRow(row, list, childrenLevel);
result.add(child);
}
return result;
}
use of org.openforis.collect.model.NameValueEntry in project collect by openforis.
the class DatabaseExternalCodeListProvider method getRootItems.
@Override
public List<ExternalCodeListItem> getRootItems(CodeList list) {
List<NameValueEntry> filters = new ArrayList<NameValueEntry>();
addSurveyFilter(list, filters);
List<NameValueEntry> emptyNextLevelsFilters = createEmptyNextLevelFilters(list, 1);
filters.addAll(emptyNextLevelsFilters);
List<Map<String, String>> rows = dynamicTableDao.loadRows(list.getLookupTable(), filters.toArray(new NameValueEntry[0]));
List<ExternalCodeListItem> result = new ArrayList<ExternalCodeListItem>();
for (Map<String, String> row : rows) {
ExternalCodeListItem item = parseRow(row, list, 1);
result.add(item);
}
return result;
}
use of org.openforis.collect.model.NameValueEntry in project collect by openforis.
the class DatabaseExternalCodeListProvider method getChildItem.
public ExternalCodeListItem getChildItem(ExternalCodeListItem item, String code) {
CodeList list = item.getCodeList();
List<NameValueEntry> filters = createChildItemsFilters(item);
int itemLevel = item.getLevel();
int childrenLevel = itemLevel + 1;
String childrenLevelColName = getLevelKeyColumnName(list, childrenLevel);
NameValueEntry codeFilter = new NameValueEntry(childrenLevelColName, code);
filters.add(codeFilter);
Map<String, String> row = dynamicTableDao.loadRow(list.getLookupTable(), filters.toArray(new NameValueEntry[0]));
return parseRow(row, list, childrenLevel);
}
use of org.openforis.collect.model.NameValueEntry in project collect by openforis.
the class DatabaseExternalCodeListProvider method hasChildItems.
public boolean hasChildItems(ExternalCodeListItem item) {
CodeList list = item.getCodeList();
List<NameValueEntry> filters = createChildItemsFilters(item);
int itemLevel = item.getLevel();
int childrenLevel = itemLevel + 1;
String childrenKeyColName = getLevelKeyColumnName(list, childrenLevel);
String[] notNullColumns = new String[] { childrenKeyColName };
return dynamicTableDao.exists(list.getLookupTable(), filters.toArray(new NameValueEntry[0]), notNullColumns);
}
Aggregations