protected String saveOperation(int operationCode) { try { String code = this.getCode(); ITicketManager ticketManager = this.getTicketManager(); Ticket ticket = ticketManager.getTicket(code); if (ticket != null) { this.setTicket(ticket); boolean allowed = this.isOperationAllowed(ticket, operationCode); boolean validated = this.validateParameters(ticket, operationCode, allowed); if (!allowed) { return "opNotAllowed"; } else if (!validated) { return INPUT; } else { Ticket newTicket = this.createTicketForUpdate(ticket, operationCode); TicketOperation operation = this.createTicketOperation(operationCode); ticketManager.updateTicketWithOperation(newTicket, operation); this.addActionMessage(this.getText("Message.ticketOperation.completed")); } } else { this.addActionError(this.getText("Errors.ticketOperation.ticketNotFound")); return "ticketNotFound"; } } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "view"); return FAILURE; } return SUCCESS; }
protected boolean validateUpdateParams() { boolean allowed = true; ITicketManager ticketManager = this.getTicketManager(); Integer interventionType = this.getInterventionType(); if (null != interventionType && 0 != interventionType.intValue() && null == ticketManager.getInterventionType(interventionType)) { this.addFieldError("interventionType", this.getText("Errors.interventionType.notValid")); allowed = false; } Integer priority = this.getPriority(); if (null != priority && 0 != priority.intValue() && null == ticketManager.getPriorities().get(priority)) { this.addFieldError("priority", this.getText("Errors.priority.notValid")); allowed = false; } return allowed; }
protected String entryOperation(int operationCode) { try { String code = this.getCode(); ITicketManager ticketManager = this.getTicketManager(); Ticket ticket = ticketManager.getTicket(code); if (ticket != null) { this.setTicket(ticket); if (this.isOperationAllowed(ticket, operationCode)) { List<TicketOperation> ticketOperations = ticketManager.getTicketOperations(code); this.setTicketOperations(ticketOperations); } else { this.addActionError(this.getText("Errors.ticketOperation.notAllowed")); return "opNotAllowed"; } } else { this.addActionError(this.getText("Errors.ticketOperation.ticketNotFound")); return "ticketNotFound"; } } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "view"); return FAILURE; } return SUCCESS; }