Search in sources :

Example 1 with DataSetDef

use of org.dashbuilder.dataset.def.DataSetDef in project kie-wb-common by kiegroup.

the class DataSetDefBuilder method build.

public DataSetDef build() {
    DataSetDef def = defBuilder.buildDef();
    def.setPublic(_public);
    return def;
}
Also used : DataSetDef(org.dashbuilder.dataset.def.DataSetDef)

Example 2 with DataSetDef

use of org.dashbuilder.dataset.def.DataSetDef 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 3 with DataSetDef

use of org.dashbuilder.dataset.def.DataSetDef in project jbpm by kiegroup.

the class QueryServiceImpl method unregisterQuery.

@Override
public void unregisterQuery(final String uniqueQueryName) throws QueryNotFoundException {
    DataSetDef def = dataSetDefRegistry.removeDataSetDef(uniqueQueryName);
    if (def == null) {
        throw new QueryNotFoundException("Query " + uniqueQueryName + " not found");
    }
    logger.info("Unregistered {} query successfully", uniqueQueryName);
}
Also used : DataSetDef(org.dashbuilder.dataset.def.DataSetDef) QueryNotFoundException(org.jbpm.services.api.query.QueryNotFoundException)

Example 4 with DataSetDef

use of org.dashbuilder.dataset.def.DataSetDef in project jbpm by kiegroup.

the class QueryServiceImpl method replaceQuery.

@Override
public void replaceQuery(QueryDefinition queryDefinition) {
    logger.debug("About to register {} query...", queryDefinition);
    if (queryDefinition instanceof SqlQueryDefinition) {
        SqlQueryDefinition sqlQueryDefinition = (SqlQueryDefinition) queryDefinition;
        SQLDataSetDefBuilder<?> builder = DataSetDefFactory.newSQLDataSetDef().uuid(sqlQueryDefinition.getName()).name(sqlQueryDefinition.getName() + "::" + sqlQueryDefinition.getTarget().toString()).dataSource(sqlQueryDefinition.getSource()).dbSQL(sqlQueryDefinition.getExpression(), true);
        DataSetDef sqlDef = builder.buildDef();
        try {
            dataSetDefRegistry.registerDataSetDef(sqlDef);
            DataSetMetadata metadata = dataSetManager.getDataSetMetadata(sqlDef.getUUID());
            if (queryDefinition.getTarget().equals(Target.BA_TASK)) {
                dataSetDefRegistry.registerPreprocessor(sqlDef.getUUID(), new BusinessAdminTasksPreprocessor(identityProvider, metadata));
            } else if (queryDefinition.getTarget().equals(Target.PO_TASK)) {
                dataSetDefRegistry.registerPreprocessor(sqlDef.getUUID(), new PotOwnerTasksPreprocessor(identityProvider, metadata));
            } else if (queryDefinition.getTarget().equals(Target.FILTERED_PROCESS)) {
                dataSetDefRegistry.registerPreprocessor(sqlDef.getUUID(), new DeploymentIdsPreprocessor(deploymentRolesManager, identityProvider, COLUMN_EXTERNALID));
            } else if (queryDefinition.getTarget().equals(Target.FILTERED_BA_TASK)) {
                dataSetDefRegistry.registerPreprocessor(sqlDef.getUUID(), new BusinessAdminTasksPreprocessor(identityProvider, metadata));
                dataSetDefRegistry.registerPreprocessor(sqlDef.getUUID(), new DeploymentIdsPreprocessor(deploymentRolesManager, identityProvider, COLUMN_DEPLOYMENTID));
            } else if (queryDefinition.getTarget().equals(Target.FILTERED_PO_TASK)) {
                dataSetDefRegistry.registerPreprocessor(sqlDef.getUUID(), new PotOwnerTasksPreprocessor(identityProvider, metadata));
                dataSetDefRegistry.registerPreprocessor(sqlDef.getUUID(), new DeploymentIdsPreprocessor(deploymentRolesManager, identityProvider, COLUMN_DEPLOYMENTID));
            }
            for (String columnId : metadata.getColumnIds()) {
                logger.debug("Column {} is of type {}", columnId, metadata.getColumnType(columnId));
                sqlDef.addColumn(columnId, metadata.getColumnType(columnId));
            }
            logger.info("Registered {} query successfully", queryDefinition.getName());
        } catch (DataSetLookupException e) {
            unregisterQuery(queryDefinition.getName());
            throw e;
        }
    }
}
Also used : DataSetDef(org.dashbuilder.dataset.def.DataSetDef) BusinessAdminTasksPreprocessor(org.jbpm.kie.services.impl.query.preprocessor.BusinessAdminTasksPreprocessor) DataSetLookupException(org.dashbuilder.dataset.exception.DataSetLookupException) PotOwnerTasksPreprocessor(org.jbpm.kie.services.impl.query.preprocessor.PotOwnerTasksPreprocessor) DeploymentIdsPreprocessor(org.jbpm.kie.services.impl.query.preprocessor.DeploymentIdsPreprocessor) DataSetMetadata(org.dashbuilder.dataset.DataSetMetadata)

Aggregations

DataSetDef (org.dashbuilder.dataset.def.DataSetDef)4 DataColumn (org.dashbuilder.dataset.DataColumn)1 DataSet (org.dashbuilder.dataset.DataSet)1 DataSetLookup (org.dashbuilder.dataset.DataSetLookup)1 DataSetMetadata (org.dashbuilder.dataset.DataSetMetadata)1 DataSetLookupException (org.dashbuilder.dataset.exception.DataSetLookupException)1 TableDisplayerSettingsBuilder (org.dashbuilder.displayer.TableDisplayerSettingsBuilder)1 GenericPortableException (org.guvnor.common.services.shared.exceptions.GenericPortableException)1 BusinessAdminTasksPreprocessor (org.jbpm.kie.services.impl.query.preprocessor.BusinessAdminTasksPreprocessor)1 DeploymentIdsPreprocessor (org.jbpm.kie.services.impl.query.preprocessor.DeploymentIdsPreprocessor)1 PotOwnerTasksPreprocessor (org.jbpm.kie.services.impl.query.preprocessor.PotOwnerTasksPreprocessor)1 QueryNotFoundException (org.jbpm.services.api.query.QueryNotFoundException)1 DataSourceDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)1