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