use of org.pentaho.metadata.model.LogicalModel in project data-access by pentaho.
the class InMemoryDSWDatasourceServiceImpl method getLogicalModels.
public List<LogicalModelSummary> getLogicalModels(String context) throws DatasourceServiceException {
List<LogicalModelSummary> logicalModelSummaries = new ArrayList<LogicalModelSummary>();
for (String domainId : getMetadataDomainRepository().getDomainIds()) {
Domain domain = getMetadataDomainRepository().getDomain(domainId);
String locale = LocaleHelper.getLocale().toString();
String[] locales = new String[domain.getLocales().size()];
for (int i = 0; i < domain.getLocales().size(); i++) {
locales[i] = domain.getLocales().get(i).getCode();
}
locale = LocaleHelper.getClosestLocale(locale, locales);
for (LogicalModel model : domain.getLogicalModels()) {
String vis = (String) model.getProperty("visible");
if (vis != null) {
String[] visibleContexts = vis.split(",");
boolean visibleToContext = false;
for (String c : visibleContexts) {
if (context.equals(c.trim())) {
visibleToContext = true;
break;
}
}
if (!visibleToContext) {
continue;
}
}
logicalModelSummaries.add(new LogicalModelSummary(domainId, model.getId(), model.getName().getString(locale)));
}
}
return logicalModelSummaries;
}
use of org.pentaho.metadata.model.LogicalModel in project data-access by pentaho.
the class WAQRTransport method createFromMetadata.
public static WAQRTransport createFromMetadata(Domain domain) {
// this assumes a single logical model with a single logical category
LogicalModel model = domain.getLogicalModels().get(0);
Iterator<String> iter = model.getName().getLocales().iterator();
String locale = iter.next();
Category category = model.getCategories().get(0);
String domainId = domain.getId();
String modelId = model.getId();
String modelName = model.getName() != null ? model.getName().getString(locale) : null;
String categoryId = category.getId();
String categoryName = category.getName() != null ? category.getName().getString(locale) : null;
String schemaName = model.getName(locale);
return createDomain(domainId, modelId, modelName, categoryId, categoryName, schemaName);
}
use of org.pentaho.metadata.model.LogicalModel in project data-access by pentaho.
the class DataAccessServiceTestBase method getDomain.
/**
* Provide a mock domain
*
* @return
*/
private Domain getDomain() {
LogicalColumn logicalColumn1;
LogicalColumn logicalColumn2;
String locale = LocaleHelper.getLocale().toString();
SqlPhysicalModel model = new SqlPhysicalModel();
SqlDataSource dataSource = new SqlDataSource();
dataSource.setDatabaseName("SampleData");
model.setDatasource(dataSource);
SqlPhysicalTable table = new SqlPhysicalTable(model);
model.getPhysicalTables().add(table);
table.setTargetTableType(TargetTableType.INLINE_SQL);
table.setTargetTable("select * from customers");
table.setId("customers");
SqlPhysicalColumn column = new SqlPhysicalColumn(table);
column.setTargetColumn("customername");
column.setName(new LocalizedString(locale, "Customer Name"));
column.setDescription(new LocalizedString(locale, "Customer Name Desc"));
column.setDataType(DataType.STRING);
column.setId("cutomer_customername");
table.getPhysicalColumns().add(column);
LogicalModel logicalModel = new LogicalModel();
model.setId("MODEL");
model.setName(new LocalizedString(locale, "My Model"));
model.setDescription(new LocalizedString(locale, "A Description of the Model"));
LogicalTable logicalTable = new LogicalTable();
logicalTable.setId("BT_CUSTOMERS");
logicalTable.setPhysicalTable(table);
logicalModel.getLogicalTables().add(logicalTable);
logicalModel.setName(new LocalizedString(locale, "My Model"));
logicalColumn1 = new LogicalColumn();
logicalColumn1.setId("LC_CUSTOMERNAME");
logicalColumn1.setPhysicalColumn(column);
logicalColumn1.setAggregationType(AggregationType.COUNT);
logicalColumn1.setLogicalTable(logicalTable);
logicalColumn1.setDataType(DataType.STRING);
logicalColumn2 = new LogicalColumn();
logicalColumn2.setId("LC_CUSTOMERNUMBER");
logicalColumn2.setAggregationType(AggregationType.COUNT);
logicalColumn2.setPhysicalColumn(column);
logicalColumn2.setLogicalTable(logicalTable);
logicalColumn2.setDataType(DataType.NUMERIC);
logicalTable.addLogicalColumn(logicalColumn1);
logicalTable.addLogicalColumn(logicalColumn2);
Domain thisDomain = new Domain();
thisDomain.addPhysicalModel(model);
thisDomain.addLogicalModel(logicalModel);
return thisDomain;
}
use of org.pentaho.metadata.model.LogicalModel in project pentaho-kettle by pentaho.
the class StarModelerPerspective method newModel.
/**
* Create a new model in the domain
*
* @param domain the domain to create the new model in
*/
private boolean newModel(Shell shell, StarDomain starDomain) {
LogicalModel model = new LogicalModel();
model.setName(new LocalizedString(defaultLocale, "Model"));
StarModelDialog dialog = new StarModelDialog(shell, model, defaultLocale);
if (dialog.open() != null) {
starDomain.getDomain().getLogicalModels().add(model);
starDomain.setChanged(true);
return true;
}
return false;
}
use of org.pentaho.metadata.model.LogicalModel 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;
}
Aggregations