Search in sources :

Example 6 with CodeListLevel

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();
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) CodeListLevel(org.openforis.idm.metamodel.CodeListLevel)

Example 7 with CodeListLevel

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);
}
Also used : CodeListLevel(org.openforis.idm.metamodel.CodeListLevel) ArrayList(java.util.ArrayList)

Example 8 with CodeListLevel

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;
}
Also used : CodeListLevel(org.openforis.idm.metamodel.CodeListLevel) ArrayList(java.util.ArrayList) NameValueEntry(org.openforis.collect.model.NameValueEntry)

Example 9 with CodeListLevel

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);
}
Also used : CodeListLevel(org.openforis.idm.metamodel.CodeListLevel)

Example 10 with CodeListLevel

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);
}
Also used : CodeListLevel(org.openforis.idm.metamodel.CodeListLevel) NotifyChange(org.zkoss.bind.annotation.NotifyChange) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Aggregations

CodeListLevel (org.openforis.idm.metamodel.CodeListLevel)15 CodeList (org.openforis.idm.metamodel.CodeList)4 ArrayList (java.util.ArrayList)3 Command (org.zkoss.bind.annotation.Command)2 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)2 HashMap (java.util.HashMap)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 MessageUtil (org.openforis.collect.designer.util.MessageUtil)1 ConfirmHandler (org.openforis.collect.designer.util.MessageUtil.ConfirmHandler)1 NameValueEntry (org.openforis.collect.model.NameValueEntry)1 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)1 CodeListItem (org.openforis.idm.metamodel.CodeListItem)1 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)1 Schema (org.openforis.idm.metamodel.Schema)1 NotifyChange (org.zkoss.bind.annotation.NotifyChange)1