public TaskData updateTaskData(TaskRepository repository, IssuesEntry issueEntry,
IProgressMonitor monitor) throws CoreException {
String repositoryUrl = repository.getRepositoryUrl();
String issueId = getIssueId(issueEntry);
TaskData data = new TaskData(getAttributeMapper(repository), repository.getConnectorKind(),
repositoryUrl, issueId);
this.initializeTaskData(repository, data, null, monitor);
String title = issueEntry.getTitle().getPlainText();
setAttributeValue(data, GoogleCodeAttribute.SUMMARY, title);
setAttributeValue(data, GoogleCodeAttribute.USER_REPORTER, issueEntry.getAuthors().get(0).getName());
String summary = getPlainTextContent(issueEntry, true);
if (data.isNew()) {
setAttributeValue(data, GoogleCodeAttribute.DESCRIPTION_NEW, summary);
} else {
setAttributeValue(data, GoogleCodeAttribute.DESCRIPTION_EXISTING, summary);
}
setAttributeValue(data, GoogleCodeAttribute.TASK_KEY, issueId);
if (issueEntry.hasStatus()) {
// {Status value=Fixed}{Status value=Duplicate}{Status
// value=WontFix}{Status value=Accepted}
Status status = issueEntry.getStatus();
setAttributeValue(data, GoogleCodeAttribute.STATUS, status.getValue());
}
if (issueEntry.hasLabels()) {
// [{Label value=Type-Defect}, {Label value=Priority-Medium}, {Label
// value=Type-Enhancement}]
for (Label label : issueEntry.getLabels()) {
if (label.hasValue()) {
String value = label.getValue();
if (value.startsWith("Type-")) {
String type = value.substring("Type-".length());
setAttributeValue(data, GoogleCodeAttribute.TYPE, type);
} else if (value.startsWith("Priority-")) {
String priority = value.substring("Priority-".length());
PriorityLevel level = LabelUtils.convertToMylyn(priority);
if (level != null) {
setAttributeValue(data, GoogleCodeAttribute.PRIORITY, level.toString());
}
} else if (value.startsWith("Milestone-")) {
String milestone = value.substring("Milestone-".length());
setAttributeValue(data, GoogleCodeAttribute.MILESTONE, milestone);
}
}
}
}
setAttributeValue(data, GoogleCodeAttribute.DATE_CREATION, issueEntry.getPublished());
setAttributeValue(data, GoogleCodeAttribute.DATE_MODIFICATION, issueEntry.getUpdated());
if (issueEntry.hasOwner()) {
IRepositoryPerson owner = getPerson(data, issueEntry.getOwner());
setAttributeValue(data, GoogleCodeAttribute.USER_ASSIGNED, owner);
}
if (!data.isNew()) {
TaskAttribute url = getAttribute(data, GoogleCodeAttribute.URL);
url.setValue(this.connector.getTaskUrl(repository.getUrl(), issueId));
}
IGoogleCodeClient client = getClient(repository);
IssueCommentsFeed comments = client.getAllComments(issueId, monitor);
if (!data.isNew()) {
addComments(issueId, data, comments, monitor);
}
// Set the completion date, this allows Mylyn mark the issue as
// completed
// There is no API for this so we make an educated guess
State state = issueEntry.getState();
if (!data.isNew() && Value.CLOSED == state.getValue()) {
// find the last comment that set the issue status to the current
// value
// it would be better to find the last comment to set that state to
// closed
// but as long as we can't do that this will have to do
// initialize with issue creation date in case we don't find any
// comments
DateTime closingDate = issueEntry.getPublished();
for (IssueCommentsEntry comment : comments.getEntries()) {
Updates updates = comment.getUpdates();
if (updates != null && issueEntry.getStatus().equals(updates.getStatus())) {
closingDate = comment.getPublished();
}
}
setAttributeValue(data, GoogleCodeAttribute.DATE_COMPLETION, closingDate);
}
data.getAttributeMapper().setIntegerValue(getAttribute(data, GoogleCodeAttribute.STARS),
issueEntry.getStars().getValue());
List<BlockedOn> blockedOn = issueEntry.getBlockedOns();
List<String> rawBlockOns = new ArrayList<String>();
for (BlockedOn blocking : blockedOn) {