Package com.agiletec.plugins.jpwtt.aps.system.services.ticket.model

Examples of com.agiletec.plugins.jpwtt.aps.system.services.ticket.model.Ticket


 
  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);
View Full Code Here


 
  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 {
View Full Code Here

    }
    return validated;
  }
 
  protected Ticket createTicketForUpdate(Ticket ticket, int operationCode) throws Exception {
    Ticket newTicket = (Ticket) ticket.clone();
    switch (operationCode) {
      case TicketOperation.OPERATIONS_TAKEINCHARGE:
        newTicket.setStatus(Ticket.STATES_ASSIGNED);
        newTicket.setWttOperator(this.getCurrentUser().getUsername());
        break;
      case TicketOperation.OPERATIONS_SETASSIGNABLE:
        newTicket.setStatus(Ticket.STATES_ASSIGNABLE);
        newTicket.setWttOperator(null);
        newTicket.setWttRole(this.getRoleName());
        break;
      case TicketOperation.OPERATIONS_UPDATE:
        if (newTicket.getStatus()==Ticket.STATES_OPENED) {
          newTicket.setStatus(Ticket.STATES_WORKING);
        }
        int priority = this.getPriority()!=null ? this.getPriority().intValue() : 0;
        newTicket.setPriority(priority);
        int interventionType = this.getInterventionType()!=null ? this.getInterventionType().intValue() : 0;
        newTicket.setOpInterventionType(interventionType);
        break;
      case TicketOperation.OPERATIONS_CLOSE:
        newTicket.setStatus(Ticket.STATES_CLOSED);
        newTicket.setClosingDate(new Date());
        if (this.getResolved()!=null) {
          newTicket.setResolved(this.getResolved().booleanValue());
        }
        newTicket.setWttOperator(null);
        break;
      case TicketOperation.OPERATIONS_ANSWER:
        if (newTicket.getStatus()==Ticket.STATES_OPENED) {
          newTicket.setStatus(Ticket.STATES_WORKING);
        }
        break;
      case TicketOperation.OPERATIONS_RELEASE:
        newTicket.setStatus(Ticket.STATES_WORKING);
        newTicket.setClosingDate(null);
        newTicket.setResolved(false);
        newTicket.setWttOperator(null);
        break;
    }
    if (this.getPriority()!=null) {
      newTicket.setPriority(this.getPriority().intValue());
    }
    return newTicket;
  }
View Full Code Here

  }
 
  @Override
  public String save() {
    try {
      Ticket ticket = this.createTicket();
      this.getTicketManager().addTicket(ticket);
    } catch(Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "save");
      return FAILURE;
    }
View Full Code Here

    }
    return SUCCESS;
  }
 
  protected Ticket createTicket() {
    Ticket ticket = new Ticket();
    ticket.setAuthor(this.getCurrentUser().getUsername());
    ticket.setCreationDate(new Date());
    ticket.setNome(this.getNome());
    ticket.setCognome(this.getCognome());
    ticket.setCodFisc(this.getCodFisc());
    ticket.setComune(this.getComune());
    ticket.setLocalita(this.getLocalita());
    ticket.setTipoIndirizzo(this.getTipoIndirizzo());
    ticket.setIndirizzo(this.getIndirizzo());
    ticket.setNumeroIndirizzo(this.getNumeroIndirizzo());
    ticket.setTelefono(this.getTelefono());
    ticket.setEmail(this.getEmail());
    ticket.setMessage(this.getMessage());
    if (null!=this.getInterventionType()) {
      int id = this.getInterventionType().intValue();
      ticket.setUserInterventionType(id);
      ticket.setOpInterventionType(id);
    }
    ticket.setStatus(Ticket.STATES_OPENED);
    return ticket;
  }
