Search in sources :

Example 1 with DataTable

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;
}
Also used : NoLink(mondrian.olap.MondrianDef.NoLink) DataTable(org.openforis.collect.relational.model.DataTable) FactLink(mondrian.olap.MondrianDef.FactLink) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) ForeignKeyLink(mondrian.olap.MondrianDef.ForeignKeyLink) CodeValueFKColumn(org.openforis.collect.relational.model.CodeValueFKColumn) DimensionLink(mondrian.olap.MondrianDef.DimensionLink)

Example 2 with DataTable

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);
    }
}
Also used : DataTable(org.openforis.collect.relational.model.DataTable) DataExtractor(org.openforis.collect.relational.data.DataExtractor)

Example 3 with DataTable

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);
}
Also used : DataTable(org.openforis.collect.relational.model.DataTable) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) BigInteger(java.math.BigInteger)

Example 4 with DataTable

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
}
Also used : DataTable(org.openforis.collect.relational.model.DataTable) Table(org.openforis.collect.relational.model.Table) DataTable(org.openforis.collect.relational.model.DataTable) RelationalSchemaGenerator(org.openforis.collect.relational.model.RelationalSchemaGenerator) RelationalSchema(org.openforis.collect.relational.model.RelationalSchema) Test(org.junit.Test)

Example 5 with DataTable

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

Aggregations

DataTable (org.openforis.collect.relational.model.DataTable)16 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)6 ArrayList (java.util.ArrayList)5 CodeTable (org.openforis.collect.relational.model.CodeTable)5 BigInteger (java.math.BigInteger)4 Record (org.jooq.Record)4 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)4 DateAttributeDefinition (org.openforis.idm.metamodel.DateAttributeDefinition)4 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)4 CodeValueFKColumn (org.openforis.collect.relational.model.CodeValueFKColumn)3 DataAncestorFKColumn (org.openforis.collect.relational.model.DataAncestorFKColumn)3 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)3 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)3 TaxonAttributeDefinition (org.openforis.idm.metamodel.TaxonAttributeDefinition)3 Field (org.jooq.Field)2 CollectRecord (org.openforis.collect.model.CollectRecord)2 DataPrimaryKeyColumn (org.openforis.collect.relational.model.DataPrimaryKeyColumn)2 RelationalSchema (org.openforis.collect.relational.model.RelationalSchema)2 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)2 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)2