How to use create method of org.cerberus.crud.factory.impl.FactoryScheduledExecution class

Best Cerberus-source code snippet using org.cerberus.crud.factory.impl.FactoryScheduledExecution.create

Source:ScheduledJob.java Github

copy

Full Screen

...84 String convertDateFireTime = simpleDateFormat.format(scheduleFireTime);85 Timestamp factice = new Timestamp(System.currentTimeMillis());86 LOG.info("Job " + schedulerId + " for '" + scheduleName + "' campaign is starting.");87 try {88 ScheduledExecution scheduledExecutionObject = factoryScheduledExecution.create(1, schedulerId, scheduleName, "TOLAUNCH", "Job is created", user, "", scheduledDate, scheduleFireTime, factice, factice);89 //if execution have type campaign90 if (type.equalsIgnoreCase("CAMPAIGN")) {91 try {92 long createScx;93 createScx = scheduledExecutionService.create(scheduledExecutionObject);94 if (createScx > 0) {95 scheduledExecutionObject.setID(createScx);96 try {97 CloseableHttpClient httpclient = null;98 HttpClientBuilder httpclientBuilder;99 httpclientBuilder = HttpClientBuilder.create();100 httpclient = httpclientBuilder.build();101 String request = new String();102 String encodeName = URLEncoder.encode(scheduleName, "UTF-8");103 request = parameterService.getParameterStringByKey("cerberus_url", "", "") + SERVLET_ADDTOEXECUTION + "?campaign=" + encodeName + "&outputformat=json";104 HttpGet requesthttp = new HttpGet(request);105 requesthttp.setHeader("apikey", apiKeyService.getServiceAccountAPIKey());106 HttpResponse responsehttp = httpclient.execute(requesthttp);107 int statusCode = responsehttp.getStatusLine().getStatusCode();108 LOG.info("Url called to trigger Campaign : '" + request + "' status code : " + statusCode);109 if (statusCode == 200 || statusCode == 201) {110 HttpEntity entity = responsehttp.getEntity();111 if (entity != null) {112 scheduledExecutionObject.setStatus(ScheduledExecution.STATUS_TRIGGERED);113 String json_string = EntityUtils.toString(entity);114 try {115 JSONObject temp1 = new JSONObject(json_string);116 StringBuilder message = new StringBuilder();117 message.append(temp1.getString("message"));118 if (!StringUtil.isNullOrEmpty(temp1.getString("tag"))) {119 message.append(" Tag Execution : ");120 message.append(temp1.getString("tag"));121 }122 if (!StringUtil.isNullOrEmpty(message.toString())) {123 scheduledExecutionObject.setComment(message.toString());124 } else {125 scheduledExecutionObject.setComment("Campaign triggered but result got no message output");126 }127 } catch (JSONException e) {128 LOG.error("Failed to parse JSON from URL call. " + request);129 scheduledExecutionObject.setStatus(ScheduledExecution.STATUS_ERROR);130 scheduledExecutionObject.setComment("Campaign triggered but result was not in json format");131 }132 } else {133 scheduledExecutionObject.setStatus(ScheduledExecution.STATUS_TRIGGERED);134 scheduledExecutionObject.setComment("Campaign triggered but empty result from Service " + SERVLET_ADDTOEXECUTION);135 }136 try {137 Answer updateScx = new Answer();138 updateScx = scheduledExecutionService.update(scheduledExecutionObject);139 scheduleEntryService.updateLastExecution(scheduledExecutionObject.getSchedulerId(), scheduledExecutionObject.getScheduledDate());140 } catch (Exception e) {141 LOG.error("Failed to update scheduledExecution", e);142 }143 } else {144 // Http code <> 200 and <> 201145 LOG.error("Request " + request + " return http" + statusCode);146 scheduledExecutionObject.setStatus(ScheduledExecution.STATUS_ERROR);147 scheduledExecutionObject.setComment("Failed to trigger Campaign. Return code : " + statusCode + " From Request : " + request);148 Answer updateScx = scheduledExecutionService.update(scheduledExecutionObject);149 }150 } catch (Exception e) {151 LOG.error("Failed to call " + SERVLET_ADDTOEXECUTION + ", catch exception", e);152 scheduledExecutionObject.setStatus(ScheduledExecution.STATUS_ERROR);153 scheduledExecutionObject.setComment("Failed to trigger Campaign. Error : '" + e.getMessage());154 Answer updateScx = scheduledExecutionService.update(scheduledExecutionObject);155 }156 } else {157 LOG.info("No execution inserted for JobId " + schedulerId + " Campaign '" + scheduleName + " FireTime '" + scheduleFireTime + "' in database (Potentialy another instance of Cerberus already triggered the job).");158 }159 } catch (Exception e) {160 LOG.info("Cannot insert execution for JobId " + schedulerId + " Campaign '" + scheduleName + " FireTime '" + scheduleFireTime + "' in database (Potentialy another instance of Cerberus already triggered the job).");161 }162 }163 } catch (Exception e) {164 //Log if executionScheduled is already insert in base165 LOG.error("Cannot create object, catch exception :" + e);166 }167 } catch (Exception e) {168 LOG.error("Exception catch on Job Execution :" + e);169 }170 }171}...

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.

Most used method in FactoryScheduledExecution

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful