Search in sources :

Example 51 with LogicalModel

use of org.pentaho.metadata.model.LogicalModel in project data-access by pentaho.

the class DatasourceModel method setDatasourceName.

@Bindable
public void setDatasourceName(String datasourceName) {
    String previousVal = this.datasourceName;
    this.datasourceName = datasourceName;
    // we need to keep the datasource name in sync
    if (domain != null) {
        domain.setId(datasourceName);
        LogicalModel model = domain.getLogicalModels().get(0);
        String localeCode = domain.getLocales().get(0).getCode();
        model.getName().setString(localeCode, datasourceName);
    }
    this.getModelInfo().setStageTableName(generateTableName());
    // $NON-NLS-1$
    this.firePropertyChange("datasourceName", previousVal, datasourceName);
    validate();
}
Also used : LogicalModel(org.pentaho.metadata.model.LogicalModel) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 52 with LogicalModel

use of org.pentaho.metadata.model.LogicalModel in project data-access by pentaho.

the class DataSourceWizardServiceTest method testGetDSWDatasourceIds.

@Test
public void testGetDSWDatasourceIds() throws Exception {
    Domain mockDomain = mock(Domain.class);
    LogicalModelSummary mockLogicalModelSummary = mock(LogicalModelSummary.class);
    List<LogicalModelSummary> mockLogicalModelSummaryList = new ArrayList<LogicalModelSummary>();
    mockLogicalModelSummaryList.add(mockLogicalModelSummary);
    List<LogicalModel> mockLogicalModelList = new ArrayList<LogicalModel>();
    LogicalModel mockLogicalModel = mock(LogicalModel.class);
    mockLogicalModelList.add(mockLogicalModel);
    Object mockObject = mock(Object.class);
    List<String> datasourceList = new ArrayList<String>();
    datasourceList.add(mockLogicalModelSummary.getDomainId());
    doReturn(mockLogicalModelSummaryList).when(dataSourceWizardService.dswService).getLogicalModels(null);
    doReturn(mockDomain).when(dataSourceWizardService.modelerService).loadDomain(anyString());
    doReturn(mockLogicalModelList).when(mockDomain).getLogicalModels();
    doReturn(mockObject).when(mockLogicalModel).getProperty("AGILE_BI_GENERATED_SCHEMA");
    List<String> response = dataSourceWizardService.getDSWDatasourceIds();
    assertEquals(datasourceList, response);
    verify(dataSourceWizardService, times(1)).getDSWDatasourceIds();
}
Also used : LogicalModel(org.pentaho.metadata.model.LogicalModel) LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Domain(org.pentaho.metadata.model.Domain) Test(org.junit.Test)

Example 53 with LogicalModel

use of org.pentaho.metadata.model.LogicalModel in project data-access by pentaho.

the class DatasourceServiceTest method isMetadataDomainTest.

@Test
public void isMetadataDomainTest() throws ObjectFactoryException {
    // given
    Domain domain = mock(Domain.class);
    List<LogicalModel> logicalModelList = new ArrayList<>();
    LogicalModel model = new LogicalModel();
    LogicalModel model2 = new LogicalModel();
    // when
    assertFalse(DatasourceService.isMetadataDatasource((Domain) null));
    assertTrue(DatasourceService.isMetadataDatasource(domain));
    logicalModelList.add(model);
    when(domain.getLogicalModels()).thenReturn(logicalModelList);
    assertTrue(DatasourceService.isMetadataDatasource(domain));
    model.setProperty("AGILE_BI_GENERATED_SCHEMA", true);
    assertFalse(DatasourceService.isMetadataDatasource(domain));
    model2.setProperty("WIZARD_GENERATED_SCHEMA", true);
    logicalModelList.clear();
    logicalModelList.add(model2);
    assertFalse(DatasourceService.isMetadataDatasource(domain));
}
Also used : LogicalModel(org.pentaho.metadata.model.LogicalModel) ArrayList(java.util.ArrayList) Domain(org.pentaho.metadata.model.Domain) Test(org.junit.Test)

Aggregations

LogicalModel (org.pentaho.metadata.model.LogicalModel)53 Domain (org.pentaho.metadata.model.Domain)29 LocalizedString (org.pentaho.metadata.model.concept.types.LocalizedString)14 Test (org.junit.Test)13 ModelerWorkspace (org.pentaho.agilebi.modeler.ModelerWorkspace)11 LogicalTable (org.pentaho.metadata.model.LogicalTable)11 ArrayList (java.util.ArrayList)10 LogicalColumn (org.pentaho.metadata.model.LogicalColumn)9 Category (org.pentaho.metadata.model.Category)8 Matchers.anyString (org.mockito.Matchers.anyString)7 SqlPhysicalModel (org.pentaho.metadata.model.SqlPhysicalModel)7 SqlPhysicalTable (org.pentaho.metadata.model.SqlPhysicalTable)6 IMetadataDomainRepository (org.pentaho.metadata.repository.IMetadataDomainRepository)6 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)6 DomainIdNullException (org.pentaho.metadata.repository.DomainIdNullException)5 DomainStorageException (org.pentaho.metadata.repository.DomainStorageException)5 ConnectionServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException)5 DatasourceServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)5 IOException (java.io.IOException)4 SqlDataSource (org.pentaho.metadata.model.SqlDataSource)4