mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
DirectoryNode being created for latest snapshot.
This commit is contained in:
+3
-3
@@ -17,11 +17,11 @@ public class SnapshotData implements JSONSource {
|
||||
public static final String JSON_KEY_ATTS = "atts";
|
||||
|
||||
private List<SnapshotFile> srcs;
|
||||
private List<SnapshotFile> atts;
|
||||
private List<SnapshotAttachment> atts;
|
||||
|
||||
public SnapshotData(JsonElement json) throws FailedConnectionException {
|
||||
srcs = new LinkedList<SnapshotFile>();
|
||||
atts = new LinkedList<SnapshotFile>();
|
||||
atts = new LinkedList<SnapshotAttachment>();
|
||||
fromJSON(json);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class SnapshotData implements JSONSource {
|
||||
return srcs;
|
||||
}
|
||||
|
||||
public List<SnapshotFile> getAtts() {
|
||||
public List<SnapshotAttachment> getAtts() {
|
||||
return atts;
|
||||
}
|
||||
}
|
||||
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
package uk.ac.ic.wlgitbridge.writelatex.filestore;
|
||||
|
||||
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.model.WLProject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Winston on 08/11/14.
|
||||
*/
|
||||
public class WLDirectoryNode {
|
||||
|
||||
private final Map<String, String> srcs;
|
||||
private final Map<String, String> atts;
|
||||
private final String rootGitDirectoryPath;
|
||||
|
||||
public WLDirectoryNode(String rootGitDirectoryPath, String projectName) {
|
||||
this.rootGitDirectoryPath = rootGitDirectoryPath;
|
||||
srcs = new HashMap<String, String>();
|
||||
atts = new HashMap<String, String>();
|
||||
}
|
||||
|
||||
public void updateFromProject(WLProject project) {
|
||||
updateFromLatestSnapshot(project.getLatestSnapshot());
|
||||
}
|
||||
|
||||
private void updateFromLatestSnapshot(Snapshot snapshot) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package uk.ac.ic.wlgitbridge.writelatex.filestore;
|
||||
|
||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.node.WLDirectoryNode;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.model.WLProject;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -25,7 +26,7 @@ public class WLFileStore {
|
||||
directoryNode = new WLDirectoryNode(rootGitDirectoryPath, projectName);
|
||||
fileStore.put(projectName, directoryNode);
|
||||
}
|
||||
directoryNode.updateFromProject(project);
|
||||
directoryNode.updateFromSnapshot(project.getLatestSnapshot());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package uk.ac.ic.wlgitbridge.writelatex.filestore.node;
|
||||
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotAttachment;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Winston on 12/11/14.
|
||||
*/
|
||||
public class AttachmentNode extends FileNode {
|
||||
|
||||
public AttachmentNode(SnapshotAttachment snapshotAttachment, Map<String, FileNode> context) {
|
||||
super(snapshotAttachment, context);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package uk.ac.ic.wlgitbridge.writelatex.filestore.node;
|
||||
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotFile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Winston on 12/11/14.
|
||||
*/
|
||||
public class BlobNode extends FileNode {
|
||||
|
||||
public BlobNode(SnapshotFile snapshotFile, Map<String, FileNode> context) {
|
||||
super(snapshotFile, context);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package uk.ac.ic.wlgitbridge.writelatex.filestore.node;
|
||||
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotFile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Winston on 12/11/14.
|
||||
*/
|
||||
public abstract class FileNode {
|
||||
|
||||
private final String filePath;
|
||||
private final boolean unchanged;
|
||||
|
||||
public FileNode(SnapshotFile snapshotFile, Map<String, FileNode> context) {
|
||||
filePath = snapshotFile.getPath();
|
||||
FileNode currentFileNode = context.get(filePath);
|
||||
unchanged = currentFileNode != null && equals(currentFileNode);
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package uk.ac.ic.wlgitbridge.writelatex.filestore.node;
|
||||
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotAttachment;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotFile;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.filestore.FileIndexStore;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.model.Snapshot;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.model.WLProject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Winston on 08/11/14.
|
||||
*/
|
||||
public class WLDirectoryNode {
|
||||
|
||||
private Map<String, FileNode> files;
|
||||
private final FileIndexStore fileIndexes;
|
||||
private final String rootGitDirectoryPath;
|
||||
|
||||
public WLDirectoryNode(String rootGitDirectoryPath, String projectName) {
|
||||
this.rootGitDirectoryPath = rootGitDirectoryPath;
|
||||
files = new HashMap<String, FileNode>();
|
||||
fileIndexes = new FileIndexStore();
|
||||
}
|
||||
|
||||
public void updateFromSnapshot(Snapshot snapshot) {
|
||||
Map<String, FileNode> updatedFiles = new HashMap<String, FileNode>();
|
||||
List<SnapshotFile> srcs = snapshot.getSrcs();
|
||||
List<SnapshotAttachment> atts = snapshot.getAtts();
|
||||
for (SnapshotFile src : srcs) {
|
||||
BlobNode blobNode = new BlobNode(src, files);
|
||||
updatedFiles.put(blobNode.getFilePath(), blobNode);
|
||||
}
|
||||
for (SnapshotAttachment att : atts) {
|
||||
AttachmentNode attachmentNode = new AttachmentNode(att, files);
|
||||
updatedFiles.put(attachmentNode.getFilePath(), attachmentNode);
|
||||
}
|
||||
files = updatedFiles;
|
||||
try {
|
||||
throw new Throwable();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
System.out.println(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return files.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package uk.ac.ic.wlgitbridge.writelatex.model;
|
||||
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.exception.FailedConnectionException;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotAttachment;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotData;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getforversion.SnapshotFile;
|
||||
import uk.ac.ic.wlgitbridge.writelatex.api.request.getsavedvers.SnapshotInfo;
|
||||
@@ -20,7 +21,7 @@ public class Snapshot {
|
||||
private final String userEmail;
|
||||
|
||||
private final List<SnapshotFile> srcs;
|
||||
private final List<SnapshotFile> atts;
|
||||
private final List<SnapshotAttachment> atts;
|
||||
|
||||
public Snapshot(SnapshotInfo info, SnapshotData data) {
|
||||
versionID = info.getVersionId();
|
||||
@@ -58,4 +59,12 @@ public class Snapshot {
|
||||
return userEmail;
|
||||
}
|
||||
|
||||
public List<SnapshotFile> getSrcs() {
|
||||
return srcs;
|
||||
}
|
||||
|
||||
public List<SnapshotAttachment> getAtts() {
|
||||
return atts;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user