Search in sources :

Example 1 with NodeLabel

use of org.openforis.idm.metamodel.NodeLabel in project collect by openforis.

the class SchemaUpdater method generateAlias.

public EntityDefinition generateAlias(EntityDefinition sourceDef, String sourceFilterAttributeName, EntityDefinition targetParentDef, String targetFilterAttributeName) {
    EntityDefinition aliasDef = survey.getSchema().cloneDefinition(sourceDef, targetFilterAttributeName);
    // add "Alias" suffix to labels
    for (NodeLabel nodeLabel : aliasDef.getLabels()) {
        aliasDef.setLabel(nodeLabel.getType(), nodeLabel.getLanguage(), nodeLabel.getText() + " Alias");
    }
    aliasDef.traverse(new NodeDefinitionVisitor() {

        public void visit(NodeDefinition def) {
            if (def instanceof AttributeDefinition) {
                AttributeDefinition attrDef = (AttributeDefinition) def;
                attrDef.setCalculated(false);
                attrDef.removeAllChecks();
                attrDef.removeAllAttributeDefaults();
            }
            def.setRelevantExpression(null);
            def.setRequiredExpression(null);
        }
    });
    targetParentDef.addChildDefinition(aliasDef);
    aliasDef.setVirtual(true);
    aliasDef.setGeneratorExpression(generateAliasGeneratorExpression(sourceDef, sourceFilterAttributeName, targetParentDef, targetFilterAttributeName));
    UIOptions uiOptions = survey.getUIOptions();
    // prevent layout errors
    uiOptions.setLayout(aliasDef, Layout.FORM);
    uiOptions.setHidden(aliasDef, true);
    return aliasDef;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) NodeLabel(org.openforis.idm.metamodel.NodeLabel) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) NodeDefinitionVisitor(org.openforis.idm.metamodel.NodeDefinitionVisitor)

Example 2 with NodeLabel

use of org.openforis.idm.metamodel.NodeLabel in project collect by openforis.

the class UIOptions method copyLabels.

protected void copyLabels(EntityDefinition nodeDefn, UITab tab) {
    removeLabels(tab);
    List<NodeLabel> labels = nodeDefn.getLabels();
    for (NodeLabel label : labels) {
        if (label.getType() == NodeLabel.Type.INSTANCE) {
            tab.setLabel(label.getLanguage(), label.getText());
        }
    }
}
Also used : NodeLabel(org.openforis.idm.metamodel.NodeLabel)

Example 3 with NodeLabel

use of org.openforis.idm.metamodel.NodeLabel in project collect by openforis.

the class UIOptionsMigrator method getLabelsByType.

protected List<NodeLabel> getLabelsByType(NodeDefinition nodeDefn, NodeLabel.Type type) {
    List<NodeLabel> result = new ArrayList<NodeLabel>();
    List<NodeLabel> labels = nodeDefn.getLabels();
    for (NodeLabel label : labels) {
        if (label.getType() == type) {
            result.add(label);
        }
    }
    return result;
}
Also used : NodeLabel(org.openforis.idm.metamodel.NodeLabel) ArrayList(java.util.ArrayList)

Aggregations

NodeLabel (org.openforis.idm.metamodel.NodeLabel)3 ArrayList (java.util.ArrayList)1 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)1 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)1 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)1 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)1 NodeDefinitionVisitor (org.openforis.idm.metamodel.NodeDefinitionVisitor)1