Search in sources :

Example 11 with CodeListLevel

use of org.openforis.idm.metamodel.CodeListLevel in project collect by openforis.

the class SurveyMigrator method fixCodeListHierarchyLevelNames.

protected void fixCodeListHierarchyLevelNames(CollectSurvey survey) {
    List<CodeList> codeLists = survey.getCodeLists();
    for (CodeList list : codeLists) {
        List<CodeListLevel> hierarchy = list.getHierarchy();
        for (CodeListLevel level : hierarchy) {
            String name = level.getName();
            Pattern pattern = Pattern.compile(INTERNAL_NAME_REGEX);
            Matcher matcher = pattern.matcher(name);
            if (!matcher.matches()) {
                String fixedName = fixInternalName(name);
                level.setName(fixedName);
            }
        }
    }
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) Pattern(java.util.regex.Pattern) CodeListLevel(org.openforis.idm.metamodel.CodeListLevel) Matcher(java.util.regex.Matcher)

Example 12 with CodeListLevel

use of org.openforis.idm.metamodel.CodeListLevel in project collect by openforis.

the class CollectSurvey method addSamplingDesignCodeList.

public CodeList addSamplingDesignCodeList() {
    CodeList list = createCodeList();
    list.setName(SAMPLING_DESIGN_CODE_LIST_NAME);
    list.setLookupTable(OfcSamplingDesign.OFC_SAMPLING_DESIGN.getName());
    // add hierarchy levels
    String[] levels = new String[] { OfcSamplingDesign.OFC_SAMPLING_DESIGN.LEVEL1.getName(), OfcSamplingDesign.OFC_SAMPLING_DESIGN.LEVEL2.getName(), OfcSamplingDesign.OFC_SAMPLING_DESIGN.LEVEL3.getName() };
    for (String name : levels) {
        CodeListLevel level = new CodeListLevel();
        level.setName(name);
        list.addLevel(level);
    }
    addCodeList(list);
    return list;
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) CodeListLevel(org.openforis.idm.metamodel.CodeListLevel)

Example 13 with CodeListLevel

use of org.openforis.idm.metamodel.CodeListLevel in project collect by openforis.

the class CodeListImportTask method addLevelsToCodeList.

private void addLevelsToCodeList() {
    if (levels != null && levels.size() > 1) {
        for (String levelName : levels) {
            CodeListLevel level = new CodeListLevel();
            level.setName(levelName);
            codeList.addLevel(level);
        }
    }
}
Also used : CodeListLevel(org.openforis.idm.metamodel.CodeListLevel)

Example 14 with CodeListLevel

use of org.openforis.idm.metamodel.CodeListLevel in project collect by openforis.

the class CodeListImportProcess method addLevelsToCodeList.

protected void addLevelsToCodeList() {
    if (levels != null && levels.size() > 1) {
        for (String levelName : levels) {
            CodeListLevel level = new CodeListLevel();
            level.setName(levelName);
            codeList.addLevel(level);
        }
    }
}
Also used : CodeListLevel(org.openforis.idm.metamodel.CodeListLevel)

Example 15 with CodeListLevel

use of org.openforis.idm.metamodel.CodeListLevel in project collect by openforis.

the class CodeListExportProcess method initHeaders.

private void initHeaders(CsvWriter writer, CollectSurvey survey, CodeList list) {
    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 = survey.getLanguages();
        for (String lang : langs) {
            colNames.add(levelName + CodeListCSVReader.LABEL_COLUMN_SUFFIX + "_" + lang);
        }
        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)

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