Snapshot.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package uk.ac.ic.wlgitbridge.writelatex.model;
  2. import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
  3. import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotAttachment;
  4. import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotData;
  5. import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotFile;
  6. import uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers.SnapshotInfo;
  7. import uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers.WLUser;
  8. import java.io.IOException;
  9. import java.util.List;
  10. /**
  11. * Created by Winston on 03/11/14.
  12. */
  13. public class Snapshot {
  14. private final int versionID;
  15. private final String comment;
  16. private final String userName;
  17. private final String userEmail;
  18. private final List<SnapshotFile> srcs;
  19. private final List<SnapshotAttachment> atts;
  20. public Snapshot(SnapshotInfo info, SnapshotData data) {
  21. versionID = info.getVersionId();
  22. comment = info.getComment();
  23. WLUser user = info.getUser();
  24. userName = user.getName();
  25. userEmail = user.getEmail();
  26. srcs = data.getSrcs();
  27. atts = data.getAtts();
  28. }
  29. public void writeToDisk(String basePath) throws IOException, FailedConnectionException {
  30. for (SnapshotFile file : srcs) {
  31. file.writeToDisk(basePath);
  32. }
  33. for (SnapshotFile file : atts) {
  34. file.writeToDisk(basePath);
  35. }
  36. }
  37. public int getVersionID() {
  38. return versionID;
  39. }
  40. public String getComment() {
  41. return comment;
  42. }
  43. public String getUserName() {
  44. return userName;
  45. }
  46. public String getUserEmail() {
  47. return userEmail;
  48. }
  49. public List<SnapshotFile> getSrcs() {
  50. return srcs;
  51. }
  52. public List<SnapshotAttachment> getAtts() {
  53. return atts;
  54. }
  55. }