Search in sources :

Example 41 with UIOptions

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

the class NodeDefinitionFormObject method saveTo.

@Override
public void saveTo(T dest, String languageCode) {
    super.saveTo(dest, languageCode);
    if (!name.equals(dest.getName())) {
        dest.rename(name);
    }
    dest.setLabel(Type.HEADING, languageCode, headingLabel);
    dest.setLabel(Type.INSTANCE, languageCode, instanceLabel);
    dest.setLabel(Type.NUMBER, languageCode, numberLabel);
    dest.setLabel(Type.ABBREVIATED, languageCode, abbreviatedLabel);
    dest.setLabel(Type.REPORTING, languageCode, reportingLabel);
    dest.setPrompt(Prompt.Type.HANDHELD, languageCode, handheldPromptLabel);
    dest.setPrompt(Prompt.Type.INTERVIEW, languageCode, interviewPromptLabel);
    dest.setPrompt(Prompt.Type.PAPER, languageCode, paperPromptLabel);
    dest.setPrompt(Prompt.Type.PC, languageCode, pcPromptLabel);
    dest.setDescription(languageCode, description);
    dest.setMinCountExpression(null);
    dest.setMaxCountExpression(null);
    dest.setRequiredExpression(null);
    CollectSurvey survey = (CollectSurvey) dest.getSurvey();
    CollectAnnotations annotations = survey.getAnnotations();
    annotations.setAutoGenerateMinItems(dest, isMultiple() && StringUtils.isNotBlank(getMinCountExpression()) && autoGenerateMinItems);
    if (dest instanceof EntityDefinition && parentDefinition == null) {
        // root entity is always true
        dest.setMultiple(true);
    } else if (!(dest instanceof AttributeDefinition && calculated)) {
        dest.setMultiple(multiple);
        if (multiple) {
            dest.setMinCountExpression(StringUtils.trimToNull(minCountExpression));
            dest.setMaxCountExpression(StringUtils.trimToNull(maxCountExpression));
        } else {
            RequirenessType requirenessTypeEnum = RequirenessType.valueOf(requirenessType);
            switch(requirenessTypeEnum) {
                case ALWAYS_REQUIRED:
                    dest.setAlwaysRequired();
                    break;
                case REQUIRED_WHEN:
                    dest.setRequiredExpression(StringUtils.trimToNull(requiredWhenExpression));
                    break;
                default:
                    break;
            }
        }
    }
    UIOptions uiOptions = survey.getUIOptions();
    RelevanceType relevanceTypeEnum = RelevanceType.valueOf(relevanceType);
    switch(relevanceTypeEnum) {
        case RELEVANT_WHEN:
            dest.setRelevantExpression(StringUtils.trimToNull(relevantExpression));
            uiOptions.setHideWhenNotRelevant(dest, hideWhenNotRelevant);
            break;
        default:
            dest.setRelevantExpression(null);
            uiOptions.setHideWhenNotRelevant(dest, false);
    }
    if (dest instanceof AttributeDefinition) {
        AttributeDefinition attrDef = (AttributeDefinition) dest;
        annotations.setFromCollectEarthCSV(attrDef, fromCollectEarthCSV);
        annotations.setIncludedInCollectEarthHeader(attrDef, includedInCollectEarthHeader);
        annotations.setShowReadOnlyFieldInCollectEarth(attrDef, showReadOnlyFieldInCollectEarth);
        annotations.setHideKeyInCollectEarthRecordList(attrDef, hideKeyInCollectEarthRecordList);
        annotations.setShowInSummary(attrDef, showInSummary);
        annotations.setQualifier(attrDef, qualifier);
    }
    // layout
    uiOptions.setColumn(dest, column);
    uiOptions.setColumnSpan(dest, columnSpan);
    uiOptions.setWidth(dest, width);
    uiOptions.setLabelWidth(dest, labelWidth);
    uiOptions.setLabelOrientation(dest, Orientation.valueOf(labelOrientation));
    if (dest instanceof Calculable) {
        ((Calculable) dest).setCalculated(calculated);
        // include in data export
        annotations.setIncludeInDataExport(dest, includeInDataExport);
        // show in ui
        uiOptions.setHidden(dest, !showInUI);
    }
    annotations.setBackgroundColor(dest, backgroundColor);
    annotations.setBackgroundAlpha(dest, fromTransparencyToAlpha(backgroundTransparency));
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Calculable(org.openforis.idm.metamodel.Calculable) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 42 with UIOptions

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

the class AttributeDefinitionFormObject method saveTo.

@Override
public void saveTo(T dest, String languageCode) {
    super.saveTo(dest, languageCode);
    dest.setKey(key);
    // save attribute defaults
    dest.removeAllAttributeDefaults();
    if (attributeDefaults != null) {
        for (AttributeDefault attrDefault : attributeDefaults) {
            dest.addAttributeDefault(attrDefault);
        }
    }
    dest.setReferencedAttribute(referencedAttributePath == null ? null : (AttributeDefinition) dest.getSchema().getDefinitionByPath(referencedAttributePath));
    CollectSurvey survey = (CollectSurvey) dest.getSurvey();
    CollectAnnotations annotations = survey.getAnnotations();
    annotations.setPhaseToApplyDefaultValue(dest, Step.valueOf(phaseToApplyDefaultValue));
    annotations.setEditable(dest, editable);
    annotations.setMeasurementAttribute(dest, measurement);
    annotations.setShowInMapBalloon(dest, showInMapBalloon);
    // save checks
    dest.removeAllChecks();
    if (checks != null) {
        for (Check<?> check : checks) {
            dest.addCheck(check);
        }
    }
    UIOptions uiOptions = getUIOptions(dest);
    uiOptions.setVisibleFields(dest, visibleFields);
}
Also used : UIOptions(org.openforis.collect.metamodel.ui.UIOptions) AttributeDefault(org.openforis.idm.metamodel.AttributeDefault) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 43 with UIOptions

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

the class UITreeModelCreator method createChildNodes.

private List<AbstractNode<SchemaNodeData>> createChildNodes(EntityDefinition entityDefn) {
    List<AbstractNode<SchemaNodeData>> childNodes = new ArrayList<AbstractNode<SchemaNodeData>>();
    CollectSurvey survey = (CollectSurvey) entityDefn.getSurvey();
    UIOptions uiOptions = survey.getUIOptions();
    UITab assignedTab = uiOptions.getAssignedTab(entityDefn);
    // include node definitions
    List<NodeDefinition> childDefns = entityDefn.getChildDefinitions();
    Collection<? extends AbstractNode<SchemaNodeData>> schemaTreeNodes = createNodes(assignedTab, childDefns);
    childNodes.addAll(schemaTreeNodes);
    // include tabs
    if (entityDefn.isMultiple() && uiOptions.getLayout(entityDefn) == Layout.FORM) {
        List<UITab> tabs = uiOptions.getTabsAssignableToChildren(entityDefn, false);
        Collection<? extends AbstractNode<SchemaNodeData>> tabNodes = createNodes(tabs);
        childNodes.addAll(tabNodes);
    }
    return childNodes;
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) AbstractNode(org.openforis.collect.designer.component.BasicTreeModel.AbstractNode) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey) SchemaNodeData(org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)

