use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class SurveyValidator method validateEnumeratingCodeListsNotChanged.
protected List<SurveyValidationResult> validateEnumeratingCodeListsNotChanged(CollectSurvey oldPublishedSurvey, CollectSurvey newSurvey) {
List<SurveyValidationResult> results = new ArrayList<SurveyValidationResult>();
List<CodeList> codeLists = newSurvey.getCodeLists();
for (CodeList codeList : codeLists) {
CodeList oldCodeList = oldPublishedSurvey.getCodeListById(codeList.getId());
if (oldCodeList != null && oldCodeList.isEnumeratingList()) {
results.addAll(validateEnumeratingCodeListNotChanged(oldCodeList, codeList));
}
}
return results;
}
use of org.openforis.idm.metamodel.CodeList 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.CodeList in project collect by openforis.
the class CollectEarthProjectFileCreatorImpl method getCodeListImageFilePath.
public static String getCodeListImageFilePath(CodeListItem item) {
CodeList codeList = item.getCodeList();
String zipImageFileName = StringUtils.join(Arrays.asList(EARTH_FILES_FOLDER_NAME, "img", "code_list", codeList.getId(), item.getId(), item.getImageFileName()), "/");
return zipImageFileName;
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class SurveyErrorsPopUpVM method createErrors.
protected static List<SurveyObjectError> createErrors(List<? extends SurveyObject> items) {
List<SurveyObjectError> errors = new ArrayList<SurveyErrorsPopUpVM.SurveyObjectError>();
for (SurveyObject item : items) {
String path = null;
String message = null;
if (item instanceof NodeDefinition) {
path = ((NodeDefinition) item).getPath();
} else if (item instanceof CodeList) {
path = ((CodeList) item).getName();
} else if (item instanceof CodeListItem) {
CodeListItem codeListItem = (CodeListItem) item;
path = getPath(codeListItem);
}
SurveyObjectError error = new SurveyObjectError(path, message);
errors.add(error);
}
return errors;
}
use of org.openforis.idm.metamodel.CodeList in project collect by openforis.
the class SurveyErrorsPopUpVM method getPath.
protected static String getPath(CodeListItem codeListItem) {
CodeList codeList = codeListItem.getCodeList();
StringBuilder sb = new StringBuilder();
CodeListItem currentItem = codeListItem;
while (currentItem != null) {
sb.insert(0, currentItem.getCode());
sb.insert(0, "/");
currentItem = currentItem.getParentItem();
}
sb.insert(0, codeList.getName());
return sb.toString();
}
Aggregations