Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2016-08-15 19:30:10 -0400
committerSam Davis2016-08-30 17:21:44 -0400
commitb4c722e53591c523bb4ca240b0aa87c5a153804c (patch)
tree58f5a0af964b3b11405de7586cebb475b67e97a7
parent5e84bcb5f7dadf1fc737b6d861686b7e22d7eddd (diff)
downloadorg.eclipse.mylyn.tasks-b4c722e53591c523bb4ca240b0aa87c5a153804c.tar.gz
org.eclipse.mylyn.tasks-b4c722e53591c523bb4ca240b0aa87c5a153804c.tar.xz
org.eclipse.mylyn.tasks-b4c722e53591c523bb4ca240b0aa87c5a153804c.zip
498906: connector migration can migrate queries
Change-Id: I0459a07552ab6fdc9b5d9b19e707d3d8c19699da Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=498906
-rw-r--r--org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/migrator/CompleteConnectorMigrationWizardTest.java67
-rw-r--r--org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/migrator/ConnectorMigratorTest.java96
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/CompleteConnectorMigrationWizard.java53
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/ConnectorMigrator.java56
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/Messages.java12
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/messages.properties21
6 files changed, 254 insertions, 51 deletions
diff --git a/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/migrator/CompleteConnectorMigrationWizardTest.java b/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/migrator/CompleteConnectorMigrationWizardTest.java
index 580224e31..9729a3b70 100644
--- a/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/migrator/CompleteConnectorMigrationWizardTest.java
+++ b/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/migrator/CompleteConnectorMigrationWizardTest.java
@@ -11,6 +11,7 @@ package org.eclipse.mylyn.internal.tasks.ui.migrator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doNothing;
@@ -60,15 +61,23 @@ public class CompleteConnectorMigrationWizardTest {
private ConnectorMigrationUi migrationUi;
+ private DefaultTasksState tasksState;
+
@SuppressWarnings("unchecked")
@Before
public void setUp() {
- DefaultTasksState tasksState = new DefaultTasksState();
+ tasksState = new DefaultTasksState();
migrationUi = spy(new ConnectorMigrationUi(TaskListView.getFromActivePerspective(),
TasksUiPlugin.getBackupManager(), tasksState));
- doNothing().when(migrationUi).warnOfValidationFailure((List<TaskRepository>) any(List.class));
+ doNothing().when(migrationUi).warnOfValidationFailure(any(List.class));
doNothing().when(migrationUi).notifyMigrationComplete();
- migrator = spy(new ConnectorMigrator(ImmutableMap.of("mock", "mock.new"), "", tasksState, migrationUi));
+ migrator = createMigrator(ImmutableMap.of("mock", "mock.new"));
+ }
+
+ private ConnectorMigrator createMigrator(ImmutableMap<String, String> kinds) {
+ ConnectorMigrator migrator = spy(new ConnectorMigrator(kinds, "", tasksState, migrationUi));
+ when(migrator.allQueriesMigrated()).thenReturn(false);
+ return migrator;
}
@After
@@ -100,11 +109,39 @@ public class CompleteConnectorMigrationWizardTest {
assertTrue(control.getChildren()[3] instanceof Tree);
}
+ @Test
+ public void firstPageSomeQueriesMigrated() {
+ when(migrator.anyQueriesMigrated()).thenReturn(true);
+ IWizardContainer container = createWizard(new CompleteConnectorMigrationWizard(migrator));
+ IWizardPage firstPage = container.getCurrentPage();
+ assertEquals("Have You Recreated Your Queries?", firstPage.getTitle());
+ assertEquals(
+ "Migration will remove your old queries. Some queries could not be automatically migrated. "
+ + "Please review your old and new queries and edit or create new ones as needed. "
+ + "Your old and new queries are shown below and you can edit them by double-clicking.",
+ firstPage.getMessage());
+ assertTrue(firstPage.getControl() instanceof Composite);
+ Composite control = (Composite) firstPage.getControl();
+ assertEquals(4, control.getChildren().length);
+ assertTrue(control.getChildren()[0] instanceof Label);
+ assertTrue(control.getChildren()[1] instanceof Label);
+ assertTrue(control.getChildren()[2] instanceof Tree);
+ assertTrue(control.getChildren()[3] instanceof Tree);
+ }
+
+ @Test
+ public void firstPageAllQueriesMigrated() {
+ when(migrator.allQueriesMigrated()).thenReturn(true);
+ IWizardContainer container = createWizard(new CompleteConnectorMigrationWizard(migrator));
+ IWizardPage firstPage = container.getCurrentPage();
+ assertEquals("Complete Migration", firstPage.getTitle());
+ assertNull(firstPage.getNextPage());
+ }
+
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void queryTreeShowsOnlySelectedConnectors() {
- migrator = new ConnectorMigrator(ImmutableMap.of("mock", "mock.new", "kind", "kind.new"), "",
- new DefaultTasksState(), migrationUi);
+ migrator = createMigrator(ImmutableMap.of("mock", "mock.new", "kind", "kind.new"));
migrator.setConnectorsToMigrate(ImmutableList.of("kind"));
createWizard(new CompleteConnectorMigrationWizard(migrator));
ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
@@ -112,8 +149,7 @@ public class CompleteConnectorMigrationWizardTest {
assertEquals(ImmutableSet.of("kind"), ImmutableSet.copyOf(captor.getAllValues().get(0)));
assertEquals(ImmutableSet.of("kind.new"), ImmutableSet.copyOf(captor.getAllValues().get(1)));
- migrator = new ConnectorMigrator(ImmutableMap.of("mock", "mock.new", "kind", "kind.new"), "",
- new DefaultTasksState(), migrationUi);
+ migrator = createMigrator(ImmutableMap.of("mock", "mock.new", "kind", "kind.new"));
migrator.setConnectorsToMigrate(ImmutableList.of("mock", "kind"));
createWizard(new CompleteConnectorMigrationWizard(migrator));
captor = ArgumentCaptor.forClass(Collection.class);
@@ -137,10 +173,11 @@ public class CompleteConnectorMigrationWizardTest {
String text = ((Text) control.getChildren()[0]).getText();
assertTrue(text.contains("When you click finish, your context, scheduled dates, private notes and other data "
+ "will be migrated to the new connectors. Any tasks in your task list that are not included in the new "
- + "queries you created will be downloaded using the new connectors. The old tasks, "
+ + "queries will be downloaded using the new connectors. The old tasks, "
+ "queries, and repositories will be deleted."));
- assertTrue(text.contains("This may take a while. You should not use the task list or task editor while this is happening. "
- + "You will be prompted when migration is complete."));
+ assertTrue(text.contains(
+ "This may take a while. You should not use the task list or task editor while this is happening. "
+ + "You will be prompted when migration is complete."));
assertTrue(text.contains("You will be able to "
+ "undo the migration by selecting \"Restore Tasks from History\" in the Task List view menu and choosing the "
+ "connector-migration-*.zip file stored in <workspace>/.metadata/.mylyn/backup. This will restore your task "
@@ -196,7 +233,7 @@ public class CompleteConnectorMigrationWizardTest {
RepositoryQuery query4 = createQuery(repository2);
Map<TaskRepository, Set<RepositoryQuery>> map = //
- new CompleteConnectorMigrationWizard(migrator).createRepositoryQueryMap(ImmutableList.of("mock"));
+ new CompleteConnectorMigrationWizard(migrator).createRepositoryQueryMap(ImmutableList.of("mock"));
assertEquals(repositories, map.keySet());
assertEquals(ImmutableSet.of(query1, query2), map.get(repository1));
assertEquals(ImmutableSet.of(query3, query4), map.get(repository2));
@@ -209,7 +246,7 @@ public class CompleteConnectorMigrationWizardTest {
RepositoryQuery query = createQuery(repository);
Map<TaskRepository, Set<RepositoryQuery>> map = //
- new CompleteConnectorMigrationWizard(migrator).createRepositoryQueryMap(ImmutableList.of("mock"));
+ new CompleteConnectorMigrationWizard(migrator).createRepositoryQueryMap(ImmutableList.of("mock"));
assertEquals(ImmutableSet.of(repository), map.keySet());
assertEquals(ImmutableSet.of(query), map.get(repository));
}
@@ -222,7 +259,7 @@ public class CompleteConnectorMigrationWizardTest {
RepositoryQuery migratedQuery = createQuery(migratedRepository);
Map<TaskRepository, Set<RepositoryQuery>> map = //
- new CompleteConnectorMigrationWizard(migrator).createRepositoryQueryMap(ImmutableList.of("mock"));
+ new CompleteConnectorMigrationWizard(migrator).createRepositoryQueryMap(ImmutableList.of("mock"));
assertEquals(ImmutableSet.of(repository), map.keySet());
assertEquals(ImmutableSet.of(query), map.get(repository));
@@ -238,8 +275,8 @@ public class CompleteConnectorMigrationWizardTest {
}
protected RepositoryQuery createQuery(TaskRepository repository) {
- RepositoryQuery query = new RepositoryQuery(repository.getConnectorKind(), repository.getConnectorKind()
- + repository.getRepositoryUrl() + Math.random());
+ RepositoryQuery query = new RepositoryQuery(repository.getConnectorKind(),
+ repository.getConnectorKind() + repository.getRepositoryUrl() + Math.random());
query.setRepositoryUrl(repository.getRepositoryUrl());
TasksUiPlugin.getTaskList().addQuery(query);
return query;
diff --git a/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/migrator/ConnectorMigratorTest.java b/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/migrator/ConnectorMigratorTest.java
index a49c07034..ea4052458 100644
--- a/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/migrator/ConnectorMigratorTest.java
+++ b/org.eclipse.mylyn.tasks.ui.tests/src/org/eclipse/mylyn/internal/tasks/ui/migrator/ConnectorMigratorTest.java
@@ -22,6 +22,7 @@ import static org.mockito.Matchers.any;
import static org.mockito.Matchers.argThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
@@ -167,7 +168,7 @@ public class ConnectorMigratorTest {
@SuppressWarnings("unchecked")
@Before
public void setUp() {
- doNothing().when(migrationUi).warnOfValidationFailure((List<TaskRepository>) any(List.class));
+ doNothing().when(migrationUi).warnOfValidationFailure(any(List.class));
doNothing().when(migrationUi).notifyMigrationComplete();
}
@@ -393,8 +394,8 @@ public class ConnectorMigratorTest {
ConnectorMigrator migrator = spy(createMigrator(true, true, kinds, ImmutableSet.of(repository), false));
TaskData taskData2 = new TaskData(mock(TaskAttributeMapper.class), "mock.new", repository.getRepositoryUrl(),
"2.migrated");
- when(migrator.getTaskData(eq("key2"), eq(newConnector), any(TaskRepository.class), any(IProgressMonitor.class)))
- .thenReturn(taskData2);
+ doReturn(taskData2).when(migrator).getTaskData(eq("key2"), eq(newConnector), any(TaskRepository.class),
+ any(IProgressMonitor.class));
ITask task1 = new TaskTask("mock", "http://mock", "1");
task1.setTaskKey("key1");
((AbstractTask) task1).setSynchronizationState(SynchronizationState.INCOMING_NEW);
@@ -450,12 +451,12 @@ public class ConnectorMigratorTest {
ConnectorMigrator migrator = spy(createMigrator(true, true, kinds, ImmutableSet.of(repository), false));
TaskData taskData1 = new TaskData(mock(TaskAttributeMapper.class), "mock.new", repository.getRepositoryUrl(),
"1");
- when(migrator.getTaskData(eq("key1"), eq(newConnector), any(TaskRepository.class), any(IProgressMonitor.class)))
- .thenReturn(taskData1);
+ doReturn(taskData1).when(migrator).getTaskData(eq("key1"), eq(newConnector), any(TaskRepository.class),
+ any(IProgressMonitor.class));
TaskData taskData2 = new TaskData(mock(TaskAttributeMapper.class), "mock.new", repository.getRepositoryUrl(),
"2");
- when(migrator.getTaskData(eq("key2"), eq(newConnector), any(TaskRepository.class), any(IProgressMonitor.class)))
- .thenReturn(taskData2);
+ doReturn(taskData2).when(migrator).getTaskData(eq("key2"), eq(newConnector), any(TaskRepository.class),
+ any(IProgressMonitor.class));
ITask task1 = new TaskTask("mock", "http://mock", "1");
task1.setTaskKey("key1");
((AbstractTask) task1).setSynchronizationState(SynchronizationState.INCOMING_NEW);
@@ -569,6 +570,87 @@ public class ConnectorMigratorTest {
assertEquals(expected, migrator.getCategories());
}
+ @Test
+ public void migrateNoQueries() {
+ ConnectorMigrator migrator = spy(createMigrator(true, true, kinds, ImmutableSet.of(repository), false));
+ RepositoryQuery q1 = createQuery("q1", repository, migrator, false);
+ RepositoryQuery q2 = createQuery("q2", repository, migrator, false);
+
+ migrator.migrateQueries(repository, migratedRepository, new NullProgressMonitor());
+ assertFalse(migrator.anyQueriesMigrated());
+ assertFalse(migrator.allQueriesMigrated());
+ }
+
+ @Test
+ public void migrateSomeQueries() {
+ ConnectorMigrator migrator = spy(createMigrator(true, true, kinds, ImmutableSet.of(repository), false));
+ RepositoryQuery q1 = createQuery("q1", repository, migrator, true);
+ RepositoryQuery q2 = createQuery("q2", repository, migrator, false);
+
+ assertFalse(migrator.anyQueriesMigrated());
+ assertTrue(migrator.allQueriesMigrated());
+
+ migrator.migrateQueries(repository, migratedRepository, new NullProgressMonitor());
+ assertTrue(migrator.anyQueriesMigrated());
+ assertFalse(migrator.allQueriesMigrated());
+ }
+
+ @Test
+ public void migrateAllQueries() {
+ ConnectorMigrator migrator = spy(createMigrator(true, true, kinds, ImmutableSet.of(repository), false));
+ RepositoryQuery q1 = createQuery("q1", repository, migrator, true);
+ RepositoryQuery q2 = createQuery("q2", repository, migrator, true);
+
+ migrator.migrateQueries(repository, migratedRepository, new NullProgressMonitor());
+ assertTrue(migrator.anyQueriesMigrated());
+ assertTrue(migrator.allQueriesMigrated());
+ }
+
+ @Test
+ public void migrateSomeQueriesMultipleRepositories() {
+ TaskRepository otherRepository = new TaskRepository("mock", "http://other-mock");
+ ConnectorMigrator migrator = spy(
+ createMigrator(true, true, kinds, ImmutableSet.of(repository, otherRepository), false));
+ RepositoryQuery q1 = createQuery("q1", repository, migrator, true);
+ RepositoryQuery q2 = createQuery("q2", repository, migrator, true);
+ RepositoryQuery q3 = createQuery("q3", otherRepository, migrator, false);
+ RepositoryQuery q4 = createQuery("q4", otherRepository, migrator, false);
+
+ migrator.migrateQueries(repository, migratedRepository, new NullProgressMonitor());
+ migrator.migrateQueries(otherRepository, migratedRepository, new NullProgressMonitor());
+ assertTrue(migrator.anyQueriesMigrated());
+ assertFalse(migrator.allQueriesMigrated());
+ }
+
+ @Test
+ public void migrateAllQueriesMultipleRepositories() {
+ TaskRepository otherRepository = new TaskRepository("mock", "http://other-mock");
+ ConnectorMigrator migrator = spy(createMigrator(true, true, kinds, ImmutableSet.of(repository), false));
+ RepositoryQuery q1 = createQuery("q1", repository, migrator, true);
+ RepositoryQuery q2 = createQuery("q2", repository, migrator, true);
+ RepositoryQuery q3 = createQuery("q3", otherRepository, migrator, true);
+ RepositoryQuery q4 = createQuery("q4", otherRepository, migrator, true);
+
+ migrator.migrateQueries(repository, migratedRepository, new NullProgressMonitor());
+ migrator.migrateQueries(otherRepository, migratedRepository, new NullProgressMonitor());
+ assertTrue(migrator.anyQueriesMigrated());
+ assertTrue(migrator.allQueriesMigrated());
+ }
+
+ private RepositoryQuery createQuery(String handle, TaskRepository repository, ConnectorMigrator migrator,
+ boolean shouldMigrate) {
+ RepositoryQuery query = new RepositoryQuery(repository.getConnectorKind(), handle);
+ query.setRepositoryUrl(repository.getRepositoryUrl());
+ tasksState.getTaskList().addQuery(query);
+ if (shouldMigrate) {
+ RepositoryQuery migratedQuery = new RepositoryQuery(repository.getConnectorKind(), handle + ".migrated");
+ migratedQuery.setRepositoryUrl(repository.getRepositoryUrl() + "/migrated");
+ when(migrator.migrateQuery(eq(query), any(TaskRepository.class), any(TaskRepository.class),
+ any(IProgressMonitor.class))).thenReturn(migratedQuery);
+ }
+ return query;
+ }
+
private AbstractTaskCategory getCategory(AbstractTask newTask) {
for (AbstractTaskCategory category : tasksState.getTaskList().getCategories()) {
Optional<ITask> task = Iterables.tryFind(category.getChildren(), Predicates.<ITask> equalTo(newTask));
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/CompleteConnectorMigrationWizard.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/CompleteConnectorMigrationWizard.java
index a7ef2cd7b..8b6601ac5 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/CompleteConnectorMigrationWizard.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/CompleteConnectorMigrationWizard.java
@@ -36,6 +36,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
@@ -46,6 +47,7 @@ import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.TaskElementLabelProvider;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
@@ -110,26 +112,33 @@ public class CompleteConnectorMigrationWizard extends Wizard {
@Override
public void addPages() {
setWindowTitle(Messages.CompleteConnectorMigrationWizard_Complete_Connector_Migration);
- addPage(new WizardPage(Messages.CompleteConnectorMigrationWizard_Migrate_Queries) {
+ if (!migrator.allQueriesMigrated()) {
+ addPage(new WizardPage(Messages.CompleteConnectorMigrationWizard_Migrate_Queries) {
- @Override
- public void createControl(Composite parent) {
- setTitle(Messages.CompleteConnectorMigrationWizard_Have_You_Recreated_Your_Queries);
- setMessage(Messages.CompleteConnectorMigrationWizard_first_page_message, IMessageProvider.INFORMATION);
- Composite c = new Composite(parent, SWT.NONE);
- GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(true).applyTo(c);
- Label oldQueriesLabel = new Label(c, SWT.NONE);
- oldQueriesLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
- oldQueriesLabel.setText(Messages.CompleteConnectorMigrationWizard_Queries_Using_Old_Connectors);
- Label newQueriesLabel = new Label(c, SWT.NONE);
- newQueriesLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
- newQueriesLabel.setText(Messages.CompleteConnectorMigrationWizard_Queries_Using_New_Connectors);
- createQueryTree(c, createRepositoryQueryMap(migrator.getSelectedConnectors().keySet()));
- createQueryTree(c, createRepositoryQueryMap(migrator.getSelectedConnectors().values()));
- setControl(c);
- }
+ @Override
+ public void createControl(Composite parent) {
+ setTitle(Messages.CompleteConnectorMigrationWizard_Have_You_Recreated_Your_Queries);
+ String message = Messages.CompleteConnectorMigrationWizard_ensure_created_queries;
+ if (migrator.anyQueriesMigrated()) {
+ message = Messages.CompleteConnectorMigrationWizard_Queries_not_migrated;
+ }
+ setMessage(NLS.bind(Messages.CompleteConnectorMigrationWizard_first_page_message, message),
+ IMessageProvider.INFORMATION);
+ Composite c = new Composite(parent, SWT.NONE);
+ GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(true).applyTo(c);
+ Label oldQueriesLabel = new Label(c, SWT.NONE);
+ oldQueriesLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
+ oldQueriesLabel.setText(Messages.CompleteConnectorMigrationWizard_Queries_Using_Old_Connectors);
+ Label newQueriesLabel = new Label(c, SWT.NONE);
+ newQueriesLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
+ newQueriesLabel.setText(Messages.CompleteConnectorMigrationWizard_Queries_Using_New_Connectors);
+ createQueryTree(c, createRepositoryQueryMap(migrator.getSelectedConnectors().keySet()));
+ createQueryTree(c, createRepositoryQueryMap(migrator.getSelectedConnectors().values()));
+ setControl(c);
+ }
- });
+ });
+ }
addPage(new WizardPage(Messages.CompleteConnectorMigrationWizard_Complete_Migration) {
@Override
@@ -161,6 +170,7 @@ public class CompleteConnectorMigrationWizard extends Wizard {
GridDataFactory.fillDefaults().grab(false, true).hint(500, SWT.DEFAULT).applyTo(viewer.getControl());
viewer.setContentProvider(new MapContentProvider(queries));
viewer.setInput(queries);
+ viewer.setSorter(new ViewerSorter());
viewer.setLabelProvider(new TaskElementLabelProvider() {
private final TaskRepositoryLabelProvider repositoryLabelProvider = new TaskRepositoryLabelProvider();
@@ -206,11 +216,12 @@ public class CompleteConnectorMigrationWizard extends Wizard {
@Override
public boolean performFinish() {
- Job job = new Job("Migrating Tasks and Private Data") {
+ Job job = new Job(Messages.CompleteConnectorMigrationWizard_Migrating_Tasks_and_Private_Data) {
@Override
protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("Completing connector migration", IProgressMonitor.UNKNOWN);
+ monitor.beginTask(Messages.CompleteConnectorMigrationWizard_Completing_connector_migration,
+ IProgressMonitor.UNKNOWN);
Collection<String> newConnectors = migrator.getSelectedConnectors().values();
waitForQueriesToSynchronize(newConnectors, monitor);
migrator.migrateTasks(monitor);
@@ -225,7 +236,7 @@ public class CompleteConnectorMigrationWizard extends Wizard {
}
protected void waitForQueriesToSynchronize(Collection<String> newConnectors, IProgressMonitor monitor) {
- monitor.subTask("Waiting for queries to complete synchronization");
+ monitor.subTask(Messages.CompleteConnectorMigrationWizard_Waiting_for_queries_to_synchronize);
Iterable<RepositoryQuery> queries = Iterables.concat(createRepositoryQueryMap(newConnectors).values());
long start = System.currentTimeMillis();
while (any(queries, isSynchronizing())
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/ConnectorMigrator.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/ConnectorMigrator.java
index a1d8b47a1..9aad78486 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/ConnectorMigrator.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/ConnectorMigrator.java
@@ -36,6 +36,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
@@ -129,6 +130,10 @@ public class ConnectorMigrator {
}
});
+ private boolean anyQueriesMigrated;
+
+ private boolean allQueriesMigrated = true;
+
public ConnectorMigrator(Map<String, String> connectorKinds, String explanatoryText, TasksState tasksState,
ConnectorMigrationUi migrationUi) {
checkArgument(!connectorKinds.isEmpty());
@@ -185,6 +190,7 @@ public class ConnectorMigrator {
for (ITask task : tasksToMigrate) {
oldTasksStates.put(newRepository, task.getTaskKey(), new OldTaskState(task));
}
+ migrateQueries(repository, newRepository, monitor);
disconnect(repository);
monitor.worked(1);
}
@@ -213,6 +219,46 @@ public class ConnectorMigrator {
}
}
+ protected void migrateQueries(TaskRepository repository, TaskRepository newRepository, IProgressMonitor monitor) {
+ Set<RepositoryQuery> queriesForUrl = getTaskList().getRepositoryQueries(repository.getRepositoryUrl());
+ Set<RepositoryQuery> queries = Sets.filter(queriesForUrl, isQueryForConnector(repository.getConnectorKind()));
+ SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.ConnectorMigrator_Migrating_Queries,
+ queries.size());
+ for (RepositoryQuery query : queries) {
+ RepositoryQuery migratedQuery = migrateQuery(query, repository, newRepository, subMonitor);
+ if (migratedQuery != null) {
+ getTaskList().addQuery(migratedQuery);
+ anyQueriesMigrated = true;
+ } else {
+ allQueriesMigrated = false;
+ }
+ subMonitor.worked(1);
+ }
+ }
+
+ /**
+ * Connectors can override to attempt to automatically migrate queries if possible.
+ */
+ protected RepositoryQuery migrateQuery(RepositoryQuery query, TaskRepository repository,
+ TaskRepository newRepository, IProgressMonitor monitor) {
+ return null;
+ }
+
+ /**
+ * @return whether any queries have been migrated for any repository
+ */
+ protected boolean anyQueriesMigrated() {
+ return anyQueriesMigrated;
+ }
+
+ /**
+ * @return whether all queries have been migrated for all migrated repositories; returns <code>true</code> if no
+ * repositories have yet been migrated
+ */
+ protected boolean allQueriesMigrated() {
+ return allQueriesMigrated;
+ }
+
protected void disconnect(TaskRepository repository) {
repository.setOffline(true);
// we need to change the label so that the new repo doesn't have the same label, so that it can be edited
@@ -382,10 +428,18 @@ public class ConnectorMigrator {
}
/**
- * Connectors may override this method to support migrating tasks that are not contained in any migrated query.
+ * This method is used to support migrating tasks that are not contained in any migrated query.
*/
protected TaskData getTaskData(String taskKey, AbstractRepositoryConnector newConnector,
TaskRepository newRepository, IProgressMonitor monitor) {
+ try {
+ if (newConnector.supportsSearchByTaskKey(newRepository)) {
+ return newConnector.searchByTaskKey(newRepository, taskKey, monitor);
+ }
+ } catch (CoreException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Failed to migrate task " //$NON-NLS-1$
+ + taskKey + " for repository " + newRepository.getRepositoryLabel(), e)); //$NON-NLS-1$
+ }
return null;
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/Messages.java
index 80a779d87..e366003d7 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/Messages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/Messages.java
@@ -20,12 +20,20 @@ public class Messages extends NLS {
public static String CompleteConnectorMigrationWizard_Complete_Migration;
+ public static String CompleteConnectorMigrationWizard_Completing_connector_migration;
+
+ public static String CompleteConnectorMigrationWizard_ensure_created_queries;
+
public static String CompleteConnectorMigrationWizard_first_page_message;
public static String CompleteConnectorMigrationWizard_Have_You_Recreated_Your_Queries;
public static String CompleteConnectorMigrationWizard_Migrate_Queries;
+ public static String CompleteConnectorMigrationWizard_Migrating_Tasks_and_Private_Data;
+
+ public static String CompleteConnectorMigrationWizard_Queries_not_migrated;
+
public static String CompleteConnectorMigrationWizard_Queries_Using_New_Connectors;
public static String CompleteConnectorMigrationWizard_Queries_Using_Old_Connectors;
@@ -34,6 +42,8 @@ public class Messages extends NLS {
public static String CompleteConnectorMigrationWizard_second_page_text;
+ public static String CompleteConnectorMigrationWizard_Waiting_for_queries_to_synchronize;
+
public static String ConnectorMigrationWizard_Connector_Migration;
public static String ConnectorMigrationWizard_End_of_Connector_Support;
@@ -51,6 +61,8 @@ public class Messages extends NLS {
public static String ConnectorMigrator_complete_migration_prompt_message;
public static String ConnectorMigrator_complete_migration_prompt_title;
+
+ public static String ConnectorMigrator_Migrating_Queries;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/messages.properties
index 543f4ad56..84d6413ec 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/messages.properties
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/migrator/messages.properties
@@ -1,15 +1,18 @@
CompleteConnectorMigrationWizard_Complete_Connector_Migration=Complete Connector Migration
CompleteConnectorMigrationWizard_Complete_Migration=Complete Migration
-CompleteConnectorMigrationWizard_first_page_message=Migration will remove your old queries. Please ensure you have created the new \
-queries you want. Your old and new queries are shown below and you can edit them by double-clicking.
+CompleteConnectorMigrationWizard_Completing_connector_migration=Completing connector migration
+CompleteConnectorMigrationWizard_ensure_created_queries=Please ensure you have created the new queries you want.
+CompleteConnectorMigrationWizard_first_page_message= Migration will remove your old queries. {0} Your old and new queries are shown below and you can edit them by double-clicking.
CompleteConnectorMigrationWizard_Have_You_Recreated_Your_Queries=Have You Recreated Your Queries?
CompleteConnectorMigrationWizard_Migrate_Queries=Migrate Queries
+CompleteConnectorMigrationWizard_Migrating_Tasks_and_Private_Data=Migrating Tasks and Private Data
+CompleteConnectorMigrationWizard_Queries_not_migrated=Some queries could not be automatically migrated. Please review your old and new queries and edit or create new ones as needed.
CompleteConnectorMigrationWizard_Queries_Using_New_Connectors=Queries Using New Connectors
CompleteConnectorMigrationWizard_Queries_Using_Old_Connectors=Queries Using Old Connectors
CompleteConnectorMigrationWizard_second_page_message=Clicking finish will migrate your tasks and private data. This may take a while.
CompleteConnectorMigrationWizard_second_page_text=When you click finish, your context, scheduled dates, private notes and other data \
will be migrated to the new connectors. Any tasks \
-in your task list that are not included in the new queries you created will be downloaded using the new connectors. The old tasks, \
+in your task list that are not included in the new queries will be downloaded using the new connectors. The old tasks, \
queries, and repositories will be deleted.\n\
\n\
This may take a while. You should not use the task list or task editor while this is happening. You will be prompted when migration \
@@ -18,6 +21,7 @@ is complete.\n\
You will be able to undo the migration by selecting "Restore Tasks from History" in the Task List view menu and choosing the \
connector-migration-*.zip file stored in <workspace>/.metadata/.mylyn/backup. This will restore your task list and repositories to \
the state they were in before the migration, but any data stored by 3rd party plugins for Mylyn may be lost.
+CompleteConnectorMigrationWizard_Waiting_for_queries_to_synchronize=Waiting for queries to complete synchronization
ConnectorMigrationWizard_Connector_Migration=Connector Migration
ConnectorMigrationWizard_End_of_Connector_Support=End of Connector Support
ConnectorMigrationWizard_Message=Support is ending for some connectors, but replacement connectors are installed. This wizard \
@@ -28,8 +32,10 @@ Your tasks, contexts, private notes, categories, scheduled dates, and private du
will be automatically migrated for all tasks. Incoming state will be migrated but all unsubmitted outgoing changes will be lost. \
You may want to cancel this wizard and submit your outgoing changes before continuing with migration.\n\
\n\
-This wizard will migrate your task repositories but you will need to manually migrate your queries before your tasks and private data \
-will be migrated. After finishing this wizard, please recreate your queries using the new connectors and then click the link in the \
+This wizard will migrate your queries if possible but in many cases you will need to manually migrate your queries \
+before your tasks and private data \
+will be migrated. After finishing this wizard, please use the new connectors to recreate any queries that were not \
+migrated and then click the link in the \
task list to complete the migration. The new connectors may not support the same queries as the old ones, \
for example, you might need to create queries that use server-side searches or favorite filters that you create in the repository's \
web UI.
@@ -42,5 +48,6 @@ ConnectorMigrationWizard_validation_failed=Could not validate the connection to
be required. Please edit the repository settings via the Task Repositories view.\n\n{0}
ConnectorMigrator_complete_migration_prompt_message=Support is ending for some of your connectors, but replacement connectors are \
installed. <a href="{0}">Click here</a> for more information or to migrate to the new connectors.
-ConnectorMigrator_complete_migration_prompt_title=Connector migration is not finished. Manually recreate your queries using the new \
-connectors and then click <a href="{0}">complete migration</a> to migrate your contexts, scheduled dates, private notes and other data.
+ConnectorMigrator_complete_migration_prompt_title=Connector migration is not finished. Use the new connectors to recreate any queries \
+that have not automatically migrated and then click <a href="{0}">complete migration</a> to migrate your contexts, scheduled dates, private notes and other data.
+ConnectorMigrator_Migrating_Queries=Migrating Queries

Back to the top