|
Lines 16-21
Link Here
|
| 16 |
|
16 |
|
| 17 |
import org.eclipse.mylyn.internal.tasks.core.TaskComment; |
17 |
import org.eclipse.mylyn.internal.tasks.core.TaskComment; |
| 18 |
import org.eclipse.mylyn.tasks.core.IRepositoryPerson; |
18 |
import org.eclipse.mylyn.tasks.core.IRepositoryPerson; |
|
|
19 |
import org.eclipse.mylyn.tasks.core.ITask; |
| 20 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
| 19 |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
21 |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
| 20 |
import org.eclipse.mylyn.tasks.core.data.TaskDataModel; |
22 |
import org.eclipse.mylyn.tasks.core.data.TaskDataModel; |
| 21 |
|
23 |
|
|
Lines 24-40
Link Here
|
| 24 |
*/ |
26 |
*/ |
| 25 |
public class CommentGroupStrategy { |
27 |
public class CommentGroupStrategy { |
| 26 |
public class CommentGroup { |
28 |
public class CommentGroup { |
| 27 |
private final List<TaskAttribute> commentAttributes; |
29 |
private final List<TaskAttribute> comments; |
| 28 |
|
30 |
|
| 29 |
private final String groupName; |
31 |
private final String groupName; |
| 30 |
|
32 |
|
| 31 |
CommentGroup(String groupName, List<TaskAttribute> commentAttributes) { |
33 |
CommentGroup(String groupName, List<TaskAttribute> comments) { |
| 32 |
this.groupName = groupName; |
34 |
this.groupName = groupName; |
| 33 |
this.commentAttributes = commentAttributes; |
35 |
this.comments = comments; |
| 34 |
} |
36 |
} |
| 35 |
|
37 |
|
| 36 |
public List<TaskAttribute> getCommentAttributes() { |
38 |
public List<TaskAttribute> getCommentAttributes() { |
| 37 |
return commentAttributes; |
39 |
return comments; |
| 38 |
} |
40 |
} |
| 39 |
|
41 |
|
| 40 |
public String getGroupName() { |
42 |
public String getGroupName() { |
|
Lines 42-51
Link Here
|
| 42 |
} |
44 |
} |
| 43 |
} |
45 |
} |
| 44 |
|
46 |
|
| 45 |
private TaskComment convertToTaskComment(TaskDataModel taskDataModel, TaskAttribute commentAttribute) { |
47 |
private TaskComment convertToTaskComment(TaskRepository taskRepository, ITask task, TaskAttribute commentAttribute) { |
| 46 |
TaskComment taskComment = new TaskComment(taskDataModel.getTaskRepository(), taskDataModel.getTask(), |
48 |
TaskComment taskComment = new TaskComment(taskRepository, task, commentAttribute); |
| 47 |
commentAttribute); |
49 |
commentAttribute.getTaskData().getAttributeMapper().updateTaskComment(taskComment, commentAttribute); |
| 48 |
taskDataModel.getTaskData().getAttributeMapper().updateTaskComment(taskComment, commentAttribute); |
|
|
| 49 |
|
50 |
|
| 50 |
return taskComment; |
51 |
return taskComment; |
| 51 |
} |
52 |
} |
|
Lines 57-82
Link Here
|
| 57 |
* extracts groups of comment for the model |
58 |
* extracts groups of comment for the model |
| 58 |
* @return list of comment groups. Groups will be ignored if there are no comments under them. |
59 |
* @return list of comment groups. Groups will be ignored if there are no comments under them. |
| 59 |
*/ |
60 |
*/ |
| 60 |
public List<CommentGroup> groupCommentsFromModel(TaskDataModel taskDataModel) { |
61 |
public List<CommentGroup> groupComments(List<TaskAttribute> comments, TaskRepository taskRepository, ITask task, |
| 61 |
List<TaskAttribute> taskAttributes = taskDataModel.getTaskData().getAttributeMapper().getAttributesByType( |
62 |
TaskDataModel taskDataModel) { |
| 62 |
taskDataModel.getTaskData(), TaskAttribute.TYPE_COMMENT); |
|
|
| 63 |
List<CommentGroup> commentGroups = new ArrayList<CommentGroup>(); |
63 |
List<CommentGroup> commentGroups = new ArrayList<CommentGroup>(); |
| 64 |
List<TaskAttribute> comments = new ArrayList<TaskAttribute>(); |
|
|
| 65 |
|
64 |
|
| 66 |
int currentFromIndex = -1; |
65 |
int currentFromIndex = -1; |
| 67 |
String currentPersonId = taskDataModel.getTaskRepository().getUserName(); |
66 |
String currentPersonId = taskRepository.getUserName(); |
| 68 |
|
67 |
|
| 69 |
// current |
68 |
// current |
| 70 |
List<TaskAttribute> current = new ArrayList<TaskAttribute>(); |
69 |
List<TaskAttribute> current = new ArrayList<TaskAttribute>(); |
| 71 |
|
70 |
|
| 72 |
// update task comment and get current group index |
71 |
// update task comment and get current group index |
| 73 |
for (int i = 0; i < taskAttributes.size(); i++) { |
72 |
for (int i = 0; i < comments.size(); i++) { |
| 74 |
TaskAttribute commentAttribute = taskAttributes.get(i); |
73 |
TaskAttribute commentAttribute = comments.get(i); |
| 75 |
final TaskComment taskComment = convertToTaskComment(taskDataModel, commentAttribute); |
74 |
final TaskComment taskComment = convertToTaskComment(taskRepository, task, commentAttribute); |
| 76 |
comments.add(commentAttribute); |
|
|
| 77 |
|
75 |
|
| 78 |
// add all incoming changes |
76 |
// add all incoming changes |
| 79 |
if (taskDataModel.hasIncomingChanges(taskComment.getTaskAttribute())) { |
77 |
if (hasIncomingChanges(taskDataModel, commentAttribute)) { |
| 80 |
current.add(commentAttribute); |
78 |
current.add(commentAttribute); |
| 81 |
} |
79 |
} |
| 82 |
|
80 |
|
|
Lines 122-125
Link Here
|
| 122 |
|
120 |
|
| 123 |
return commentGroups; |
121 |
return commentGroups; |
| 124 |
} |
122 |
} |
|
|
123 |
|
| 124 |
protected boolean hasIncomingChanges(TaskDataModel taskDataModel, TaskAttribute commentAttribute) { |
| 125 |
return taskDataModel.hasIncomingChanges(commentAttribute); |
| 126 |
} |
| 125 |
} |
127 |
} |