use of org.openforis.collect.relational.model.DataTable in project collect by openforis.
the class Mondrian4SchemaGenerator method createDimensionLink.
private DimensionLink createDimensionLink(Dimension dimension, AttributeDefinition attrDef) {
DimensionLink dimensionLink;
if (attrDef instanceof CodeAttributeDefinition) {
CodeAttributeDefinition codeAttrDef = (CodeAttributeDefinition) attrDef;
if (codeAttrDef.isMultiple()) {
dimensionLink = new NoLink();
} else if (codeAttrDef.getList().isExternal()) {
dimensionLink = new FactLink();
} else {
dimensionLink = new ForeignKeyLink();
DataTable dataTable = rdbSchema.getDataTable(attrDef.getParentEntityDefinition());
CodeValueFKColumn fkColumn = dataTable.getForeignKeyCodeColumn((CodeAttributeDefinition) attrDef);
((ForeignKeyLink) dimensionLink).foreignKeyColumn = fkColumn.getName();
}
} else {
dimensionLink = new FactLink();
}
dimensionLink.dimension = dimension.name;
return dimensionLink;
}
use of org.openforis.collect.relational.model.DataTable in project collect by openforis.
the class JooqDatabaseExporter method insertRecordData.
@Override
public void insertRecordData(CollectRecord record, ProgressListener progressListener) {
for (DataTable table : schema.getDataTables()) {
DataExtractor extractor = DataExtractorFactory.getRecordDataExtractor(table, record);
batchExecutor.addInserts(extractor);
}
}
use of org.openforis.collect.relational.model.DataTable in project collect by openforis.
the class JooqDatabaseExporter method deleteAttribute.
@Override
public void deleteAttribute(int recordId, int attributeId, int definitionId) {
DataTable tableToDeleteFor = schema.getDataTableByDefinitionId(definitionId);
NodeDefinition defToDeleteFor = tableToDeleteFor.getNodeDefinition();
BigInteger pkValue = getTableArtificialPK(recordId, defToDeleteFor, attributeId);
batchExecutor.addDelete(tableToDeleteFor, tableToDeleteFor.getPrimaryKeyColumn(), pkValue);
}
use of org.openforis.collect.relational.model.DataTable in project collect by openforis.
the class RelationalSchemaGeneratorTest method testGenerator.
@Test
public void testGenerator() throws Exception {
RelationalSchemaGenerator rsg = new RelationalSchemaGenerator();
RelationalSchema rs = rsg.generateSchema(survey, "archenland1");
List<Table<?>> tables = rs.getTables();
// Debug
for (Table<?> table : tables) {
DataTable t = (DataTable) table;
t.print(System.out);
}
// TODO proper integration test
}
use of org.openforis.collect.relational.model.DataTable 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;
}
Aggregations