Subversion Repositories XServices

Rev

Rev 42 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 42 Rev 52
Line 24... Line 24...
24
import java.util.List;
24
import java.util.List;
25
import java.util.Map;
25
import java.util.Map;
Line 26... Line 26...
26
 
26
 
27
import net.brutex.mylyn.sbmconnector.SBMConnectorPlugin;
27
import net.brutex.mylyn.sbmconnector.SBMConnectorPlugin;
-
 
28
import net.brutex.mylyn.sbmconnector.core.model.SBMStaticFields;
28
import net.brutex.mylyn.sbmconnector.core.model.SBMStaticFields;
29
import net.brutex.mylyn.sbmconnector.ui.SBMQueryComposite;
29
import net.brutex.mylyn.sbmconnector.ui.SBMRepositoryQueryPage;
30
import net.brutex.mylyn.sbmconnector.ui.SBMRepositoryQueryPage;
30
import net.brutex.mylyn.sbmconnector.ui.SBMRepositorySettingsPage;
31
import net.brutex.mylyn.sbmconnector.ui.SBMRepositorySettingsPage;
Line 31... Line 32...
31
import net.brutex.sbm.wsclient.TTItem;
32
import net.brutex.sbm.wsclient.TTItem;
32
 
33
 
33
import org.eclipse.core.runtime.CoreException;
34
import org.eclipse.core.runtime.CoreException;
34
import org.eclipse.core.runtime.IProgressMonitor;
35
import org.eclipse.core.runtime.IProgressMonitor;
35
import org.eclipse.core.runtime.IStatus;
-
 
36
import org.eclipse.core.runtime.Status;
36
import org.eclipse.core.runtime.IStatus;
37
import org.eclipse.core.runtime.jobs.Job;
37
import org.eclipse.core.runtime.Status;
38
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
38
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
39
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
39
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
40
import org.eclipse.mylyn.tasks.core.ITask;
40
import org.eclipse.mylyn.tasks.core.ITask;
41
import org.eclipse.mylyn.tasks.core.TaskRepository;
41
import org.eclipse.mylyn.tasks.core.TaskRepository;
42
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
42
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
43
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
43
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
44
import org.eclipse.mylyn.tasks.core.data.TaskData;
44
import org.eclipse.mylyn.tasks.core.data.TaskData;
45
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
45
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
46
import org.eclipse.mylyn.tasks.core.data.TaskMapper;
-
 
Line 47... Line 46...
47
import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession;
46
import org.eclipse.mylyn.tasks.core.data.TaskMapper;
Line 48... Line 47...
48
import org.eclipse.ui.statushandlers.StatusManager;
47
import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession;
49
 
48
 
Line 119... Line 118...
119
	}
118
	}
Line 120... Line 119...
120
 
119
 
121
	@Override
120
	@Override
122
	public String getTaskUrl(String repositoryUrl, String taskId) {
121
	public String getTaskUrl(String repositoryUrl, String taskId) {
123
		// TODO Auto-generated method stub
122
		// TODO Auto-generated method stub
124
		return null;
123
		return "http://something/I/havent/implemented/yet?"+taskId;
Line 125... Line 124...
125
	}
124
	}
126
 
125
 
127
	@Override
126
	@Override
Line 144... Line 143...
144
 
143
 
145
	@Override
144
	@Override
