Search in sources :

Example 1 with GenericPortableException

use of org.guvnor.common.services.shared.exceptions.GenericPortableException in project kie-wb-common by kiegroup.

the class DataManagementServiceImpl method getDisplayerSettings.

@Override
public DisplayerSettings getDisplayerSettings(String dataSourceUuid, String schema, String table) {
    checkNotNull("dataSourceUuid", dataSourceUuid);
    checkNotNull("table", table);
    try {
        DataSourceDeploymentInfo deploymentInfo = dataSourceRuntimeManager.getDataSourceDeploymentInfo(dataSourceUuid);
        DataSetDef dataSetDef = DataSetDefBuilder.newBuilder().dataSetUuid(buildDataSetUuid(dataSourceUuid, schema, table)).dataSetName(buildDataSetName(schema, table)).dataSourceUuid(deploymentInfo.getUuid()).schema(schema).table(buildDataSetTableName(dataSourceUuid, table)).isPublic(false).build();
        dataSetDefRegistry.registerDataSetDef(dataSetDef);
        DataSetLookup lookup = new DataSetLookup();
        lookup.setDataSetUUID(dataSetDef.getUUID());
        DataSet dataSet = dataSetManager.lookupDataSet(lookup);
        TableDisplayerSettingsBuilder settingsBuilder = DisplayerSettingsFactory.newTableSettings().dataset(dataSetDef.getUUID()).title(table).titleVisible(true).tablePageSize(20).tableOrderEnabled(true);
        List<DataColumn> columns = dataSet.getColumns();
        for (DataColumn column : columns) {
            settingsBuilder.column(column.getId());
        }
        int tableWith = columns.size() * COLUMN_WIDTH;
        settingsBuilder.tableWidth(tableWith);
        settingsBuilder.renderer(DefaultRenderer.UUID);
        return settingsBuilder.buildSettings();
    } catch (Exception e) {
        throw new GenericPortableException(e.getMessage());
    }
}
Also used : DataSetDef(org.dashbuilder.dataset.def.DataSetDef) DataSet(org.dashbuilder.dataset.DataSet) DataColumn(org.dashbuilder.dataset.DataColumn) GenericPortableException(org.guvnor.common.services.shared.exceptions.GenericPortableException) TableDisplayerSettingsBuilder(org.dashbuilder.displayer.TableDisplayerSettingsBuilder) DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo) DataSetLookup(org.dashbuilder.dataset.DataSetLookup) GenericPortableException(org.guvnor.common.services.shared.exceptions.GenericPortableException)

Example 2 with GenericPortableException

use of org.guvnor.common.services.shared.exceptions.GenericPortableException in project kie-wb-common by kiegroup.

the class DatabaseMetadataServiceImpl method findTables.

@Override
public List<TableMetadata> findTables(String dataSourceUuid, String schema, String tableNamePattern, DatabaseMetadata.TableType... types) {
    checkNotNull("dataSourceUuid", dataSourceUuid);
    checkNotNull("types", types);
    try {
        DataSource dataSource = dataSourceRuntimeManager.lookupDataSource(dataSourceUuid);
        return DatabaseMetadataUtil.findTables(dataSource.getConnection(), schema, tableNamePattern, types);
    } catch (Exception e) {
        logger.error("It was not possible to get database metadata for data source: " + dataSourceUuid, e);
        throw new GenericPortableException("It was not possible to get database metadata for data source: " + dataSourceUuid + ": " + e.getMessage(), e);
    }
}
Also used : GenericPortableException(org.guvnor.common.services.shared.exceptions.GenericPortableException) GenericPortableException(org.guvnor.common.services.shared.exceptions.GenericPortableException) DataSource(org.kie.workbench.common.screens.datasource.management.backend.core.DataSource)

Example 3 with GenericPortableException

use of org.guvnor.common.services.shared.exceptions.GenericPortableException in project drools-wb by kiegroup.

the class ScenarioRunnerService method run.

public TestScenarioResult run(final String identifier, final Scenario scenario, final KieModule module) {
    try {
        final HashMap<String, KieSession> ksessions = new HashMap<String, KieSession>();
        final String ksessionName = getKSessionName(scenario.getKSessions());
        ksessions.put(ksessionName, loadKSession(module, ksessionName));
        final AuditLogger auditLogger = new AuditLogger(ksessions);
        final ScenarioRunner4JUnit scenarioRunner = new ScenarioRunner4JUnit(scenario, ksessions, getMaxRuleFirings());
        run(identifier, scenarioRunner, defaultTestResultMessageEvent);
        return new TestScenarioResult(scenario, auditLogger.getLog());
    } catch (InitializationError initializationError) {
        throw new GenericPortableException(initializationError.getMessage());
    }
}
Also used : HashMap(java.util.HashMap) InitializationError(org.junit.runners.model.InitializationError) GenericPortableException(org.guvnor.common.services.shared.exceptions.GenericPortableException) KieSession(org.kie.api.runtime.KieSession) ScenarioRunner4JUnit(org.drools.workbench.models.testscenarios.backend.ScenarioRunner4JUnit) TestScenarioResult(org.drools.workbench.screens.testscenario.model.TestScenarioResult)

Aggregations

GenericPortableException (org.guvnor.common.services.shared.exceptions.GenericPortableException)3 HashMap (java.util.HashMap)1 DataColumn (org.dashbuilder.dataset.DataColumn)1 DataSet (org.dashbuilder.dataset.DataSet)1 DataSetLookup (org.dashbuilder.dataset.DataSetLookup)1 DataSetDef (org.dashbuilder.dataset.def.DataSetDef)1 TableDisplayerSettingsBuilder (org.dashbuilder.displayer.TableDisplayerSettingsBuilder)1 ScenarioRunner4JUnit (org.drools.workbench.models.testscenarios.backend.ScenarioRunner4JUnit)1 TestScenarioResult (org.drools.workbench.screens.testscenario.model.TestScenarioResult)1 InitializationError (org.junit.runners.model.InitializationError)1 KieSession (org.kie.api.runtime.KieSession)1 DataSource (org.kie.workbench.common.screens.datasource.management.backend.core.DataSource)1 DataSourceDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)1