Search in sources :

Example 81 with CodeList

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

Example 82 with CodeList

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

Example 83 with CodeList

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

Example 84 with CodeList

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

Example 85 with CodeList

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

Aggregations

CodeList (org.openforis.idm.metamodel.CodeList)88 CodeListItem (org.openforis.idm.metamodel.CodeListItem)24 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)20 ArrayList (java.util.ArrayList)16 CollectSurvey (org.openforis.collect.model.CollectSurvey)15 PersistedCodeListItem (org.openforis.idm.metamodel.PersistedCodeListItem)14 Test (org.junit.Test)10 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)10 HashMap (java.util.HashMap)7 NameValueEntry (org.openforis.collect.model.NameValueEntry)7 CodeListService (org.openforis.idm.metamodel.CodeListService)7 ExternalCodeListItem (org.openforis.idm.metamodel.ExternalCodeListItem)6 List (java.util.List)5 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)5 ModelVersion (org.openforis.idm.metamodel.ModelVersion)5 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)5 Code (org.openforis.idm.model.Code)5 Record (org.openforis.idm.model.Record)5 CodeAttributeDefinitionFormObject (org.openforis.collect.designer.form.CodeAttributeDefinitionFormObject)4 CodeListImportProcess (org.openforis.collect.manager.codelistimport.CodeListImportProcess)4