diff options
author | Steffen Pingel | 2011-11-05 10:24:54 +0000 |
---|---|---|
committer | Steffen Pingel | 2011-11-05 10:24:54 +0000 |
commit | 456c4a723418af21d91b00f010292a1138953a1d (patch) | |
tree | 403b427b1db7d83936dd8ad4923e5f277c7a6ef1 | |
parent | 9774c84b20d611b5cd0f7813991c3451d5d6f3ff (diff) | |
download | org.eclipse.mylyn.incubator-456c4a723418af21d91b00f010292a1138953a1d.tar.gz org.eclipse.mylyn.incubator-456c4a723418af21d91b00f010292a1138953a1d.tar.xz org.eclipse.mylyn.incubator-456c4a723418af21d91b00f010292a1138953a1d.zip |
add example for creating a task
-rw-r--r-- | org.eclipse.mylyn.examples.bugzilla/src/org/eclipse/mylyn/internal/examples/bugzilla/CreateTask.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.examples.bugzilla/src/org/eclipse/mylyn/internal/examples/bugzilla/CreateTask.java b/org.eclipse.mylyn.examples.bugzilla/src/org/eclipse/mylyn/internal/examples/bugzilla/CreateTask.java new file mode 100644 index 00000000..17db7429 --- /dev/null +++ b/org.eclipse.mylyn.examples.bugzilla/src/org/eclipse/mylyn/internal/examples/bugzilla/CreateTask.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2011 Mylyn project committers 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 + *******************************************************************************/ + +package org.eclipse.mylyn.internal.examples.bugzilla; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.mylyn.commons.net.AuthenticationCredentials; +import org.eclipse.mylyn.commons.net.AuthenticationType; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; +import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector; +import org.eclipse.mylyn.tasks.core.TaskRepository; +import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper; +import org.eclipse.mylyn.tasks.core.data.TaskData; +import org.eclipse.mylyn.tasks.core.data.TaskMapper; + +/** + * @author Steffen Pingel + */ +public class CreateTask { + + private static final String URL = "http://mylyn.org/tractest"; + + public static void main(String[] args) throws CoreException { + // create task repository + TaskRepository repository = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, URL); + + // set repository credentials + if (args.length >= 2) { + AuthenticationCredentials credentials = new AuthenticationCredentials(args[0], args[1]); + repository.setCredentials(AuthenticationType.REPOSITORY, credentials, false); + } + + // create bugzilla connector + BugzillaRepositoryConnector connector = new BugzillaRepositoryConnector(); + + // initialize task data + TaskAttributeMapper attributeMapper = connector.getTaskDataHandler().getAttributeMapper(repository); + TaskData taskData = new TaskData(attributeMapper, repository.getConnectorKind(), repository.getRepositoryUrl(), + ""); + connector.getTaskDataHandler().initializeTaskData(repository, taskData, null, null); + + // set attributes + TaskMapper mapping = connector.getTaskMapping(taskData); + mapping.setSummary("new task"); + mapping.setDescription("Task created."); + + connector.getTaskDataHandler().postTaskData(repository, taskData, null, null); + } + +} |