Search in sources :

Example 1 with TableType

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;
}
Also used : TableType(org.pentaho.metadata.model.concept.types.TableType) LogicalTable(org.pentaho.metadata.model.LogicalTable)

Example 2 with TableType

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);
    }
}
Also used : TableType(org.pentaho.metadata.model.concept.types.TableType) Point(org.pentaho.di.core.gui.Point) EColor(org.pentaho.di.core.gui.PrimitiveGCInterface.EColor) Point(org.pentaho.di.core.gui.Point)

Example 3 with TableType

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;
}
Also used : DimensionType(org.pentaho.di.starmodeler.DimensionType) TableType(org.pentaho.metadata.model.concept.types.TableType) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) LogicalTable(org.pentaho.metadata.model.LogicalTable) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 4 with TableType

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));
}
Also used : LogicalModel(org.pentaho.metadata.model.LogicalModel) TableType(org.pentaho.metadata.model.concept.types.TableType) LogicalTable(org.pentaho.metadata.model.LogicalTable) Test(org.junit.Test)

Example 5 with TableType

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);
}
Also used : TableType(org.pentaho.metadata.model.concept.types.TableType) TableItem(org.eclipse.swt.widgets.TableItem) LogicalTable(org.pentaho.metadata.model.LogicalTable) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString)

Aggregations

TableType (org.pentaho.metadata.model.concept.types.TableType)8 LogicalTable (org.pentaho.metadata.model.LogicalTable)5 Test (org.junit.Test)3 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 Point (org.pentaho.di.core.gui.Point)2 DimensionType (org.pentaho.di.starmodeler.DimensionType)2 ArrayList (java.util.ArrayList)1 TableItem (org.eclipse.swt.widgets.TableItem)1 Database (org.pentaho.di.core.database.Database)1 KettleException (org.pentaho.di.core.exception.KettleException)1 EColor (org.pentaho.di.core.gui.PrimitiveGCInterface.EColor)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 JobHopMeta (org.pentaho.di.job.JobHopMeta)1 JobMeta (org.pentaho.di.job.JobMeta)1 JobEntrySQL (org.pentaho.di.job.entries.sql.JobEntrySQL)1 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)1 TransMeta (org.pentaho.di.trans.TransMeta)1 LogicalColumn (org.pentaho.metadata.model.LogicalColumn)1 LogicalModel (org.pentaho.metadata.model.LogicalModel)1