use of mondrian.olap.MondrianDef.PhysicalSchema in project collect by openforis.
the class Mondrian4SchemaGenerator method generatePhysicalSchema.
// private String getDateFieldLevelType(String fieldName) {
// if (DateAttributeDefinition.YEAR_FIELD_NAME.equals(fieldName)) {
// return "TimeYears";
// } else if (DateAttributeDefinition.MONTH_FIELD_NAME.equals(fieldName)) {
// return "TimeMonths";
// } else if(DateAttributeDefinition.DAY_FIELD_NAME.equals(fieldName)) {
// return "TimeDays";
// } else {
// throw new IllegalArgumentException("Unexpected date attribute field name: " + fieldName);
// }
// }
private PhysicalSchema generatePhysicalSchema() {
PhysicalSchema physicalSchema = new PhysicalSchema();
for (org.openforis.collect.relational.model.Table<?> rdbTable : rdbSchema.getTables()) {
Table table = new Table();
table.name = rdbTable.getName();
PrimaryKeyConstraint pkConstraint = rdbTable.getPrimaryKeyConstraint();
table.keyColumn = pkConstraint.getPrimaryKeyColumn().getName();
physicalSchema.children.add(table);
// add foreign keys
for (ReferentialConstraint referentialConstraint : rdbTable.getReferentialContraints()) {
UniquenessConstraint referencedKey = referentialConstraint.getReferencedKey();
org.openforis.collect.relational.model.Table<?> referencedRdbTable = referencedKey.getTable();
Link link = new Link();
link.source = rdbTable.getName();
link.target = referencedRdbTable.getName();
ForeignKey foreignKey = new ForeignKey();
for (org.openforis.collect.relational.model.Column<?> referencedRdbColumn : referencedKey.getColumns()) {
Column fkColumn = new Column();
fkColumn.name = referencedRdbColumn.getName();
foreignKey.list().add(fkColumn);
}
link.foreignKey = foreignKey;
physicalSchema.children.add(link);
}
}
return physicalSchema;
}
use of mondrian.olap.MondrianDef.PhysicalSchema in project collect by openforis.
the class Mondrian4SchemaGenerator method generateSchema.
public MondrianDef.Schema generateSchema() {
MondrianDef.Schema schema = new MondrianDef.Schema();
schema.metamodelVersion = VERSION_4_0;
schema.name = survey.getName();
PhysicalSchema physicalSchema = generatePhysicalSchema();
schema.children.add(physicalSchema);
for (DataTable dataTable : rdbSchema.getDataTables()) {
schema.children.add(createCube(dataTable));
}
return schema;
}
Aggregations