@Override
    public void run() {
      Message tempMessage = null;
      try {
        Client tempClient = clients.take();
        clients.add(tempClient);
        BufferedReader reader = tempClient.getReader();

        StringBuilder sb = new StringBuilder();
        Thread.sleep(1000);

        while (reader.ready()) {
          sb.append(reader.readLine());

          tempMessage = new Message(tempClient.getId(), sb.toString());

          messages.add(tempMessage);
          clients.add(tempClient);
          // pool.submit(this);

          System.out.println(sb.toString());
        }
      } catch (InterruptedException | IOException e) {
        clients.remove(tempMessage);
        e.printStackTrace();
      }
      pool.execute(this);
    }
 @Override
 public boolean equals(Object otherClient) {
   if (!(otherClient instanceof Client)) {
     return false;
   } else {
     Client newClient = (Client) otherClient;
     return this.getName().equals(newClient.getName()) && this.getId() == newClient.getId();
   }
 }
Example #3
0
 /** Decides whether the {@link #getCurrentPlayer()} is defeated or not. */
 void checkIfCurrentPlayerIsDefeated() {
   Client client = getCurrentPlayer();
   if (client.isDefeated()) return;
   // If the king is checked, go through all active figures and check if we can do any moves.
   // If we can't do any moves the player is defeated
   if (isKingChecked(client.getId())
       && getFigures()
               .stream()
               // Just the players figures
               .filter(hexagonFigure -> hexagonFigure.getClient().getId().equals(client.getId()))
               // Just non removed figures
               .filter(hexagonFigure -> !hexagonFigure.isRemoved())
               // Change type to a list of hexagon
               .map(hexagonFigure -> hexagonFigure.getPossibleMovements(this))
               // Convert list of list of hexagon to list of hexagon
               .flatMap(Collection::stream)
               .count()
           == 0) client.setDefeated(true);
 }
Example #4
0
 @AfterClass
 public static void afterClass() throws Exception {
   jToggl.destroyTimeEntry(timeEntry.getId());
   jToggl.destroyClient(client.getId());
   try {
     jToggl.destroyTask(task.getId());
   } catch (Exception e) {
     // Ignore because Task is only for paying customers
   }
 }
Example #5
0
 /**
  * найти животных по имени клиента
  *
  * @param client имя клиента
  */
 public SimpleLinkedList<Pet> findPetsByClient(final String client) {
   SimpleLinkedList<Pet> foundedPets = new SimpleLinkedList<Pet>();
   int i = 0;
   for (Client clientId : clients) {
     if (clientId != null && clientId.getId().equals(client)) {
       foundedPets.addLast(clientId.getPet());
       i++;
     }
   }
   return foundedPets;
 }
Example #6
0
 private AutomationClient(Client client) {
   super(
       client.getId(),
       client.getName(),
       client.getDescription(),
       client.getCreatedAt(),
       client.getCreatedBy(),
       client.getUpdatedAt(),
       client.getUpdatedBy(),
       client.isEnabled(),
       true);
 }
Example #7
0
 /**
  * печать клиентов, найденных по имени животного
  *
  * @param name имя животинки
  */
 public void printClientsByPetName(final String name) {
   SimpleLinkedList<Client> foundedClients = findClientsByPetName(name);
   int j = 0;
   for (Client client : foundedClients) {
     if (client != null) {
       System.out.println(client.getId());
       j = j + 1;
     }
   }
   if (j == 0) {
     System.out.println("Client with that pet's name didn't find");
   }
 }
 public String showMedicalHistory() throws Exception {
   client = ClientDao.getClientById(getId());
   medicalHistory = MedicalHistoryDao.getMedicalHistoryByClientId(client.getId());
   visitsList = VisitDao.getVisitsListByMedicalHistoryId(medicalHistory.getId());
   for (Visit visit : visitsList) {
     Order order = OrderDao.getOrderById(visit.getOrderId());
     Doctor doctor = DoctorDao.getDoctorById(order.getDoctorId());
     visit.setDoctorFullname(doctor.getFullname());
     visit.setDoctorSpeciality(doctor.getSpeciality());
     visit.setDate(UnixTimeConverter.convertUnixTimeToTime(order.getDate(), "yyyy-MM-dd"));
   }
   return Action.SUCCESS;
 }
Example #9
0
 @Override
 public String toString() {
   return "ClientDailyOrder{"
       + "id="
       + id
       + ", restaurantId="
       + restaurantId.getId()
       + ", clientId="
       + clientId.getId()
       + ", menuItemId="
       + menuItemId.getDishName()
       + ", orderDate="
       + orderDate
       + ", isVoted="
       + isConfirmed
       + '}';
 }
