Search in sources :

Example 96 with NodeDefinition

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

the class ValidationMessageBuilder method getPrettyFormatPath.

public String getPrettyFormatPath(Node<? extends NodeDefinition> node, Locale locale) {
    NodeDefinition defn = node.getDefinition();
    String label = getPrettyLabelText(defn, locale);
    if (defn instanceof EntityDefinition) {
        String keyText = getKeyText((Entity) node, locale);
        if (StringUtils.isBlank(keyText)) {
            label += "[" + (node.getIndex() + 1) + "]";
        } else {
            label += " " + keyText;
        }
    }
    if (node.getParent() == null || node.getParent().getParent() == null) {
        return label;
    } else {
        return getPrettyFormatPath(node.getParent(), locale) + PRETTY_PATH_SEPARATOR + label;
    }
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 97 with NodeDefinition

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

the class DataMarshaller method writeEmptyNodes.

/**
 * Writes empty nodes child of an entity if there is a node state specified.
 *
 * @param serializer
 * @param entity
 * @throws IOException
 */
private void writeEmptyNodes(XmlSerializer serializer, Entity entity) throws IOException {
    EntityDefinition defn = entity.getDefinition();
    List<NodeDefinition> childDefns = defn.getChildDefinitions();
    for (NodeDefinition childDefn : childDefns) {
        if (entity.getCount(childDefn) == 0) {
            State childState = entity.getChildState(childDefn);
            int childStateInt = childState.intValue();
            if (childStateInt > 0) {
                String childName = childDefn.getName();
                serializer.startTag(null, childName);
                serializer.attribute(null, STATE_ATTRIBUTE, Integer.toString(childStateInt));
                serializer.endTag(null, childName);
            }
        }
    }
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) State(org.openforis.idm.model.State) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 98 with NodeDefinition

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

the class DataQueryValidator method validateConditions.

private boolean validateConditions(DataQueryForm target, Errors errors) {
    CollectSurvey survey = sessionManager.getActiveSurvey();
    NodeDefinition contextNodeDef = survey.getSchema().getDefinitionById(target.getEntityDefinitionId());
    NodeDefinition thisNodeDef = survey.getSchema().getDefinitionById(target.getAttributeDefinitionId());
    String expression = target.getConditions();
    boolean valid = validateBooleanExpression(errors, contextNodeDef, thisNodeDef, CONDITIONS_FIELD, expression);
    return valid;
}
Also used : NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 99 with NodeDefinition

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

the class SchemaTreeModel method getSiblingsAndSelf.

public List<SurveyObject> getSiblingsAndSelf(SurveyObject obj, boolean sameType) {
    List<SurveyObject> result = new ArrayList<SurveyObject>();
    TreeNode<SchemaNodeData> treeNode = getTreeNode(obj);
    SchemaTreeNode parent = (SchemaTreeNode) treeNode.getParent();
    List<TreeNode<SchemaNodeData>> children = parent.getChildren();
    for (TreeNode<SchemaNodeData> child : children) {
        SurveyObject surveyObject = child.getData().getSurveyObject();
        if (sameType && ((obj instanceof UITab && surveyObject instanceof UITab) || (obj instanceof NodeDefinition && surveyObject instanceof NodeDefinition))) {
            result.add(surveyObject);
        }
    }
    return result;
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) SurveyObject(org.openforis.idm.metamodel.SurveyObject) TreeNode(org.zkoss.zul.TreeNode) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 100 with NodeDefinition

use of org.openforis.idm.metamodel.NodeDefinition 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)

Aggregations

NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)173 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)70 ArrayList (java.util.ArrayList)42 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)27 Schema (org.openforis.idm.metamodel.Schema)24 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)22 CollectSurvey (org.openforis.collect.model.CollectSurvey)20 Entity (org.openforis.idm.model.Entity)19 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)16 NodeDefinitionVisitor (org.openforis.idm.metamodel.NodeDefinitionVisitor)14 UITab (org.openforis.collect.metamodel.ui.UITab)12 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)11 Survey (org.openforis.idm.metamodel.Survey)11 Test (org.junit.Test)10 DateAttributeDefinition (org.openforis.idm.metamodel.DateAttributeDefinition)9 ModelVersion (org.openforis.idm.metamodel.ModelVersion)9 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)8 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)8 NumberAttributeDefinition (org.openforis.idm.metamodel.NumberAttributeDefinition)8 Node (org.openforis.idm.model.Node)8