use of org.openforis.idm.path.Path in project collect by openforis.
the class RelationalTransformer method initDataTableTransformations.
/**
* Recursively init table transformations
* @param defn
*/
private void initDataTableTransformations(EntityDefinition defn) {
List<NodeDefinition> children = defn.getChildDefinitions();
for (NodeDefinition child : children) {
if (child instanceof EntityDefinition) {
initDataTableTransformations((EntityDefinition) child);
}
}
if (defn.isMultiple()) {
Transformation xform = Transformation.createDefaultTransformation(defn);
Path path = (Path) xform.getRowAxis();
dataTransforms.put(path, xform);
System.out.println(path);
}
}
use of org.openforis.idm.path.Path in project collect by openforis.
the class RelationalTransformer method initDataTableTransformations.
private void initDataTableTransformations() {
this.dataTransforms = new LinkedHashMap<Path, Transformation>();
this.schema = survey.getSchema();
List<EntityDefinition> roots = schema.getRootEntityDefinitions();
for (EntityDefinition root : roots) {
initDataTableTransformations(root);
}
}
use of org.openforis.idm.path.Path in project collect by openforis.
the class RelationalSchemaGenerator method addDataObjects.
/**
* Recursively creates and adds tables and columns
*
* @param rs
* @param parentTable
* @param defn
* @throws CollectRdbException
*/
private void addDataObjects(RelationalSchema rs, DataTable table, NodeDefinition defn, Path relativePath) throws CollectRdbException {
if (defn instanceof EntityDefinition) {
if (defn.isMultiple()) {
// Create table for multiple entity
table = createDataTable(rs, table, defn, relativePath);
rs.addTable(table);
} else {
// just keep a reference
rs.assignAncestorTable((EntityDefinition) defn);
}
// Add child tables and columns
EntityDefinition entityDefn = (EntityDefinition) defn;
for (NodeDefinition child : entityDefn.getChildDefinitions()) {
Path childPath;
if (defn.isMultiple()) {
childPath = Path.relative(child.getName());
} else {
childPath = relativePath.appendElement(child.getName());
}
addDataObjects(rs, table, child, childPath);
}
} else if (defn instanceof AttributeDefinition) {
AttributeDefinition attrDefn = (AttributeDefinition) defn;
CollectSurvey survey = (CollectSurvey) defn.getSurvey();
CollectAnnotations annotations = survey.getAnnotations();
// do not include if it's a calculated attribute and it has not to be included in data export
if (!attrDefn.isCalculated() || annotations.isIncludedInDataExport(defn)) {
if (defn.isMultiple()) {
// Create table for multiple attributes
table = createDataTable(rs, table, defn, relativePath);
rs.addTable(table);
relativePath = Path.relative(".");
}
// Add columns for attributes in entity tables or attribute tables
addDataColumns(rs, table, (AttributeDefinition) defn, relativePath);
}
}
}
use of org.openforis.idm.path.Path in project collect by openforis.
the class RelationalSchemaGenerator method addDataTables.
private void addDataTables(RelationalSchema rs) throws CollectRdbException {
Survey survey = rs.getSurvey();
Schema schema = survey.getSchema();
// Recursively create tables, columns and constraints
List<EntityDefinition> roots = schema.getRootEntityDefinitions();
for (EntityDefinition root : roots) {
Path relativePath = Path.relative(root.getName());
addDataObjects(rs, null, root, relativePath);
}
}
use of org.openforis.idm.path.Path in project collect by openforis.
the class Record method findNodesByPath.
public <N extends Node<?>> List<N> findNodesByPath(String path) {
Path p = Path.parse(path);
@SuppressWarnings("unchecked") List<N> result = (List<N>) p.evaluate(this);
return result;
}
Aggregations