Search in sources :

Example 26 with AttributeDefinition

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

the class Validator method validate.

public ValidationResults validate(Attribute<?, ?> attribute) {
    ValidationResults results = new ValidationResults();
    // skip validations if attribute is calculated
    AttributeDefinition definition = attribute.getDefinition();
    if (definition.isCalculated()) {
        return results;
    }
    if (!attribute.isEmpty()) {
        validateAttributeValue(attribute, results);
        if (!results.hasErrors()) {
            validateAttributeChecks(attribute, results);
        }
    }
    return results;
}
Also used : KeyAttributeDefinition(org.openforis.idm.metamodel.KeyAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition)

Example 27 with AttributeDefinition

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

the class AbstractExpression method getReferencedNodeDefinition.

private NodeDefinition getReferencedNodeDefinition(NodeDefinition context, NodeDefinition thisNodeDef, String path) throws InvalidExpressionException {
    StringTokenizer tokenizer = new StringTokenizer(path, String.valueOf(Path.SEPARATOR));
    NodeDefinition currentContext = context;
    while (tokenizer.hasMoreTokens()) {
        String pathSection = tokenizer.nextToken();
        if (currentContext instanceof AttributeDefinition && pathSection.startsWith("@")) {
            if (tokenizer.hasMoreTokens()) {
                String message = String.format("cannot have nested levels inside %s", currentContext.getPath());
                throw new InvalidExpressionException(message, compiledExpression.toString());
            }
            checkPropertyExists((AttributeDefinition) currentContext, pathSection);
            return currentContext;
        } else {
            currentContext = getChildDefinition(currentContext, thisNodeDef, pathSection);
        }
    }
    return currentContext;
}
Also used : StringTokenizer(java.util.StringTokenizer) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition)

Example 28 with AttributeDefinition

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

the class NewMondrianSchemaGenerator method generateCube.

private Cube generateCube(EntityDefinition multipleEntityDef) {
    Cube cube = new Cube(determineCubeName(multipleEntityDef));
    cube.caption = extractLabel(multipleEntityDef);
    DataTable dataTable = rdbSchema.getDataTable(multipleEntityDef);
    Table table = new Table(dbSchemaName, dataTable.getName() + "_view");
    cube.tables.add(table);
    addCountMeasure(cube, multipleEntityDef);
    List<EntityDefinition> viewEntityDefinitions = new ArrayList<EntityDefinition>();
    viewEntityDefinitions.addAll(multipleEntityDef.getAncestorEntityDefinitions());
    viewEntityDefinitions.add(multipleEntityDef);
    for (EntityDefinition entityDef : viewEntityDefinitions) {
        List<AttributeDefinition> attributes = entityDef.getNestedAttributes();
        for (AttributeDefinition attrDef : attributes) {
            if (canBeMeasured(attrDef)) {
                Dimension dimension = generateDimension(cube, attrDef);
                cube.dimensions.add(dimension);
                addMeasures(cube, attrDef);
            }
        }
    }
    if (survey.getTarget() == SurveyTarget.COLLECT_EARTH) {
        cube.measures.addAll(1, generateEarthSpecificMeasures());
    }
    return cube;
}
Also used : DataTable(org.openforis.collect.relational.model.DataTable) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) CodeTable(org.openforis.collect.relational.model.CodeTable) DataTable(org.openforis.collect.relational.model.DataTable) ArrayList(java.util.ArrayList) CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) TextAttributeDefinition(org.openforis.idm.metamodel.TextAttributeDefinition) NumericAttributeDefinition(org.openforis.idm.metamodel.NumericAttributeDefinition) DateAttributeDefinition(org.openforis.idm.metamodel.DateAttributeDefinition) TaxonAttributeDefinition(org.openforis.idm.metamodel.TaxonAttributeDefinition) NumberAttributeDefinition(org.openforis.idm.metamodel.NumberAttributeDefinition) TimeAttributeDefinition(org.openforis.idm.metamodel.TimeAttributeDefinition) BooleanAttributeDefinition(org.openforis.idm.metamodel.BooleanAttributeDefinition)

