How to use readByKey method of org.cerberus.crud.service.impl.LogEventService class

Best Cerberus-source code snippet using org.cerberus.crud.service.impl.LogEventService.readByKey

Source:UpdateScheduleEntry.java Github

copy

Full Screen

1/**2 * Cerberus Copyright (C) 2013 - 2017 cerberustesting3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4 *5 * This file is part of Cerberus.6 *7 * Cerberus is free software: you can redistribute it and/or modify8 * it under the terms of the GNU General Public License as published by9 * the Free Software Foundation, either version 3 of the License, or10 * (at your option) any later version.11 *12 * Cerberus is distributed in the hope that it will be useful,13 * but WITHOUT ANY WARRANTY; without even the implied warranty of14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15 * GNU General Public License for more details.16 *17 * You should have received a copy of the GNU General Public License18 * along with Cerberus. If not, see <http://www.gnu.org/licenses/>.19 */20package org.cerberus.servlet.crud.scheduleentry;21import java.io.IOException;22import java.util.Date;23import javax.servlet.ServletException;24import javax.servlet.annotation.WebServlet;25import javax.servlet.http.HttpServlet;26import javax.servlet.http.HttpServletRequest;27import javax.servlet.http.HttpServletResponse;28import org.apache.logging.log4j.LogManager;29import org.apache.logging.log4j.Logger;30import org.cerberus.crud.entity.ScheduleEntry;31import org.cerberus.crud.factory.IFactoryLogEvent;32import org.cerberus.crud.factory.IFactoryScheduleEntry;33import org.cerberus.crud.factory.impl.FactoryLogEvent;34import org.cerberus.crud.service.ILogEventService;35import org.cerberus.crud.service.IMyVersionService;36import org.cerberus.crud.service.IScheduleEntryService;37import org.cerberus.crud.service.impl.LogEventService;38import org.cerberus.engine.entity.MessageEvent;39import org.cerberus.enums.MessageEventEnum;40import org.cerberus.util.ParameterParserUtil;41import org.cerberus.util.answer.Answer;42import org.cerberus.util.answer.AnswerItem;43import org.cerberus.util.servlet.ServletUtil;44import org.json.JSONException;45import org.json.JSONObject;46import org.owasp.html.PolicyFactory;47import org.owasp.html.Sanitizers;48import org.springframework.context.ApplicationContext;49import org.springframework.web.context.support.WebApplicationContextUtils;50/**51 *52 * @author cdelage53 */54@WebServlet(name = "UpdateScheduleEntry", urlPatterns = {"/UpdateScheduleEntry"})55public class UpdateScheduleEntry extends HttpServlet {56 private static final Logger LOG = LogManager.getLogger(UpdateScheduleEntry.class);57 /**58 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>59 * methods.60 *61 * @param request servlet request62 * @param response servlet response63 * @throws ServletException if a servlet-specific error occurs64 * @throws IOException if an I/O error occurs65 */66 protected void processRequest(HttpServletRequest request, HttpServletResponse response)67 throws ServletException, IOException, JSONException {68 JSONObject jsonResponse = new JSONObject();69 Answer ans = new AnswerItem<>();70 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);71 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));72 ans.setResultMessage(msg);73 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);74 response.setContentType("application/json");75 // Calling Servlet Transversal Util.76 ServletUtil.servletStart(request);77 /**78 * Parsing and securing all required parameters.79 */80 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());81 IFactoryScheduleEntry factoryScheduleEntry = appContext.getBean(IFactoryScheduleEntry.class);82 IScheduleEntryService scheduleEntryService = appContext.getBean(IScheduleEntryService.class);83 Integer id = ParameterParserUtil.parseIntegerParam(request.getParameter("id"), 0);84 ScheduleEntry oldScheduleEntry = new ScheduleEntry();85 oldScheduleEntry = scheduleEntryService.readbykey(id).getItem();86 String oldName = oldScheduleEntry.getName();87 String name = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("name"), oldName);88 String cronDefinition = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("cronDefinition"), "");89 String type = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("type"), "CAMPAIGN");90 String active = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("active"), "Y");91 String userModif = request.getUserPrincipal().getName();92 Boolean validCron = org.quartz.CronExpression.isValidExpression(cronDefinition);93 /**94 * Checking all constrains before calling the services.95 */96 if (name.isEmpty() || cronDefinition.isEmpty() || !validCron) {97 msg = new MessageEvent(MessageEventEnum.SCHEDULER_ERROR_EXPECTED);98 msg.setDescription(msg.getDescription().replace("%ITEM%", "campaign")99 .replace("%OPERATION%", "Update")100 .replace("%REASON%", "Some mendatory fields are missing!"));101 ans.setResultMessage(msg);102 } else {103 /**104 * All data seems cleans so we can call the services.105 */106 107 ScheduleEntry scheduleEntry = scheduleEntryService.readbykey(id).getItem();108 scheduleEntry.setName(name);109 scheduleEntry.setType(type);110 scheduleEntry.setCronDefinition(cronDefinition);111 scheduleEntry.setActive(active);112 scheduleEntry.setUsrModif(userModif);113 ans = scheduleEntryService.update(scheduleEntry);114 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {115 /**116 * Object created. Updating scheduler entry.117 */118 IMyVersionService myVersionService = appContext.getBean(IMyVersionService.class);119 myVersionService.updateMyVersionString("scheduler_version", String.valueOf(new Date()));120 /**121 * Object created. Adding Log entry.122 */123 ILogEventService logEventService = appContext.getBean(LogEventService.class);124 IFactoryLogEvent factoryLogEvent = appContext.getBean(FactoryLogEvent.class);125 logEventService.createForPrivateCalls("/UpdateScheduleEntry", "Update", "Update schedule entry : ['" + scheduleEntry.getName() + "']", request);126 }127 }128 /**129 * Formating and returning the json result.130 */131 jsonResponse.put("messageType", ans.getResultMessage().getMessage().getCodeString());132 jsonResponse.put("message", ans.getResultMessage().getDescription());133 response.getWriter().print(jsonResponse);134 response.getWriter().flush();135 }136 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">137 /**138 * Handles the HTTP <code>GET</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 doGet(HttpServletRequest request, HttpServletResponse response)147 throws ServletException, IOException {148 try {149 processRequest(request, response);150 } catch (JSONException ex) {151 LOG.warn(ex);152 }153 }154 /**155 * Handles the HTTP <code>POST</code> method.156 *157 * @param request servlet request158 * @param response servlet response159 * @throws ServletException if a servlet-specific error occurs160 * @throws IOException if an I/O error occurs161 */162 @Override163 protected void doPost(HttpServletRequest request, HttpServletResponse response)164 throws ServletException, IOException {165 try {166 processRequest(request, response);167 } catch (JSONException ex) {168 LOG.warn(ex);169 }170 }171 /**172 * Returns a short description of the servlet.173 *174 * @return a String containing servlet description175 */176 @Override177 public String getServletInfo() {178 return "Short description";179 }// </editor-fold>180}...

