use of org.pentaho.metadata.model.concept.types.TableType in project pentaho-kettle by pentaho.
the class ConceptUtil method indexOfFactTable.
public static int indexOfFactTable(LogicalModel logicalModel) {
for (int i = 0; i < logicalModel.getLogicalTables().size(); i++) {
LogicalTable logicalTable = logicalModel.getLogicalTables().get(i);
TableType type = getTableType(logicalTable);
if (type == TableType.FACT) {
return i;
}
}
return -1;
}
use of org.pentaho.metadata.model.concept.types.TableType in project pentaho-kettle by pentaho.
the class StarModelPainter method drawCircleName.
private void drawCircleName(Point center, LogicalTable logicalTable) {
String name = ConceptUtil.getName(logicalTable, locale);
if (!Utils.isEmpty(name)) {
Point nameSize = gc.textExtent(name);
int margin = 20;
nameSize.x += margin;
nameSize.y += margin;
EColor bg = EColor.BACKGROUND;
TableType tableType = (TableType) logicalTable.getProperty(DefaultPropertyID.TABLE_TYPE.getId());
if (tableType != null && TableType.FACT == tableType) {
bg = EColor.LIGHTGRAY;
}
gc.setBackground(bg);
gc.fillRoundRectangle(center.x - nameSize.x / 2, center.y - nameSize.y / 2, nameSize.x, nameSize.y, 20, 20);
gc.drawRoundRectangle(center.x - nameSize.x / 2, center.y - nameSize.y / 2, nameSize.x, nameSize.y, 20, 20);
gc.drawText(name, center.x - nameSize.x / 2 + margin / 2, center.y - nameSize.y / 2 + margin / 2, true);
gc.setBackground(EColor.BACKGROUND);
}
}
use of org.pentaho.metadata.model.concept.types.TableType in project pentaho-kettle by pentaho.
the class JobGenerator method generateDimensionTransformations.
/**
* This method generates a list of transformations: one for each dimension.
*
* @return the list of generated transformations
*/
public List<TransMeta> generateDimensionTransformations() throws KettleException {
DatabaseMeta databaseMeta = findTargetDatabaseMeta();
List<TransMeta> transMetas = new ArrayList<TransMeta>();
List<LogicalTable> logicalTables = getUniqueLogicalTables();
for (LogicalTable logicalTable : logicalTables) {
TableType tableType = ConceptUtil.getTableType(logicalTable);
DimensionType dimensionType = ConceptUtil.getDimensionType(logicalTable);
if (tableType == TableType.DIMENSION) {
switch(dimensionType) {
case SLOWLY_CHANGING_DIMENSION:
case JUNK_DIMENSION:
{
TransMeta transMeta = generateDimensionTransformation(databaseMeta, logicalTable);
transMetas.add(transMeta);
}
break;
case // TODO: generate a standard date transformation
DATE:
{
TransMeta transMeta = generateDateTransformation(databaseMeta, logicalTable);
transMetas.add(transMeta);
}
break;
case // TODO: generate a standard time transformation
TIME:
{
TransMeta transMeta = generateTimeTransformation(databaseMeta, logicalTable);
transMetas.add(transMeta);
}
break;
default:
break;
}
}
}
return transMetas;
}
use of org.pentaho.metadata.model.concept.types.TableType in project pentaho-kettle by pentaho.
the class ConceptUtilTest method testFindLogicalTables.
@Test
public void testFindLogicalTables() throws Exception {
final LogicalModel logicalModel = mock(LogicalModel.class);
final TableType dimension = TableType.DIMENSION;
final LogicalTable logicalTable1 = mock(LogicalTable.class);
when(logicalTable1.getProperty(eq(DefaultPropertyID.TABLE_TYPE.getId()))).thenReturn(dimension);
final LogicalTable logicalTable2 = mock(LogicalTable.class);
when(logicalTable2.getProperty(eq(DefaultPropertyID.TABLE_TYPE.getId()))).thenReturn(TableType.FACT);
final LogicalTable logicalTable3 = mock(LogicalTable.class);
when(logicalTable3.getProperty(eq(DefaultPropertyID.TABLE_TYPE.getId()))).thenReturn(dimension);
when(logicalModel.getLogicalTables()).thenReturn(new LinkedList<LogicalTable>() {
{
add(logicalTable1);
add(logicalTable2);
add(logicalTable3);
}
});
final List<LogicalTable> logicalTables = ConceptUtil.findLogicalTables(logicalModel, dimension);
assertEquals(2, logicalTables.size());
assertEquals(logicalTable1, logicalTables.get(0));
assertEquals(logicalTable3, logicalTables.get(1));
}
use of org.pentaho.metadata.model.concept.types.TableType in project pentaho-kettle by pentaho.
the class StarModelDialog method refreshTablesList.
protected void refreshTablesList() {
wTablesList.clearAll();
for (LogicalTable logicalTable : logicalModel.getLogicalTables()) {
TableType tableType = (TableType) logicalTable.getProperty(DefaultPropertyID.TABLE_TYPE.getId());
if (tableType == TableType.DIMENSION) {
TableItem item = new TableItem(wTablesList.table, SWT.NONE);
item.setText(1, Const.NVL(ConceptUtil.getName(logicalTable, locale), ""));
item.setText(2, Const.NVL(ConceptUtil.getDescription(logicalTable, locale), ""));
String typeDescription = tableType == null ? "" : tableType.name();
if (tableType == TableType.DIMENSION) {
DimensionType dimType = ConceptUtil.getDimensionType(logicalTable);
if (dimType != DimensionType.OTHER) {
typeDescription += " - " + dimType.name();
}
}
item.setText(3, typeDescription);
}
}
wTablesList.removeEmptyRows();
wTablesList.setRowNums();
wTablesList.optWidth(true);
String[] dimensionNames = getDimensionTableNames();
factColumns[5].setComboValues(dimensionNames);
}
Aggregations