Search in sources :

Example 1 with QueryDefinitionEntity

use of org.jbpm.kie.services.impl.query.persistence.QueryDefinitionEntity in project jbpm by kiegroup.

the class QueryServiceImpl method init.

public void init() {
    if (dataSetDefRegistry == null && dataSetManager == null && providerRegistry == null) {
        dataSetDefRegistry = DataSetCore.get().getDataSetDefRegistry();
        dataSetManager = DataSetCore.get().getDataSetManager();
        providerRegistry = DataSetCore.get().getDataSetProviderRegistry();
        providerRegistry.registerDataProvider(SQLDataSetProvider.get());
        dataSetDefRegistry.addListener(new PersistDataSetListener(commandService));
    }
    // load previously registered query definitions
    if (commandService != null) {
        List<QueryDefinitionEntity> queries = commandService.execute(new QueryNameCommand<List<QueryDefinitionEntity>>("getQueryDefinitions"));
        for (QueryDefinitionEntity entity : queries) {
            QueryDefinition definition = entity.toQueryDefinition();
            try {
                registerQuery(definition);
            } catch (QueryAlreadyRegisteredException e) {
                logger.debug("Query {} already registered, skipping...", definition.getName());
            }
        }
    }
}
Also used : QueryDefinitionEntity(org.jbpm.kie.services.impl.query.persistence.QueryDefinitionEntity) QueryDefinition(org.jbpm.services.api.query.model.QueryDefinition) List(java.util.List) ArrayList(java.util.ArrayList) PersistDataSetListener(org.jbpm.kie.services.impl.query.persistence.PersistDataSetListener) QueryAlreadyRegisteredException(org.jbpm.services.api.query.QueryAlreadyRegisteredException)

Example 2 with QueryDefinitionEntity

use of org.jbpm.kie.services.impl.query.persistence.QueryDefinitionEntity in project jbpm by kiegroup.

the class QueryServiceImpl method getQueries.

@Override
public List<QueryDefinition> getQueries(QueryContext queryContext) {
    List<QueryDefinition> result = new ArrayList<QueryDefinition>();
    Map<String, Object> params = new HashMap<String, Object>();
    applyQueryContext(params, queryContext);
    List<QueryDefinitionEntity> queries = commandService.execute(new QueryNameCommand<List<QueryDefinitionEntity>>("getQueryDefinitions", params));
    for (QueryDefinitionEntity entity : queries) {
        QueryDefinition definition = entity.toQueryDefinition();
        result.add(definition);
    }
    return result;
}
Also used : QueryDefinition(org.jbpm.services.api.query.model.QueryDefinition) QueryDefinitionEntity(org.jbpm.kie.services.impl.query.persistence.QueryDefinitionEntity) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 QueryDefinitionEntity (org.jbpm.kie.services.impl.query.persistence.QueryDefinitionEntity)2 QueryDefinition (org.jbpm.services.api.query.model.QueryDefinition)2 HashMap (java.util.HashMap)1 PersistDataSetListener (org.jbpm.kie.services.impl.query.persistence.PersistDataSetListener)1 QueryAlreadyRegisteredException (org.jbpm.services.api.query.QueryAlreadyRegisteredException)1