Commit 9a44428e by Billy Larru

quitando librerias de pruebas

parent 904229ff
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=SalidasAutomaticas
application.vendor=sistem19user
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
......@@ -26,17 +27,13 @@ dist.archive.excludes=
dist.dir=dist
dist.jar=${dist.dir}/SalidasAutomaticas.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.c3p0-0.9.1.1.jar=librerias\\c3p0-0.9.1.1.jar
file.reference.commons-dbcp-1.4.jar=librerias\\commons-dbcp-1.4.jar
file.reference.commons-pool-1.6.jar=librerias\\commons-pool-1.6.jar
file.reference.json-20151123.jar=librerias\\json-20151123.jar
file.reference.log4j-1.2.16.jar=librerias\\log4j-1.2.16.jar
file.reference.mysql-connector-java-3.1.14-bin.jar=librerias\\mysql-connector-java-3.1.14-bin.jar
file.reference.quartz-2.2.3.jar=librerias\\quartz-2.2.3.jar
file.reference.quartz-jobs-2.2.3.jar=librerias\\quartz-jobs-2.2.3.jar
file.reference.slf4j-api-1.7.7.jar=librerias\\slf4j-api-1.7.7.jar
file.reference.slf4j-log4j12-1.7.7.jar=librerias\\slf4j-log4j12-1.7.7.jar
includes=**
jar.compress=false
javac.classpath=\
......@@ -44,12 +41,7 @@ javac.classpath=\
${file.reference.commons-dbcp-1.4.jar}:\
${file.reference.commons-pool-1.6.jar}:\
${file.reference.json-20151123.jar}:\
${file.reference.log4j-1.2.16.jar}:\
${file.reference.mysql-connector-java-3.1.14-bin.jar}:\
${file.reference.quartz-2.2.3.jar}:\
${file.reference.quartz-jobs-2.2.3.jar}:\
${file.reference.slf4j-api-1.7.7.jar}:\
${file.reference.slf4j-log4j12-1.7.7.jar}
${file.reference.mysql-connector-java-3.1.14-bin.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package salidasautomaticas.schedule;
import java.time.LocalDate;
import java.time.LocalDateTime;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
/**
*
* @author sistem19user
*/
public class GenerarSalidasJob implements Job{
@Override
public void execute(JobExecutionContext jec) throws JobExecutionException {
System.out.println("Salida "+LocalDateTime.now());
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package salidasautomaticas.schedule;
import org.quartz.SchedulerFactory;
import org.quartz.impl.StdSchedulerFactory;
/**
*
* @author sistem19user
*/
public class Planificador {
private static Planificador instance;
private StdSchedulerFactory sf;
private Planificador(){
sf = new StdSchedulerFactory();
}
public static Planificador getInstance(){
if(instance==null) instance = new Planificador();
return instance;
}
public SchedulerFactory getSchedulerFactory(){
return sf;
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package salidasautomaticas.schedule;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.json.JSONArray;
import org.json.JSONObject;
import static org.quartz.CronScheduleBuilder.cronSchedule;
import org.quartz.CronTrigger;
import org.quartz.Job;
import static org.quartz.JobBuilder.newJob;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import static org.quartz.TriggerBuilder.newTrigger;
import org.quartz.impl.StdSchedulerFactory;
import salidasautomaticas.main.Main;
import salidasautomaticas.services.SalidasServices;
/**
*
* @author sistem19user
*/
public class ProgramarSalidasJob implements Job{
@Override
public void execute(JobExecutionContext jec) throws JobExecutionException {
SalidasServices services = new SalidasServices();
try {
JSONArray listaHorarios = services.obtenerHorariosSalida();
Iterator it = listaHorarios.iterator();
int i =0;
while(it.hasNext()){
JSONObject objJSON = (JSONObject) it.next();
String horaSalida = objJSON.getString("salida");
System.out.println(horaSalida);
programar(horaSalida, Integer.toString(i));
i++;
}
} catch (Exception ex) {
Logger.getLogger(ProgramarSalidasJob.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void programar(String horaSalida, String jobName){
SchedulerFactory sf = Planificador.getInstance().getSchedulerFactory();
Scheduler scheduler;
String[] splitHora = horaSalida.split(":");
try {
scheduler = sf.getScheduler();
JobDetail job = newJob(GenerarSalidasJob.class).withIdentity(jobName, "groupSalida1").build();
String cronExpression = "0 %s %s * * ?";
cronExpression = String.format(cronExpression, splitHora[1], splitHora[0]);
CronTrigger trigger = newTrigger().withIdentity("triggerSalida"+jobName, "groupSalida1").withSchedule(cronSchedule(cronExpression))
.build();
scheduler.scheduleJob(job, trigger);
scheduler.start();
} catch (SchedulerException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment