Search in sources :

Example 61 with UIOptions

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

the class CalculatedAttributeDefinitionFormObject method saveTo.

@Override
public void saveTo(T dest, String languageCode) {
    super.saveTo(dest, languageCode);
    dest.setType(Type.valueOf(type));
    dest.setFormulas(formulas);
    CollectSurvey survey = (CollectSurvey) dest.getSurvey();
    // include in data export
    CollectAnnotations annotations = survey.getAnnotations();
    annotations.setIncludeInDataExport(dest, includeInDataExport);
    // show in ui
    UIOptions uiOptions = survey.getUIOptions();
    uiOptions.setShowInUI(dest, showInUI);
}
Also used : UIOptions(org.openforis.collect.metamodel.ui.UIOptions) CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 62 with UIOptions

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

the class CalculatedAttributeDefinitionFormObject method loadFrom.

@Override
public void loadFrom(T source, String languageCode) {
    super.loadFrom(source, languageCode);
    Type typeEnum = source.getType();
    type = typeEnum.name();
    formulas = new ArrayList<CalculatedAttributeDefinition.Formula>(source.getFormulas());
    CollectSurvey survey = (CollectSurvey) source.getSurvey();
    // show in UI
    UIOptions uiOptions = survey.getUIOptions();
    showInUI = uiOptions.isShownInUI(source);
    CollectAnnotations annotations = survey.getAnnotations();
    includeInDataExport = annotations.isIncludedInDataExport(source);
}
Also used : Formula(org.openforis.idm.metamodel.CalculatedAttributeDefinition.Formula) Type(org.openforis.idm.metamodel.CalculatedAttributeDefinition.Type) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 63 with UIOptions

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

the class SurveyValidator method validateEntity.

protected List<SurveyValidationResult> validateEntity(EntityDefinition entityDef) {
    List<SurveyValidationResult> results = new ArrayList<SurveyValidator.SurveyValidationResult>();
    List<NodeDefinition> childDefinitions = entityDef.getChildDefinitions();
    if (childDefinitions.size() == 0) {
        // empty entity
        results.add(new SurveyValidationResult(entityDef.getPath(), "survey.validation.error.empty_entity"));
    }
    if (entityDef.isMultiple()) {
        UIOptions uiOptions = ((CollectSurvey) entityDef.getSurvey()).getUIOptions();
        EntityDefinition parentEntity = entityDef.getParentEntityDefinition();
        if (parentEntity != null && parentEntity.isMultiple()) {
            Layout layout = uiOptions.getLayout(entityDef);
            Layout parentLayout = uiOptions.getLayout(parentEntity);
            if (TABLE == layout && TABLE == parentLayout) {
                results.add(new SurveyValidationResult(entityDef.getPath(), "survey.validation.error.nested_tables"));
            }
        }
    }
    if (entityDef.isVirtual()) {
        String generatorExpression = entityDef.getGeneratorExpression();
        String sourceEntityPath = Path.getAbsolutePath(generatorExpression);
        EntityDefinition sourceEntityDef = (EntityDefinition) entityDef.getParentDefinition().getDefinitionByPath(sourceEntityPath);
        for (NodeDefinition sourceChildDef : sourceEntityDef.getChildDefinitions()) {
            boolean skipNode = sourceChildDef instanceof AttributeDefinition && ((AttributeDefinition) sourceChildDef).getReferencedAttribute() != null;
            if (!skipNode) {
                if (entityDef.containsChildDefinition(sourceChildDef.getName())) {
                    NodeDefinition foundChildDef = entityDef.getChildDefinition(sourceChildDef.getName());
                    if (foundChildDef.getClass() != sourceChildDef.getClass()) {
                        results.add(new SurveyValidationResult(Flag.ERROR, entityDef.getPath(), "survey.validation.entity.error.invalid_virtual_node_type", foundChildDef.getName()));
                    }
                } else {
                    results.add(new SurveyValidationResult(Flag.WARNING, entityDef.getPath(), "survey.validation.entity.error.missing_virtual_node", sourceChildDef.getName()));
                }
            }
        }
        for (NodeDefinition virtualChildDef : entityDef.getChildDefinitions()) {
            if (!sourceEntityDef.containsChildDefinition(virtualChildDef.getName())) {
                results.add(new SurveyValidationResult(Flag.WARNING, entityDef.getPath(), "survey.validation.entity.error.source_node_not_found_for_virtual_node", virtualChildDef.getName(), sourceEntityDef.getName()));
            }
        }
    }
    return results;
}
Also used : UIOptions(org.openforis.collect.metamodel.ui.UIOptions) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) NumericAttributeDefinition(org.openforis.idm.metamodel.NumericAttributeDefinition) KeyAttributeDefinition(org.openforis.idm.metamodel.KeyAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) TaxonAttributeDefinition(org.openforis.idm.metamodel.TaxonAttributeDefinition) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Layout(org.openforis.collect.metamodel.ui.UIOptions.Layout) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 64 with UIOptions

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