View Full Code Here

  }

  public void testList() throws Throwable {
    String username = "admin";
    assertEquals(0, this._ticketManager.searchTicketIds(null).size());
    Ticket t1 = this._helper.createTicket(null, new Date(), null, "message1", username, 0, 0, "pageManagerCustomers",
        null, Ticket.STATES_OPENED, null, false);
    this._ticketManager.addTicket(t1);
    Ticket t2 = this._helper.createTicket(null, new Date(), null, "message2", username, 1, 1, "mainEditor",
        null, Ticket.STATES_ASSIGNED, new Date(), false);
    this._ticketManager.addTicket(t2);
    Ticket t3 = this._helper.createTicket(null, new Date(), null, "message3", username, 2, 2, "editorCustomers",
        null, Ticket.STATES_CLOSED, null, false);
    this._ticketManager.addTicket(t3);
    Ticket t4 = this._helper.createTicket(null, new Date(), null, "message4", "pageManagerCustomers", 1,
        0, "editorCustomers", null, Ticket.STATES_ASSIGNABLE, new Date(), true);
    this._ticketManager.addTicket(t4);

    String result = this.executeList(username);
    assertEquals(Action.SUCCESS, result);

    AbstractTicketFinderAction action = (AbstractTicketFinderAction) this.getAction();

    List<String> ticketIds = action.getTicketIds();
    assertEquals(4, ticketIds.size());
    assertTrue(ticketIds.contains(t1.getCode()));
    assertTrue(ticketIds.contains(t2.getCode()));
    assertTrue(ticketIds.contains(t3.getCode()));
    assertTrue(ticketIds.contains(t4.getCode()));
  }
View Full Code Here

  }

  public void testSearchAdmin() throws Throwable {
    String username = "supervisorCoach";// User with jpwwtAdmin permission
    assertEquals(0, this._ticketManager.searchTicketIds(null).size());
    Ticket t1 = this._helper.createTicket(null, new Date(), "nome1", "cognome1", "codFisc1", "comune1",
        "localita1", "ind1", "indirizzo1", "num1", "telefono1", "email1@email.itte", "message1",
        username, 0, 1, 0, "pageManagerCustomers", "pageManager", Ticket.STATES_OPENED, null, false);
    this._ticketManager.addTicket(t1);
    Ticket t2 = this._helper.createTicket(null, new Date(), null, "message2", username, 1,
        1, "mainEditor", null, Ticket.STATES_ASSIGNED, new Date(), false);
    this._ticketManager.addTicket(t2);
    Ticket t3 = this._helper.createTicket(null, new Date(), null, "message3", null, 2,
        2, "editorCustomers", null, Ticket.STATES_DISPATCHED, null, true);
    this._ticketManager.addTicket(t3);
    Ticket t4 = this._helper.createTicket(null, new Date(), null, null, "pageManagerCustomers", 1,
        0, "editorCustomers", null, Ticket.STATES_CLOSED, new Date(), false);
    this._ticketManager.addTicket(t4);

    Map<String, String> params = this.prepareParams("message2", "", "", "", "", "", "", "");
    String result = this.executeSearch(username, params); // message = 'message2'
    assertEquals(Action.SUCCESS, result);
    List<String> ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { t2.getCode() }, ticketIds);

    params.put("message", "ess");
    result = this.executeSearch(username, params); // message = 'ess'
    assertEquals(Action.SUCCESS, result);
    ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { t1.getCode(), t2.getCode(), t3.getCode() }, ticketIds);

    params.put("priority", "0");
    params.remove("message");
    result = this.executeSearch(username, params); // priority = '0'
    assertEquals(Action.SUCCESS, result);
    ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { t1.getCode(), t4.getCode() }, ticketIds);

    params.put("userInterventionType", "0");
    params.put("assignedInterventionType", "1");
    result = this.executeSearch(username, params); // priority = '0', userInterventionType = '0', assignedInterventionType = '1'
    assertEquals(Action.SUCCESS, result);
    ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { t1.getCode() }, ticketIds);

    params.put("userInterventionType", "1");
    params.put("assignedInterventionType", "");
    result = this.executeSearch(username, params); // priority = '0', userInterventionType = '1'
    assertEquals(Action.SUCCESS, result);
    ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { t4.getCode() }, ticketIds);

    params.put("priority", "");
    result = this.executeSearch(username, params); // userInterventionType = '1'
    assertEquals(Action.SUCCESS, result);
    ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { t2.getCode(), t4.getCode() }, ticketIds);

    params.put("status", String.valueOf(Ticket.STATES_DISPATCHED));
    result = this.executeSearch(username, params); // userInterventionType = '1', status = 'DISPATCHED'
    assertEquals(Action.SUCCESS, result);
    ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { }, ticketIds);

    params.put("userInterventionType", "");
    result = this.executeSearch(username, params); // status = 'DISPATCHED'
    assertEquals(Action.SUCCESS, result);
    ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { t3.getCode() }, ticketIds);

    params.put("status", "");
    params.put("userInterventionType", "");
    params.put("resolved", "1");
    result = this.executeSearch(username, params); // resolved = 'true'
    assertEquals(Action.SUCCESS, result);
    ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { t3.getCode() }, ticketIds);

    params.put("resolved", "0");
    result = this.executeSearch(username, params); // resolved = 'false'
    assertEquals(Action.SUCCESS, result);
    ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { t1.getCode(), t2.getCode(), t4.getCode() }, ticketIds);

    params.put("resolved", "");
    result = this.executeSearch(username, params); // resolved = ''
    assertEquals(Action.SUCCESS, result);
    ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { t1.getCode(), t2.getCode(), t3.getCode(), t4.getCode() }, ticketIds);
  }
