Search in sources :

Example 1 with ModelerException

use of org.pentaho.agilebi.modeler.ModelerException in project data-access by pentaho.

the class InlineSqlModelerSource method generateDomain.

@Override
public Domain generateDomain(boolean dualModelingMode) throws ModelerException {
    try {
        BusinessData bd = datasourceImpl.generateLogicalModel(datasourceName, connectionName, dbType, query, "10");
        Domain domain = bd.getDomain();
        return domain;
    } catch (DatasourceServiceException dce) {
        throw new ModelerException(dce);
    }
}
Also used : BusinessData(org.pentaho.platform.dataaccess.datasource.beans.BusinessData) ModelerException(org.pentaho.agilebi.modeler.ModelerException) Domain(org.pentaho.metadata.model.Domain) DatasourceServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)

Example 2 with ModelerException

use of org.pentaho.agilebi.modeler.ModelerException in project data-access by pentaho.

the class ModelerDialog method xulLoaded.

public void xulLoaded(GwtXulRunner gwtXulRunner) {
    container = gwtXulRunner.getXulDomContainers().get(0);
    container.addEventHandler(this);
    BogoPojo bogo = new BogoPojo();
    service.gwtWorkaround(bogo, new XulServiceCallback<BogoPojo>() {

        public void success(BogoPojo retVal) {
        }

        public void error(String message, Throwable error) {
        }
    });
    datasourceService = new DSWDatasourceServiceGwtImpl();
    // connectionService = new ConnectionServiceGwtImpl();
    csvService = (ICsvDatasourceServiceAsync) GWT.create(ICsvDatasourceService.class);
    if (wizard == null) {
        wizard = new EmbeddedWizard(false);
        wizard.setDatasourceService(datasourceService);
        // wizard.setConnectionService(connectionService);
        wizard.setCsvDatasourceService(csvService);
        wizard.init(null);
    }
    messages = new GwtModelerMessages((ResourceBundle) container.getResourceBundles().get(0));
    try {
        ModelerMessagesHolder.setMessages(messages);
    } catch (Exception ignored) {
    // Messages may have been set earlier, ignore.
    }
    IModelerWorkspaceHelper workspacehelper = model.getWorkspaceHelper();
    controller = new ModelerController(model);
    controller.setWorkspaceHelper(workspacehelper);
    // controller.setMessages(messages);
    final BindingFactory bf = new GwtBindingFactory(container.getDocumentRoot());
    controller.setBindingFactory(bf);
    container.addEventHandler(controller);
    try {
        controller.init();
    } catch (ModelerException e) {
        e.printStackTrace();
    }
    bf.setBindingType(Binding.Type.ONE_WAY);
    bf.createBinding(model, "valid", "modeler_dialog_accept", "disabled", new BindingConvertor<Boolean, Boolean>() {

        @Override
        public Boolean sourceToTarget(Boolean value) {
            return !value;
        }

        @Override
        public Boolean targetToSource(Boolean value) {
            return !value;
        }
    });
    bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
    // go get the geocontext from the server. Prop forms are initialized after this call returns as they
    // may need them to create the UI
    datasourceService.getGeoContext(new XulServiceCallback<GeoContext>() {

        public void success(GeoContext geoContext) {
            model.setGeoContext(geoContext);
            ModelerUiHelper.configureControllers(container, model, bf, controller, new ColResolverController());
            ModelerDialog.this.constructorListener.asyncConstructorDone(ModelerDialog.this);
        }

        public void error(String s, Throwable throwable) {
            throwable.printStackTrace();
            // put in a stub to ensure the rest of the dialog works
            model.setGeoContext(new GeoContext());
            ModelerUiHelper.configureControllers(container, model, bf, controller, new ColResolverController());
            ModelerDialog.this.constructorListener.asyncConstructorDone(ModelerDialog.this);
        }
    });
}
Also used : ModelerException(org.pentaho.agilebi.modeler.ModelerException) EmbeddedWizard(org.pentaho.platform.dataaccess.datasource.wizard.EmbeddedWizard) ModelerController(org.pentaho.agilebi.modeler.ModelerController) GwtModelerMessages(org.pentaho.agilebi.modeler.gwt.GwtModelerMessages) ModelerException(org.pentaho.agilebi.modeler.ModelerException) GeoContext(org.pentaho.agilebi.modeler.geo.GeoContext) ColResolverController(org.pentaho.agilebi.modeler.ColResolverController) IModelerWorkspaceHelper(org.pentaho.agilebi.modeler.IModelerWorkspaceHelper) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) ResourceBundle(org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle) DSWDatasourceServiceGwtImpl(org.pentaho.platform.dataaccess.datasource.wizard.service.impl.DSWDatasourceServiceGwtImpl) BogoPojo(org.pentaho.agilebi.modeler.gwt.BogoPojo) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)

