Esempio n. 1
0
  public void removeNotLastModifications() {
    List<String> uniquePaths = getUniquePaths();
    for (String path : uniquePaths) {
      int lastRevision = getLastModificationRevisionForPath(path);

      int count = logEntries.size();
      int i = 0;

      while (i < count) {
        LogEntry entry = logEntries.get(i);

        if (entry.getRevision() < lastRevision) {
          entry.removeEntriesWithPath(path);
          if (entry.isEmpty()) {
            logEntries.remove(entry);
            count--;
            i--;
          }
        }

        i++;
      }
    }

    isOrdered = false;
  }
Esempio n. 2
0
  public void removeEntriesWithPathForAuthor(String path, String author) {
    if (logEntries == null || logEntries.isEmpty()) {
      return;
    }

    int count = logEntries.size();
    int i = 0;

    while (i < count) {
      LogEntry logEntry = logEntries.get(i);
      if (!logEntry.getAuthor().equals(author)) {
        i++;
        continue;
      }

      logEntry.removeEntriesWithPath(path);
      if (logEntry.isEmpty()) {
        logEntries.remove(logEntry);
        count--;
        continue;
      }

      i++;
    }

    isOrdered = false;
  }
Esempio n. 3
0
  private void writeLogEntry(PrintWriter out, LogEntry logEntry) {
    if (logEntry.getEntriesCount() == 0) {
      return;
    }

    String message = logEntry.getMessage().replace(QUOTE_CHARACTER, QUOTE_SPECIAL_CHARACTER);
    message =
        message.replace(ANGLE_OPENING_BRACKET_CHARACTER, ANGLE_OPENING_BRACKET_SPECIAL_CHARACTER);
    message =
        message.replace(ANGLE_CLOSING_BRACKET_CHARACTER, ANGLE_CLOSING_BRACKET_SPECIAL_CHARACTER);

    out.println(
        MessageFormat.format(
            LOGENTRY_START_NODE,
            new String[] {message, Integer.toString(logEntry.getRevision()), logEntry.getDate()}));

    List<PathEntry> pathEntries = logEntry.getPathEntries();
    for (PathEntry pathEntry : pathEntries) {
      out.println(
          MessageFormat.format(
              PATH_NODE, new String[] {pathEntry.getAction(), pathEntry.getPath()}));
    }

    out.println(LOGENTRY_END_NODE);
  }
Esempio n. 4
0
  public int getLogEntriesCount() {
    int count = 0;

    for (LogEntry logEntry : logEntries) {
      count += logEntry.getEntriesCount();
    }

    return count;
  }
Esempio n. 5
0
  public LogEntry getLogEntryByRevision(int revision) {
    for (LogEntry logEntry : logEntries) {
      if (logEntry.getRevision() == revision) {
        return logEntry;
      }
    }

    return null;
  }
Esempio n. 6
0
  public LogReport getLogReportForAuthor(String author) {
    LogReport report = new LogReport();

    for (LogEntry entry : logEntries) {
      if (entry.getAuthor().equals(author)) {
        report.addLogEntry(entry);
      }
    }

    return report.isEmpty() ? null : report;
  }
Esempio n. 7
0
  public int getAuthorLogEntriesCount(String author) {
    List<LogEntry> logEntries = getUnorderedAuthorLogEntries(author);

    int count = 0;

    for (LogEntry logEntry : logEntries) {
      count += logEntry.getEntriesCount();
    }

    return count;
  }
Esempio n. 8
0
  private List<LogEntry> getUnorderedAuthorLogEntries(String author) {
    List<LogEntry> entries = new LinkedList<LogEntry>();

    for (LogEntry logEntry : logEntries) {
      if (logEntry.getAuthor().equals(author)) {
        entries.add(logEntry);
      }
    }

    return entries;
  }
Esempio n. 9
0
  public List<String> getAuthors() {
    List<String> authors = new LinkedList<String>();

    for (LogEntry logEntry : logEntries) {
      if (!authors.contains(logEntry.getAuthor())) {
        authors.add(logEntry.getAuthor());
      }
    }

    Collections.sort(authors);

    return authors;
  }
Esempio n. 10
0
  public List<String> getUniquePaths() {
    List<String> uniquePathEntries = new LinkedList<String>();

    for (LogEntry logEntry : logEntries) {
      List<PathEntry> pathEntries = logEntry.getPathEntries();
      for (PathEntry pathEntry : pathEntries) {
        if (!uniquePathEntries.contains(pathEntry.getPath())) {
          uniquePathEntries.add(pathEntry.getPath());
        }
      }
    }

    return uniquePathEntries;
  }
