use of org.jbpm.kie.services.impl.query.preprocessor.DeploymentIdsPreprocessor 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;
}
}
}
Aggregations