use of org.pentaho.metadata.model.LogicalTable in project pentaho-kettle by pentaho.
the class StarModelerPerspective method save.
@Override
public boolean save(EngineMetaInterface meta, String fname, boolean isExport) {
try {
//
if (meta instanceof StarDomain) {
StarDomain starDomain = (StarDomain) meta;
// Make sure we pick the active MetaStore to save to, otherwise it's hard to verify
//
IMetaStore metaStore = Spoon.getInstance().metaStore.getActiveMetaStore();
LogChannel.GENERAL.logBasic("Saving star domain to meta store: " + metaStore.getName());
// Save the name and description of the shared dimension in the metastore
//
StarDomainMetaStoreUtil.saveStarDomain(metaStore, starDomain);
//
for (LogicalTable sharedDimension : starDomain.getSharedDimensions()) {
SharedDimensionMetaStoreUtil.saveSharedDimension(metaStore, sharedDimension, defaultLocale);
}
meta.clearChanged();
Spoon.getInstance().enableMenus();
return true;
}
} catch (Exception e) {
new ErrorDialog(Spoon.getInstance().getShell(), "Error saving model", "There was an error while saving the model:", e);
}
return false;
}
use of org.pentaho.metadata.model.LogicalTable in project pentaho-kettle by pentaho.
the class JobGenerator method getUniqueLogicalTables.
/**
* Get a list of all unique physical table names wrapped in their logical tables
* @return
*/
protected List<LogicalTable> getUniqueLogicalTables() {
List<LogicalTable> tables = new ArrayList<LogicalTable>();
List<String> phTabs = new ArrayList<String>();
for (LogicalModel model : domain.getLogicalModels()) {
for (LogicalTable table : model.getLogicalTables()) {
String phTable = ConceptUtil.getString(table, DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME);
if (!Utils.isEmpty(phTable)) {
if (!phTabs.contains(phTable)) {
phTabs.add(phTable);
tables.add(table);
}
}
}
}
return tables;
}
use of org.pentaho.metadata.model.LogicalTable in project pentaho-kettle by pentaho.
the class StarModelDialog method getRelationshipsFromFact.
protected void getRelationshipsFromFact() {
logicalRelationships = new ArrayList<LogicalRelationship>();
getFactColumns();
for (LogicalColumn column : factTable.getLogicalColumns()) {
String dimensionName = ConceptUtil.getString(column, DefaultIDs.LOGICAL_COLUMN_DIMENSION_NAME);
if (!Utils.isEmpty(dimensionName)) {
LogicalTable dimensionTable = ConceptUtil.findDimensionWithName(logicalModel, dimensionName, locale);
if (dimensionTable != null) {
LogicalColumn tk = ConceptUtil.findLogicalColumn(dimensionTable, AttributeType.TECHNICAL_KEY);
if (tk == null) {
tk = ConceptUtil.findLogicalColumn(dimensionTable, AttributeType.SMART_TECHNICAL_KEY);
}
if (tk != null) {
LogicalTable fromTable = factTable;
LogicalColumn fromColumn = column;
LogicalTable toTable = dimensionTable;
LogicalColumn toColumn = tk;
LogicalRelationship relationship = new LogicalRelationship(logicalModel, fromTable, toTable, fromColumn, toColumn);
logicalRelationships.add(relationship);
}
}
}
}
}
use of org.pentaho.metadata.model.LogicalTable in project pentaho-kettle by pentaho.
the class StarModelDialog method newTable.
protected boolean newTable(Shell shell, LogicalModel logicalModel) {
LogicalTable logicalTable = new LogicalTable(logicalModel, null);
logicalTable.setId(UUID.randomUUID().toString());
logicalTable.setName(new LocalizedString(locale, "New table"));
logicalTable.setDescription(new LocalizedString(locale, "New table description"));
DimensionTableDialog dialog = new DimensionTableDialog(shell, logicalTable, locale);
if (dialog.open() != null) {
logicalModel.addLogicalTable(logicalTable);
return true;
}
return false;
}
use of org.pentaho.metadata.model.LogicalTable in project pentaho-kettle by pentaho.
the class StarModelDialog method copyTable.
protected boolean copyTable(Shell shell, LogicalModel logicalModel, String tableName) {
LogicalTable originalTable = findLogicalTable(tableName);
if (originalTable != null) {
// Copy
//
LogicalTable logicalTable = new LogicalTable();
logicalTable.setId(UUID.randomUUID().toString());
logicalTable.setName(new LocalizedString(locale, ConceptUtil.getName(originalTable, locale) + " (Copy)"));
logicalTable.setDescription(new LocalizedString(locale, ConceptUtil.getDescription(originalTable, locale) + " (Copy)"));
logicalTable.setProperty(DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME, originalTable.getProperty(DefaultIDs.LOGICAL_TABLE_PHYSICAL_TABLE_NAME));
logicalTable.setProperty(DefaultPropertyID.TABLE_TYPE.getId(), originalTable.getProperty(DefaultPropertyID.TABLE_TYPE.getId()));
for (LogicalColumn column : originalTable.getLogicalColumns()) {
logicalTable.getLogicalColumns().add((LogicalColumn) column.clone());
}
DimensionTableDialog dialog = new DimensionTableDialog(shell, logicalTable, locale);
if (dialog.open() != null) {
logicalModel.addLogicalTable(logicalTable);
return true;
}
}
return false;
}
Aggregations