Esempio n. 11
0
  public int getLastModificationRevisionForPath(String path) {
    int revision = -1;

    for (LogEntry logEntry : logEntries) {
      List<PathEntry> pathEntries = logEntry.getPathEntries();
      for (PathEntry pathEntry : pathEntries) {
        if (pathEntry.getPath().equals(path) && revision < pathEntry.getRevision()) {
          revision = pathEntry.getRevision();
          break;
        }
      }
    }

    return revision;
  }
Esempio n. 12
0
  public List<PathEntry> getOrderedByRevisionAuthorPathEntries(String author) {
    List<PathEntry> orderedPathEntries = new LinkedList<PathEntry>();

    List<LogEntry> logEntries = getUnorderedAuthorLogEntries(author);
    for (LogEntry logEntry : logEntries) {
      List<PathEntry> pathEntries = logEntry.getPathEntries();
      for (PathEntry pathEntry : pathEntries) {
        orderedPathEntries.add(pathEntry);
      }
    }

    Collections.sort(orderedPathEntries);

    return orderedPathEntries;
  }
Esempio n. 13
0
  public List<String> getAuthorUniquePaths(String author) {
    List<LogEntry> logEntries = getUnorderedAuthorLogEntries(author);
    List<String> uniquePathEntries = new LinkedList<String>();

    for (LogEntry logEntry : logEntries) {
      List<PathEntry> pathEntries = logEntry.getPathEntries();
      for (PathEntry pathEntry : pathEntries) {
        if (!uniquePathEntries.contains(pathEntry.getPath())) {
          uniquePathEntries.add(pathEntry.getPath());
        }
      }
    }

    return uniquePathEntries;
  }
Esempio n. 14
0
  public boolean isExpectedPathEntryExists(MergeExpectedPathEntry expectedEntry) {
    if (expectedEntry == null) {
      return false;
    }

    for (LogEntry logEntry : logEntries) {
      if (logEntry.getRevision() < expectedEntry.getAllowedRevision()) {
        continue;
      }

      if (expectedEntry.isExpectedPathEntryExists(logEntry.getPathEntries())) {
        return true;
      }
    }

    return false;
  }
Esempio n. 15
0
  public boolean hasSamePathEntryWithHigherRevisionForAuthor(PathEntry pathEntry, String author) {
    for (LogEntry logEntry : logEntries) {
      if (!logEntry.getAuthor().equals(author)
          || logEntry.getRevision() < pathEntry.getRevision()) {
        continue;
      }

      List<PathEntry> pathEntries = logEntry.getPathEntries();
      for (PathEntry _pathEntry : pathEntries) {
        if (_pathEntry.getPath().equals(pathEntry.getPath())
            && _pathEntry.getAction().equals(pathEntry.getAction())) {
          return true;
        }
      }
    }

    return false;
  }
Esempio n. 16
0
  public void union(LogReport report) {
    if (report == null) {
      return;
    }

    List<LogEntry> logEntries = report.getOrderedLogEntries();
    for (LogEntry logEntry : logEntries) {
      LogEntry _logEntry = getLogEntryByRevision(logEntry.getRevision());
      if (_logEntry == null) {
        this.addLogEntry(logEntry);
        continue;
      }

      _logEntry.union(logEntry);
    }

    isOrdered = false;
  }
Esempio n. 17
0
  public void removeLogEntriesWithRevisionLowerThan(int revision) {
    List<LogEntry> logEntries = getOrderedLogEntries();
    if (logEntries.isEmpty()) {
      return;
    }

    int count = this.logEntries.size();
    int i = 0;

    while (i < count) {
      LogEntry entry = this.logEntries.get(i);
      if (entry.getRevision() < revision) {
        this.logEntries.remove(entry);
        count--;
        continue;
      }

      i++;
    }

    isOrdered = false;
  }
Esempio n. 18
0
  public void removeEntriesWithPath(String path) {
    if (logEntries == null || logEntries.isEmpty()) {
      return;
    }

    int count = logEntries.size();
    int i = 0;

    while (i < count) {
      LogEntry logEntry = logEntries.get(i);
      logEntry.removeEntriesWithPath(path);

      if (logEntry.isEmpty()) {
        logEntries.remove(logEntry);
        count--;
        continue;
      }

      i++;
    }

    isOrdered = false;
  }