Example #10
0
 /**
  * Decides whether the {@link Figure} on a field is owned by an enemy or not.
  *
  * @param targetField The {@link Field} the figure stand on.
  * @param client The {@link Client} from which point of view we are looking
  * @return Returns true if there is no figure on the field or the {@link Figure} on the {@link
  *     Field} does not belong to the {@link Client} in the parameter.
  */
 public boolean isFigureOwnedByEnemy(Field targetField, Client client) {
   return getFigures()
           .stream()
           // Just use non removed figures. Fixes CCD2015-51
           .filter(o -> !((Figure) o).isRemoved())
           // Just those figures on the target position
           .filter(
               o ->
                   ((Figure) o)
                       .getHypotheticalPosition()
                       .getNotation()
                       .equals(targetField.getNotation()))
           // Just enemy figures
           .filter(o -> ((Figure) o).getClient().getId().equals(client.getId()))
           .count()
       == 0;
 }
Example #11
0
  private static Project createProject() {
    List<Project> projects = jToggl.getProjects();
    for (Project project : projects) {
      if ("JUnit Project".equals(project.getName())) {
        return project;
      }
    }

    Project pr = new Project();
    pr.setName("JUnit Project");
    pr.setCid(client.getId());

    List<Workspace> ws = jToggl.getWorkspaces();
    pr.setWorkspace(ws.get(0));

    pr = jToggl.createProject(pr);
    Assert.assertNotNull(pr);

    return pr;
  }
 @Override
 public String toString() {
   String str;
   str = "\nReserva amb ID: " + id + "\n";
   str += "--------------------------------------\n";
   str += "Client: " + clientReserva.getId() + "\n";
   str += "Moto: " + motoReserva.getIdMoto() + "\n";
   str += "Cost: " + preu + "€\n";
   if (penalitzacioMoto) {
     str += "La moto té algun desperfecte.\n";
   } else {
     str += "La moto s'ha retornat amb bon estat.\n";
   }
   if (penalitzacioTemps) {
     str += "La moto no s'ha retornat a temps.\n";
   } else {
     str += "La moto s'ha retornat a temps.\n";
   }
   str += "Local d'inici: " + localInicial.toString() + "\n";
   str += "Data d'inici: " + dataInicial.toString() + "\n";
   str += "Local de finalització: " + localFinal.toString() + "\n";
   str += "Data de finalització: " + dataFinal.toString() + "\n";
   return str;
 }
Example #13
0
  @RequestMapping(value = "/api/client/{client}/summarystate", method = RequestMethod.GET)
  public @ResponseBody SummaryState getSummaryState(@PathVariable String client) throws Exception {
    Client cl = clientService.get(client);

    SummaryState summaryState = new SummaryState();

    List<SalesItem> items = itemService.getItemsForClient(cl.getId());
    summaryState.itemHash = HashUtil.getHash(items);

    List<SalesCategory> cats = categoryService.getAllCategoriesForClient(cl.getId());
    summaryState.categoryHash = HashUtil.getHash(cats);

    List<SalesCategoryGroup> grps = categoryService.getGroupForClient(cl.getId());
    summaryState.categoryGroupHash = HashUtil.getHash(grps);

    List<SalesItemOption> opts = optionService.getOptionsForClient(cl.getId());
    summaryState.optionsHash = HashUtil.getHash(opts);

    List<SalesItemOptions> optGrp = optionService.getOptionGroupsForClient(cl.getId());
    summaryState.optionGroupHash = HashUtil.getHash(optGrp);

    List<User> users = userService.findAllUsersForClient(cl.getId());
    summaryState.userHash = HashUtil.getHash(users);

    try {

      log.debug("items", new ObjectMapper().writeValueAsString(items));
      log.debug("cats", new ObjectMapper().writeValueAsString(cats));
      log.debug("grps", new ObjectMapper().writeValueAsString(grps));
      log.debug("opts", new ObjectMapper().writeValueAsString(opts));
      log.debug("optGrp", new ObjectMapper().writeValueAsString(optGrp));
      log.debug("user", new ObjectMapper().writeValueAsString(users));

    } catch (Exception e) {
      log.debug("Error getting state", e);
    }

    return summaryState;
  }
Example #14
0
 /** печать всех клиентов клиники и их домашних животных */
 public void printAllClients() {
   for (Client client : clients) {
     System.out.println(client.getId() + " - " + client.getPet().getName());
   }
 }