How to use findBuildRevisionParametersByKey method of org.cerberus.servlet.crud.buildrevisionchange.ReadBuildRevisionParameters class

Best Cerberus-source code snippet using org.cerberus.servlet.crud.buildrevisionchange.ReadBuildRevisionParameters.findBuildRevisionParametersByKey

Source:ReadBuildRevisionParameters.java Github

copy

Full Screen

...113 AnswerItem answer = new AnswerItem<>(msg);114 try {115 JSONObject jsonResponse = new JSONObject();116 if ((request.getParameter("id") != null) && !(brpid_error)) { // ID parameter is specified so we return the unique record of object.117 answer = findBuildRevisionParametersByKey(brpid, appContext, userHasPermissions);118 jsonResponse = (JSONObject) answer.getItem();119 } else if ((request.getParameter("system") != null) && (request.getParameter("getlast") != null)) { // getlast parameter trigger the last release from the system..120 answer = findlastBuildRevisionParametersBySystem(request.getParameter("system"), appContext, userHasPermissions);121 jsonResponse = (JSONObject) answer.getItem();122 } else if ((request.getParameter("system") != null) && (request.getParameter("build") != null) && (request.getParameter("revision") != null) && (request.getParameter("getSVNRelease") != null)) { // getSVNRelease parameter trigger the list of SVN Release inside he build per Application.123 answer = findSVNBuildRevisionParametersBySystem(request.getParameter("system"), request.getParameter("country"), request.getParameter("environment"), request.getParameter("build"), request.getParameter("revision"), request.getParameter("lastbuild"), request.getParameter("lastrevision"), appContext, userHasPermissions);124 jsonResponse = (JSONObject) answer.getItem();125 } else if ((request.getParameter("system") != null) && (request.getParameter("build") != null) && (request.getParameter("revision") != null) && (request.getParameter("getNonSVNRelease") != null)) { // getNonSVNRelease parameter trigger the list of Manual Release with corresponding links.126 answer = findManualBuildRevisionParametersBySystem(request.getParameter("system"), request.getParameter("build"), request.getParameter("revision"), request.getParameter("lastbuild"), request.getParameter("lastrevision"), appContext, userHasPermissions);127 jsonResponse = (JSONObject) answer.getItem();128 } else if ((request.getParameter("system") != null) && !Strings.isNullOrEmpty(columnName)) {129 answer = findDistinctValuesOfColumn(request.getParameter("system"), appContext, request, columnName);130 jsonResponse = (JSONObject) answer.getItem();131 } else { // Default behaviour, we return the list of objects.132 answer = findBuildRevisionParametersList(request.getParameter("system"), request.getParameter("build"), request.getParameter("revision"), request.getParameter("application"), appContext, userHasPermissions, request);133 jsonResponse = (JSONObject) answer.getItem();134 }135 jsonResponse.put("messageType", answer.getResultMessage().getMessage().getCodeString());136 jsonResponse.put("message", answer.getResultMessage().getDescription());137 jsonResponse.put("sEcho", echo);138 response.getWriter().print(jsonResponse.toString());139 } catch (JSONException e) {140 LOG.warn(e);141 //returns a default error message with the json format that is able to be parsed by the client-side142 response.getWriter().print(AnswerUtil.createGenericErrorAnswer());143 }144 }145 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">146 /**147 * Handles the HTTP <code>GET</code> method.148 *149 * @param request servlet request150 * @param response servlet response151 * @throws ServletException if a servlet-specific error occurs152 * @throws IOException if an I/O error occurs153 */154 @Override155 protected void doGet(HttpServletRequest request, HttpServletResponse response)156 throws ServletException, IOException {157 try {158 processRequest(request, response);159 } catch (CerberusException ex) {160 LOG.warn(ex);161 }162 }163 /**164 * Handles the HTTP <code>POST</code> method.165 *166 * @param request servlet request167 * @param response servlet response168 * @throws ServletException if a servlet-specific error occurs169 * @throws IOException if an I/O error occurs170 */171 @Override172 protected void doPost(HttpServletRequest request, HttpServletResponse response)173 throws ServletException, IOException {174 try {175 processRequest(request, response);176 } catch (CerberusException ex) {177 LOG.warn(ex);178 }179 }180 /**181 * Returns a short description of the servlet.182 *183 * @return a String containing servlet description184 */185 @Override186 public String getServletInfo() {187 return "Short description";188 }// </editor-fold>189 private AnswerItem<JSONObject> findBuildRevisionParametersList(String system, String build, String revision, String application, ApplicationContext appContext, boolean userHasPermissions, HttpServletRequest request) throws JSONException {190 AnswerItem<JSONObject> item = new AnswerItem<>();191 JSONObject object = new JSONObject();192 brpService = appContext.getBean(BuildRevisionParametersService.class);193 int startPosition = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayStart"), "0"));194 int length = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayLength"), "0"));195 /*int sEcho = Integer.valueOf(request.getParameter("sEcho"));*/196 String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");197 int columnToSortParameter = Integer.parseInt(ParameterParserUtil.parseStringParam(request.getParameter("iSortCol_0"), "1"));198 String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "ID,Build,Revision,Release,Application,Project,TicketIDFixed,BugIDFixed,Link,ReleaseOwner,Subject,datecre,jenkinsbuildid,mavengroupid,mavenartifactid,mavenversion");199 String columnToSort[] = sColumns.split(",");200 String columnName = columnToSort[columnToSortParameter];201 String sort = ParameterParserUtil.parseStringParam(request.getParameter("sSortDir_0"), "asc");202 List<String> individualLike = new ArrayList<>(Arrays.asList(ParameterParserUtil.parseStringParam(request.getParameter("sLike"), "").split(",")));203 204 Map<String, List<String>> individualSearch = new HashMap<>();205 for (int a = 0; a < columnToSort.length; a++) {206 if (null!=request.getParameter("sSearch_" + a) && !request.getParameter("sSearch_" + a).isEmpty()) {207 List<String> search = new ArrayList<>(Arrays.asList(request.getParameter("sSearch_" + a).split(",")));208 if(individualLike.contains(columnToSort[a])) {209 individualSearch.put(columnToSort[a]+":like", search);210 }else {211 individualSearch.put(columnToSort[a], search);212 } 213 }214 }215 216 AnswerList<BuildRevisionParameters> resp = brpService.readByVarious1ByCriteria(system, application, build, revision, startPosition, length, columnName, sort, searchParameter, individualSearch);217 JSONArray jsonArray = new JSONArray();218 if (resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {//the service was able to perform the query, then we should get all values219 for (BuildRevisionParameters brp : (List<BuildRevisionParameters>) resp.getDataList()) {220 jsonArray.put(convertBuildRevisionParametersToJSONObject(brp));221 }222 }223 object.put("hasPermissions", userHasPermissions);224 object.put("contentTable", jsonArray);225 object.put("iTotalRecords", resp.getTotalRows());226 object.put("iTotalDisplayRecords", resp.getTotalRows());227 item.setItem(object);228 item.setResultMessage(resp.getResultMessage());229 return item;230 }231 private AnswerItem<JSONObject> findBuildRevisionParametersByKey(Integer id, ApplicationContext appContext, boolean userHasPermissions) throws JSONException, CerberusException {232 AnswerItem<JSONObject> item = new AnswerItem<>();233 JSONObject object = new JSONObject();234 IBuildRevisionParametersService libService = appContext.getBean(IBuildRevisionParametersService.class);235 //finds the project 236 AnswerItem answer = libService.readByKeyTech(id);237 if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {238 //if the service returns an OK message then we can get the item and convert it to JSONformat239 BuildRevisionParameters brp = (BuildRevisionParameters) answer.getItem();240 JSONObject response = convertBuildRevisionParametersToJSONObject(brp);241 object.put("contentTable", response);242 }243 object.put("hasPermissions", userHasPermissions);244 item.setItem(object);245 item.setResultMessage(answer.getResultMessage());...

Full Screen

Full Screen

findBuildRevisionParametersByKey

Using AI Code Generation

copy

Full Screen

1var buildRevisionId = request.getParameter("buildrevisionid");2var buildRevisionParameters = org.cerberus.servlet.crud.buildrevisionchange.ReadBuildRevisionParameters.findBuildRevisionParametersByKey(buildRevisionId);3response.getWriter().print(buildRevisionParameters);4[code=java]package org.cerberus.servlet.crud.buildrevisionchange;5import java.sql.Connection;6import java.sql.PreparedStatement;7import java.sql.ResultSet;8import java.sql.SQLException;9import java.util.ArrayList;10import java.util.List;11import org.apache.logging.log4j.LogManager;12import org.apache.logging.log4j.Logger;13import org.cerberus.database.DatabaseSpring;14import org.cerberus.crud.entity.BuildRevisionParameters;15import org.cerberus.crud.factory.IFactoryBuildRevisionParameters;16import org.cerberus.crud.factory.impl.FactoryBuildRevisionParameters;17import org.cerberus.exception.CerberusException;18import org.cerberus.util.ParameterParserUtil;19import org.json.JSONArray;20import org.json.JSONException;21import org.json.JSONObject;22import org.springframework.beans.factory.annotation.Autowired;23import org.springframework.context.ApplicationContext;24import org.springframework.stereotype.Controller;25import org.springframework.web.context.support.WebApplicationContextUtils;26public class ReadBuildRevisionParameters {27 private static final Logger LOG = LogManager.getLogger(ReadBuildRevisionParameters.class);28 private DatabaseSpring databaseSpring;29 private IFactoryBuildRevisionParameters factoryBuildRevisionParameters;30 public String findBuildRevisionParametersByKey(String buildRevisionId) throws CerberusException {31 JSONArray response = new JSONArray();32 boolean throwEx = false;33 StringBuilder query = new StringBuilder();34 query.append("SELECT * FROM buildrevisionparameters brp WHERE brp.build

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful