Search in sources :

Example 1 with GeoContext

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

the class MultitableDatasourceService method serializeJoins.

public IDatasourceSummary serializeJoins(MultiTableDatasourceDTO dto, IDatabaseConnection connection) throws DatasourceServiceException {
    try {
        ModelerService modelerService = new ModelerService();
        modelerService.initKettle();
        DSWDatasourceServiceImpl datasourceService = new DSWDatasourceServiceImpl();
        GeoContext geoContext = datasourceService.getGeoContext();
        DatabaseMeta databaseMeta = this.getDatabaseMeta(connection);
        MultiTableModelerSource multiTable = new MultiTableModelerSource(databaseMeta, dto.getSchemaModel(), dto.getDatasourceName(), dto.getSelectedTables(), geoContext);
        Domain domain = multiTable.generateDomain(dto.isDoOlap());
        String modelState = serializeModelState(dto);
        for (LogicalModel lm : domain.getLogicalModels()) {
            lm.setProperty("datasourceModel", modelState);
            lm.setProperty("DatasourceType", "MULTI-TABLE-DS");
            // BISERVER-6450 - add security settings to the logical model
            applySecurity(lm);
        }
        modelerService.serializeModels(domain, dto.getDatasourceName(), dto.isDoOlap());
        QueryDatasourceSummary summary = new QueryDatasourceSummary();
        summary.setDomain(domain);
        return summary;
    } catch (Exception e) {
        logger.error("Error serializing joins", e);
        throw new DatasourceServiceException(e);
    }
}
Also used : MultiTableModelerSource(org.pentaho.agilebi.modeler.util.MultiTableModelerSource) LogicalModel(org.pentaho.metadata.model.LogicalModel) QueryDatasourceSummary(org.pentaho.platform.dataaccess.datasource.wizard.sources.query.QueryDatasourceSummary) Domain(org.pentaho.metadata.model.Domain) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) GeoContext(org.pentaho.agilebi.modeler.geo.GeoContext) DatasourceServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) ConnectionServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException) DatasourceServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)

Example 2 with GeoContext

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

the class DatasourceServiceHelperTest method testGetGeoContext.

@Test
public void testGetGeoContext() throws Exception {
    try {
        KettleEnvironment.init();
        Props.init(Props.TYPE_PROPERTIES_EMPTY);
    } catch (Exception e) {
    // may already be initialized by another test
    }
    GeoContext geo = DatasourceServiceHelper.getGeoContext();
    assertEquals("Geography", geo.getDimensionName());
    assertEquals(6, geo.size());
    assertNotNull(geo.getLocationRole());
    // make sure they are in the same order as entered in the props file
    String rolesCsv = "continent, country, state, city, postal_code";
    String[] tokens = rolesCsv.split(",");
    for (int i = 0; i < tokens.length; i++) {
        assertEquals(tokens[i].trim(), geo.getGeoRole(i).getName());
    }
}
Also used : GeoContext(org.pentaho.agilebi.modeler.geo.GeoContext) Test(org.junit.Test)

Example 3 with GeoContext

use of org.pentaho.agilebi.modeler.geo.GeoContext 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 4 with GeoContext

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

the class DataAccessServiceTestBase method setUp.