View Full Code Here

  }

  public void testSearchOperator() throws Throwable {
    String username = "mainEditor";
    assertEquals(0, this._ticketManager.searchTicketIds(null).size());
    Ticket t1 = this._helper.createTicket(null, new Date(), null, "message1", username, 1,
        1, "mainEditor", "supervisor", Ticket.STATES_ASSIGNABLE, new Date(), false);
    this._ticketManager.addTicket(t1);
    Ticket t2 = this._helper.createTicket(null, new Date(), null, "message2", username, 1,
        1, "mainEditor", null, Ticket.STATES_ASSIGNED, new Date(), false);
    this._ticketManager.addTicket(t2);
    Ticket t3 = this._helper.createTicket(null, new Date(), null, "message3", null, 2,
        2, "mainEditor", "editor", Ticket.STATES_WORKING, null, true);
    this._ticketManager.addTicket(t3);
    Ticket t4 = this._helper.createTicket(null, new Date(), null, "message4", "pageManagerCustomers", 1,
        0, "editorCustomers", null, Ticket.STATES_ASSIGNED, new Date(), false);
    this._ticketManager.addTicket(t4);
    Ticket t5 = this._helper.createTicket(null, new Date(), null, "message5", "pageManagerCustomers", 1,
        0, "editorCustomers", "editor", Ticket.STATES_ASSIGNABLE, new Date(), false);
    this._ticketManager.addTicket(t5);

    Map<String, String> params = this.prepareParams("ess", "", "admin", "", "", "", "", "");
    String result = this.executeSearch(username, params); // message = 'ess'
    assertEquals(Action.SUCCESS, result);
    List<String> ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { t2.getCode(), t5.getCode() }, ticketIds);

    params.put("status", String.valueOf(Ticket.STATES_ASSIGNABLE));
    result = this.executeSearch(username, params); // message = 'ess'
    assertEquals(Action.SUCCESS, result);
    ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
    this.verifyTicketIds(new String[] { t5.getCode() }, ticketIds);

    params.put("status", String.valueOf(Ticket.STATES_ASSIGNED));
    result = this.executeSearch(username, params); // message = 'ess'
    assertEquals(Action.SUCCESS, result);
    ticketIds = ((AbstractTicketFinderAction) this.getAction()).getTicketIds();
View Full Code Here

public class TestTicketAction extends ApsAdminPluginBaseTestCase {

