WLProject.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package uk.ac.ic.wlgitbridge.writelatex.model;
  2. import uk.ac.ic.wlgitbridge.writelatex.SnapshotFetcher;
  3. import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
  4. import uk.ac.ic.wlgitbridge.writelatex.api.request.getdoc.exception.InvalidProjectException;
  5. import java.util.HashMap;
  6. import java.util.Map;
  7. import java.util.SortedSet;
  8. /**
  9. * Created by Winston on 06/11/14.
  10. */
  11. public class WLProject {
  12. private final String name;
  13. private final Map<Integer, Snapshot> snapshots;
  14. private final SnapshotFetcher snapshotFetcher;
  15. private Snapshot latestSnapshot;
  16. public WLProject(String name) {
  17. this.name = name;
  18. snapshots = new HashMap<Integer, Snapshot>();
  19. snapshotFetcher = new SnapshotFetcher(name, snapshots);
  20. }
  21. public SortedSet<Snapshot> fetchNewSnapshots() throws FailedConnectionException, InvalidProjectException {
  22. SortedSet<Snapshot> newSnapshots = snapshotFetcher.fetchNewSnapshots();
  23. latestSnapshot = snapshotFetcher.getLatestSnapshot();
  24. return newSnapshots;
  25. }
  26. public String getName() {
  27. return name;
  28. }
  29. public Snapshot getLatestSnapshot() {
  30. return latestSnapshot;
  31. }
  32. }