use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.
the class ModelMetaStoreUtil method buildLogicalModel.
/**
* Inflate a logical model from a metastore element.
*
* @param metaStore The metastore to read from
* @param element The element to read from
* @return The Logical Model
* @throws MetaStoreException in case something goes wrong
*/
public static LogicalModel buildLogicalModel(IMetaStore metaStore, IMetaStoreElement element) throws MetaStoreException {
try {
LogicalModel model = new LogicalModel();
model.setName(new LocalizedString(defaultLocale, element.getName()));
model.setDescription(new LocalizedString(defaultLocale, getChildString(element, Attribute.ID_MODEL_DESCRIPTION.id)));
return model;
} catch (Exception e) {
throw new MetaStoreException("Unable to inflate logical model from metastore element", e);
}
}
use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.
the class ConceptUtilTest method testGetName.
@Test
public void testGetName() throws Exception {
final Concept concept = mock(Concept.class);
final LocalizedString localizedString = mock(LocalizedString.class);
final String result = "result";
when(localizedString.getLocalizedString(eq(locale))).thenReturn(result);
when(concept.getProperty(anyString())).thenReturn(localizedString);
final String name = ConceptUtil.getName(concept, locale);
verify(localizedString, times(1)).getLocalizedString(eq(locale));
assertEquals(result, name);
}
use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-kettle by pentaho.
the class ConceptUtilTest method testGetDescription.
@Test
public void testGetDescription() throws Exception {
final Concept concept = mock(Concept.class);
final LocalizedString localizedString = mock(LocalizedString.class);
final String result = "result";
when(localizedString.getLocalizedString(eq(locale))).thenReturn(result);
when(concept.getProperty(anyString())).thenReturn(localizedString);
final String description = ConceptUtil.getDescription(concept, locale);
verify(localizedString, times(1)).getLocalizedString(eq(locale));
assertEquals(result, description);
}
use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-platform by pentaho.
the class MockSessionAwareMetadataDomainRepository method getDomain.
@Override
public Domain getDomain(String id) {
// $NON-NLS-1$
incrementInvocationCount("getDomain");
Domain d = domains.get(id);
if (d == null) {
return null;
}
d = (Domain) d.clone();
final IPentahoSession session = PentahoSessionHolder.getSession();
if (session == null) {
return d;
}
d.setDescription(new LocalizedString(TEST_LOCALE, PentahoSessionHolder.getSession().getId()));
return d;
}
use of org.pentaho.metadata.model.concept.types.LocalizedString in project pentaho-platform by pentaho.
the class MetadataQueryComponentIT method getBasicDomain.
public Domain getBasicDomain() {
SqlPhysicalModel model = new SqlPhysicalModel();
SqlDataSource dataSource = new SqlDataSource();
dataSource.setDatabaseName("SampleData");
dataSource.setDialectType("HYPERSONIC");
dataSource.setType(DataSourceType.JNDI);
model.setDatasource(dataSource);
SqlPhysicalTable table = new SqlPhysicalTable(model);
table.setId("PT1");
model.getPhysicalTables().add(table);
table.setTargetTableType(TargetTableType.INLINE_SQL);
table.setTargetTable("select distinct customername, salesrepemployeenumber from customers");
SqlPhysicalColumn column = new SqlPhysicalColumn(table);
column.setId("PC1");
column.setTargetColumn("CUSTOMERNAME");
column.setName(new LocalizedString("en_US", "Customer Name"));
column.setDescription(new LocalizedString("en_US", "Customer Name Desc"));
column.setDataType(DataType.STRING);
table.getPhysicalColumns().add(column);
SqlPhysicalColumn column2 = new SqlPhysicalColumn(table);
column2.setId("PC2");
column2.setTargetColumn("SALESREPEMPLOYEENUMBER");
column2.setName(new LocalizedString("en_US", "Sales Rep"));
column2.setDescription(new LocalizedString("en_US", "Sales Rep Employee Number"));
column2.setDataType(DataType.NUMERIC);
table.getPhysicalColumns().add(column2);
LogicalModel logicalModel = new LogicalModel();
logicalModel.setPhysicalModel(model);
logicalModel.setId("MODEL");
logicalModel.setName(new LocalizedString("en_US", "My Model"));
logicalModel.setDescription(new LocalizedString("en_US", "A Description of the Model"));
LogicalTable logicalTable = new LogicalTable();
logicalTable.setId("LT");
logicalTable.setPhysicalTable(table);
logicalModel.getLogicalTables().add(logicalTable);
LogicalColumn logicalColumn = new LogicalColumn();
logicalColumn.setId("LC_CUSTOMERNAME");
logicalColumn.setPhysicalColumn(column);
logicalColumn.setLogicalTable(logicalTable);
logicalTable.addLogicalColumn(logicalColumn);
LogicalColumn logicalColumn2 = new LogicalColumn();
logicalColumn2.setId("LC_SALESREP");
logicalColumn2.setPhysicalColumn(column2);
logicalColumn2.setLogicalTable(logicalTable);
logicalTable.addLogicalColumn(logicalColumn2);
Category mainCategory = new Category();
mainCategory.setId("CATEGORY");
mainCategory.setName(new LocalizedString("en_US", "Category"));
mainCategory.addLogicalColumn(logicalColumn);
mainCategory.addLogicalColumn(logicalColumn2);
logicalModel.getCategories().add(mainCategory);
Domain domain = new Domain();
domain.setId("DOMAIN");
domain.addPhysicalModel(model);
domain.addLogicalModel(logicalModel);
return domain;
}
Aggregations