use of org.openforis.idm.metamodel.CodeListLevel in project collect by openforis.
the class MondrianCubeGenerator method extractCodeListName.
private String extractCodeListName(CodeAttributeDefinition codeAttrDef) {
StringBuffer codeListName = new StringBuffer(codeAttrDef.getList().getName());
int levelIdx = codeAttrDef.getLevelIndex();
if (levelIdx != -1) {
CodeList codeList = codeAttrDef.getList();
List<CodeListLevel> codeHierarchy = codeList.getHierarchy();
if (!codeHierarchy.isEmpty()) {
CodeListLevel currentLevel = codeHierarchy.get(levelIdx);
codeListName.append("_");
codeListName.append(currentLevel.getName());
}
}
return codeListName.toString();
}
use of org.openforis.idm.metamodel.CodeListLevel in project collect by openforis.
the class CodeListExportTask method initHeaders.
private void initHeaders() {
ArrayList<String> colNames = new ArrayList<String>();
List<CodeListLevel> levels = list.getHierarchy();
List<String> levelNames = new ArrayList<String>();
if (levels.isEmpty()) {
// fake level for flat list
levelNames.add(FLAT_LIST_LEVEL_NAME);
} else {
for (CodeListLevel level : levels) {
String levelName = level.getName();
levelNames.add(levelName);
}
}
for (String levelName : levelNames) {
colNames.add(levelName + CodeListCSVReader.CODE_COLUMN_SUFFIX);
List<String> langs = list.getSurvey().getLanguages();
// add label columns
for (String lang : langs) {
colNames.add(levelName + CodeListCSVReader.LABEL_COLUMN_SUFFIX + "_" + lang);
}
// add description columns
for (String lang : langs) {
colNames.add(levelName + CodeListCSVReader.DESCRIPTION_COLUMN_SUFFIX + "_" + lang);
}
}
writer.writeHeaders(colNames);
}
use of org.openforis.idm.metamodel.CodeListLevel in project collect by openforis.
the class DatabaseExternalCodeListProvider method createEmptyNextLevelFilters.
protected List<NameValueEntry> createEmptyNextLevelFilters(CodeList list, int level) {
List<NameValueEntry> result = new ArrayList<NameValueEntry>();
List<CodeListLevel> hierarchy = list.getHierarchy();
for (int i = level; i < hierarchy.size(); i++) {
CodeListLevel codeListLevel = hierarchy.get(i);
String name = codeListLevel.getName();
result.add(new NameValueEntry(name, ""));
}
return result;
}
use of org.openforis.idm.metamodel.CodeListLevel in project collect by openforis.
the class ExternalCodeListIntegrationTest method createHierarchicalTestList.
protected void createHierarchicalTestList() {
hierarchicalList = survey.createCodeList();
hierarchicalList.setName(TEST_HIERARCHICAL_CODE_LIST_NAME);
hierarchicalList.setLookupTable(TEST_HIERARCHICAL_CODE_TABLE_NAME);
CodeListLevel level = new CodeListLevel();
level.setName("level1");
hierarchicalList.addLevel(level);
level = new CodeListLevel();
level.setName("level2");
hierarchicalList.addLevel(level);
level = new CodeListLevel();
level.setName("level3");
hierarchicalList.addLevel(level);
survey.addCodeList(hierarchicalList);
}
use of org.openforis.idm.metamodel.CodeListLevel in project collect by openforis.
the class CodeListsVM method addLevel.
@Command
@NotifyChange({ "listLevels" })
public void addLevel() {
List<CodeListLevel> levels = editedItem.getHierarchy();
int levelPosition = levels.size() + 1;
CodeListLevel level = new CodeListLevel();
String generatedName = Labels.getLabel(SURVEY_CODE_LIST_GENERATED_LEVEL_NAME_LABEL_KEY, new Object[] { levelPosition });
level.setName(generatedName);
editedItem.addLevel(level);
}
Aggregations