Search in sources :

Example 1 with UIModelObject

use of org.openforis.collect.metamodel.ui.UIModelObject in project collect by openforis.

the class SurveyMigrator method migrate.

public void migrate(final CollectSurvey survey) {
    fixCodeListHierarchyLevelNames(survey);
    if (survey.getCollectVersion().compareTo(ENUMERATE_VERSION) < 0) {
        survey.getSchema().traverse(new NodeDefinitionVisitor() {

            public void visit(NodeDefinition defn) {
                if (defn instanceof EntityDefinition && defn.isMultiple()) {
                    EntityDefinition entityDefn = (EntityDefinition) defn;
                    UIConfiguration uiConfig = survey.getUIConfiguration();
                    if (uiConfig != null) {
                        UIModelObject uiModelObject = uiConfig.getModelObjectByNodeDefinitionId(entityDefn.getId());
                        CollectAnnotations annotations = survey.getAnnotations();
                        if (survey.getTarget() == SurveyTarget.COLLECT_EARTH || uiModelObject == null || uiModelObject instanceof UITable) {
                            if (defn.getMinCountExpression() != null) {
                                annotations.setAutoGenerateMinItems(entityDefn, true);
                            }
                            if (entityDefn.isEnumerable()) {
                                entityDefn.setEnumerate(true);
                            }
                        }
                    }
                }
            }
        });
    }
    survey.setCollectVersion(VERSION);
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) UIModelObject(org.openforis.collect.metamodel.ui.UIModelObject) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) UIConfiguration(org.openforis.collect.metamodel.ui.UIConfiguration) UITable(org.openforis.collect.metamodel.ui.UITable) CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) NodeDefinitionVisitor(org.openforis.idm.metamodel.NodeDefinitionVisitor)

Aggregations

CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)1 UIConfiguration (org.openforis.collect.metamodel.ui.UIConfiguration)1 UIModelObject (org.openforis.collect.metamodel.ui.UIModelObject)1 UITable (org.openforis.collect.metamodel.ui.UITable)1 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)1 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)1 NodeDefinitionVisitor (org.openforis.idm.metamodel.NodeDefinitionVisitor)1