Ejemplo n.º 1
0
  private long getUnixTimeLastRunParagraph(Paragraph paragraph) {

    Date lastRunningDate;
    long lastRunningUnixTime;

    Date paragaraphDate = paragraph.getDateStarted();
    // diff started time <-> finishied time
    if (paragaraphDate == null) {
      paragaraphDate = paragraph.getDateFinished();
    } else {
      if (paragraph.getDateFinished() != null
          && paragraph.getDateFinished().after(paragaraphDate)) {
        paragaraphDate = paragraph.getDateFinished();
      }
    }

    // finished time and started time is not exists.
    if (paragaraphDate == null) {
      paragaraphDate = paragraph.getDateCreated();
    }

    // set last update unixtime(ms).
    lastRunningDate = paragaraphDate;

    lastRunningUnixTime = lastRunningDate.getTime();

    return lastRunningUnixTime;
  }
Ejemplo n.º 2
0
 private Map<String, String> populateParagraphInfo(Paragraph p) {
   Map<String, String> info = new HashMap<>();
   info.put("id", p.getId());
   info.put("status", p.getStatus().toString());
   if (p.getDateStarted() != null) {
     info.put("started", p.getDateStarted().toString());
   }
   if (p.getDateFinished() != null) {
     info.put("finished", p.getDateFinished().toString());
   }
   if (p.getStatus().isRunning()) {
     info.put("progress", String.valueOf(p.progress()));
   } else {
     info.put("progress", String.valueOf(100));
   }
   return info;
 }