Search in sources :

Example 16 with LocalizedString

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);
    }
}
Also used : LogicalModel(org.pentaho.metadata.model.LogicalModel) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException)

Example 17 with LocalizedString

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);
}
Also used : Concept(org.pentaho.metadata.model.concept.Concept) Matchers.anyString(org.mockito.Matchers.anyString) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) Test(org.junit.Test)

Example 18 with LocalizedString

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);
}
Also used : Concept(org.pentaho.metadata.model.concept.Concept) Matchers.anyString(org.mockito.Matchers.anyString) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) Test(org.junit.Test)

Example 19 with LocalizedString

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;
}
Also used : IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Domain(org.pentaho.metadata.model.Domain) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString)

Example 20 with LocalizedString

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;
}
Also used : LogicalModel(org.pentaho.metadata.model.LogicalModel) LogicalColumn(org.pentaho.metadata.model.LogicalColumn) Category(org.pentaho.metadata.model.Category) SqlDataSource(org.pentaho.metadata.model.SqlDataSource) SqlPhysicalColumn(org.pentaho.metadata.model.SqlPhysicalColumn) LogicalTable(org.pentaho.metadata.model.LogicalTable) SqlPhysicalModel(org.pentaho.metadata.model.SqlPhysicalModel) LocalizedString(org.pentaho.metadata.model.concept.types.LocalizedString) Domain(org.pentaho.metadata.model.Domain) SqlPhysicalTable(org.pentaho.metadata.model.SqlPhysicalTable)

Aggregations

LocalizedString (org.pentaho.metadata.model.concept.types.LocalizedString)25 LogicalColumn (org.pentaho.metadata.model.LogicalColumn)11 LogicalTable (org.pentaho.metadata.model.LogicalTable)10 LogicalModel (org.pentaho.metadata.model.LogicalModel)8 Domain (org.pentaho.metadata.model.Domain)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)4 Category (org.pentaho.metadata.model.Category)4 SqlDataSource (org.pentaho.metadata.model.SqlDataSource)4 SqlPhysicalColumn (org.pentaho.metadata.model.SqlPhysicalColumn)4 SqlPhysicalModel (org.pentaho.metadata.model.SqlPhysicalModel)4 SqlPhysicalTable (org.pentaho.metadata.model.SqlPhysicalTable)4 TableItem (org.eclipse.swt.widgets.TableItem)3 Matchers.anyString (org.mockito.Matchers.anyString)3 List (java.util.List)2 MessageBox (org.eclipse.swt.widgets.MessageBox)2 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)2 DatabaseConnection (org.pentaho.database.model.DatabaseConnection)2 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)2 Concept (org.pentaho.metadata.model.concept.Concept)2