Skip to content
Snippets Groups Projects
Commit a90bfc91 authored by Jack MacLauchlan CS2015's avatar Jack MacLauchlan CS2015
Browse files

watchers and assignees blobs created, no commands for them yet

parent a1230143
No related branches found
No related tags found
1 merge request!2Commit tree
......@@ -101,8 +101,16 @@ class IssueReader {
buildComment(issue, path, data);
break;
case "tags":
issue.setTags(mapper.readValue(data, new TypeReference<Set<User>>(){}));
issue.setTags(mapper.readValue(data, new TypeReference<Set<User>>() {
}));
break;
case "watchers":
issue.setWatchers(mapper.readValue(data, new TypeReference<Set<User>>() {
}));
break;
case "assignees":
issue.setAssignees(mapper.readValue(data, new TypeReference<Set<User>>() {
}));
default:
//ignore
break;
......
......@@ -22,6 +22,7 @@ class IssueTreeBuilder {
TreeFormatter issueTreeFormatter = new TreeFormatter();
byte[] assigneesJson = mapper.writeValueAsBytes(issue.getAssignees());
byte[] creationTimeJson = mapper.writeValueAsBytes(issue.getCreationTime());
byte[] creatorJson = mapper.writeValueAsBytes(issue.getCreator());
byte[] descriptionJson = mapper.writeValueAsBytes(issue.getDescription());
......@@ -29,7 +30,10 @@ class IssueTreeBuilder {
byte[] statusJson = mapper.writeValueAsBytes(issue.isOpen());
byte[] tagsJsonBytes = mapper.writeValueAsBytes(issue.getTags());
byte[] titleJson = mapper.writeValueAsBytes(issue.getTitle());
byte[] watchersJson = mapper.writeValueAsBytes(issue.getWatchers());
ObjectId assignees = oi.insert(Constants.OBJ_BLOB, assigneesJson);
ObjectId comments = buildCommentTree(issue.getComments());
ObjectId creationTime = oi.insert(Constants.OBJ_BLOB, creationTimeJson);
ObjectId creator = oi.insert(Constants.OBJ_BLOB, creatorJson);
......@@ -38,7 +42,9 @@ class IssueTreeBuilder {
ObjectId status = oi.insert(Constants.OBJ_BLOB, statusJson);
ObjectId tags = oi.insert(Constants.OBJ_BLOB, tagsJsonBytes);
ObjectId title = oi.insert(Constants.OBJ_BLOB, titleJson);
ObjectId watchers = oi.insert(Constants.OBJ_BLOB, watchersJson);
issueTreeFormatter.append("assignees", FileMode.REGULAR_FILE, assignees);
issueTreeFormatter.append("comments", FileMode.TREE, comments);
issueTreeFormatter.append("creationTime", FileMode.REGULAR_FILE, creationTime);
issueTreeFormatter.append("creator", FileMode.REGULAR_FILE, creator);
......@@ -47,7 +53,7 @@ class IssueTreeBuilder {
issueTreeFormatter.append("status", FileMode.REGULAR_FILE, status);
issueTreeFormatter.append("tags", FileMode.REGULAR_FILE, tags);
issueTreeFormatter.append("title", FileMode.REGULAR_FILE, title);
issueTreeFormatter.append("watchers", FileMode.REGULAR_FILE, watchers);
return oi.insert(Constants.OBJ_TREE, issueTreeFormatter.toByteArray());
}
......
......@@ -6,10 +6,10 @@ import java.util.*;
public class Issue {
private Set<String> tags;
private List<Comment> comments;
private List<User> assignees;
private List<User> watchers;
private Set<String> tags;
private Set<User> assignees;
private Set<User> watchers;
private String title;
private String description;
private User creator;
......@@ -28,15 +28,15 @@ public class Issue {
this.originalHash = DigestUtils.sha256Hex(title + description + creationTime);
this.comments = new ArrayList<>();
this.tags = new HashSet<>();
this.assignees = new ArrayList<>();
this.watchers = new ArrayList<>();
this.assignees = new HashSet<>();
this.watchers = new HashSet<>();
}
public Issue() {
comments = new ArrayList<>();
tags = new HashSet<>();
assignees = new ArrayList<>();
watchers = new ArrayList<>();
assignees = new HashSet<>();
watchers = new HashSet<>();
}
public void edited() {
......@@ -79,26 +79,30 @@ public class Issue {
watchers.add(user);
}
public List<User> getWatchers(){
public Set<User> getWatchers() {
return watchers;
}
public void removeWatcher(User user){
public void removeWatcher(User user) {
watchers.remove(user);
}
public void setWatchers(Set<User> watchers) {this.watchers = watchers;}
public void addAssignee(User user) {
assignees.add(user);
}
public List<User> getAssignees(){
public Set<User> getAssignees() {
return assignees;
}
public void removeAssignee(User user){
public void removeAssignee(User user) {
assignees.remove(user);
}
public void setAssignees(Set<User> assignees) {this.assignees = assignees;}
public void addTags(String tag) {
List<String> strings = Arrays.asList(tag.split("\\s*,\\s*"));
strings.forEach(t -> {
......@@ -108,7 +112,7 @@ public class Issue {
});
}
public void addTag(String tag){
public void addTag(String tag) {
tags.add(tag);
}
......@@ -126,7 +130,7 @@ public class Issue {
return tags;
}
public void setTags(Set<String> tags){
public void setTags(Set<String> tags) {
this.tags = tags;
}
......
......@@ -12,7 +12,8 @@ public class User {
this.email = email;
}
public User(){}
public User() {
}
@Override
public boolean equals(Object o) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment