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;
}
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());
}
}
}
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;
}
Aggregations