use of io.github.asw.i3a.operatorsWebClient.entitites.Incident in project InciDashboard_i3a by Arquisoft.
the class IncidentService method getInProcessIncidentsOfOperator.
public static List<Incident> getInProcessIncidentsOfOperator(String id) {
try {
HttpResponse<JsonNode> response = Unirest.post(API_GATEWAY + "/incidents?operatorId=" + id + "&status=IN_PROCESS").asJson();
ObjectMapper mapper = new ObjectMapper();
List<Incident> items = mapper.readValue(response.getBody().toString(), mapper.getTypeFactory().constructParametricType(List.class, Incident.class));
return items;
} catch (IOException | UnirestException e) {
e.printStackTrace();
return null;
}
}
use of io.github.asw.i3a.operatorsWebClient.entitites.Incident in project InciDashboard_i3a by Arquisoft.
the class IncidentService method getAllOpenIncidents.
public static Incident[] getAllOpenIncidents() {
try {
HttpResponse<JsonNode> response = Unirest.post(API_GATEWAY + "/incidents?status=OPEN").asJson();
ObjectMapper mapper = new ObjectMapper();
Incident[] items = mapper.readValue(response.getBody().toString(), Incident[].class);
log.info("Incidents retrieved: " + items.length);
return items;
} catch (IOException | UnirestException e) {
log.error("Error getting all open incidents: " + e.getMessage());
return null;
}
}
use of io.github.asw.i3a.operatorsWebClient.entitites.Incident in project InciDashboard_i3a by Arquisoft.
the class IncidentService method getAllIncidents.
public static List<Incident> getAllIncidents() {
try {
HttpResponse<JsonNode> response = Unirest.post(API_GATEWAY + "/incidents").asJson();
ObjectMapper mapper = new ObjectMapper();
List<Incident> items = mapper.readValue(response.getBody().toString(), mapper.getTypeFactory().constructParametricType(List.class, Incident.class));
return items;
} catch (IOException | UnirestException e) {
e.printStackTrace();
return null;
}
}
use of io.github.asw.i3a.operatorsWebClient.entitites.Incident in project InciDashboard_i3a by Arquisoft.
the class IncidentController method getDetail.
@RequestMapping("/incident/details/{id}")
public String getDetail(Model model, @PathVariable String id, @Nullable @CookieValue("operatorId") String opId) {
if (opId == null)
return "redirect:/login";
Incident inci = IncidentService.getIncident(id);
model.addAttribute("incident", inci);
try {
if (!inci.getLocation().isEmpty() && inci.getLocation().contains(", "))
model.addAttribute("lat", Double.parseDouble(inci.getLocation().split(", ")[0]));
model.addAttribute("lng", Double.parseDouble(inci.getLocation().split(", ")[1]));
} catch (Exception e) {
log.error("Error parsin the location of the incident no map will be displayed.");
}
log.info("Seeing incent: " + id + " details");
return "incident/details";
}
use of io.github.asw.i3a.operatorsWebClient.entitites.Incident in project InciDashboard_i3a by Arquisoft.
the class IncidentController method setEdit.
@RequestMapping(value = "/incident/edit/{id}", method = RequestMethod.POST)
public String setEdit(Model model, @ModelAttribute("inciInfo") InciInfo newInciData, @Nullable @CookieValue("operatorId") String opId, @PathVariable String id) {
if (opId == null)
return "redirect:/login";
Incident incident = IncidentService.getIncident(id);
giveNewDataToIncident(newInciData, incident, opId);
assignOp(opId, incident);
incident.setIncidentId(id);
log.info("Operator assigned to the incident");
IncidentService.saveIncident(incident);
log.info("Incident updated in the database");
return "redirect:/operator/listMyIncidents";
}
Aggregations