Search in sources :

Example 16 with SubstitutesDataModel

use of org.wso2.carbon.bpmn.core.mgt.model.SubstitutesDataModel in project carbon-business-process by wso2.

the class ActivitiDAO method querySubstituteInfoWithoutEnabled.

/**
 * Return the list of substitute info based on query parameters except enabled property.
 * @param model data model with only required query parameter values. Leave others as null.
 * @return List<PaginatedSubstitutesDataModel> Result set of substitute info
 */
public List<SubstitutesDataModel> querySubstituteInfoWithoutEnabled(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.querySubstitutesWithoutEnabled(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 17 with SubstitutesDataModel

use of org.wso2.carbon.bpmn.core.mgt.model.SubstitutesDataModel in project carbon-business-process by wso2.

the class TransitivityResolver method resolveSubstituteForSingleUser.

protected boolean resolveSubstituteForSingleUser(SubstitutesDataModel dataModel, int tenantId) {
    if (SubstitutionDataHolder.getInstance().isTransitivityEnabled()) {
        subsMap = dao.selectActiveSubstitutesByTenant(tenantId, new Date(System.currentTimeMillis()));
        SubstitutesDataModel subDataModel = dao.selectSubstituteInfo(dataModel.getSubstitute(), tenantId);
        if (subDataModel != null) {
            String newSub = calculateTransitiveSubstitute(dataModel, dataModel.getUser(), dataModel.getSubstitute());
            if (BPMNConstants.TRANSITIVE_SUB_UNDEFINED.equals(newSub)) {
                return false;
            } else {
                dao.updateTransitiveSub(dataModel.getUser(), tenantId, newSub);
                return true;
            }
        } else {
            dao.updateTransitiveSub(dataModel.getUser(), tenantId, BPMNConstants.TRANSITIVE_SUB_NOT_APPLICABLE);
            return true;
        }
    } else {
        // transitivity not enabled. NO issue with transitive properties.
        return true;
    }
}
Also used : SubstitutesDataModel(org.wso2.carbon.bpmn.core.mgt.model.SubstitutesDataModel) Date(java.util.Date)

Aggregations

SubstitutesDataModel (org.wso2.carbon.bpmn.core.mgt.model.SubstitutesDataModel)15 PaginatedSubstitutesDataModel (org.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel)11 ActivitiDAO (org.wso2.carbon.bpmn.core.mgt.dao.ActivitiDAO)7 AbstractCustomSqlExecution (org.activiti.engine.impl.cmd.AbstractCustomSqlExecution)3 SubstitutesMapper (org.wso2.carbon.bpmn.core.internal.mapper.SubstitutesMapper)3 Date (java.util.Date)2 List (java.util.List)2 RowBounds (org.apache.ibatis.session.RowBounds)2 BPMNForbiddenException (org.wso2.carbon.bpmn.rest.common.exception.BPMNForbiddenException)2 ActivitiException (org.activiti.engine.ActivitiException)1 HashedMap (org.apache.commons.collections.map.HashedMap)1 PrivilegedCarbonContext (org.wso2.carbon.context.PrivilegedCarbonContext)1 UserStoreException (org.wso2.carbon.user.api.UserStoreException)1