use of io.github.asw.i3a.operatorsWebClient.entitites.Incident in project InciDashboard_i3a by Arquisoft.
the class OperatorController method getMyIncidentsList.
@RequestMapping("/operator/listMyIncidents")
public String getMyIncidentsList(Model model, @Nullable @CookieValue("operatorId") String opId) {
if (opId == null)
return "redirect:/login";
List<Incident> incidents = IncidentService.getInProcessIncidentsOfOperator(opId);
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", new Locale("us"));
Collections.sort(incidents, Collections.reverseOrder((i1, i2) -> {
try {
return sdf.parse(i1.getDate()).compareTo(sdf.parse(i2.getDate()));
} catch (ParseException e) {
log.error(e.getMessage());
return 0;
}
}));
model.addAttribute("incidents", incidents);
log.info("Redirecting to the incidents of the operator");
return "operator/incidents";
}
use of io.github.asw.i3a.operatorsWebClient.entitites.Incident in project InciDashboard_i3a by Arquisoft.
the class Receiver method listen.
@KafkaListener(topics = "${kafka.topic}")
public void listen(String kafkaInput) {
JsonNode kafkaPayload = new JsonNode(kafkaInput);
String incidentId = "";
try {
incidentId = kafkaPayload.getObject().getString("incidentId");
log.info("Incident received on kafka with id: " + incidentId);
} catch (JSONException e) {
log.error(e.getMessage());
}
Incident in = assignOperator(IncidentService.getIncident(incidentId));
this.template.convertAndSend("/topic/incidents", in);
}
use of io.github.asw.i3a.operatorsWebClient.entitites.Incident in project InciDashboard_i3a by Arquisoft.
the class IncidentController method getListOpen.
@RequestMapping(value = "/incidents", method = RequestMethod.GET)
public String getListOpen(Model model, @Nullable @CookieValue("operatorId") String opId) {
if (opId == null)
return "redirect:/login";
List<Incident> incidents = Arrays.asList(IncidentService.getAllOpenIncidents());
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", new Locale("us"));
Collections.sort(incidents, Collections.reverseOrder((i1, i2) -> {
try {
return sdf.parse(i1.getDate()).compareTo(sdf.parse(i2.getDate()));
} catch (ParseException e) {
log.error(e.getMessage());
return 0;
}
}));
model.addAttribute("incidents", incidents);
log.info("Incidents sent to the model: " + incidents.size());
return "incident/list";
}
use of io.github.asw.i3a.operatorsWebClient.entitites.Incident in project InciDashboard_i3a by Arquisoft.
the class IncidentController method getEdit.
@RequestMapping(value = "/incident/edit/{id}", method = RequestMethod.GET)
public String getEdit(Model model, @Nullable @CookieValue("operatorId") String opId, @PathVariable String id) {
if (opId == null)
return "redirect:/login";
Incident incident = IncidentService.getIncident(id);
model.addAttribute("incident", incident);
log.info("Page for editing incident: " + id);
return "incident/edit";
}
use of io.github.asw.i3a.operatorsWebClient.entitites.Incident in project InciDashboard_i3a by Arquisoft.
the class IncidentTest method extraTest.
@Test
public void extraTest() {
Incident i = new Incident();
i.setIncidentId("5aef2acdb1f3911fd0bdb41c");
assertNotNull(i.getDate().equals("Sun May 06 18:18:21 CEST 2018"));
Incident i2 = new Incident();
assertTrue(i.canEquals(i2));
}
Aggregations