Search in sources :

Example 1 with AppServiceService

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

the class ReadAppService method findAppServiceByLikeName.

private AnswerItem findAppServiceByLikeName(String key, ApplicationContext appContext, int limit) throws JSONException {
    AnswerItem answerItem = new AnswerItem();
    JSONObject response = new JSONObject();
    appServiceService = appContext.getBean(AppServiceService.class);
    AnswerList resp = appServiceService.readByLikeName(key, limit);
    AppService p = null;
    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 (AppService appService : (List<AppService>) resp.getDataList()) {
            jsonArray.put(convertSoapLibraryToJSONObject(appService));
        }
    }
    response.put("contentTable", jsonArray);
    response.put("iTotalRecords", resp.getTotalRows());
    response.put("iTotalDisplayRecords", resp.getTotalRows());
    answerItem.setItem(response);
    answerItem.setResultMessage(resp.getResultMessage());
    return answerItem;
}
Also used : AnswerList(org.cerberus.util.answer.AnswerList) AppService(org.cerberus.crud.entity.AppService) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) AnswerList(org.cerberus.util.answer.AnswerList) AppServiceService(org.cerberus.crud.service.impl.AppServiceService) IAppServiceService(org.cerberus.crud.service.IAppServiceService) AnswerItem(org.cerberus.util.answer.AnswerItem)

Example 2 with AppServiceService

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

the class ReadAppService method findAppServiceList.

private AnswerItem findAppServiceList(ApplicationContext appContext, boolean userHasPermissions, HttpServletRequest request) throws JSONException {
    AnswerItem item = new AnswerItem();
    JSONObject object = new JSONObject();
    appServiceService = appContext.getBean(AppServiceService.class);
    int startPosition = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayStart"), "0"));
    int length = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayLength"), "0"));
    /*int sEcho  = Integer.valueOf(request.getParameter("sEcho"));*/
    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"), "service,type,method,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<>();
    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 = appServiceService.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 (AppService param : (List<AppService>) resp.getDataList()) {
            jsonArray.put(convertSoapLibraryToJSONObject(param));
        }
    }
    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 : AnswerList(org.cerberus.util.answer.AnswerList) AppService(org.cerberus.crud.entity.AppService) JSONArray(org.json.JSONArray) AnswerItem(org.cerberus.util.answer.AnswerItem) JSONObject(org.json.JSONObject) AnswerList(org.cerberus.util.answer.AnswerList) AppServiceService(org.cerberus.crud.service.impl.AppServiceService) IAppServiceService(org.cerberus.crud.service.IAppServiceService)

Example 3 with AppServiceService

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

the class ReadAppService method findAppServiceBySystemByKey.

private AnswerItem findAppServiceBySystemByKey(String key, ApplicationContext appContext, boolean userHasPermissions) throws JSONException {
    JSONObject response = new JSONObject();
    appServiceService = appContext.getBean(AppServiceService.class);
    AnswerItem resp = appServiceService.readByKeyWithDependency(key, null);
    AppService p = null;
    if (resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
        // the service was able to perform the query, then we should get all values
        p = (AppService) resp.getItem();
    }
    JSONObject item = convertSoapLibraryToJSONObject(p);
    response.put("contentTable", item);
    item.put("hasPermissions", userHasPermissions);
    resp.setItem(response);
    return resp;
}
Also used : AppService(org.cerberus.crud.entity.AppService) JSONObject(org.json.JSONObject) AppServiceService(org.cerberus.crud.service.impl.AppServiceService) IAppServiceService(org.cerberus.crud.service.IAppServiceService) AnswerItem(org.cerberus.util.answer.AnswerItem)

Aggregations

AppService (org.cerberus.crud.entity.AppService)3 IAppServiceService (org.cerberus.crud.service.IAppServiceService)3 AppServiceService (org.cerberus.crud.service.impl.AppServiceService)3 AnswerItem (org.cerberus.util.answer.AnswerItem)3 JSONObject (org.json.JSONObject)3 AnswerList (org.cerberus.util.answer.AnswerList)2 JSONArray (org.json.JSONArray)2