Subversion Repositories XServices

Rev

Rev 42 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 42 Rev 52
1
/*
1
/*
2
 *   Mylyn Connector for Serena Business Mashups
2
 *   Mylyn Connector for Serena Business Mashups
3
 * 	 Copyright 2010 Brian Rosenberger (Brutex Network)
3
 * 	 Copyright 2010 Brian Rosenberger (Brutex Network)
4
 *
4
 *
5
 *   Licensed under the Apache License, Version 2.0 (the "License");
5
 *   Licensed under the Apache License, Version 2.0 (the "License");
6
 *   you may not use this file except in compliance with the License.
6
 *   you may not use this file except in compliance with the License.
7
 *   You may obtain a copy of the License at
7
 *   You may obtain a copy of the License at
8
 *
8
 *
9
 *       http://www.apache.org/licenses/LICENSE-2.0
9
 *       http://www.apache.org/licenses/LICENSE-2.0
10
 *
10
 *
11
 *   Unless required by applicable law or agreed to in writing, software
11
 *   Unless required by applicable law or agreed to in writing, software
12
 *   distributed under the License is distributed on an "AS IS" BASIS,
12
 *   distributed under the License is distributed on an "AS IS" BASIS,
13
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 *   See the License for the specific language governing permissions and
14
 *   See the License for the specific language governing permissions and
15
 *   limitations under the License.
15
 *   limitations under the License.
16
 * 
16
 * 
17
 *   Serena, TeamTrack and Serena Business Mashup are 
17
 *   Serena, TeamTrack and Serena Business Mashup are 
18
 * 	 registered trademarks of SERENA Software Inc.
18
 * 	 registered trademarks of SERENA Software Inc.
19
 */
19
 */
20
package net.brutex.mylyn.sbmconnector.core;
20
package net.brutex.mylyn.sbmconnector.core;
21
 
21
 
22
import java.util.Date;
22
import java.util.Date;
23
import java.util.GregorianCalendar;
23
import java.util.GregorianCalendar;
24
import java.util.List;
24
import java.util.List;
25
import java.util.Set;
25
import java.util.Set;
26
 
26
 
27
import javax.xml.datatype.DatatypeConfigurationException;
27
import javax.xml.datatype.DatatypeConfigurationException;
28
import javax.xml.datatype.DatatypeFactory;
28
import javax.xml.datatype.DatatypeFactory;
29
import javax.xml.datatype.XMLGregorianCalendar;
29
import javax.xml.datatype.XMLGregorianCalendar;
30
 
30
 
31
import net.brutex.mylyn.sbmconnector.SBMConnectorPlugin;
31
import net.brutex.mylyn.sbmconnector.SBMConnectorPlugin;
32
import net.brutex.mylyn.sbmconnector.core.model.SBMField;
32
import net.brutex.mylyn.sbmconnector.core.model.SBMField;
33
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldAttributes;
33
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldAttributes;
34
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldTypes;
34
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldTypes;
35
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldValue;
35
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldValue;
36
import net.brutex.mylyn.sbmconnector.core.model.SBMNote;
36
import net.brutex.mylyn.sbmconnector.core.model.SBMNote;
37
import net.brutex.mylyn.sbmconnector.core.model.SBMStaticFields;
37
import net.brutex.mylyn.sbmconnector.core.model.SBMStaticFields;
38
import net.brutex.mylyn.sbmconnector.core.model.SBMSystemFields;
38
import net.brutex.mylyn.sbmconnector.core.model.SBMSystemFields;
39
import net.brutex.mylyn.sbmconnector.ui.SBMRepositorySettingsPage;
39
import net.brutex.mylyn.sbmconnector.ui.SBMRepositorySettingsPage;
40
import net.brutex.sbm.wsclient.TTItem;
40
import net.brutex.sbm.wsclient.TTItem;
41
 
41
 
