Example #1
0
  public long getTotalPages(String d, int pSize) {

    DateFormat dateformat = new SimpleDateFormat("yyyy-mm-dd");
    Date dayEnd = new Date();
    try {

      dayEnd = new Date((dateformat.parse(d).getTime() + 24 * 60 * 60 * 1000));
      System.out.println(auiRepo.totalLogsBetween(d, dateformat.format(dayEnd)));
    } catch (ParseException e) {

      e.printStackTrace();
    }

    return Math.round(
        Math.ceil(auiRepo.totalLogsBetween(d, dateformat.format(dayEnd)) / (double) pSize));
  }
Example #2
0
 private void saveLogDataInModel(Map<String, String> resultMap) {
   AuiCurrent auiLogModel = new AuiCurrent();
   auiLogModel.setByteSent(Integer.parseInt(resultMap.get("BytesSent")));
   auiLogModel.setEndpoint(resultMap.get("ServerName") + ":" + resultMap.get("CanonicalPort"));
   auiLogModel.setProcessId(resultMap.get("ProcessIdChild"));
   auiLogModel.setReferHead(resultMap.get("Referer"));
   auiLogModel.setRemoteHostName(resultMap.get("RemoteHostName"));
   auiLogModel.setRequestMethod(resultMap.get("RequestMethod"));
   auiLogModel.setTimeInMicro(Integer.parseInt(resultMap.get("ResponseTimeMicroSecond")));
   auiLogModel.setUrlRequested(resultMap.get("URLPathRequested"));
   auiLogModel.setQueryString(resultMap.get("QueryString"));
   auiLogModel.setUserAgent(resultMap.get("User-Agent"));
   auiLogModel.setStatusCode(resultMap.get("FinalStatus"));
   Date dateOfRequest = null;
   try {
     dateOfRequest = Constant.formatter.parse(resultMap.get("TimeOfRequest").replaceAll("\"", ""));
   } catch (ParseException e) {
     e.printStackTrace();
   }
   auiLogModel.setTime(dateOfRequest);
   auiRepo.saveAndFlush(auiLogModel);
 }
Example #3
0
  public List<AuiCurrent> getAUILog(
      String d, int pagenumber, int pSize, String order, String sortBy) {

    PageRequest pageRequest =
        new PageRequest(
            pagenumber,
            pSize,
            order.equals("DESC") ? Sort.Direction.DESC : Sort.Direction.ASC,
            sortBy);
    Pageable p = pageRequest;
    List<AuiCurrent> list = new ArrayList<>();
    try {
      DateFormat dateformat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss.S");
      Date dayStart = dateformat.parse(d + " 00:00:00.0");
      Date dayEnd = dateformat.parse(d + " 23:59:59.9");
      list.addAll(auiRepo.findByTimeBetween(dayStart, dayEnd, p).getContent());
    } catch (ParseException e) {

      e.printStackTrace();
    }

    return list;
  }