use of org.openforis.collect.metamodel.ui.UITable 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);
}
use of org.openforis.collect.metamodel.ui.UITable in project collect by openforis.
the class CollectEarthBalloonGenerator method createTabComponent.
private CETab createTabComponent(EntityDefinition rootEntityDef, UIForm form, boolean main) {
final CollectAnnotations annotations = survey.getAnnotations();
String label = form.getLabel(language);
if (label == null && !isDefaultLanguage()) {
String defaultLanguage = survey.getDefaultLanguage();
label = form.getLabel(defaultLanguage);
}
CETab tab = new CETab(rootEntityDef.getName(), label);
// consider the first tab as the main one
tab.setMain(main);
for (UIFormComponent formComponent : form.getChildren()) {
if (formComponent instanceof NodeDefinitionUIComponent) {
NodeDefinition nodeDef = ((NodeDefinitionUIComponent) formComponent).getNodeDefinition();
if (formComponent instanceof UIField) {
AttributeDefinition attrDef = ((UIField) formComponent).getAttributeDefinition();
String nodeName = nodeDef.getName();
boolean includeInHTML = !(HIDDEN_ATTRIBUTE_NAMES.contains(nodeName) || (annotations.isFromCollectEarthCSV(attrDef) && !annotations.isShowReadOnlyFieldInCollectEarth(attrDef)) || ((UIField) formComponent).isHidden() || ((UIField) formComponent).getAttributeDefinition().isKey());
boolean includeAsAncillaryData = annotations.isIncludedInCollectEarthHeader((AttributeDefinition) nodeDef);
if (includeInHTML) {
CEComponent component = createComponent(nodeDef);
tab.addChild(component);
} else if (includeAsAncillaryData) {
CEAncillaryFields ancillaryDataHeader = tab.getAncillaryDataHeader();
if (ancillaryDataHeader == null) {
ancillaryDataHeader = new CEAncillaryFields("ancillary_data", "Ancillary data");
tab.setAncillaryDataHeader(ancillaryDataHeader);
}
CEComponent component = createComponent(nodeDef);
ancillaryDataHeader.addChild(component);
}
} else if (formComponent instanceof UITable || formComponent instanceof UIFormSection) {
CEComponent component = createComponent(nodeDef);
tab.addChild(component);
} else {
// $NON-NLS-1$
throw new IllegalArgumentException("Form component not supported: " + formComponent.getClass().getName());
}
}
}
return tab;
}
Aggregations