Search in sources :

Example 1 with TaskDataCollector

use of org.eclipse.mylyn.tasks.core.data.TaskDataCollector in project linuxtools by eclipse.

the class OSIORestHarness method getTaskIdWithSummary.

private String getTaskIdWithSummary(String summary) throws OSIORestException, CoreException {
    String taskID = null;
    String queryUrlString = repository().getRepositoryUrl() + "/bug?" + "short_desc=" + summary;
    RepositoryQuery query = new RepositoryQuery(repository().getConnectorKind(), "handle-testQueryViaConnector");
    query.setUrl(queryUrlString);
    final Map<Integer, TaskData> changedTaskData = new HashMap<Integer, TaskData>();
    TaskDataCollector collector = new TaskDataCollector() {

        @Override
        public void accept(TaskData taskData) {
            changedTaskData.put(Integer.valueOf(taskData.getTaskId()), taskData);
        }
    };
    connector().performQuery(repository(), query, collector, null, new NullProgressMonitor());
    if (changedTaskData.size() > 0) {
        Set<Integer> ks = changedTaskData.keySet();
        SortedSet<Integer> sks = new TreeSet<Integer>(ks);
        taskID = sks.last().toString();
    } else {
        final TaskMapping taskMappingInit = new TaskMapping() {

            @Override
            public String getSummary() {
                return summary;
            }

            @Override
            public String getDescription() {
                return "The Description";
            }

            @Override
            public String getProduct() {
                return "ManualTest";
            }

            @Override
            public String getComponent() {
                return "ManualC1";
            }

            @Override
            public String getVersion() {
                return "R1";
            }
        };
        taskID = getNewTaksIdFromInitMapping(taskMappingInit, taskInitializationData);
    }
    return taskID;
}
Also used : SingleTaskDataCollector(org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.SingleTaskDataCollector) TaskDataCollector(org.eclipse.mylyn.tasks.core.data.TaskDataCollector) RepositoryQuery(org.eclipse.mylyn.internal.tasks.core.RepositoryQuery) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) ITaskMapping(org.eclipse.mylyn.tasks.core.ITaskMapping) TaskMapping(org.eclipse.mylyn.tasks.core.TaskMapping) TaskData(org.eclipse.mylyn.tasks.core.data.TaskData)

Aggregations

HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 SingleTaskDataCollector (org.eclipse.linuxtools.internal.mylyn.osio.rest.core.response.data.SingleTaskDataCollector)1 RepositoryQuery (org.eclipse.mylyn.internal.tasks.core.RepositoryQuery)1 ITaskMapping (org.eclipse.mylyn.tasks.core.ITaskMapping)1 TaskMapping (org.eclipse.mylyn.tasks.core.TaskMapping)1 TaskData (org.eclipse.mylyn.tasks.core.data.TaskData)1 TaskDataCollector (org.eclipse.mylyn.tasks.core.data.TaskDataCollector)1