use of org.openforis.idm.metamodel.EntityDefinition in project collect by openforis.
the class CollectValidator method isRootEntityKey.
private boolean isRootEntityKey(Attribute<?, ?> attribute) {
AttributeDefinition attrDef = attribute.getDefinition();
if (attrDef.isKey()) {
Record record = attribute.getRecord();
Entity rootEntity = record.getRootEntity();
EntityDefinition rootEntityDef = rootEntity.getDefinition();
List<AttributeDefinition> keyAttributeDefs = rootEntityDef.getKeyAttributeDefinitions();
for (AttributeDefinition keyDef : keyAttributeDefs) {
if (keyDef.getId() == attrDef.getId()) {
return true;
}
}
}
return false;
}
use of org.openforis.idm.metamodel.EntityDefinition in project collect by openforis.
the class Mondrian4SchemaGenerator method createCube.
private Cube createCube(DataTable dataTable) {
NodeDefinition nodeDef = dataTable.getNodeDefinition();
Cube cube = new Cube();
cube.name = nodeDef.getName();
MeasureGroups measureGroups = new MondrianDef.MeasureGroups();
MeasureGroup measureGroup = new MeasureGroup();
measureGroup.name = cube.name;
Measures measures = new Measures();
List<Measure> measureList = createMeasures(dataTable);
measures.list().addAll(measureList);
measureGroup.children.add(measures);
measureGroup.table = dataTable.getName();
DimensionLinks dimensionLinks = new DimensionLinks();
measureGroup.children.add(dimensionLinks);
measureGroups.list().add(measureGroup);
cube.children.add(measureGroups);
if (nodeDef instanceof EntityDefinition) {
Dimensions dimensions = new Dimensions();
Queue<NodeDefinition> queue = new LinkedList<NodeDefinition>();
queue.addAll(((EntityDefinition) nodeDef).getChildDefinitions());
while (!queue.isEmpty()) {
NodeDefinition def = queue.poll();
if (def instanceof AttributeDefinition) {
AttributeDefinition attrDef = (AttributeDefinition) def;
Dimension dimension = createDimension(dataTable, attrDef);
if (dimension != null) {
dimensions.list().add(dimension);
// add dimension link
DimensionLink dimensionLink = createDimensionLink(dimension, attrDef);
dimensionLinks.list().add(dimensionLink);
}
} else if (!def.isMultiple()) {
queue.addAll(((EntityDefinition) def).getChildDefinitions());
}
}
cube.children.add(dimensions);
}
return cube;
}
use of org.openforis.idm.metamodel.EntityDefinition 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.metamodel.EntityDefinition 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.metamodel.EntityDefinition in project collect by openforis.
the class DataCleansingChainIntegrationTest method testSimpleChain.
@Test
public void testSimpleChain() {
DataCleansingChain chain = new DataCleansingChain(survey);
chain.setTitle("Test chain");
chain.setDescription("This is just a test");
DataQuery query = new DataQuery(survey);
EntityDefinition treeDef = (EntityDefinition) survey.getSchema().getDefinitionByPath("/cluster/plot/tree");
NumberAttributeDefinition dbhDef = (NumberAttributeDefinition) survey.getSchema().getDefinitionByPath("/cluster/plot/tree/dbh");
query.setTitle("Find trees with invalid DBH");
query.setEntityDefinition(treeDef);
query.setAttributeDefinition(dbhDef);
query.setConditions("dbh > 20");
dataQueryManager.save(query, user);
int initialCount = countResults(query);
assertEquals(1, initialCount);
DataCleansingStep step = new DataCleansingStep(survey);
step.setTitle("Step 1");
step.setDescription("This is the step 1");
step.setQuery(query);
DataCleansingStepValue updateValue = new DataCleansingStepValue();
updateValue.setUpdateType(UpdateType.ATTRIBUTE);
// set dbh = 20
updateValue.setFixExpression("20");
step.addUpdateValue(updateValue);
stepManager.save(step, user);
chain.addStep(step);
chainManager.save(chain, user);
DataCleansingChainExecutorJob job = jobManager.createJob(DataCleansingChainExecutorJob.class);
job.setSurvey(survey);
job.setChain(chain);
job.setRecordStep(Step.ENTRY);
job.setActiveUser(user);
jobManager.start(job, false);
int finalCount = countResults(query);
assertEquals(0, finalCount);
}
Aggregations