Search in sources :

Example 1 with LogicalModelSummary

use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.

the class DataSourceWizardServiceTest method testGetDSWDatasourceIdsError.

@Test
public void testGetDSWDatasourceIdsError() throws Exception {
    LogicalModelSummary mockLogicalModelSummary = mock(LogicalModelSummary.class);
    List<LogicalModelSummary> mockLogicalModelSummaryList = new ArrayList<LogicalModelSummary>();
    mockLogicalModelSummaryList.add(mockLogicalModelSummary);
    doReturn(mockLogicalModelSummaryList).when(dataSourceWizardService.dswService).getLogicalModels(null);
    RuntimeException mockException = mock(RuntimeException.class);
    doThrow(mockException).when(dataSourceWizardService.modelerService).loadDomain(anyString());
    List<String> response = dataSourceWizardService.getDSWDatasourceIds();
    assertEquals(null, response);
    verify(dataSourceWizardService, times(1)).getDSWDatasourceIds();
}
Also used : LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 2 with LogicalModelSummary

use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.

the class DatasourceSelectionDialogController method removeDatasourceAccept.

@Bindable
public void removeDatasourceAccept() {
    if (removeDatasourceButton.isDisabled()) {
        return;
    }
    removeDatasourceButton.setDisabled(true);
    LogicalModelSummary logicalModelSummary = getDialogResult();
    datasourceService.deleteLogicalModel(logicalModelSummary.getDomainId(), logicalModelSummary.getModelId(), new XulServiceCallback<Boolean>() {

        public void error(String message, Throwable error) {
            // $NON-NLS-1$
            showMessagebox("Error", error.getLocalizedMessage());
            removeDatasourceButton.setDisabled(false);
        }

        public void success(Boolean retVal) {
            refreshDatasources(null, null);
            removeDatasourceConfirmationDialog.hide();
            removeDatasourceButton.setDisabled(false);
        }
    });
}
Also used : LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 3 with LogicalModelSummary

use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.

the class DSWDatasourceServiceImpl method getLogicalModels.

public List<LogicalModelSummary> getLogicalModels(String context) throws DatasourceServiceException {
    if (!hasDataAccessViewPermission()) {
        // $NON-NLS-1$
        logger.error(Messages.getErrorString("DatasourceServiceImpl.ERROR_0001_PERMISSION_DENIED"));
        throw new DatasourceServiceException(Messages.getErrorString(// $NON-NLS-1$
        "DatasourceServiceImpl.ERROR_0001_PERMISSION_DENIED"));
    }
    List<LogicalModelSummary> logicalModelSummaries = new ArrayList<LogicalModelSummary>();
    for (String domainId : getMetadataDomainRepository().getDomainIds()) {
        Domain domain;
        try {
            domain = getMetadataDomainRepository().getDomain(domainId);
        } catch (Exception e) {
            logger.error(Messages.getErrorString("DatasourceServiceImpl.ERROR_0022_UNABLE_TO_PROCESS_LOGICAL_MODEL", domainId), e);
            continue;
        }
        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(LM_PROP_VISIBLE);
            if (vis != null) {
                String[] visibleContexts = vis.split(",");
                boolean visibleToContext = false;
                for (String c : visibleContexts) {
                    if (StringUtils.isNotEmpty(c.trim()) && c.trim().equals(context)) {
                        visibleToContext = true;
                        break;
                    }
                }
                if (!visibleToContext) {
                    continue;
                }
            }
            logicalModelSummaries.add(new LogicalModelSummary(domainId, model.getId(), model.getName(locale)));
        }
    }
    return logicalModelSummaries;
}
Also used : LogicalModel(org.pentaho.metadata.model.LogicalModel) LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary) ArrayList(java.util.ArrayList) Domain(org.pentaho.metadata.model.Domain) ModelerException(org.pentaho.agilebi.modeler.ModelerException) QueryValidationException(org.pentaho.platform.dataaccess.datasource.wizard.service.QueryValidationException) SQLModelGeneratorException(org.pentaho.metadata.util.SQLModelGeneratorException) DomainStorageException(org.pentaho.metadata.repository.DomainStorageException) DatasourceServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException) DomainIdNullException(org.pentaho.metadata.repository.DomainIdNullException) SQLException(java.sql.SQLException) SqlQueriesNotSupportedException(org.pentaho.platform.dataaccess.datasource.wizard.service.SqlQueriesNotSupportedException) MondrianCatalogServiceException(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogServiceException) ConnectionServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException) DomainAlreadyExistsException(org.pentaho.metadata.repository.DomainAlreadyExistsException) IOException(java.io.IOException) CsvTransformGeneratorException(org.pentaho.platform.dataaccess.datasource.wizard.models.CsvTransformGeneratorException) DatasourceServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)

Example 4 with LogicalModelSummary

use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary 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;
}
Also used : LogicalModel(org.pentaho.metadata.model.LogicalModel) LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary) ArrayList(java.util.ArrayList) Domain(org.pentaho.metadata.model.Domain)

Example 5 with LogicalModelSummary

use of org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary in project data-access by pentaho.

the class DSWDatasourceServiceImplTest method testGetLogicalModels_NullContext.

private void testGetLogicalModels_NullContext(String context) throws DatasourceServiceException {
    doReturn(true).when(dswService).hasDataAccessPermission();
    doReturn(true).when(dswService).hasDataAccessViewPermission();
    List<LogicalModelSummary> models = dswService.getLogicalModels(context);
    assertNotNull(models);
    for (LogicalModelSummary logicalModelSummary : models) {
        assertEquals(domain2Models.getId(), logicalModelSummary.getDomainId());
    }
}
Also used : LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary)

Aggregations

LogicalModelSummary (org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary)9 ArrayList (java.util.ArrayList)5 Domain (org.pentaho.metadata.model.Domain)4 LogicalModel (org.pentaho.metadata.model.LogicalModel)3 Bindable (org.pentaho.ui.xul.stereotype.Bindable)3 List (java.util.List)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 IDatasourceInfo (org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)2 RequestException (com.google.gwt.http.client.RequestException)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 ModelerException (org.pentaho.agilebi.modeler.ModelerException)1 DomainAlreadyExistsException (org.pentaho.metadata.repository.DomainAlreadyExistsException)1 DomainIdNullException (org.pentaho.metadata.repository.DomainIdNullException)1 DomainStorageException (org.pentaho.metadata.repository.DomainStorageException)1 SQLModelGeneratorException (org.pentaho.metadata.util.SQLModelGeneratorException)1 CsvTransformGeneratorException (org.pentaho.platform.dataaccess.datasource.wizard.models.CsvTransformGeneratorException)1 ConnectionServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException)1 DatasourceServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)1