use of org.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel in project carbon-business-process by wso2.
the class UserSubstitutionUtils method querySubstitutions.
/**
* Query substitution records by given properties.
* Allowed properties: user, substitute, enabled.
* Pagination parameters : start, size, sort, order
* @param propertiesMap
* @return Paginated list of PaginatedSubstitutesDataModel
*/
public static List<SubstitutesDataModel> querySubstitutions(Map<String, String> propertiesMap, int tenantId) {
ActivitiDAO activitiDAO = SubstitutionDataHolder.getInstance().getActivitiDAO();
PaginatedSubstitutesDataModel model = getPaginatedModelFromRequest(propertiesMap, tenantId);
String enabled = propertiesMap.get(SubstitutionQueryProperties.ENABLED);
boolean enabledProvided = false;
if (enabled != null) {
enabledProvided = true;
}
if (!enabledProvided) {
return prepareEndTime(activitiDAO.querySubstituteInfoWithoutEnabled(model));
} else {
return prepareEndTime(activitiDAO.querySubstituteInfo(model));
}
}
use of org.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel 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.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel in project carbon-business-process by wso2.
the class UserSubstitutionUtils method getPaginatedModelFromRequest.
/**
* Prepare the paginated data model for a substitution query
* @param propertiesMap
* @param tenantId
* @return PaginatedSubstitutesDataModel
*/
private static PaginatedSubstitutesDataModel getPaginatedModelFromRequest(Map<String, String> propertiesMap, int tenantId) {
PaginatedSubstitutesDataModel model = new PaginatedSubstitutesDataModel();
if (propertiesMap.get(SubstitutionQueryProperties.SUBSTITUTE) != null) {
model.setSubstitute(propertiesMap.get(SubstitutionQueryProperties.SUBSTITUTE));
}
if (propertiesMap.get(SubstitutionQueryProperties.USER) != null) {
model.setUser(propertiesMap.get(SubstitutionQueryProperties.USER));
}
String enabled = propertiesMap.get(SubstitutionQueryProperties.ENABLED);
if (enabled != null) {
if (enabled.equalsIgnoreCase("true")) {
model.setEnabled(true);
} else if (enabled.equalsIgnoreCase("false")) {
model.setEnabled(false);
} else {
throw new ActivitiIllegalArgumentException("Invalid parameter " + enabled + " for enabled property.");
}
}
model.setTenantId(tenantId);
int start = Integer.parseInt(propertiesMap.get(SubstitutionQueryProperties.START));
int size = Integer.parseInt(propertiesMap.get(SubstitutionQueryProperties.SIZE));
model.setStart(start);
model.setSize(size);
model.setOrder(propertiesMap.get(SubstitutionQueryProperties.ORDER));
model.setSort(propertiesMap.get(SubstitutionQueryProperties.SORT));
return model;
}
use of org.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel in project carbon-business-process by wso2.
the class UserSubstitutionUtils method getQueryResultCount.
/**
* Total count of query substitution result by given properties.
* Allowed properties: user, substitute, enabled.
* Pagination parameters : start, size, sort, order
* @param propertiesMap
* @return Total count of query result
*/
public static int getQueryResultCount(Map<String, String> propertiesMap, int tenantId) {
ActivitiDAO activitiDAO = SubstitutionDataHolder.getInstance().getActivitiDAO();
PaginatedSubstitutesDataModel model = getPaginatedModelFromRequest(propertiesMap, tenantId);
String enabled = propertiesMap.get(SubstitutionQueryProperties.ENABLED);
boolean enabledProvided = false;
if (enabled != null) {
enabledProvided = true;
}
if (!enabledProvided) {
return activitiDAO.selectQueryResultCountWithoutEnabled(model);
} else {
return activitiDAO.selectQueryResultCount(model);
}
}
use of org.wso2.carbon.bpmn.core.mgt.model.PaginatedSubstitutesDataModel 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);
}
Aggregations