Skip to main content
summaryrefslogtreecommitdiffstats
blob: 05d70a23822eaaab59f26561befd26fd3a61a65b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*******************************************************************************
 * Copyright (c) 2004, 2008 Tasktop Technologies and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Tasktop Technologies - initial API and implementation
 *     Frank Becker - improvements
 *******************************************************************************/

package org.eclipse.mylyn.tasks.core.data;

import java.util.Set;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
import org.eclipse.mylyn.tasks.core.TaskRepository;

/**
 * Responsible for retrieving and posting task data to a repository. Clients may subclass.
 * 
 * @author Mik Kersten
 * @author Rob Elves
 * @author Steffen Pingel
 * @since 3.0
 */
public abstract class AbstractTaskDataHandler {

	/**
	 * Download task data for each id provided Override {@link #canGetMultiTaskData(TaskRepository)} to return true and
	 * implement this method if connector supports download of multiple task data in one request.
	 * 
	 * @since 3.0
	 */
	public void getMultiTaskData(@NonNull TaskRepository repository, @NonNull Set<String> taskIds, @NonNull TaskDataCollector collector,
			@Nullable IProgressMonitor monitor) throws CoreException {
		throw new UnsupportedOperationException();
	}

	/**
	 * Return a reference to the newly created report in the case of new task submission, null otherwise
	 * 
	 * @since 3.0
	 */
	public abstract RepositoryResponse postTaskData(@NonNull TaskRepository repository, @NonNull TaskData taskData,
			@Nullable Set<TaskAttribute> oldAttributes, @Nullable IProgressMonitor monitor) throws CoreException;

	/**
	 * Initialize a new task data object with default attributes and values
	 * 
	 * @since 3.0
	 */
	public abstract boolean initializeTaskData(@NonNull TaskRepository repository, @NonNull TaskData data,
			@Nullable ITaskMapping initializationData, @Nullable IProgressMonitor monitor) throws CoreException;

	/**
	 * Initializes <code>taskData</code> with default attributes for a subtask of <code>parentTaskData</code>.
	 * 
	 * @return false if this operation is not supported by the connector, true if initialized
	 * @since 3.0
	 */
	public boolean initializeSubTaskData(@NonNull TaskRepository repository, @NonNull TaskData taskData, @NonNull TaskData parentTaskData,
			@Nullable IProgressMonitor monitor) throws CoreException {
		return false;
	}

	/**
	 * @param repository
	 *            TODO
	 * @param task
	 *            the parent task, may be null
	 * @param task
	 *            the parent task data, may be null
	 * @since 3.0
	 */
	public boolean canInitializeSubTaskData(@NonNull TaskRepository repository, @Nullable ITask task) {
		return false;
	}

	/**
	 * Returns a {@link TaskAttributeMapper} for <code>repository</code>.
	 * 
	 * @see TaskAttributeMapper
	 * @since 3.0
	 */
	public abstract TaskAttributeMapper getAttributeMapper(@NonNull TaskRepository repository);

	/**
	 * Returns true if connector support downloading multiple task data in single request, false otherwise. If true,
	 * override and implement {@link #getMultiTaskData(TaskRepository, Set, TaskDataCollector, IProgressMonitor)}.
	 * 
	 * @param repository
	 *            the repository for which multi task data download is supported
	 * @since 3.0
	 */
	public boolean canGetMultiTaskData(@NonNull TaskRepository repository) {
		return false;
	}

	/**
	 * Invoked each time task data is loaded.
	 * <p>
	 * Sub classes may override to migrate attributes on <code>taskData</code>.
	 * </p>
	 * 
	 * @since 3.0
	 */
	public void migrateTaskData(@NonNull TaskRepository repository, @NonNull TaskData taskData) {
	}

}

Back to the top