use of org.activiti.engine.impl.cmd.AbstractCustomSqlExecution in project Activiti by Activiti.
the class CustomMybatisMapperTest method testFetchTaskWithSpecificVariable.
public void testFetchTaskWithSpecificVariable() {
// Create test data
for (int i = 0; i < 5; i++) {
Task task = taskService.newTask();
task.setName(i + "");
taskService.saveTask(task);
taskService.setVariable(task.getId(), "myVar", Long.valueOf(task.getId()) * 2);
taskService.setVariable(task.getId(), "myVar2", "SomeOtherValue");
}
// Fetch data with custom query
CustomSqlExecution<MyTestMapper, List<Map<String, Object>>> customSqlExecution = new AbstractCustomSqlExecution<MyTestMapper, List<Map<String, Object>>>(MyTestMapper.class) {
public List<Map<String, Object>> execute(MyTestMapper customMapper) {
return customMapper.selectTaskWithSpecificVariable("myVar");
}
};
// Verify
List<Map<String, Object>> results = managementService.executeCustomSql(customSqlExecution);
assertEquals(5, results.size());
for (int i = 0; i < 5; i++) {
Map<String, Object> result = results.get(i);
Long id = Long.valueOf((String) getResultObject("TASKID", result));
Long variableValue = ((Number) getResultObject("VARIABLEVALUE", result)).longValue();
assertEquals(id * 2, variableValue.longValue());
}
// Cleanup
for (Task task : taskService.createTaskQuery().list()) {
taskService.deleteTask(task.getId());
historyService.deleteHistoricTaskInstance(task.getId());
}
}
use of org.activiti.engine.impl.cmd.AbstractCustomSqlExecution in project carbon-business-process by wso2.
the class ActivitiDAO method querySubstituteInfo.
/**
* Return the list of substitute info based on query parameters.
* @param model model with only required query parameter values. Leave others as null. By default enabled=false.
* @return List<SubstitutesDataModel> Result set of substitute info
*/
public List<SubstitutesDataModel> querySubstituteInfo(final PaginatedSubstitutesDataModel model) {
final RowBounds rw = new RowBounds(model.getStart(), model.getSize());
CustomSqlExecution<SubstitutesMapper, List<SubstitutesDataModel>> customSqlExecution = new AbstractCustomSqlExecution<SubstitutesMapper, List<SubstitutesDataModel>>(SubstitutesMapper.class) {
public List<SubstitutesDataModel> execute(SubstitutesMapper substitutesMapper) {
return substitutesMapper.querySubstitutes(rw, model);
}
};
return managementService.executeCustomSql(customSqlExecution);
}
use of org.activiti.engine.impl.cmd.AbstractCustomSqlExecution in project Activiti by Activiti.
the class CustomMybatisMapperTest method testSelectTaskColumns.
public void testSelectTaskColumns() {
// Create test data
for (int i = 0; i < 5; i++) {
Task task = taskService.newTask();
task.setName(i + "");
taskService.saveTask(task);
}
// Fetch the columns we're interested in
CustomSqlExecution<MyTestMapper, List<Map<String, Object>>> customSqlExecution = new AbstractCustomSqlExecution<MyTestMapper, List<Map<String, Object>>>(MyTestMapper.class) {
public List<Map<String, Object>> execute(MyTestMapper customMapper) {
return customMapper.selectTasks();
}
};
// Verify
List<Map<String, Object>> tasks = managementService.executeCustomSql(customSqlExecution);
assertEquals(5, tasks.size());
for (int i = 0; i < 5; i++) {
Map<String, Object> task = tasks.get(i);
assertNotNull(getResultObject("ID", task));
assertNotNull(getResultObject("NAME", task));
assertNotNull(getResultObject("CREATETIME", task));
}
// Cleanup
for (Task task : taskService.createTaskQuery().list()) {
taskService.deleteTask(task.getId());
historyService.deleteHistoricTaskInstance(task.getId());
}
}
use of org.activiti.engine.impl.cmd.AbstractCustomSqlExecution in project carbon-business-process by wso2.
the class ActivitiDAO method selectTenantAwareDeploymentModel.
/**
* invokes the DeploymentMapper.selectMetaData for a given tenant id and package name
*
* @param tenantID tenant id
* @param bpmnPackageName package name
* @return DeploymentMetaDataModel object
*/
public DeploymentMetaDataModel selectTenantAwareDeploymentModel(final String tenantID, final String bpmnPackageName) {
CustomSqlExecution<DeploymentMapper, DeploymentMetaDataModel> customSqlExecution = new AbstractCustomSqlExecution<DeploymentMapper, DeploymentMetaDataModel>(DeploymentMapper.class) {
public DeploymentMetaDataModel execute(DeploymentMapper deploymentMapper) {
return deploymentMapper.selectMetaData(tenantID, bpmnPackageName);
}
};
DeploymentMetaDataModel deploymentMetaDataModel = managementService.executeCustomSql(customSqlExecution);
if (log.isDebugEnabled()) {
if (deploymentMetaDataModel != null) {
log.debug("DeploymentDataModel exists when selecting models=" + deploymentMetaDataModel.getId());
} else {
log.debug("DeploymentDataModel null when selecting models");
}
}
return deploymentMetaDataModel;
}
use of org.activiti.engine.impl.cmd.AbstractCustomSqlExecution in project carbon-business-process by wso2.
the class ActivitiDAO method updateSubstituteInfo.
/**
* Update the substitute record for given user
* @param substitutesDataModel
* @return updated row count. Ideally should return 1.
*/
public int updateSubstituteInfo(final SubstitutesDataModel substitutesDataModel) {
substitutesDataModel.setUpdated(new Date());
CustomSqlExecution<SubstitutesMapper, Integer> customSqlExecution = new AbstractCustomSqlExecution<SubstitutesMapper, Integer>(SubstitutesMapper.class) {
public Integer execute(SubstitutesMapper substitutesMapper) {
return substitutesMapper.updateSubstitute(substitutesDataModel);
}
};
return managementService.executeCustomSql(customSqlExecution);
}
Aggregations