public void cargarSchedule(Boolean start) {
try {
Document doc;
Document docViajes = new Document("activo", "si");
doc = new Document("activo", "si");
List<Viaje> list = viajesRepository.findBy(docViajes, new Document("fecha", 1));
solicitudList = solicitudRepository.findBy(doc, new Document("fecha", 1));
eventModel = new DefaultScheduleModel();
if (!solicitudList.isEmpty()) {
solicitudList.forEach((a) -> {
String car = "{ ";
car = a.getTipovehiculo().stream().map((t) -> t.getIdtipovehiculo() + " ").reduce(car, String::concat);
car += " }";
String tema = "schedule-blue";
switch (a.getEstatus().getIdestatus()) {
case "SOLICITADO":
tema = "schedule-orange";
break;
case "APROBADO":
String viajest = "{";
viajest = a.getViaje().stream().map((t) -> t.getIdviaje() + " ").reduce(viajest, String::concat);
viajest = "}";
car += viajest;
tema = "schedule-green";
break;
case "RECHAZADO":
tema = "schedule-red";
break;
case "CANCELADO":
tema = "schedule-red";
break;
}
eventModel.addEvent(
new DefaultScheduleEvent("# " + a.getIdsolicitud() + " Mision: " + a.getMision() + " Responsable: " + a.getUsuario().get(1).getNombre() + " " + a.getEstatus().getIdestatus()
+ car,
a.getFechahorapartida(), a.getFechahoraregreso(), tema)
);
});
}
//Viajes
if (!list.isEmpty()) {
list.forEach((v) -> {
totalViajes++;
String car = v.getVehiculo().getMarca() + " " + v.getVehiculo().getModelo() + " " + v.getVehiculo().getPlaca();
String chofer = "{";
chofer = v.getConductor().getNombre();
chofer += " }";
eventModel.addEvent(
new DefaultScheduleEvent("#" + v.getIdviaje() + " Viaje: " + car + " " + chofer,
v.getFechahorainicioreserva(), v.getFechahorafinreserva(), "schedule-blue")
);
}
);
}
} catch (Exception e) {
errorServices.errorDialog(nameOfClass(), nameOfMethod(), "cargarSchedule", e.getLocalizedMessage());
}
}
// </editor-fold>