Exemplo n.º 1
0
  public Operation ScanIn(Integer cardId, Date date, Time time) {
    Operation operation = new Operation(cardId, time, TypeOfOperation.IN);

    if (turniketDB.getOperations().containsKey(cardId)) {

      Map<Date, List<Operation>> dateListMap = turniketDB.getOperations().get(cardId);

      if (dateListMap.containsKey(date)) {
        dateListMap.get(date).add(operation);
      } else {
        List<Operation> operations = new ArrayList<>();
        operations.add(operation);
        dateListMap.put(date, operations);
      }

    } else {
      List<Operation> operations = new ArrayList<>();
      operations.add(operation);
      Map<Date, List<Operation>> map = new HashMap<>();
      map.put(date, operations);
      turniketDB.getOperations().put(cardId, map);
    }

    return operation;
  }
Exemplo n.º 2
0
 @Override
 public boolean deleteCard(Integer cardId) {
   if (turniketDB.getCards().containsKey(cardId)) {
     turniketDB.getCards().remove(cardId);
     turniketDB.getOperations().remove(cardId);
     return true;
   } else {
     return false;
   }
 }
Exemplo n.º 3
0
 @Override
 public boolean addCard(Integer cardId, String employee) {
   if (turniketDB.getCards().containsKey(cardId)) {
     return false;
   } else {
     turniketDB.getCards().put(cardId, employee);
     // turniketDB.getOperations().put(cardId, null);
     return true;
   }
 }
Exemplo n.º 4
0
 public Operation ScanOut(Integer cardId, Date date, Time time) {
   Operation operation = new Operation(cardId, time, TypeOfOperation.OUT);
   turniketDB.getOperations().get(cardId).get(date).add(operation);
   return operation;
 }
Exemplo n.º 5
0
 @Override
 public String employee(Integer cardId) {
   return turniketDB.getCards().get(cardId);
 }