Search in sources :

Example 1 with DeployTypeService

use of org.cerberus.crud.service.impl.DeployTypeService in project cerberus-source by cerberustesting.

the class ReadDeployType method findDeployTypeList.

// </editor-fold>
private AnswerItem findDeployTypeList(ApplicationContext appContext, boolean userHasPermissions, HttpServletRequest request) throws JSONException {
    AnswerItem item = new AnswerItem();
    JSONObject object = new JSONObject();
    deployTypeService = appContext.getBean(DeployTypeService.class);
    int startPosition = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayStart"), "0"));
    int length = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayLength"), "0"));
    String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");
    int columnToSortParameter = Integer.parseInt(ParameterParserUtil.parseStringParam(request.getParameter("iSortCol_0"), "0"));
    String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "deploytype,description");
    String[] columnToSort = sColumns.split(",");
    String columnName = columnToSort[columnToSortParameter];
    String sort = ParameterParserUtil.parseStringParam(request.getParameter("sSortDir_0"), "asc");
    List<String> individualLike = new ArrayList(Arrays.asList(ParameterParserUtil.parseStringParam(request.getParameter("sLike"), "").split(",")));
    Map<String, List<String>> individualSearch = new HashMap<String, List<String>>();
    for (int a = 0; a < columnToSort.length; a++) {
        if (null != request.getParameter("sSearch_" + a) && !request.getParameter("sSearch_" + a).isEmpty()) {
            List<String> search = new ArrayList(Arrays.asList(request.getParameter("sSearch_" + a).split(",")));
            if (individualLike.contains(columnToSort[a])) {
                individualSearch.put(columnToSort[a] + ":like", search);
            } else {
                individualSearch.put(columnToSort[a], search);
            }
        }
    }
    AnswerList resp = deployTypeService.readByCriteria(startPosition, length, columnName, sort, searchParameter, individualSearch);
    JSONArray jsonArray = new JSONArray();
    if (resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
        // the service was able to perform the query, then we should get all values
        for (DeployType deploytype : (List<DeployType>) resp.getDataList()) {
            jsonArray.put(convertDeployTypeToJSONObject(deploytype));
        }
    }
    object.put("hasPermissions", userHasPermissions);
    object.put("contentTable", jsonArray);
    object.put("iTotalRecords", resp.getTotalRows());
    object.put("iTotalDisplayRecords", resp.getTotalRows());
    item.setItem(object);
    item.setResultMessage(resp.getResultMessage());
    return item;
}
Also used : DeployType(org.cerberus.crud.entity.DeployType) AnswerList(org.cerberus.util.answer.AnswerList) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) AnswerItem(org.cerberus.util.answer.AnswerItem) IDeployTypeService(org.cerberus.crud.service.IDeployTypeService) DeployTypeService(org.cerberus.crud.service.impl.DeployTypeService) JSONObject(org.json.JSONObject) AnswerList(org.cerberus.util.answer.AnswerList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 DeployType (org.cerberus.crud.entity.DeployType)1 IDeployTypeService (org.cerberus.crud.service.IDeployTypeService)1 DeployTypeService (org.cerberus.crud.service.impl.DeployTypeService)1 AnswerItem (org.cerberus.util.answer.AnswerItem)1 AnswerList (org.cerberus.util.answer.AnswerList)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1