Example 3 with ModelerException

use of org.pentaho.agilebi.modeler.ModelerException in project data-access by pentaho.

the class InMemoryDSWDatasourceServiceImpl method generateQueryDomain.

@Override
public QueryDatasourceSummary generateQueryDomain(String name, String query, DatabaseConnection connection, DatasourceDTO datasourceDTO) throws DatasourceServiceException {
    ModelerWorkspace modelerWorkspace = new ModelerWorkspace(new GwtModelerWorkspaceHelper(), getGeoContext());
    ModelerService modelerService = new ModelerService();
    modelerWorkspace.setModelName(name);
    try {
        Boolean securityEnabled = (getPermittedRoleList() != null && getPermittedRoleList().size() > 0) || (getPermittedUserList() != null && getPermittedUserList().size() > 0);
        SerializedResultSet resultSet = DatasourceInMemoryServiceHelper.getSerializeableResultSet(connection.getName(), query, Integer.parseInt("10"), null);
        SQLModelGenerator sqlModelGenerator = new SQLModelGenerator(name, connection.getName(), connection.getDatabaseType().getShortName(), resultSet.getColumnTypes(), resultSet.getColumns(), query, securityEnabled, getPermittedRoleList(), getPermittedUserList(), getDefaultAcls(), "joe");
        Domain domain = sqlModelGenerator.generate();
        modelerWorkspace.setDomain(domain);
        modelerWorkspace.getWorkspaceHelper().autoModelFlat(modelerWorkspace);
        modelerWorkspace.setModelName(datasourceDTO.getDatasourceName());
        modelerWorkspace.getWorkspaceHelper().populateDomain(modelerWorkspace);
        domain.getLogicalModels().get(0).setProperty("datasourceModel", serializeModelState(datasourceDTO));
        domain.getLogicalModels().get(0).setProperty("DatasourceType", "SQL-DS");
        QueryDatasourceSummary summary = new QueryDatasourceSummary();
        modelerService.serializeModels(domain, modelerWorkspace.getModelName());
        summary.setDomain(domain);
        return summary;
    } catch (SQLModelGeneratorException smge) {
        logger.error(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0016_UNABLE_TO_GENERATE_MODEL", smge.getLocalizedMessage()), smge);
        throw new DatasourceServiceException(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0015_UNABLE_TO_GENERATE_MODEL"), // $NON-NLS-1$
        smge);
    } catch (QueryValidationException e) {
        logger.error(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0009_QUERY_VALIDATION_FAILED", e.getLocalizedMessage()), // $NON-NLS-1$
        e);
        throw new DatasourceServiceException(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0009_QUERY_VALIDATION_FAILED", e.getLocalizedMessage()), // $NON-NLS-1$
        e);
    } catch (ModelerException e) {
        logger.error(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0016_UNABLE_TO_GENERATE_MODEL", e.getLocalizedMessage()), e);
        throw new DatasourceServiceException(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0015_UNABLE_TO_GENERATE_MODEL"), // $NON-NLS-1$
        e);
    } catch (Exception e) {
        logger.error(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0016_UNABLE_TO_GENERATE_MODEL", e.getLocalizedMessage()), e);
        throw new DatasourceServiceException(Messages.getErrorString("InMemoryDatasourceServiceImpl.ERROR_0015_UNABLE_TO_GENERATE_MODEL"), // $NON-NLS-1$
        e);
    }
}
Also used : SQLModelGeneratorException(org.pentaho.metadata.util.SQLModelGeneratorException) ModelerException(org.pentaho.agilebi.modeler.ModelerException) SerializedResultSet(org.pentaho.platform.dataaccess.datasource.beans.SerializedResultSet) DomainStorageException(org.pentaho.metadata.repository.DomainStorageException) DatasourceServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException) DomainIdNullException(org.pentaho.metadata.repository.DomainIdNullException) ModelerException(org.pentaho.agilebi.modeler.ModelerException) SQLException(java.sql.SQLException) QueryValidationException(org.pentaho.platform.dataaccess.datasource.wizard.service.QueryValidationException) DomainAlreadyExistsException(org.pentaho.metadata.repository.DomainAlreadyExistsException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) SQLModelGeneratorException(org.pentaho.metadata.util.SQLModelGeneratorException) GwtModelerWorkspaceHelper(org.pentaho.agilebi.modeler.gwt.GwtModelerWorkspaceHelper) QueryDatasourceSummary(org.pentaho.platform.dataaccess.datasource.wizard.sources.query.QueryDatasourceSummary) SQLModelGenerator(org.pentaho.metadata.util.SQLModelGenerator) QueryValidationException(org.pentaho.platform.dataaccess.datasource.wizard.service.QueryValidationException) Domain(org.pentaho.metadata.model.Domain) ModelerWorkspace(org.pentaho.agilebi.modeler.ModelerWorkspace) DatasourceServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)

Example 4 with ModelerException

use of org.pentaho.agilebi.modeler.ModelerException in project data-access by pentaho.

the class DSWDatasourceServiceImplTest method testGenerateQueryDomain_UnableToSerialize.

@Test(expected = DatasourceServiceException.class)
public void testGenerateQueryDomain_UnableToSerialize() throws Exception {
    when(modelerService.serializeModels(any(Domain.class), anyString())).thenThrow(new ModelerException());
    testGenerateQueryDomain(MODEL_NAME, VALID_QUERY, null, null);
}
Also used : ModelerException(org.pentaho.agilebi.modeler.ModelerException) Domain(org.pentaho.metadata.model.Domain) Test(org.junit.Test)

Example 5 with ModelerException

use of org.pentaho.agilebi.modeler.ModelerException in project data-access by pentaho.

the class ModelerDialog method onAccept.

@Bindable
public void onAccept() {
    enableWaitCursor(true);
    try {
        model.getWorkspaceHelper().populateDomain(model);
    } catch (ModelerException e) {
        e.printStackTrace();
        showErrorDialog(messages.getString("ModelEditor.ERROR"), messages.getString("ModelEditor.ERROR_0001_SAVING_MODELS"));
    }
    boolean doOlap = true;
    LogicalModel lModel = model.getLogicalModel(ModelerPerspective.ANALYSIS);
    if (lModel == null) {
        lModel = model.getLogicalModel(ModelerPerspective.REPORTING);
    }
    if (lModel.getProperty("MondrianCatalogRef") == null && (lModel.getProperty("DUAL_MODELING_SCHEMA") == null || "false".equals(lModel.getProperty("DUAL_MODELING_SCHEMA")))) {
        doOlap = false;
    }
    service.serializeModels(model.getDomain(), model.getModelName(), doOlap, new XulServiceCallback<String>() {

        public void success(String retVal) {
            enableWaitCursor(false);
            hideDialog();
            model.getDomain().setId(retVal);
            ModelerDialog.this.listener.onDialogAccept(model.getDomain());
        }

        public void error(String message, Throwable error) {
            enableWaitCursor(false);
            showErrorDialog(messages.getString("ModelEditor.ERROR"), messages.getString("ModelEditor.ERROR_0001_SAVING_MODELS"));
        }
    });
}
Also used : ModelerException(org.pentaho.agilebi.modeler.ModelerException) LogicalModel(org.pentaho.metadata.model.LogicalModel) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Aggregations

ModelerException (org.pentaho.agilebi.modeler.ModelerException)7 Domain (org.pentaho.metadata.model.Domain)4 DatasourceServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)4 IOException (java.io.IOException)3 FileNotFoundException (java.io.FileNotFoundException)2 SQLException (java.sql.SQLException)2 ModelerWorkspace (org.pentaho.agilebi.modeler.ModelerWorkspace)2 GeoContext (org.pentaho.agilebi.modeler.geo.GeoContext)2 GwtModelerWorkspaceHelper (org.pentaho.agilebi.modeler.gwt.GwtModelerWorkspaceHelper)2 DomainAlreadyExistsException (org.pentaho.metadata.repository.DomainAlreadyExistsException)2 DomainIdNullException (org.pentaho.metadata.repository.DomainIdNullException)2 DomainStorageException (org.pentaho.metadata.repository.DomainStorageException)2 SQLModelGenerator (org.pentaho.metadata.util.SQLModelGenerator)2 SQLModelGeneratorException (org.pentaho.metadata.util.SQLModelGeneratorException)2 SerializedResultSet (org.pentaho.platform.dataaccess.datasource.beans.SerializedResultSet)2 QueryValidationException (org.pentaho.platform.dataaccess.datasource.wizard.service.QueryValidationException)2 QueryDatasourceSummary (org.pentaho.platform.dataaccess.datasource.wizard.sources.query.QueryDatasourceSummary)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 Properties (java.util.Properties)1