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