use of org.pentaho.metadata.model.LogicalModel in project pentaho-kettle by pentaho.
the class JobGeneratorTest method testGenerateDimensionTransformations.
@Test
public void testGenerateDimensionTransformations() throws Exception {
final LogicalModel logicalModel = mock(LogicalModel.class);
when(jobGenerator.domain.getLogicalModels()).thenReturn(new LinkedList<LogicalModel>() {
{
add(logicalModel);
}
});
final LogicalTable logicalTable = mock(LogicalTable.class);
when(logicalTable.getProperty(eq(DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME))).thenReturn("test_table_name");
when(logicalModel.getLogicalTables()).thenReturn(new LinkedList<LogicalTable>() {
{
add(logicalTable);
}
});
when(logicalTable.getProperty(eq(DefaultPropertyID.TABLE_TYPE.getId()))).thenReturn(TableType.DIMENSION);
when(logicalTable.getProperty(eq(DefaultIDs.LOGICAL_TABLE_DIMENSION_TYPE))).thenReturn(DimensionType.JUNK_DIMENSION.name());
final List<TransMeta> transMetas = jobGenerator.generateDimensionTransformations();
assertNotNull(transMetas);
assertEquals(1, transMetas.size());
}
use of org.pentaho.metadata.model.LogicalModel in project pentaho-kettle by pentaho.
the class JobGeneratorTest method testGetUniqueLogicalTables.
@Test
public void testGetUniqueLogicalTables() throws Exception {
final LogicalModel logicalModel = mock(LogicalModel.class);
when(jobGenerator.domain.getLogicalModels()).thenReturn(new LinkedList<LogicalModel>() {
{
add(logicalModel);
}
});
final LogicalTable logicalTable = mock(LogicalTable.class);
when(logicalTable.getProperty(eq(DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME))).thenReturn("test_table_name");
when(logicalModel.getLogicalTables()).thenReturn(new LinkedList<LogicalTable>() {
{
add(logicalTable);
}
});
final List<LogicalTable> uniqueLogicalTables = jobGenerator.getUniqueLogicalTables();
assertNotNull(uniqueLogicalTables);
assertEquals(1, uniqueLogicalTables.size());
assertEquals(logicalTable, uniqueLogicalTables.get(0));
}
use of org.pentaho.metadata.model.LogicalModel in project pentaho-kettle by pentaho.
the class StarModelerPerspective method deleteModel.
/**
* Delete a model in the domain
*
* @param domain the domain to delete the model from
* @param modelName the name of the model to delete
*/
private boolean deleteModel(Shell shell, StarDomain starDomain, String locale, String modelName) {
LogicalModel logicalModel = findLogicalTable(starDomain.getDomain(), locale, modelName);
if (logicalModel != null) {
// TODO: show warning dialog.
//
starDomain.getDomain().getLogicalModels().remove(logicalModel);
starDomain.setChanged(true);
return true;
}
return false;
}
use of org.pentaho.metadata.model.LogicalModel in project pentaho-kettle by pentaho.
the class StarModelerPerspective method refreshModelsList.
protected void refreshModelsList(StarDomain starDomain, TableView modelsList) {
modelsList.clearAll();
for (LogicalModel model : starDomain.getDomain().getLogicalModels()) {
TableItem item = new TableItem(modelsList.table, SWT.NONE);
item.setText(1, Const.NVL(model.getName(defaultLocale), ""));
item.setText(2, Const.NVL(model.getDescription(defaultLocale), ""));
}
modelsList.removeEmptyRows();
modelsList.setRowNums();
modelsList.optWidth(true);
Spoon.getInstance().enableMenus();
}
use of org.pentaho.metadata.model.LogicalModel in project pentaho-kettle by pentaho.
the class MetadataGenerator method generatePhysicalMetadataModel.
public Domain generatePhysicalMetadataModel() throws KettleException {
// First do some checking and lookups...
//
String targetDatabaseName = ConceptUtil.getString(logicalDomain, DefaultIDs.DOMAIN_TARGET_DATABASE);
if (Utils.isEmpty(targetDatabaseName)) {
throw new KettleException("Please specify a target database!");
}
DatabaseMeta targetDatabaseMeta = DatabaseMeta.findDatabase(databases, targetDatabaseName);
if (targetDatabaseMeta == null) {
throw new KettleException("Target database with name '" + targetDatabaseName + "' can't be found!");
}
// Now start creation of a new domain with physical underpinning.
//
Domain domain = new Domain();
// Copy the domain information...
//
domain.setId(createId("DOMAIN", null, domain));
domain.setName(logicalDomain.getName());
domain.setDescription(logicalDomain.getDescription());
//
for (LogicalModel logicalModel : logicalDomain.getLogicalModels()) {
// Copy model information...
//
LogicalModel model = new LogicalModel();
model.setId(createId("MODEL", domain, model));
model.setName(logicalModel.getName());
model.setDescription(logicalModel.getDescription());
// Create a physical model...
//
SqlPhysicalModel sqlModel = new SqlPhysicalModel();
sqlModel.setDatasource(createSqlDataSource(targetDatabaseMeta));
model.setPhysicalModel(sqlModel);
for (LogicalTable logicalTable : logicalModel.getLogicalTables()) {
LogicalTable table = new LogicalTable();
table.setId(createId("LOGICAL_TABLE", logicalModel, logicalTable));
table.setName(logicalTable.getName());
table.setDescription(logicalTable.getDescription());
String targetTable = ConceptUtil.getString(logicalTable, DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME);
SqlPhysicalTable sqlTable = new SqlPhysicalTable(sqlModel);
table.setPhysicalTable(sqlTable);
// Copy name & description from physical level...
//
sqlTable.setId(createId("PHYSICAL_TABLE", logicalModel, logicalTable));
sqlTable.setName(logicalTable.getName());
sqlTable.setDescription(logicalTable.getDescription());
sqlTable.setTableType(ConceptUtil.getTableType(logicalTable));
sqlTable.setTargetSchema(targetDatabaseMeta.getPreferredSchemaName());
sqlTable.setTargetTable(targetTable);
}
}
return domain;
}
Aggregations