Search in sources :

Example 1 with DataSetMetadata

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

the class ContributorsManagerTest method testBuildDataSet.

@Test
public void testBuildDataSet() throws Exception {
    DataSet dataSet = contributorsManager.buildDataSet(null);
    assertEquals(68, dataSet.getRowCount());
    assertEquals(6, dataSet.getColumns().size());
    DataColumn column = dataSet.getColumns().get(0);
    assertEquals(ColumnType.LABEL, column.getColumnType());
    assertEquals(COLUMN_ORG, column.getId());
    column = dataSet.getColumns().get(1);
    assertEquals(ColumnType.LABEL, column.getColumnType());
    assertEquals(COLUMN_REPO, column.getId());
    column = dataSet.getColumns().get(2);
    assertEquals(ColumnType.LABEL, column.getColumnType());
    assertEquals(COLUMN_PROJECT, column.getId());
    column = dataSet.getColumns().get(3);
    assertEquals(ColumnType.LABEL, column.getColumnType());
    assertEquals(COLUMN_AUTHOR, column.getId());
    column = dataSet.getColumns().get(4);
    assertEquals(ColumnType.TEXT, column.getColumnType());
    assertEquals(COLUMN_MSG, column.getId());
    column = dataSet.getColumns().get(5);
    assertEquals(ColumnType.DATE, column.getColumnType());
    assertEquals(COLUMN_DATE, column.getId());
    DataSetMetadata metadata = dataSet.getMetadata();
    assertNotNull(metadata);
}
Also used : DataSet(org.dashbuilder.dataset.DataSet) DataColumn(org.dashbuilder.dataset.DataColumn) DataSetMetadata(org.dashbuilder.dataset.DataSetMetadata) Test(org.junit.Test)

Example 2 with DataSetMetadata

use of org.dashbuilder.dataset.DataSetMetadata 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

DataSetMetadata (org.dashbuilder.dataset.DataSetMetadata)2 DataColumn (org.dashbuilder.dataset.DataColumn)1 DataSet (org.dashbuilder.dataset.DataSet)1 DataSetDef (org.dashbuilder.dataset.def.DataSetDef)1 DataSetLookupException (org.dashbuilder.dataset.exception.DataSetLookupException)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 Test (org.junit.Test)1