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);
}
}
}
}
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;
}
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);
}
}
}
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);
}
}
}
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);
}
Aggregations