42
import org.eclipse.core.runtime.CoreException;
42
import org.eclipse.core.runtime.CoreException;
43
import org.eclipse.core.runtime.IProgressMonitor;
43
import org.eclipse.core.runtime.IProgressMonitor;
44
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
44
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
45
import org.eclipse.mylyn.tasks.core.ITaskMapping;
45
import org.eclipse.mylyn.tasks.core.ITaskMapping;
46
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
46
import org.eclipse.mylyn.tasks.core.RepositoryResponse;
47
import org.eclipse.mylyn.tasks.core.TaskRepository;
47
import org.eclipse.mylyn.tasks.core.TaskRepository;
48
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
48
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler;
49
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
49
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
50
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
50
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
51
import org.eclipse.mylyn.tasks.core.data.TaskCommentMapper;
51
import org.eclipse.mylyn.tasks.core.data.TaskCommentMapper;
52
import org.eclipse.mylyn.tasks.core.data.TaskData;
52
import org.eclipse.mylyn.tasks.core.data.TaskData;
53
 
53
 
54
/**
54
/**
55
 * The Class SBMTicketDataHandler.
55
 * The Class SBMTicketDataHandler.
56
 */
56
 */
57
public class SBMTicketDataHandler extends AbstractTaskDataHandler {
57
public class SBMTicketDataHandler extends AbstractTaskDataHandler {
58
 
58
 
59
	/** The connector. */
59
	/** The connector. */
60
	private final SBMRepositoryConnector connector;
60
	private final SBMRepositoryConnector connector;
61
 
61
 
62
	/**
62
	/**
63
	 * Instantiates a new SBM ticket data handler.
63
	 * Instantiates a new SBM ticket data handler.
64
	 * 
64
	 * 
65
	 * @param connector
65
	 * @param connector
66
	 *            the connector
66
	 *            the connector
67
	 */
67
	 */
68
	public SBMTicketDataHandler(SBMRepositoryConnector connector) {
68
	public SBMTicketDataHandler(SBMRepositoryConnector connector) {
69
		this.connector = connector;
69
		this.connector = connector;
70
	}
70
	}
71
 
71
 
72
	/*
72
	/*
73
	 * (non-Javadoc)
73
	 * (non-Javadoc)
74
	 * 
74
	 * 
75
	 * @see
75
	 * @see
76
	 * org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler#getAttributeMapper
76
	 * org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler#getAttributeMapper
77
	 * (org.eclipse.mylyn.tasks.core.TaskRepository)
77
	 * (org.eclipse.mylyn.tasks.core.TaskRepository)
78
	 */
78
	 */
79
	@Override
79
	@Override
80
	public TaskAttributeMapper getAttributeMapper(TaskRepository taskRepository) {
80
	public TaskAttributeMapper getAttributeMapper(TaskRepository taskRepository) {
81
		return new SBMTicketAttributeMapper(taskRepository);
81
		return new SBMTicketAttributeMapper(taskRepository);
82
	}
82
	}
83
 
83
 
84
	/*
84
	/*
85
	 * (non-Javadoc)
85
	 * (non-Javadoc)
86
	 * 
86
	 * 
87
	 * @see
87
	 * @see
88
	 * org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler#initializeTaskData
88
	 * org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler#initializeTaskData
89
	 * (org.eclipse.mylyn.tasks.core.TaskRepository,
89
	 * (org.eclipse.mylyn.tasks.core.TaskRepository,
90
	 * org.eclipse.mylyn.tasks.core.data.TaskData,
90
	 * org.eclipse.mylyn.tasks.core.data.TaskData,
91
	 * org.eclipse.mylyn.tasks.core.ITaskMapping,
91
	 * org.eclipse.mylyn.tasks.core.ITaskMapping,
92
	 * org.eclipse.core.runtime.IProgressMonitor)
92
	 * org.eclipse.core.runtime.IProgressMonitor)
93
	 */
93
	 */
94
	@Override
94
	@Override
95
	public boolean initializeTaskData(TaskRepository repository,
95
	public boolean initializeTaskData(TaskRepository repository,
96
			TaskData taskData, ITaskMapping initializationData,
96
			TaskData taskData, ITaskMapping initializationData,
97
			IProgressMonitor monitor) throws CoreException {
97
			IProgressMonitor monitor) throws CoreException {
98
		monitor.subTask("Initialising task ...");
98
		monitor.subTask("Initialising task ...");
99
		taskData.setPartial(true);
99
		taskData.setPartial(true);
100
		return true;
100
		return true;
101
	}
101
	}
102
 
102
 
103
	/*
103
	/*
104
	 * (non-Javadoc)
104
	 * (non-Javadoc)
105
	 * 
105
	 * 
106
	 * @see
106
	 * @see
107
	 * org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler#postTaskData
107
	 * org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler#postTaskData
108
	 * (org.eclipse.mylyn.tasks.core.TaskRepository,
108
	 * (org.eclipse.mylyn.tasks.core.TaskRepository,
109
	 * org.eclipse.mylyn.tasks.core.data.TaskData, java.util.Set,
109
	 * org.eclipse.mylyn.tasks.core.data.TaskData, java.util.Set,
110
	 * org.eclipse.core.runtime.IProgressMonitor)
110
	 * org.eclipse.core.runtime.IProgressMonitor)
111
	 */
111
	 */
112
	@Override
112
	@Override
113
	public RepositoryResponse postTaskData(TaskRepository repository,
113
	public RepositoryResponse postTaskData(TaskRepository repository,
114
			TaskData taskData, Set<TaskAttribute> oldAttributes,
114
			TaskData taskData, Set<TaskAttribute> oldAttributes,
115
			IProgressMonitor monitor) throws CoreException {
115
			IProgressMonitor monitor) throws CoreException {
116
		// TODO Auto-generated method stub
116
		// TODO Auto-generated method stub
117
		return null;
117
		return null;
118
	}
118
	}
119
 
119
 
120
	/**
120
	/**
121
	 * Convert.
121
	 * Convert.
122
	 * 
122
	 * 
123
	 * @param repository
123
	 * @param repository	the repository
124
	 *            the repository
-
 
125
	 * @param ttitem
124
	 * @param ttitem
126
	 *            the ttitem
125
	 *            the ttitem
127
	 * @param monitor
126
	 * @param monitor
128
	 *            the monitor
127
	 *            the monitor
129
	 * @return the task data
128
	 * @return the task data
130
	 * @throws CoreException
129
	 * @throws CoreException
131
	 *             the core exception
130
	 *             the core exception
132
	 */
131
	 */
133
	public TaskData convert(TaskRepository repository, TTItem ttitem,
132
	public TaskData convert(TaskRepository repository, TTItem ttitem,
134
			IProgressMonitor monitor, IRepositoryQuery query)
133
			IProgressMonitor monitor, IRepositoryQuery query)
135
			throws CoreException {
134
			throws CoreException {
136
		SBMClient client = SBMRepositoryConnector.getClient(repository);
135
		SBMClient client = SBMRepositoryConnector.getClient(repository);
137
		TaskData data = new TaskData(new SBMTicketAttributeMapper(repository),
136
		TaskData data = new TaskData(new SBMTicketAttributeMapper(repository),
138
				SBMConnectorPlugin.CONNECTOR_KIND, repository
137
				SBMConnectorPlugin.CONNECTOR_KIND, repository
139
						.getRepositoryUrl(), ttitem.getGenericItem().getValue()
138
						.getRepositoryUrl(), ttitem.getGenericItem().getValue()
140
						.getItemName().getValue()
139
						.getItemName().getValue()
141
						+ " ["
140
						+ " ["
142
						+ ttitem.getGenericItem().getValue().getItemID()
141
						+ ttitem.getGenericItem().getValue().getItemID()
143
								.getValue() + "]");
142
								.getValue() + "]");
144
		initializeTaskData(repository, data, null, monitor);
143
		initializeTaskData(repository, data, null, monitor);
145
		String fieldlist = "";
144
		String fieldlist = "";
146
		if (repository
145
		if (repository
147
				.hasProperty(SBMRepositorySettingsPage.STRING_TABLEFIELDLIST)) {
146
				.hasProperty(SBMRepositorySettingsPage.STRING_TABLEFIELDLIST)) {
148
			fieldlist = repository
147
			fieldlist = repository
149
					.getProperty(SBMRepositorySettingsPage.STRING_TABLEFIELDLIST);
148
					.getProperty(SBMRepositorySettingsPage.STRING_TABLEFIELDLIST);
150
		}
149
		}
151
		// Create Fields for all the generic SBM (system) fields
150
		// Create Fields for all the generic SBM (system) fields
152
		monitor.subTask("Creating generic SBM fields...");
151
		monitor.subTask("Creating generic SBM fields...");
153
		for (SBMSystemFields sysfield : SBMSystemFields.values()) {
152
		for (SBMSystemFields sysfield : SBMSystemFields.values()) {
154
			if(!sysfield.hasTaskAttribute()) {
153
			if(!sysfield.hasTaskAttribute()) {
155
				// skip the field here, because we do not have a
154
				// skip the field here, because we do not have a
156
				// matching task attribute to map. The field
155
				// matching task attribute to map. The field
157
				// will be processed in the custom field section
156
				// will be processed in the custom field section
158
				continue;
157
				continue;
159
			}
158
			}
160
			if (!fieldlist.contains("," + sysfield.getValue() + ",")) {
159
			if (!fieldlist.contains("," + sysfield.getValue() + ",")) {
161
				// do not process custom field when it has not
160
				// do not process custom field when it has not
162
				// been selected by user in repository settings page
161
				// been selected by user in repository settings page
163
				continue;
162
				continue;
164
			}
163
			}
165
			// try to initialize the SBM attribute
164
			// try to initialize the SBM attribute
166
			SBMTicketAttribute f = null;
165
			SBMTicketAttribute f = null;
167
			TaskAttribute attr = null;
166
			TaskAttribute attr = null;
168
			try {
167
			try {
169
				f = SBMTicketAttribute.valueOf(sysfield.getValue());
168
				f = SBMTicketAttribute.valueOf(sysfield.getValue());
170
			} catch (IllegalArgumentException e) {
169
			} catch (IllegalArgumentException e) {
171
				// the field is a valid sbm system field and is set up to
170
				// the field is a valid sbm system field and is set up to
172
				// have an equivalent in the task attributes. It must have an
171
				// have an equivalent in the task attributes. It must have an
173
				// entry in the SBMTicketAttribute class !
172
				// entry in the SBMTicketAttribute class !
174
				continue; // we just skip the field 
173
				continue; // we just skip the field 
175
			}
174
			}
176
			
175
			
177
			if (f.getTaskName() != null) {
176
			if (f.getTaskName() != null) {
178
				attr = data.getRoot().createMappedAttribute(f.getTaskName());
177
				attr = data.getRoot().createMappedAttribute(f.getTaskName());
179
			} else {
178
			} else {
180
				// again the field is set up to have an task attribute
179
				// again the field is set up to have an task attribute
181
				// equivalent, but it is not set up in SBMAttributes correctly
180
				// equivalent, but it is not set up in SBMAttributes correctly
182
				continue;
181
				continue;
183
			}
182
			}
184
			
183
			
185
			attr.getMetaData().setReadOnly(true); //we do not support writing yet 
184
			attr.getMetaData().setReadOnly(true); //we do not support writing yet 
186
			attr.getMetaData().setType(f.getTaskType()); // set the mapped field type
185
			attr.getMetaData().setType(f.getTaskType()); // set the mapped field type
187
			attr.getMetaData().setLabel(client.getFieldLabel(ttitem, f.getSBMName())); // get and set the field label
186
			attr.getMetaData().setLabel(client.getFieldLabel(ttitem, f.getSBMName())); // get and set the field label
188
			if (f.isVisible()) {
187
			if (f.isVisible()) {
189
				// field is not hidden, display it by setting KIND_DEFAULT
188
				// field is not hidden, display it by setting KIND_DEFAULT
190
				attr.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
189
				attr.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
191
			} else {
190
			} else {
192
				// field is hidden
191
				// field is hidden
193
				attr.getMetaData().setKind(null);
192
				attr.getMetaData().setKind(null);
194
			}
193
			}
195
			
194
			
196
			attr.setValue(client.getStaticFieldValue(ttitem, f.getSBMName())); // get and set the field value
195
			attr.setValue(client.getStaticFieldValue(ttitem, f.getSBMName())); // get and set the field value
197
		}
196
		}
198
		monitor.worked(1);
197
		monitor.worked(1);
199
		
198
		
200
		//--------------
199
		//--------------
201
		// Custom fields
200
		// Custom fields
202
		//--------------
201
		//--------------
203
		List<SBMField> customfields = client.getFields(client
202
		List<SBMField> customfields = client.getFields(client
204
				.getTableName(ttitem));
203
				.getTableName(ttitem));
205
		for (SBMField f : customfields) {
204
		for (SBMField f : customfields) {
206
			if (!fieldlist.contains("," + f.getName() + ",")) {
205
			if (!fieldlist.contains("," + f.getName() + ",")) {
207
				// do not process custom field when it has not
206
				// do not process custom field when it has not
208
				// been selected by user in repository settings page
207
				// been selected by user in repository settings page
209
				continue;
208
				continue;
210
			}
209
			}
211
			try {
210
			try {
212
				SBMSystemFields sysfield = SBMSystemFields.valueOf(f.getName());
211
				SBMSystemFields sysfield = SBMSystemFields.valueOf(f.getName());
213
				if( sysfield.hasTaskAttribute()) {
212
				if( sysfield.hasTaskAttribute()) {
214
					// the field has an equivalent in the task attribute
213
					// the field has an equivalent in the task attribute
215
					// mappings and therefore it can be skipped in the custom
214
					// mappings and therefore it can be skipped in the custom
216
					// fields section
215
					// fields section
217
					continue;
216
					continue;
218
				}
217
				}
219
			} catch (IllegalArgumentException e) {
218
			} catch (IllegalArgumentException e) {
220
				//field is not a system field, do nothing
219
				//field is not a system field, do nothing
221
			}
220
			}
222
			monitor.subTask("Read custom field [" + f.getName() + "]");
221
			monitor.subTask("Read custom field [" + f.getName() + "]");
223
			TaskAttribute custom = data.getRoot().createAttribute(f.getName());
222
			TaskAttribute custom = data.getRoot().createAttribute(f.getName());
224
			custom.getMetaData().setType(
223
			custom.getMetaData().setType(
225
					new SBMTicketAttributeMapper(repository).mapToTaskKey(f
224
					new SBMTicketAttributeMapper(repository).mapToTaskKey(f
226
							.getType()));
225
							.getType()));
227
			custom.getMetaData().setLabel(f.getLabel());
226
			custom.getMetaData().setLabel(f.getLabel());
228
			custom.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
227
			custom.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
229
			custom.getMetaData().setReadOnly(true);
228
			custom.getMetaData().setReadOnly(true);
230
			
229
			
231
			//set value/ values depending on field type
230
			//set value/ values depending on field type
232
			// single selection
231
			// single selection
233
			if (f.getType() == SBMFieldTypes.SELECTION
232
			if (f.getType() == SBMFieldTypes.SELECTION
234
					&& client.getFieldValue(ttitem, f.getName()) != null) {
233
					&& client.getFieldValue(ttitem, f.getName()) != null) {
235
				//List<SBMFieldValue> options = client.getValidSet(client
234
				//List<SBMFieldValue> options = client.getValidSet(client
236
				//		.getTableName(ttitem), f.getName());
235
				//		.getTableName(ttitem), f.getName());
237
				//for (SBMFieldValue optionvalue : options) {
236
				//for (SBMFieldValue optionvalue : options) {
238
				//	custom.putOption(optionvalue.getInternalValue(),
237
				//	custom.putOption(optionvalue.getInternalValue(),
239
				//			optionvalue.getValue());
238
				//			optionvalue.getValue());
240
				//}
239
				//}
241
				String val = client.getFieldValue(ttitem, f.getName())
240
				String val = client.getFieldValue(ttitem, f.getName())
242
						.getValue();
241
						.getValue();
243
				custom.setValue(val);
242
				custom.setValue(val);
244
			// Multi-Type fields
243
			// Multi-Type fields
245
			} else if (f.getType() == SBMFieldTypes.MULTIPLE_SELECTION
244
			} else if (f.getType() == SBMFieldTypes.MULTIPLE_SELECTION
246
					|| f.getType() == SBMFieldTypes.MULTIPLE_RELATIONAL
245
					|| f.getType() == SBMFieldTypes.MULTIPLE_RELATIONAL
247
					|| f.getType() == SBMFieldTypes.MULTIPLE_GROUP
246
					|| f.getType() == SBMFieldTypes.MULTIPLE_GROUP
248
					|| f.getType() == SBMFieldTypes.MULTIPLE_USERGROUP) {
247
					|| f.getType() == SBMFieldTypes.MULTIPLE_USERGROUP) {
249
				List<SBMFieldValue> values = client.getFieldValues(ttitem, f
248
				List<SBMFieldValue> values = client.getFieldValues(ttitem, f
250
						.getName());
249
						.getName());
251
				for (SBMFieldValue val : values) {
250
				for (SBMFieldValue val : values) {
252
					custom.putOption(val.getInternalValue(), val.getValue());
251
					custom.putOption(val.getInternalValue(), val.getValue());
253
					custom.addValue(val.getValue());
252
					custom.addValue(val.getValue());
254
				}
253
				}
255
			//Date fields
254
			//Date fields
256
			} else if (f.getType() == SBMFieldTypes.DATETIME) {
255
			} else if (f.getType() == SBMFieldTypes.DATETIME) {
257
				String datestring = client.getFieldValue(ttitem, f.getName()).getValue();
256
				String datestring = client.getFieldValue(ttitem, f.getName()).getValue();
258
				long timestamp;
257
				long timestamp;
259
				try {
258
				try {
260
					timestamp = DatatypeFactory.newInstance().newXMLGregorianCalendar(datestring).toGregorianCalendar().getTimeInMillis();
259
					timestamp = DatatypeFactory.newInstance().newXMLGregorianCalendar(datestring).toGregorianCalendar().getTimeInMillis();
261
					custom.setValue(String.valueOf(timestamp));
260
					custom.setValue(String.valueOf(timestamp));
262
				} catch (DatatypeConfigurationException e) {
261
				} catch (DatatypeConfigurationException e) {
263
					// TODO Auto-generated catch block
262
					// TODO Auto-generated catch block
264
					e.printStackTrace();
263
					e.printStackTrace();
265
				} catch (IllegalArgumentException e) {
264
				} catch (IllegalArgumentException e) {
266
					//date field is probably empty
265
					//date field is probably empty
267
					custom.setValue("");
266
					custom.setValue("");
268
				}
267
				}
269
				
268
				
270
			// any other field type
269
			// any other field type
271
			} else if (client.getFieldValue(ttitem, f.getName()) != null) {
270
			} else if (client.getFieldValue(ttitem, f.getName()) != null) {
272
				custom.setValue(client.getFieldValue(ttitem, f.getName())
271
				custom.setValue(client.getFieldValue(ttitem, f.getName())
273
						.getValue());
272
						.getValue());
274
			}
273
			}
275
		}
274
		}
276
		monitor.worked(1);
275
		monitor.worked(1);
277
 
276
 
278
		// ----------
277
		// ----------
279
		// Notes
278
		// Notes
280
		// ----------
279
		// ----------
281
		monitor.subTask("Read notes.");
280
		monitor.subTask("Read notes.");
282
		for (SBMNote n : client.getNotes(ttitem)) {
281
		for (SBMNote n : client.getNotes(ttitem)) {
283
			TaskCommentMapper mapper = new TaskCommentMapper();
282
			TaskCommentMapper mapper = new TaskCommentMapper();
284
			mapper.setCommentId(n.getId());
283
			mapper.setCommentId(n.getId());
285
			mapper.setNumber(Integer.valueOf(n.getId()));
284
			mapper.setNumber(Integer.valueOf(n.getId()));
286
			mapper.setText(n.getText());
285
			mapper.setText(n.getText());
287
			mapper.setCreationDate(n.getCreation());
286
			mapper.setCreationDate(n.getCreation());
288
 
287
 
289
			TaskAttribute a = data.getRoot()
288
			TaskAttribute a = data.getRoot()
290
					.createAttribute("NOTE" + n.getId());
289
					.createAttribute("NOTE" + n.getId());
291
			mapper.applyTo(a);
290
			mapper.applyTo(a);
292
		}
291
		}
293
		monitor.worked(1);
292
		monitor.worked(1);
294
 
293
 
295
		data.setPartial(false);
294
		data.setPartial(false);
296
		return data;
295
		return data;
297
	}
296
	}
298
}
297
}