public TaskData fillTaskData()

in org.eclipse.mylyn.github.core/src/org/eclipse/mylyn/internal/github/core/gist/GistTaskDataHandler.java [87:167]


	public TaskData fillTaskData(TaskRepository repository, TaskData data,
			Gist gist) {
		boolean isOwner = isOwner(repository, gist.getOwner());
		TaskAttributeMapper mapper = data.getAttributeMapper();

		TaskAttribute key = GistAttribute.KEY.getMetadata().create(data);
		mapper.setValue(key, gist.getId());

		TaskAttribute description = GistAttribute.DESCRIPTION.getMetadata()
				.create(data);
		description.getMetaData().setReadOnly(!isOwner);
		String gistDescription = gist.getDescription();
		if (gistDescription != null)
			mapper.setValue(description, gistDescription);

		TaskAttribute created = GistAttribute.CREATED.getMetadata()
				.create(data);
		mapper.setDateValue(created, gist.getCreatedAt());

		TaskAttribute updated = GistAttribute.UPDATED.getMetadata()
				.create(data);
		mapper.setDateValue(updated, gist.getUpdatedAt());

		TaskAttribute url = GistAttribute.URL.getMetadata().create(data);
		url.setValue(gist.getHtmlUrl());

		TaskAttribute cloneUrl = GistAttribute.CLONE_URL.getMetadata().create(
				data);
		if (isOwner)
			cloneUrl.setValue(gist.getGitPushUrl());
		else
			cloneUrl.setValue(gist.getGitPullUrl());

		IRepositoryPerson reporterPerson = null;
		User owner = gist.getOwner();
		if (owner != null) {
			TaskAttribute reporter = GistAttribute.AUTHOR.getMetadata().create(
					data);
			reporterPerson = createPerson(owner, repository);
			mapper.setRepositoryPerson(reporter, reporterPerson);

			TaskAttribute gravatar = GistAttribute.AUTHOR_GRAVATAR
					.getMetadata().create(data);
			mapper.setValue(gravatar, owner.getAvatarUrl());
		}

		Map<String, GistFile> files = gist.getFiles();
		int fileCount = 0;
		long sizeCount = 0;
		if (files != null && !files.isEmpty()) {
			int count = 1;
			for (GistFile file : files.values()) {
				fileCount++;
				sizeCount += file.getSize();
				TaskAttachmentMapper attachmentMapper = new TaskAttachmentMapper();
				attachmentMapper.setFileName(file.getFilename());
				attachmentMapper.setReplaceExisting(Boolean.TRUE);
				attachmentMapper.setLength(Long.valueOf(file.getSize()));
				attachmentMapper.setPatch(Boolean.FALSE);
				attachmentMapper.setAuthor(reporterPerson);
				attachmentMapper.setAttachmentId(file.getFilename());
				TaskAttribute attribute = data.getRoot().createAttribute(
						TaskAttribute.PREFIX_ATTACHMENT + count);
				attachmentMapper.applyTo(attribute);

				GistAttribute.RAW_FILE_URL.getMetadata().create(attribute)
						.setValue(file.getRawUrl());

				count++;
			}
		}

		GistAttribute.COMMENT_NEW.getMetadata().create(data);

		TaskAttribute summary = GistAttribute.SUMMARY.getMetadata()
				.create(data);
		mapper.setValue(summary,
				generateSummary(fileCount, sizeCount, gist.getDescription()));

		return data;
	}