Search in sources :

Example 1 with VersionableSurveyObject

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

the class VersioningVM method getReferencesInSchema.

protected List<VersionableSurveyObject> getReferencesInSchema(ModelVersion version) {
    List<VersionableSurveyObject> references = new ArrayList<VersionableSurveyObject>();
    Schema schema = survey.getSchema();
    List<EntityDefinition> rootEntities = schema.getRootEntityDefinitions();
    Stack<NodeDefinition> stack = new Stack<NodeDefinition>();
    stack.addAll(rootEntities);
    while (!stack.isEmpty()) {
        NodeDefinition defn = stack.pop();
        if (isVersionInUse(version, defn)) {
            references.add(defn);
        }
        if (defn instanceof EntityDefinition) {
            stack.addAll(((EntityDefinition) defn).getChildDefinitions());
        }
    }
    return references;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) VersionableSurveyObject(org.openforis.idm.metamodel.VersionableSurveyObject) Schema(org.openforis.idm.metamodel.Schema) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) Stack(java.util.Stack)

Example 2 with VersionableSurveyObject

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

the class VersioningVM method getReferencesInCodeLists.

protected List<VersionableSurveyObject> getReferencesInCodeLists(ModelVersion version) {
    List<VersionableSurveyObject> references = new ArrayList<VersionableSurveyObject>();
    List<CodeList> codeLists = survey.getCodeLists();
    for (CodeList codeList : codeLists) {
        if (isVersionInUse(version, codeList)) {
            references.add(codeList);
        }
        if (!codeList.isExternal()) {
            List<CodeListItem> items = codeList.getItems();
            Stack<CodeListItem> itemsStack = new Stack<CodeListItem>();
            itemsStack.addAll(items);
            while (!itemsStack.isEmpty()) {
                CodeListItem item = itemsStack.pop();
                if (isVersionInUse(version, item)) {
                    references.add(item);
                }
                itemsStack.addAll(item.getChildItems());
            }
        }
    }
    return references;
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) VersionableSurveyObject(org.openforis.idm.metamodel.VersionableSurveyObject) ArrayList(java.util.ArrayList) CodeListItem(org.openforis.idm.metamodel.CodeListItem) Stack(java.util.Stack)

Aggregations

ArrayList (java.util.ArrayList)2 Stack (java.util.Stack)2 VersionableSurveyObject (org.openforis.idm.metamodel.VersionableSurveyObject)2 CodeList (org.openforis.idm.metamodel.CodeList)1 CodeListItem (org.openforis.idm.metamodel.CodeListItem)1 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)1 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)1 Schema (org.openforis.idm.metamodel.Schema)1