Full Screen

Full Screen

readByKey

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.service.impl.LogEventService;2import org.cerberus.crud.entity.LogEvent;3import org.cerberus.crud.factory.IFactoryLogEvent;4import java.util.List;5def factoryLogEvent = appContext.getBean("factoryLogEvent", IFactoryLogEvent.class);6def logEventService = appContext.getBean("logEventService", LogEventService.class);

Full Screen

Full Screen

readByKey

Using AI Code Generation

copy

Full Screen

1LogEventService logEventService = appContext.getBean(LogEventService.class);2LogEvent logEvent = logEventService.readByKey("id");3TestCaseExecutionService testCaseExecutionService = appContext.getBean(TestCaseExecutionService.class);4TestCaseExecution testCaseExecution = testCaseExecutionService.readByKey("id");5TestCaseService testCaseService = appContext.getBean(TestCaseService.class);6TestCase testCase = testCaseService.readByKey("id");7TestCaseStepService testCaseStepService = appContext.getBean(TestCaseStepService.class);8TestCaseStep testCaseStep = testCaseStepService.readByKey("id");9TestCaseStepActionService testCaseStepActionService = appContext.getBean(TestCaseStepActionService.class);10TestCaseStepAction testCaseStepAction = testCaseStepActionService.readByKey("id");11TestCaseStepActionControlService testCaseStepActionControlService = appContext.getBean(TestCaseStepActionControlService.class);12TestCaseStepActionControl testCaseStepActionControl = testCaseStepActionControlService.readByKey("id");13TestBatteryService testBatteryService = appContext.getBean(TestBatteryService.class);14TestBattery testBattery = testBatteryService.readByKey("id");15TestBatteryContentService testBatteryContentService = appContext.getBean(TestBatteryContentService.class);16TestBatteryContent testBatteryContent = testBatteryContentService.readByKey("id");17TestBatteryContentService testBatteryContentService = appContext.getBean(TestBatteryContentService.class);18TestBatteryContent testBatteryContent = testBatteryContentService.readByKey("id");19TestBatteryContentService testBatteryContentService = appContext.getBean(TestBatteryContentService.class);

Full Screen

Full Screen

readByKey

Using AI Code Generation

copy

Full Screen

1LogEvent logEvent = logEventService.readByKey(id);2LogEvent logEvent = logEventService.readByKey(id);3public interface ILogEventService {4 LogEvent readByKey(long id);5}6LogEvent logEvent = logEventService.readByKey(id);7public class LogEventService implements ILogEventService {8 public LogEvent readByKey(long id) {9 return logEventDAO.readByKey(id);10 }11}12public interface ILogEventDAO {13 LogEvent readByKey(long id);14}15public class LogEventDAO implements ILogEventDAO {

Full Screen

Full Screen

readByKey

Using AI Code Generation

copy

Full Screen

1LogEventService logEventService = appContext.getBean(LogEventService.class);2LogEvent logEvent = logEventService.readByKey(1);3TestCaseStepActionControlService testCaseStepActionControlService = appContext.getBean(TestCaseStepActionControlService.class);4TestCaseStepActionControl testCaseStepActionControl = testCaseStepActionControlService.readByKey(1);5TestCaseStepActionService testCaseStepActionService = appContext.getBean(TestCaseStepActionService.class);6TestCaseStepAction testCaseStepAction = testCaseStepActionService.readByKey(1);7TestCaseStepService testCaseStepService = appContext.getBean(TestCaseStepService.class);8TestCaseStep testCaseStep = testCaseStepService.readByKey(1);9TestCaseService testCaseService = appContext.getBean(TestCaseService.class);10TestCase testCase = testCaseService.readByKey(1);11TestCaseCountryPropertiesService testCaseCountryPropertiesService = appContext.getBean(TestCaseCountryPropertiesService.class);12TestCaseCountryProperties testCaseCountryProperties = testCaseCountryPropertiesService.readByKey(1);13TestCaseCountryService testCaseCountryService = appContext.getBean(TestCaseCountryService.class);

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