|
|
@ -109,7 +109,7 @@ public class RedmineClient { |
|
|
|
return tickets; |
|
|
|
} |
|
|
|
|
|
|
|
//Aqui se parsean todos los tickets que existen y se les da un formato con los campos a mostrarse |
|
|
|
// Aquí se parsean todos los tickets que existen y se les da un formato con los campos a mostrarse |
|
|
|
private List<Ticket> parseTickets(String json) { |
|
|
|
List<Ticket> tickets = new ArrayList<>(); |
|
|
|
try { |
|
|
@ -118,12 +118,27 @@ public class RedmineClient { |
|
|
|
if (issues != null) { |
|
|
|
for (JsonElement issueElement : issues) { |
|
|
|
JsonObject issue = issueElement.getAsJsonObject(); |
|
|
|
int id = issue.has("id") ? issue.get("id").getAsInt() : 0; |
|
|
|
String subject = issue.has("subject") ? issue.get("subject").getAsString() : ""; |
|
|
|
String description = issue.has("description") ? issue.get("description").getAsString() : ""; |
|
|
|
String status = issue.has("status") ? issue.getAsJsonObject("status").get("name").getAsString() : "Unknown"; |
|
|
|
String dateString = issue.has("created_on") ? issue.get("created_on").getAsString() : ""; |
|
|
|
|
|
|
|
// Verifica y obtiene el ID |
|
|
|
int id = issue.has("id") && !issue.get("id").isJsonNull() ? issue.get("id").getAsInt() : 0; |
|
|
|
|
|
|
|
// Verifica y obtiene el subject |
|
|
|
String subject = issue.has("subject") && !issue.get("subject").isJsonNull() ? issue.get("subject").getAsString() : ""; |
|
|
|
|
|
|
|
// Verifica y obtiene la descripción |
|
|
|
String description = issue.has("description") && !issue.get("description").isJsonNull() ? issue.get("description").getAsString() : ""; |
|
|
|
|
|
|
|
// Verifica y obtiene el status |
|
|
|
String status = "Unknown"; |
|
|
|
if (issue.has("status") && !issue.get("status").isJsonNull()) { |
|
|
|
JsonObject statusObject = issue.getAsJsonObject("status"); |
|
|
|
if (statusObject.has("name") && !statusObject.get("name").isJsonNull()) { |
|
|
|
status = statusObject.get("name").getAsString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Verifica y obtiene la fecha de creación |
|
|
|
String dateString = issue.has("created_on") && !issue.get("created_on").isJsonNull() ? issue.get("created_on").getAsString() : ""; |
|
|
|
LocalDate date = null; |
|
|
|
if (!dateString.isEmpty()) { |
|
|
|
try { |
|
|
@ -135,13 +150,17 @@ public class RedmineClient { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
JsonObject authorJson = issue.has("author") ? issue.getAsJsonObject("author") : null; |
|
|
|
// Verifica y obtiene el autor |
|
|
|
Ticket.User author = null; |
|
|
|
if (authorJson != null) { |
|
|
|
String username = authorJson.has("name") ? authorJson.get("name").getAsString() : "Unknown"; |
|
|
|
author = new Ticket.User(username); |
|
|
|
if (issue.has("author") && !issue.get("author").isJsonNull()) { |
|
|
|
JsonObject authorJson = issue.getAsJsonObject("author"); |
|
|
|
if (authorJson.has("name") && !authorJson.get("name").isJsonNull()) { |
|
|
|
String username = authorJson.get("name").getAsString(); |
|
|
|
author = new Ticket.User(username); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Agrega el ticket a la lista |
|
|
|
tickets.add(new Ticket(id, subject, description, status, date != null ? date.toString() : "", author)); |
|
|
|
} |
|
|
|
} else { |
|
|
@ -156,6 +175,7 @@ public class RedmineClient { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class TicketResponse { |
|
|
|
private List<Ticket> issues; |
|
|
|
|
|
|
|