the class CollectTaxonVernacularLanguageValidator method evaluate.

/**
 * Returns:
 * - OK if vernacular name, language code and language variety are all blank or all specified or
 * 		vernacular name is specified and language code and language variety are not visible in the UI
 * - ERROR if vernacular name is specified but language code not
 * - WARNING if vernacular name is specified and reason blank for language code is specified too
 */
@Override
public ValidationResultFlag evaluate(TaxonAttribute attribute) {
    TaxonAttributeDefinition defn = attribute.getDefinition();
    CollectSurvey survey = (CollectSurvey) defn.getSurvey();
    UIOptions uiOptions = survey.getUIOptions();
    boolean vernacularNameBlank = StringUtils.isBlank(attribute.getVernacularName());
    boolean langCodeBlank = StringUtils.isBlank(attribute.getLanguageCode());
    boolean langCodeVisible = uiOptions.isVisibleField(defn, TaxonAttributeDefinition.LANGUAGE_CODE_FIELD_NAME);
    boolean langVarietyBlank = StringUtils.isBlank(attribute.getLanguageVariety());
    if ((vernacularNameBlank && langCodeBlank && langVarietyBlank) || (!vernacularNameBlank && !(langCodeVisible && langCodeBlank))) {
        return ValidationResultFlag.OK;
    } else {
        CollectRecord record = (CollectRecord) attribute.getRecord();
        Step step = record.getStep();
        if (step == Step.ENTRY && langCodeBlank && FieldSymbol.isReasonBlankSpecified(attribute.getLanguageCodeField())) {
            return ValidationResultFlag.WARNING;
        } else {
            return ValidationResultFlag.ERROR;
        }
    }
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) TaxonAttributeDefinition(org.openforis.idm.metamodel.TaxonAttributeDefinition) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) Step(org.openforis.collect.model.CollectRecord.Step) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 65 with UIOptions

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

the class CollectEarthBalloonGenerator method generateRootComponent.

private CETabSet generateRootComponent() {
    EntityDefinition rootEntityDef = getRootEntity();
    UIOptions uiOptions = survey.getUIOptions();
    UIConfiguration uiConfiguration = survey.getUIConfiguration();
    if (uiConfiguration == null) {
        // $NON-NLS-1$
        throw new IllegalStateException("Error unmarshalling the survey - no UI configruration!");
    }
    if (uiConfiguration.getFormSets().isEmpty()) {
        // no ui configuration defined
        // $NON-NLS-1$ //$NON-NLS-2$
        CETabSet tabSet = new CETabSet("", "");
        // $NON-NLS-1$
        CETab tab = new CETab(rootEntityDef.getName(), "");
        for (NodeDefinition childDef : rootEntityDef.getChildDefinitions()) {
            if (!uiOptions.isHidden(childDef)) {
                tab.addChild(createComponent(childDef));
            }
        }
        tabSet.addTab(tab);
        return tabSet;
    } else {
        // $NON-NLS-1$ //$NON-NLS-2$
        CETabSet tabSet = new CETabSet("", "");
        UIFormSet formSet = uiConfiguration.getMainFormSet();
        for (UIForm form : formSet.getForms()) {
            boolean main = tabSet.getTabs().isEmpty();
            CETab tab = createTabComponent(rootEntityDef, form, main);
            tabSet.addTab(tab);
        }
        return tabSet;
    }
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) UIConfiguration(org.openforis.collect.metamodel.ui.UIConfiguration) UIForm(org.openforis.collect.metamodel.ui.UIForm) UIFormSet(org.openforis.collect.metamodel.ui.UIFormSet)

Aggregations

UIOptions (org.openforis.collect.metamodel.ui.UIOptions)69 CollectSurvey (org.openforis.collect.model.CollectSurvey)38 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)22 UITab (org.openforis.collect.metamodel.ui.UITab)19 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)18 Layout (org.openforis.collect.metamodel.ui.UIOptions.Layout)10 ArrayList (java.util.ArrayList)9 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)9 UITabSet (org.openforis.collect.metamodel.ui.UITabSet)9 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)9 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)5 Schema (org.openforis.idm.metamodel.Schema)5 Command (org.zkoss.bind.annotation.Command)5 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)5 ExternalizedProperty (org.granite.messaging.amf.io.util.externalizer.annotation.ExternalizedProperty)4 SchemaNodeData (org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)4 SchemaTreeNode (org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode)4 SurveyObjectsGenerator (org.openforis.collect.manager.SurveyObjectsGenerator)3 KeyAttributeDefinition (org.openforis.idm.metamodel.KeyAttributeDefinition)3 SurveyObject (org.openforis.idm.metamodel.SurveyObject)3