146
	public IStatus performQuery(TaskRepository repository,
145
	public IStatus performQuery(TaskRepository repository,
147
			IRepositoryQuery query, TaskDataCollector collector,
146
			IRepositoryQuery query, TaskDataCollector collector,
-
 
147
			ISynchronizationSession session, IProgressMonitor monitor) {
-
 
148
 
-
 
149
		SBMClient client = new SBMClient(repository);
-
 
150
		// do we use a report or a query?
-
 
151
		if (query.getAttribute(SBMRepositoryQueryPage.SQL_QUERY_NAME).equals(
148
			ISynchronizationSession session, IProgressMonitor monitor) {
152
				query.getAttribute(SBMRepositoryQueryPage.REPORT_OR_QUERY))) {
149
			monitor.subTask("Calculating query result size ...");
153
			monitor.subTask("Calculating query result size ...");
-
 
154
			try {
150
		try {
155
 
151
			SBMClient client = new SBMClient(repository);
156
				List<String> idlist = client.getResultCount(
152
			List<String> idlist = client.getResultCount(getQueryTable(repository), 
157
						getQueryTable(repository),
153
					query.getAttribute("sql_where"));
158
						query.getAttribute("sql_where"));
154
			int countItem = idlist.size();
159
				int countItem = idlist.size();
155
			monitor.beginTask("", countItem);
160
				monitor.beginTask("", countItem);
Line 160... Line 165...
160
			//		true);
165
				// true);
161
			monitor.worked(1);
166
				monitor.worked(1);
162
			int i = 1;
167
				int i = 1;
163
			for (String id : idlist) {
168
				for (String id : idlist) {
164
				if(id!=null) {
169
					if (id != null) {
165
				monitor.subTask("Loading item "+i+"/"+countItem+" ...");
170
						monitor.subTask("Loading item " + i + "/" + countItem
-
 
171
								+ " ...");
166
				TTItem ttitem = client.getTTItem("["+id+"]");
172
						TTItem ttitem = client.getTTItem("[" + id + "]");
167
				TaskData data = datahandler.convert(repository, ttitem,
173
						TaskData data = datahandler.convert(repository, ttitem,
168
						monitor, query);
174
								monitor, query);
169
				collector.accept(data);
175
						collector.accept(data);
170
				}
176
					}
171
				monitor.worked(1);
177
					monitor.worked(1);
-
 
178
					if (monitor.isCanceled())
172
				if(monitor.isCanceled()) return Status.CANCEL_STATUS;
179
						return Status.CANCEL_STATUS;
173
				i++;
180
					i++;
174
			}
181
				}
175
		} catch (CoreException e) {
182
			} catch (CoreException e) {
176
			IStatus status =  new Status(IStatus.ERROR, SBMConnectorPlugin.PLUGIN_ID,
183
				IStatus status = new Status(IStatus.ERROR,
-
 
184
						SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e);
-
 
185
				// StatusManager.getManager().handle(status,
-
 
186
				// StatusManager.BLOCK);
-
 
187
				return status;
-
 
188
			} finally {
-
 
189
				monitor.done();
-
 
190
			}
-
 
191
		} else {
-
 
192
			// use report
-
 
193
			monitor.beginTask("Loading Report", 0);
-
 
194
			try {
-
 
195
				List<TTItem> list = client.getTTItemsByReport(query
-
 
196
						.getAttribute(SBMRepositoryQueryPage.REPORT));
-
 
197
				for(TTItem i:list) {
-
 
198
					TaskData data = datahandler.convert(repository, i,
-
 
199
							monitor, query);
177
					e.getMessage(), e);
200
					collector.accept(data);
-
 
201
				}
-
 
202
			} catch (CoreException e) {
-
 
203
				IStatus status = new Status(IStatus.ERROR,
-
 
204
						SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e);
178
			//StatusManager.getManager().handle(status, StatusManager.BLOCK);
205
				// StatusManager.getManager().handle(status,
-
 
206
				// StatusManager.BLOCK);
179
			return status;
207
				return status;
180
		} finally {
208
			} finally {
181
			monitor.done();
209
				monitor.done();
182
		}
210
			}
-
 
211
		}
-
 
212
 
183
		return Status.OK_STATUS;
213
		return Status.OK_STATUS;
184
	}
214
	}
Line 185... Line 215...
185
 
215
 
186
	@Override
216
	@Override
Line 204... Line 234...
204
	@Override
234
	@Override
205
	public AbstractTaskDataHandler getTaskDataHandler() {
235
	public AbstractTaskDataHandler getTaskDataHandler() {
206
		return datahandler;
236
		return datahandler;
207
	}
237
	}
Line 208... Line -...
208
 
-
 
209
	@Override
238
 
210
	public boolean canDeleteTask(TaskRepository repository, ITask task) {
239
	public boolean canDeleteTask(TaskRepository repository, ITask task) {
211
		return false;
240
		return false;
Line 212... Line 241...
212
	}
241
	}
Line 221... Line 250...
221
	private String getQueryTable(TaskRepository repository) {
250
	private String getQueryTable(TaskRepository repository) {
222
		return repository
251
		return repository
223
				.getProperty(SBMRepositorySettingsPage.STRING_SOLUTIONTABLE);
252
				.getProperty(SBMRepositorySettingsPage.STRING_SOLUTIONTABLE);
224
	}
253
	}
Line -... Line 254...
-
 
254
 
225
 
255