Example 44 with UIOptions

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

the class UITreeModelCreator method createChildNodes.

private List<SchemaTreeNode> createChildNodes(UITab tab) {
    List<SchemaTreeNode> result = new ArrayList<SchemaTreeNode>();
    // add schema node definition tree nodes
    UIOptions uiOptions = tab.getUIOptions();
    List<NodeDefinition> childDefns = uiOptions.getNodesPerTab(tab, false);
    List<SchemaTreeNode> childSchemaNodes = createNodes(tab, childDefns);
    result.addAll(childSchemaNodes);
    // add children unassigned tab tree nodes
    // List<UITab> unassignedTabs = new ArrayList<UITab>();
    // UITabSet rootTabSet = tab.getRootTabSet();
    // EntityDefinition rootEntity = uiOptions.getRootEntityDefinition(rootTabSet);
    // 
    // for (UITab childTab : tab.getTabs()) {
    // boolean unassigned = uiOptions.isUnassigned(childTab, rootEntity);
    // if ( unassigned ) {
    // unassignedTabs.add(childTab);
    // }
    // }
    // List<SchemaTreeNode> unassignedTabNodes = fromTabsList(unassignedTabs, version, includeAttributes, labelLanguage);
    // result.addAll(unassignedTabNodes);
    List<UITab> nestedTabs = new ArrayList<UITab>();
    for (UITab childTab : tab.getTabs()) {
        List<NodeDefinition> nodes = uiOptions.getNodesPerTab(childTab, false);
        boolean toBeAdded = true;
        for (NodeDefinition nestedTabChildNode : nodes) {
            for (NodeDefinition childDefn : childDefns) {
                if (childDefn == nestedTabChildNode || (childDefn instanceof EntityDefinition && nestedTabChildNode.isDescendantOf((EntityDefinition) childDefn))) {
                    toBeAdded = false;
                    break;
                }
            }
        }
        if (toBeAdded) {
            nestedTabs.add(childTab);
        }
    }
    Collection<SchemaTreeNode> tabNodes = createNodes(nestedTabs);
    result.addAll(tabNodes);
    return result;
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) SchemaTreeNode(org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 45 with UIOptions

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

the class EntityDefinitionFormObject method loadFrom.

@Override
public void loadFrom(T source, String languageCode) {
    super.loadFrom(source, languageCode);
    virtual = source.isVirtual();
    generatorExpression = source.getGeneratorExpression();
    enumerate = source.isEnumerate();
    UIOptions uiOptions = getUIOptions(source);
    Layout layout = uiOptions.getLayout(source);
    layoutType = layout.name();
    countInRecordSummary = uiOptions.getCountInSumamryListValue(source);
    showRowNumbers = uiOptions.getShowRowNumbersValue(source);
    direction = uiOptions.getDirection(source).getValue();
}
Also used : Layout(org.openforis.collect.metamodel.ui.UIOptions.Layout) UIOptions(org.openforis.collect.metamodel.ui.UIOptions)

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