How to use findDistinctValuesOfColumn method of org.cerberus.servlet.crud.testexecution.ReadTag class

Best Cerberus-source code snippet using org.cerberus.servlet.crud.testexecution.ReadTag.findDistinctValuesOfColumn

Source:ReadTag.java Github

copy

Full Screen

...99 answer = findTagByKey(tag, appContext, request);100 jsonResponse = (JSONObject) answer.getItem();101 } else if (!Strings.isNullOrEmpty(columnName)) {102 //If columnName is present, then return the distinct value of this column.103 answer = findDistinctValuesOfColumn(appContext, request, columnName);104 jsonResponse = (JSONObject) answer.getItem();105 } else {106 answer = findTagList(appContext, userHasPermissions, request);107 jsonResponse = (JSONObject) answer.getItem();108 }109 jsonResponse.put("messageType", answer.getResultMessage().getMessage().getCodeString());110 jsonResponse.put("message", answer.getResultMessage().getDescription());111 jsonResponse.put("sEcho", echo);112 response.getWriter().print(jsonResponse.toString());113 } catch (JSONException e) {114 LOG.warn(e);115 //returns a default error message with the json format that is able to be parsed by the client-side116 response.getWriter().print(AnswerUtil.createGenericErrorAnswer());117 }118 }119 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">120 /**121 * Handles the HTTP <code>GET</code> method.122 *123 * @param request servlet request124 * @param response servlet response125 * @throws ServletException if a servlet-specific error occurs126 * @throws IOException if an I/O error occurs127 */128 @Override129 protected void doGet(HttpServletRequest request, HttpServletResponse response)130 throws ServletException, IOException {131 try {132 processRequest(request, response);133 } catch (CerberusException ex) {134 LOG.warn(ex);135 }136 }137 /**138 * Handles the HTTP <code>POST</code> method.139 *140 * @param request servlet request141 * @param response servlet response142 * @throws ServletException if a servlet-specific error occurs143 * @throws IOException if an I/O error occurs144 */145 @Override146 protected void doPost(HttpServletRequest request, HttpServletResponse response)147 throws ServletException, IOException {148 try {149 processRequest(request, response);150 } catch (CerberusException ex) {151 LOG.warn(ex);152 }153 }154 /**155 * Returns a short description of the servlet.156 *157 * @return a String containing servlet description158 */159 @Override160 public String getServletInfo() {161 return "Short description";162 }// </editor-fold>163 private AnswerItem<JSONObject> findTagList(ApplicationContext appContext, boolean userHasPermissions, HttpServletRequest request) throws JSONException {164 AnswerItem<JSONObject> item = new AnswerItem<>();165 JSONObject object = new JSONObject();166 tagService = appContext.getBean(TagService.class);167 int startPosition = 0;168 if (request.getParameter("iDisplayStartPage") != null) {169 startPosition = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayStartPage"), "0"));170 startPosition--;171 startPosition = startPosition * 30;172 } else {173 startPosition = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayStart"), "0"));174 }175 int length = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayLength"), "0"));176 /*int sEcho = Integer.valueOf(request.getParameter("sEcho"));*/177 String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");178 int columnToSortParameter = Integer.parseInt(ParameterParserUtil.parseStringParam(request.getParameter("iSortCol_0"), "1"));179 String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "id,tag,campaign,description");180 String columnToSort[] = sColumns.split(",");181 String columnName = columnToSort[columnToSortParameter];182 String sort = ParameterParserUtil.parseStringParam(request.getParameter("sSortDir_0"), "desc");183 List<String> systems = ParameterParserUtil.parseListParamAndDecodeAndDeleteEmptyValue(request.getParameterValues("system"), Arrays.asList("DEFAULT"), "UTF-8");184 Map<String, List<String>> individualSearch = new HashMap<>();185 for (int a = 0; a < columnToSort.length; a++) {186 if (null != request.getParameter("sSearch_" + a) && !request.getParameter("sSearch_" + a).isEmpty()) {187 List<String> search = new ArrayList<>(Arrays.asList(request.getParameter("sSearch_" + a).split(",")));188 individualSearch.put(columnToSort[a], search);189 }190 }191 AnswerList<Tag> resp = tagService.readByCriteria(startPosition, length, columnName, sort, searchParameter, individualSearch, systems);192 JSONArray jsonArray = new JSONArray();193 if (resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {//the service was able to perform the query, then we should get all values194 for (Tag tagCur : (List<Tag>) resp.getDataList()) {195 jsonArray.put(convertTagToJSONObject(tagCur));196 }197 }198 object.put("hasPermissions", userHasPermissions);199 object.put("contentTable", jsonArray);200 object.put("iTotalRecords", resp.getTotalRows());201 object.put("iTotalDisplayRecords", resp.getTotalRows());202 item.setItem(object);203 item.setResultMessage(resp.getResultMessage());204 return item;205 }206 private AnswerItem<JSONObject> findTagByKeyTech(long id, ApplicationContext appContext, boolean userHasPermissions) throws JSONException, CerberusException {207 AnswerItem<JSONObject> item = new AnswerItem<>();208 JSONObject object = new JSONObject();209 ITagService libService = appContext.getBean(ITagService.class);210 //finds the project211 AnswerItem answer = libService.readByKeyTech(id);212 if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {213 //if the service returns an OK message then we can get the item and convert it to JSONformat214 Tag tag = (Tag) answer.getItem();215 JSONObject response = convertTagToJSONObject(tag);216 object.put("contentTable", response);217 }218 object.put("hasPermissions", userHasPermissions);219 item.setItem(object);220 item.setResultMessage(answer.getResultMessage());221 return item;222 }223 private AnswerItem<JSONObject> findTagByKey(String tag, ApplicationContext appContext, HttpServletRequest request) throws JSONException, CerberusException {224 AnswerItem<JSONObject> item = new AnswerItem<>();225 JSONObject object = new JSONObject();226 ITagService libService = appContext.getBean(ITagService.class);227 //finds the project228 AnswerItem answer = libService.readByKey(tag);229 if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {230 //if the service returns an OK message then we can get the item and convert it to JSONformat231 Tag tagObj = (Tag) answer.getItem();232 JSONObject response = convertTagToJSONObject(tagObj);233// response.put("hasPermissionsUpdate", libService.hasPermissionsUpdate(tagObj, request));234// response.put("hasPermissionsDelete", libService.hasPermissionsDelete(tagObj, request));235 object.put("contentTable", response);236 }237// object.put("hasPermissionsCreate", libService.hasPermissionsCreate(null, request));238 item.setItem(object);239 item.setResultMessage(answer.getResultMessage());240 return item;241 }242 private JSONObject convertTagToJSONObject(Tag tag) throws JSONException {243 Gson gson = new Gson();244 JSONObject result = new JSONObject(gson.toJson(tag));245 return result;246 }247 private AnswerItem<JSONObject> findDistinctValuesOfColumn(ApplicationContext appContext, HttpServletRequest request, String columnName) throws JSONException {248 AnswerItem<JSONObject> answer = new AnswerItem<>();249 JSONObject object = new JSONObject();250 tagService = appContext.getBean(TagService.class);251 String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");252 String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "test,testcase,application,project,ticket,description,detailedDescription,readonly,bugtrackernewurl,deploytype,mavengroupid");253 String columnToSort[] = sColumns.split(",");254 Map<String, List<String>> individualSearch = new HashMap<>();255 for (int a = 0; a < columnToSort.length; a++) {256 if (null != request.getParameter("sSearch_" + a) && !request.getParameter("sSearch_" + a).isEmpty()) {257 List<String> search = new ArrayList<>(Arrays.asList(request.getParameter("sSearch_" + a).split(",")));258 individualSearch.put(columnToSort[a], search);259 }260 }261 AnswerList tagList = tagService.readDistinctValuesByCriteria(null, searchParameter, individualSearch, columnName);...

Full Screen

Full Screen

findDistinctValuesOfColumn

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.entity.TestCaseExecution;2import org.cerberus.crud.entity.TestCaseExecutionData;3import org.cerberus.crud.factory.IFactoryTestCaseExecutionData;4import org.cerberus.crud.service.ITestCaseExecutionDataService;5import org.cerberus.crud.service.impl.TestCaseExecutionDataService;6import org.cerberus.servlet.crud.testexecution.ReadTag;7import org.cerberus.util.answer.AnswerItem;8import org.springframework.beans.factory.annotation.Autowired;9List<TestCaseExecutionData> tcedList = new ArrayList<TestCaseExecutionData>();10List<TestCaseExecutionData> tcedList2 = new ArrayList<TestCaseExecutionData>();11List<TestCaseExecutionData> tcedList3 = new ArrayList<TestCaseExecutionData>();12List<TestCaseExecutionData> tcedList4 = new ArrayList<TestCaseExecutionData>();13TestCaseExecution tce = new TestCaseExecution();14tce.setTest("TEST");15tce.setTestCase("TESTCASE");16tce.setCountry("FR");17tce.setEnvironment("QA");18tce.setBuild("1.0.0");19tce.setRevision("1.0.0");20ReadTag rt = new ReadTag();21TestCaseExecutionDataService tceds = new TestCaseExecutionDataService();22TestCaseExecutionData tced = new TestCaseExecutionData();23tced.setTest("TEST");24tced.setTestCase("TESTCASE");25tced.setCountry("FR");26tced.setEnvironment("QA");27tced.setBuild("1.0.0");28tced.setRevision("1.0.0");29tced.setProperty("PROPERTY");30tced.setValue("VALUE");31tcedList.add(tced);32tced.setProperty("PROPERTY2");33tced.setValue("VALUE2");34tcedList.add(tced);35tced.setProperty("PROPERTY3");36tced.setValue("

Full Screen

Full Screen

findDistinctValuesOfColumn

Using AI Code Generation

copy

Full Screen

1package org.cerberus.servlet.crud.testexecution;2import java.io.IOException;3import java.io.PrintWriter;4import java.sql.Connection;5import java.sql.ResultSet;6import java.sql.SQLException;7import java.sql.Statement;8import java.util.ArrayList;9import java.util.HashMap;10import java.util.List;11import java.util.logging.Level;12import java.util.logging.Logger;13import java.util.regex.Matcher;14import java.util.regex.Pattern;15import javax.servlet.ServletException;16import javax.servlet.http.HttpServlet;17import javax.servlet.http.HttpServletRequest;18import javax.servlet.http.HttpServletResponse;19import org.apache.commons.lang3.StringUtils;20import org.cerberus.database.DatabaseSpring;21import org.cerberus.engine.entity.MessageEvent;22import org.cerberus.engine.entity.MessageGeneral;23import org.cerberus.engine.entity.MessageEventEnum;24import org.cerberus.factory.IFactoryLogEvent;25import org.cerberus.log.MyLogger;26import org.cerberus.service.datalib.IDataLibService;27import org.cerberus.service.datalib.impl.DataLibService;28import org.cerberus.service.engine.IParameterService;29import org.cerberus.service.engine.IRecorderService;30import org.cerberus.service.engine.impl.ParameterService;31import org.cerberus.service.engine.impl.RecorderService;32import org.cerberus.service.sql.ISqlService;33import org.cerberus.service.sql.impl.SqlService;34import org.cerberus.util.ParameterParserUtil;35import org.cerberus.util.answer.Answer;36import org.cerberus.util.answer.AnswerItem;37import org.cerberus.util.answer.AnswerList;38import org.cerberus.version.Infos;39import org.springframework.context.ApplicationContext;40import org.springframework.context.support.ClassPathXmlApplicationContext

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful