Subversion Repositories XServices

Rev

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

Rev 30 Rev 31
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
 
-
 
22
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldTypes;
21
 
23
 
22
import org.eclipse.mylyn.tasks.core.TaskRepository;
24
import org.eclipse.mylyn.tasks.core.TaskRepository;
23
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
25
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
24
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
26
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
25
 
27
 
26
public class SBMTicketAttributeMapper extends TaskAttributeMapper {
28
public class SBMTicketAttributeMapper extends TaskAttributeMapper {
27
 
29
 
28
	public SBMTicketAttributeMapper(TaskRepository taskRepository) {
30
	public SBMTicketAttributeMapper(TaskRepository taskRepository) {
29
		super(taskRepository);
31
		super(taskRepository);
30
	}
32
	}
31
	
33
	
32
	@Override
34
	@Override
33
	public String mapToRepositoryKey(TaskAttribute parent, String key) {
35
	public String mapToRepositoryKey(TaskAttribute parent, String key) {
34
		SBMTicketAttribute attribute = SBMTicketAttribute.getSBMAttributeByTaskName(key);
36
		SBMTicketAttribute attribute = SBMTicketAttribute.getSBMAttributeByTaskName(key);
35
		if(attribute != null) {
37
		if(attribute != null) {
36
			return attribute.getSBMName();
38
			return attribute.getSBMName();
37
		}
39
		}
38
		return super.mapToRepositoryKey(parent, key); //just returns key
40
		return super.mapToRepositoryKey(parent, key); //just returns key
39
	}
41
	}
40
	
42
	
41
	@Override
43
	@Override
42
	public TaskAttribute getAssoctiatedAttribute(TaskAttribute taskAttribute) {
44
	public TaskAttribute getAssoctiatedAttribute(TaskAttribute taskAttribute) {
43
		// TODO Auto-generated method stub
-
 
44
		return super.getAssoctiatedAttribute(taskAttribute);
45
		return super.getAssoctiatedAttribute(taskAttribute);
45
	}
46
	}
-
 
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
	}
46
}
81
}