Subversion Repositories XServices

Rev

Rev 30 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
30 brianR 1
/*
2
 *   Mylyn Connector for Serena Business Mashups
3
 * 	 Copyright 2010 Brian Rosenberger (Brutex Network)
4
 *
5
 *   Licensed under the Apache License, Version 2.0 (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
8
 *
9
 *       http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 *   Unless required by applicable law or agreed to in writing, software
12
 *   distributed under the License is distributed on an "AS IS" BASIS,
13
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 *   See the License for the specific language governing permissions and
15
 *   limitations under the License.
16
 *
17
 *   Serena, TeamTrack and Serena Business Mashup are
18
 * 	 registered trademarks of SERENA Software Inc.
19
 */
20
package net.brutex.mylyn.sbmconnector.core;
21
 
31 brianR 22
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldTypes;
23
 
30 brianR 24
import org.eclipse.mylyn.tasks.core.TaskRepository;
25
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
26
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
27
 
28
public class SBMTicketAttributeMapper extends TaskAttributeMapper {
29
 
30
	public SBMTicketAttributeMapper(TaskRepository taskRepository) {
31
		super(taskRepository);
32
	}
33
 
34
	@Override
35
	public String mapToRepositoryKey(TaskAttribute parent, String key) {
36
		SBMTicketAttribute attribute = SBMTicketAttribute.getSBMAttributeByTaskName(key);
37
		if(attribute != null) {
38
			return attribute.getSBMName();
39
		}
40
		return super.mapToRepositoryKey(parent, key); //just returns key
41
	}
42
 
43
	@Override
44
	public TaskAttribute getAssoctiatedAttribute(TaskAttribute taskAttribute) {
45
		return super.getAssoctiatedAttribute(taskAttribute);
46
	}
31 brianR 47
 
48
	/**
49
	 * Map SBM field type to task field type. This mapping is a hint only because
50
	 * SBM allows fields to have a type and subtype, but the subtype is not returned
51
	 * by the SBM web service.
52
	 *
53
	 * @param sbmtype the SBM field type (unfortunately without field subtype)
54
	 * @return the mylyn task field type
55
	 */
56
	public String mapToTaskKey(SBMFieldTypes sbmtype) {
57
		String tasktype = TaskAttribute.TYPE_SHORT_TEXT;
58
		switch(sbmtype) {
59
			case NUMERIC: tasktype = TaskAttribute.TYPE_LONG; break;
60
			case TEXT: tasktype = TaskAttribute.TYPE_LONG_TEXT; break;
61
			case DATETIME: tasktype = TaskAttribute.TYPE_DATETIME; break;
62
			case SELECTION: tasktype = TaskAttribute.TYPE_SINGLE_SELECT; break;
63
			case BINARY: tasktype = TaskAttribute.TYPE_BOOLEAN; break;
64
			case STATE: tasktype = TaskAttribute.TYPE_SINGLE_SELECT; break;
65
			case USER: tasktype = TaskAttribute.TYPE_PERSON; break;
66
			case PROJECT: tasktype = TaskAttribute.TYPE_SINGLE_SELECT; break;
67
			case SUMMATION: tasktype = TaskAttribute.TYPE_INTEGER; break;
68
			case MULTIPLE_SELECTION: tasktype = TaskAttribute.TYPE_MULTI_SELECT; break;
69
			case CONTACT: tasktype = TaskAttribute.TYPE_PERSON; break;
70
			case INCIDENT: tasktype = TaskAttribute.TYPE_TASK_DEPENDENCY; break;
71
			case FOLDER: tasktype = TaskAttribute.TYPE_SINGLE_SELECT; break;
72
			case RELATIONAL: tasktype = TaskAttribute.TYPE_SINGLE_SELECT; break;
73
			case SUBRELATIONAL: tasktype = TaskAttribute.TYPE_SHORT_TEXT; break;
74
			case SYSTEM: tasktype = TaskAttribute.TYPE_SHORT_TEXT; break;
75
			case MULTIPLE_RELATIONAL: tasktype = TaskAttribute.TYPE_MULTI_SELECT; break;
76
			case MULTIPLE_GROUP: tasktype = TaskAttribute.TYPE_MULTI_SELECT; break;
77
			case MULTIPLE_USERGROUP: tasktype = TaskAttribute.TYPE_MULTI_SELECT; break;
78
		}
79
		return tasktype;
80
	}
30 brianR 81
}