Search in sources :

Example 1 with UIOptions

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

the class UIOptionsBinder method unmarshal.

@Override
public UIOptions unmarshal(Survey survey, String type, String body) {
    XmlPullParser parser = null;
    try {
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        parser = factory.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
        Reader reader = new StringReader(body);
        parser.setInput(reader);
        UIOptions uiOptions = new UIOptions((CollectSurvey) survey);
        UITabSet tabSet = unmarshalTabSet(parser, uiOptions);
        while (tabSet != null) {
            uiOptions.addTabSet(tabSet);
            tabSet = unmarshalTabSet(parser, uiOptions);
        }
        return uiOptions;
    } catch (Exception e) {
        throw new DataInconsistencyException(e.getMessage(), e);
    }
}
Also used : XmlPullParserFactory(org.xmlpull.v1.XmlPullParserFactory) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) UITabSet(org.openforis.collect.metamodel.ui.UITabSet) XmlPullParser(org.xmlpull.v1.XmlPullParser) StringReader(java.io.StringReader) Reader(java.io.Reader) StringReader(java.io.StringReader) DataInconsistencyException(org.openforis.collect.persistence.DataInconsistencyException) IOException(java.io.IOException) DataInconsistencyException(org.openforis.collect.persistence.DataInconsistencyException) XmlParseException(org.openforis.idm.metamodel.xml.XmlParseException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Example 2 with UIOptions

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

the class CollectValidator method isReasonBlankAlwaysSpecified.

static boolean isReasonBlankAlwaysSpecified(Attribute<?, ?> attribute) {
    int fieldCount = 0;
    // ignore unit for numeric attributes
    if (attribute instanceof NumberAttribute || attribute instanceof CodeAttribute) {
        fieldCount = 1;
    } else if (attribute instanceof NumericRangeAttribute) {
        fieldCount = 2;
    } else {
        fieldCount = attribute.getFieldCount();
    }
    AttributeDefinition defn = attribute.getDefinition();
    CollectSurvey survey = (CollectSurvey) defn.getSurvey();
    UIOptions uiOptions = survey.getUIOptions();
    for (int i = 0; i < fieldCount; i++) {
        Field<?> field = attribute.getField(i);
        boolean visible = uiOptions.isVisibleField(defn, field.getName());
        if (visible) {
            FieldSymbol symbol = FieldSymbol.valueOf(field.getSymbol());
            if (symbol == null || !symbol.isReasonBlank()) {
                return false;
            }
        }
    }
    return true;
}
Also used : CodeAttribute(org.openforis.idm.model.CodeAttribute) FieldSymbol(org.openforis.collect.model.FieldSymbol) NumericRangeAttribute(org.openforis.idm.model.NumericRangeAttribute) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NumberAttribute(org.openforis.idm.model.NumberAttribute) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 3 with UIOptions

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

the class TextAttributeDefinitionFormObject method saveTo.

@Override
public void saveTo(T dest, String languageCode) {
    super.saveTo(dest, languageCode);
    Type typeEnum = TextAttributeDefinition.Type.valueOf(type);
    dest.setType(typeEnum);
    dest.setAnnotation(Annotation.AUTOCOMPLETE.getQName(), autocompleteGroup);
    UIOptions uiOptions = getUIOptions(dest);
    uiOptions.setAutoUppercase(dest, autoUppercase);
    CollectAnnotations annotations = ((CollectSurvey) dest.getSurvey()).getAnnotations();
    TextInput textInput = TextInput.valueOf(input);
    annotations.setTextInput(dest, textInput);
    annotations.setGeometry(dest, geometry);
}
Also used : Type(org.openforis.idm.metamodel.TextAttributeDefinition.Type) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey) TextInput(org.openforis.collect.metamodel.CollectAnnotations.TextInput)

Example 4 with UIOptions

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

the class NodeDefinitionFormObject method getUIOptions.

protected UIOptions getUIOptions(NodeDefinition nodeDefn) {
    CollectSurvey survey = (CollectSurvey) nodeDefn.getSurvey();
    UIOptions uiOptions = survey.getUIOptions();
    return uiOptions;
}
Also used : UIOptions(org.openforis.collect.metamodel.ui.UIOptions) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 5 with UIOptions

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

the class SchemaLayoutVM method getRootTabSet.

protected UITabSet getRootTabSet(Treeitem treeItem) {
    if (treeItem != null) {
        TreeNode<NodeDefinition> treeNode = treeItem.getValue();
        NodeDefinition nodeDefn = treeNode.getData();
        UIOptions uiOptions = survey.getUIOptions();
        EntityDefinition rootEntity = nodeDefn.getRootEntity();
        return uiOptions.getAssignedRootTabSet(rootEntity);
    } else {
        return null;
    }
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

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