use of org.cerberus.crud.service.impl.ApplicationService in project cerberus-source by cerberustesting.
the class ReadApplication method findApplicationList.
// </editor-fold>
private AnswerItem findApplicationList(String system, ApplicationContext appContext, boolean userHasPermissions, HttpServletRequest request) throws JSONException {
AnswerItem item = new AnswerItem();
JSONObject object = new JSONObject();
applicationService = appContext.getBean(ApplicationService.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"), "2"));
String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "Application,Description,sort,type,system,subsystem,svnurl,bugtrackerurl,bugtrackernewurl,deploytype,mavengroupid");
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 = applicationService.readBySystemByCriteria(system, 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 (Application application : (List<Application>) resp.getDataList()) {
jsonArray.put(convertApplicationToJSONObject(application));
}
}
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;
}
use of org.cerberus.crud.service.impl.ApplicationService in project cerberus-source by cerberustesting.
the class ReadTestCaseExecution method findValuesForColumnFilter.
/**
* Find Values to display for Column Filter
*
* @param system
* @param test
* @param appContext
* @param request
* @param columnName
* @return
* @throws JSONException
*/
private AnswerItem findValuesForColumnFilter(String system, String test, ApplicationContext appContext, HttpServletRequest request, String columnName) throws JSONException {
AnswerItem answer = new AnswerItem();
JSONObject object = new JSONObject();
AnswerList values = new AnswerList();
Map<String, List<String>> individualSearch = new HashMap<>();
testCaseService = appContext.getBean(TestCaseService.class);
invariantService = appContext.getBean(InvariantService.class);
buildRevisionInvariantService = appContext.getBean(BuildRevisionInvariantService.class);
applicationService = appContext.getBean(ApplicationService.class);
LOG.debug(columnName);
switch(columnName) {
/**
* Columns from Status
*/
case "exe.controlStatus":
List<String> dataList = new ArrayList<>();
dataList.add(TestCaseExecution.CONTROLSTATUS_CA);
dataList.add(TestCaseExecution.CONTROLSTATUS_FA);
dataList.add(TestCaseExecution.CONTROLSTATUS_KO);
dataList.add(TestCaseExecution.CONTROLSTATUS_NA);
dataList.add(TestCaseExecution.CONTROLSTATUS_NE);
dataList.add(TestCaseExecution.CONTROLSTATUS_OK);
dataList.add(TestCaseExecution.CONTROLSTATUS_PE);
values.setDataList(dataList);
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
msg.setDescription(msg.getDescription().replace("%ITEM%", "execution").replace("%OPERATION%", "SELECT"));
values.setResultMessage(msg);
break;
/**
* For columns test and testcase, get distinct values from test
* table
*/
case "exe.test":
case "exe.testcase":
case "exe.status":
values = testCaseService.readDistinctValuesByCriteria(system, test, "", null, columnName.replace("exe.", "tec."));
break;
/**
* For columns country, environment get values from invariant
*/
case "exe.country":
case "exe.environment":
try {
/**
*/
AnswerList<Invariant> invariants = invariantService.readByIdname(columnName.replace("exe.", ""));
List<Invariant> invariantList = invariantService.convert(invariants);
List<String> stringResult = new ArrayList();
for (Invariant inv : invariantList) {
stringResult.add(inv.getValue());
}
values.setDataList(stringResult);
values.setTotalRows(invariantList.size());
values.setResultMessage(invariants.getResultMessage());
} catch (CerberusException ex) {
LOG.warn(ex);
}
break;
/**
* For columns build, revision get values from
* buildrevisioninvariant
*/
case "exe.build":
case "exe.revision":
individualSearch = new HashMap<>();
individualSearch.put("level", new ArrayList(Arrays.asList(columnName.equals("exe.build") ? "1" : "2")));
values = buildRevisionInvariantService.readDistinctValuesByCriteria(system, "", individualSearch, "versionName");
break;
/**
* For columns application get values from application
*/
case "exe.application":
values = applicationService.readDistinctValuesByCriteria(system, "", null, columnName.replace("exe.", ""));
break;
/**
* For all other columns, get distinct values from testcaseexecution
*/
default:
String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");
String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "tec.test,tec.testcase,application,project,ticket,description,behaviororvalueexpected,readonly,bugtrackernewurl,deploytype,mavengroupid");
String[] columnToSort = sColumns.split(",");
List<String> individualLike = new ArrayList(Arrays.asList(ParameterParserUtil.parseStringParam(request.getParameter("sLike"), "").split(",")));
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);
}
}
}
values = testCaseExecutionService.readDistinctValuesByCriteria(system, test, searchParameter, individualSearch, columnName);
}
object.put("distinctValues", values.getDataList());
answer.setItem(object);
answer.setResultMessage(values.getResultMessage());
return answer;
}
Aggregations