Search in sources :

Example 1 with AbstractCustomSqlExecution

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());
    }
}
Also used : Task(org.activiti.engine.task.Task) AbstractCustomSqlExecution(org.activiti.engine.impl.cmd.AbstractCustomSqlExecution) List(java.util.List) Map(java.util.Map)

Example 2 with AbstractCustomSqlExecution

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);
}
Also used : PaginatedSubstitutesDataModel(org.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel) SubstitutesDataModel(org.wso2.carbon.bpmn.core.mgt.model.SubstitutesDataModel) AbstractCustomSqlExecution(org.activiti.engine.impl.cmd.AbstractCustomSqlExecution) RowBounds(org.apache.ibatis.session.RowBounds) List(java.util.List) SubstitutesMapper(org.wso2.carbon.bpmn.core.internal.mapper.SubstitutesMapper)

Example 3 with AbstractCustomSqlExecution

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());
    }
}
Also used : Task(org.activiti.engine.task.Task) AbstractCustomSqlExecution(org.activiti.engine.impl.cmd.AbstractCustomSqlExecution) List(java.util.List) Map(java.util.Map)

Example 4 with AbstractCustomSqlExecution

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;
}
Also used : DeploymentMapper(org.wso2.carbon.bpmn.core.internal.mapper.DeploymentMapper) AbstractCustomSqlExecution(org.activiti.engine.impl.cmd.AbstractCustomSqlExecution) DeploymentMetaDataModel(org.wso2.carbon.bpmn.core.mgt.model.DeploymentMetaDataModel)

Example 5 with AbstractCustomSqlExecution

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);
}
Also used : AbstractCustomSqlExecution(org.activiti.engine.impl.cmd.AbstractCustomSqlExecution) SubstitutesMapper(org.wso2.carbon.bpmn.core.internal.mapper.SubstitutesMapper) Date(java.util.Date)

Aggregations

AbstractCustomSqlExecution (org.activiti.engine.impl.cmd.AbstractCustomSqlExecution)6 List (java.util.List)4 SubstitutesMapper (org.wso2.carbon.bpmn.core.internal.mapper.SubstitutesMapper)3 Map (java.util.Map)2 Task (org.activiti.engine.task.Task)2 RowBounds (org.apache.ibatis.session.RowBounds)2 PaginatedSubstitutesDataModel (org.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel)2 SubstitutesDataModel (org.wso2.carbon.bpmn.core.mgt.model.SubstitutesDataModel)2 Date (java.util.Date)1 DeploymentMapper (org.wso2.carbon.bpmn.core.internal.mapper.DeploymentMapper)1 DeploymentMetaDataModel (org.wso2.carbon.bpmn.core.mgt.model.DeploymentMetaDataModel)1