@Before
public void setUp() throws Exception {
    platform = new MicroPlatform();
    metadataRepository = mock(IMetadataDomainRepository.class);
    platform.defineInstance(IMetadataDomainRepository.class, metadataRepository);
    importer = mock(IPlatformImporter.class);
    platform.defineInstance(IPlatformImporter.class, importer);
    policy = mock(IAuthorizationPolicy.class);
    platform.defineInstance(IAuthorizationPolicy.class, policy);
    catalogService = mock(IAclAwareMondrianCatalogService.class);
    platform.defineInstance(IMondrianCatalogService.class, catalogService);
    permissionHandler = mock(IDataAccessPermissionHandler.class);
    platform.defineInstance(IDataAccessPermissionHandler.class, permissionHandler);
    userRoleListService = mock(IUserRoleListService.class);
    platform.defineInstance(IUserRoleListService.class, userRoleListService);
    pluginResourceLoader = mock(IPluginResourceLoader.class);
    platform.defineInstance(IPluginResourceLoader.class, pluginResourceLoader);
    mondrianCatalogService = mock(IMondrianCatalogService.class);
    platform.defineInstance(IMondrianCatalogService.class, mondrianCatalogService);
    final IUnifiedRepository unifiedRepository = new FileSystemBackedUnifiedRepository("target/test-classes/solution1");
    platform.defineInstance(IUnifiedRepository.class, unifiedRepository);
    platform.defineInstance(String.class, "admin");
    config = new GeoContextPropertiesProvider(getGeoProps());
    GeoContext geo = GeoContextFactory.create(config);
    platform.start();
    acl.setOwner("owner");
    acl.setOwnerType(RepositoryFileSid.Type.USER.ordinal());
    modelerService = new ModelerService();
    datasourceService = mock(DSWDatasourceServiceImpl.class);
    when(datasourceService.getGeoContext()).thenReturn(geo);
    modelerService.setDatasourceService(datasourceService);
    domain = getDomain();
}
Also used : IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) GeoContextPropertiesProvider(org.pentaho.agilebi.modeler.geo.GeoContextPropertiesProvider) IMetadataDomainRepository(org.pentaho.metadata.repository.IMetadataDomainRepository) IMondrianCatalogService(org.pentaho.platform.plugin.action.mondrian.catalog.IMondrianCatalogService) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader) GeoContext(org.pentaho.agilebi.modeler.geo.GeoContext) IAclAwareMondrianCatalogService(org.pentaho.platform.plugin.action.mondrian.catalog.IAclAwareMondrianCatalogService) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IPlatformImporter(org.pentaho.platform.plugin.services.importer.IPlatformImporter) IUserRoleListService(org.pentaho.platform.api.engine.IUserRoleListService) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) Before(org.junit.Before)

Example 5 with GeoContext

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

the class InMemoryDSWDatasourceServiceImpl method getGeoContext.

public GeoContext getGeoContext() throws DatasourceServiceException {
    try {
        Properties props = new Properties();
        props.load(new FileInputStream(new File("target/test-classes/geoContextSample.properties")));
        GeoContext geo = GeoContextFactory.create(new GeoContextPropertiesProvider(props));
        return geo;
    } catch (ModelerException e) {
        throw new DatasourceServiceException(e);
    } catch (FileNotFoundException e) {
        throw new DatasourceServiceException(e);
    } catch (IOException e) {
        // To change body of catch statement use File | Settings | File Templates.
        e.printStackTrace();
    }
    return null;
}
Also used : ModelerException(org.pentaho.agilebi.modeler.ModelerException) GeoContextPropertiesProvider(org.pentaho.agilebi.modeler.geo.GeoContextPropertiesProvider) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream) GeoContext(org.pentaho.agilebi.modeler.geo.GeoContext) DatasourceServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)

Aggregations

GeoContext (org.pentaho.agilebi.modeler.geo.GeoContext)5 ModelerException (org.pentaho.agilebi.modeler.ModelerException)2 GeoContextPropertiesProvider (org.pentaho.agilebi.modeler.geo.GeoContextPropertiesProvider)2 DatasourceServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ColResolverController (org.pentaho.agilebi.modeler.ColResolverController)1 IModelerWorkspaceHelper (org.pentaho.agilebi.modeler.IModelerWorkspaceHelper)1 ModelerController (org.pentaho.agilebi.modeler.ModelerController)1 BogoPojo (org.pentaho.agilebi.modeler.gwt.BogoPojo)1 GwtModelerMessages (org.pentaho.agilebi.modeler.gwt.GwtModelerMessages)1 MultiTableModelerSource (org.pentaho.agilebi.modeler.util.MultiTableModelerSource)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)1 ResourceBundle (org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle)1