Example 29 with AttributeDefinition

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

the class SchemaVM method refreshNodeForm.

protected void refreshNodeForm() {
    nodeFormInclude.setSrc(null);
    if (editedNode != null) {
        nodeFormInclude.setDynamicProperty("parentEntity", editedNodeParentEntity);
        nodeFormInclude.setDynamicProperty("item", editedNode);
        nodeFormInclude.setDynamicProperty("newItem", newNode);
        String nodeNameTextboxPath;
        String location;
        if (editedNode instanceof UITab) {
            location = Resources.Component.TAB.getLocation();
            nodeNameTextboxPath = TAB_NAME_LABEL_PATH;
        } else if (editedNode instanceof EntityDefinition) {
            location = Resources.Component.ENTITY.getLocation();
            nodeNameTextboxPath = ENTITY_NAME_TEXTBOX_PATH;
        } else {
            AttributeType attributeType = AttributeType.valueOf((AttributeDefinition) editedNode);
            String locationFormat = Resources.Component.ATTRIBUTE.getLocation();
            String attributeTypeShort = attributeType.name().toLowerCase(Locale.ENGLISH);
            location = MessageFormat.format(locationFormat, attributeTypeShort);
            nodeNameTextboxPath = ATTRIBUTE_NAME_TEXTBOX_PATH;
        }
        nodeFormInclude.setSrc(location);
        // set focus on name textbox
        Textbox nodeNameTextbox = (Textbox) Path.getComponent(nodeFormInclude.getSpaceOwner(), nodeNameTextboxPath);
        nodeNameTextbox.setFocus(true);
    }
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) AttributeType(org.openforis.collect.designer.metamodel.AttributeType) Textbox(org.zkoss.zul.Textbox) KeyAttributeDefinition(org.openforis.idm.metamodel.KeyAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition)

Example 30 with AttributeDefinition

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

the class SchemaVM method changeEditedNodeParentEntity.

private void changeEditedNodeParentEntity(EntityDefinition newParentEntity) {
    // update parent entity
    NodeDefinition node = (NodeDefinition) editedNode;
    Schema schema = survey.getSchema();
    schema.changeParentEntity(node, newParentEntity);
    // update tab
    UIOptions uiOptions = survey.getUIOptions();
    uiOptions.removeTabAssociation(node);
    if (node instanceof AttributeDefinition) {
        survey.getAnnotations().setMeasurementAttribute((AttributeDefinition) node, false);
    }
    // update ui
    refreshTreeModel();
    editedNodeParentEntity = newParentEntity;
    selectTreeNode(editedNode);
    treeModel.showSelectedNode();
    notifyChange("selectedTreeNode", "editedNode");
}
Also used : Schema(org.openforis.idm.metamodel.Schema) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) KeyAttributeDefinition(org.openforis.idm.metamodel.KeyAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition)

Aggregations

AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)107 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)47 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)37 ArrayList (java.util.ArrayList)33 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)27 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)21 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)20 DateAttributeDefinition (org.openforis.idm.metamodel.DateAttributeDefinition)18 NumberAttributeDefinition (org.openforis.idm.metamodel.NumberAttributeDefinition)18 CollectSurvey (org.openforis.collect.model.CollectSurvey)17 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)16 KeyAttributeDefinition (org.openforis.idm.metamodel.KeyAttributeDefinition)16 TextAttributeDefinition (org.openforis.idm.metamodel.TextAttributeDefinition)12 TimeAttributeDefinition (org.openforis.idm.metamodel.TimeAttributeDefinition)12 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)11 Schema (org.openforis.idm.metamodel.Schema)10 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)9 Entity (org.openforis.idm.model.Entity)9 Value (org.openforis.idm.model.Value)9 RangeAttributeDefinition (org.openforis.idm.metamodel.RangeAttributeDefinition)8