  public void testView() throws Throwable {
    assertEquals(0, this._ticketManager.searchTicketIds(null).size());
    Ticket t1 = this._helper.createTicket(null, new Date(), null, "message1", "mainEditor", 0, 0, "pageManagerCustomers", null, Ticket.STATES_ASSIGNED, null, false);
    this._ticketManager.addTicket(t1);
    String ticketCode = t1.getCode();
    TicketOperation op1 = this._helper.createTicketOperation(0, ticketCode, "pageManagerCustomers", TicketOperation.OPERATIONS_TAKEINCHARGE, "notw", 0, 0, null, new Date());
    this._ticketManager.updateTicketWithOperation(t1, op1);

    String result = this.executeAction("pageManagerCoach", "view", ticketCode);
    assertEquals(BaseAction.USER_NOT_ALLOWED, result);

    result = this.executeAction("admin", "view", ticketCode);
    assertEquals(Action.SUCCESS, result);
    Ticket ticket = ((AbstractTicketAction) this.getAction()).getTicket();
    this.compareTickets(t1, ticket);
    List<TicketOperation> operations = ((AbstractTicketAction) this.getAction()).getTicketOperations();
    assertEquals(1, operations.size());
  }
View Full Code Here

  }

  public void testTakeInCharge() throws Throwable {
    String actionCode = "takeInCharge";
    assertEquals(0, this._ticketManager.searchTicketIds(null).size());
    Ticket t1 = this._helper.createTicket(null, new Date(), null, "message1", null, 0, 0, null, null, Ticket.STATES_OPENED, null, false);
    this._ticketManager.addTicket(t1);
    Ticket t2 = this._helper.createTicket(null, new Date(), null, "message2", null, 0, 0, "pageManagerCustomers", Permission.SUPERVISOR, Ticket.STATES_ASSIGNABLE, null, false);
    this._ticketManager.addTicket(t2);
    Ticket t3 = this._helper.createTicket(null, new Date(), null, "message3", null, 0, 0, "pageManagerCustomers", null, Ticket.STATES_ASSIGNED, null, false);
    this._ticketManager.addTicket(t3);
    Ticket t4 = this._helper.createTicket(null, new Date(), null, "message4", null, 0, 0, "pageManagerCustomers", "editor", Ticket.STATES_ASSIGNABLE, null, false);
    this._ticketManager.addTicket(t4);
    Ticket t5 = this._helper.createTicket(null, new Date(), null, "message5", null, 0, 0, "pageManagerCustomers", null, Ticket.STATES_CLOSED, null, false);
    this._ticketManager.addTicket(t5);

    // t1 OPENED
    Ticket current = t1;
    String result = this.executeAction("admin", actionCode, current.getCode());
    assertEquals(Action.SUCCESS, result);
    Ticket ticket = this._ticketManager.getTicket(current.getCode());
    assertEquals(Ticket.STATES_ASSIGNED, ticket.getStatus());
    assertEquals("admin", ticket.getWttOperator());
    List<TicketOperation> operations = this._ticketManager.getTicketOperations(current.getCode());
    assertEquals(1, operations.size());
    TicketOperation operation = operations.get(0);
    assertEquals(TicketOperation.OPERATIONS_TAKEINCHARGE, operation.getOperationCode());
    assertEquals("admin", operation.getOperator());

    // t2 ASSIGNABLE
    current = t2;
    result = this.executeAction("admin", actionCode, current.getCode());
    assertEquals("opNotAllowed", result);
    ticket = this._ticketManager.getTicket(current.getCode());
    this.compareTickets(current, ticket);
    assertEquals(0, this._ticketManager.getTicketOperations(current.getCode()).size());

    // t3 ASSIGNED
    current = t3;
    result = this.executeAction("admin", actionCode, current.getCode());
    assertEquals("opNotAllowed", result);
    ticket = this._ticketManager.getTicket(current.getCode());
    this.compareTickets(current, ticket);
    assertEquals(0, this._ticketManager.getTicketOperations(current.getCode()).size());

    // t4 ASSIGNABLE
    current = t4;
    result = this.executeAction("mainEditor", actionCode, current.getCode());
    assertEquals(Action.SUCCESS, result);
    ticket = this._ticketManager.getTicket(current.getCode());
    assertEquals(Ticket.STATES_ASSIGNED, ticket.getStatus());
    assertEquals("mainEditor", ticket.getWttOperator());
    operations = this._ticketManager.getTicketOperations(current.getCode());
    assertEquals(1, operations.size());
    operation = operations.get(0);
    assertEquals(TicketOperation.OPERATIONS_TAKEINCHARGE, operation.getOperationCode());
    assertEquals("mainEditor", operation.getOperator());
View Full Code Here

TOP

Related Classes of com.agiletec.plugins.jpwtt.aps.system.services.ticket.model.Ticket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.