Subversion Repositories XServices

Rev

Rev 31 | Go to most recent revision | Details | 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
 
22
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldTypes;
23
import net.brutex.mylyn.sbmconnector.core.model.SBMStaticFields;
24
 
25
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
26
 
27
 
28
/**
29
 * Map the Mylyn TaskAttributes to SBMTicket Attributes and vice versa.
30
 * @author Brian Rosenberger
31
 *
32
 */
33
public enum SBMTicketAttribute {
34
	DESCRIPTION(
35
			"DESCRIPTION",
36
			"label_description",
37
			SBMFieldTypes.TEXT,
38
			TaskAttribute.DESCRIPTION,
39
			TaskAttribute.TYPE_LONG_RICH_TEXT,
40
			SBMTicketAttribute.HIDDEN),	//hidden because has extra part
41
	ID(
42
			SBMStaticFields.ID.getValue(),
43
			"ts_id",
44
			SBMFieldTypes.SYSTEM,
45
			TaskAttribute.TASK_KEY,
46
			TaskAttribute.TYPE_SHORT_TEXT,
47
			SBMTicketAttribute.HIDDEN),
48
	UUID(
49
			SBMStaticFields.UUID.getValue(),
50
			"ts_uuid",
51
			SBMFieldTypes.SYSTEM,
52
			TaskAttribute.KIND_DEFAULT,
53
			TaskAttribute.TYPE_SHORT_TEXT,
54
			SBMTicketAttribute.HIDDEN),
55
	PROJECT(
56
			SBMStaticFields.PROJECTID.getValue(),
57
			"label_project",
58
			SBMFieldTypes.SYSTEM,
59
			TaskAttribute.PRODUCT,
60
			TaskAttribute.TYPE_SHORT_TEXT),
61
	STATE(
62
			SBMStaticFields.STATE.getValue(),
63
			"label_state",
64
			SBMFieldTypes.SYSTEM,
65
			TaskAttribute.STATUS,
66
			TaskAttribute.TYPE_SHORT_TEXT,
67
			SBMTicketAttribute.HIDDEN),	//hidden because has extra part
68
	SUBMITTER(
69
			SBMStaticFields.SUBMITTER.getValue(),
70
			"label_submitter",
71
			SBMFieldTypes.USER,
72
			TaskAttribute.USER_REPORTER,
73
			TaskAttribute.TYPE_PERSON),
74
	SUBMITDATE(
75
			SBMStaticFields.SUBMITDATE.getValue(),
76
			"label_submitdate",
77
			SBMFieldTypes.DATETIME,
78
			TaskAttribute.DATE_CREATION,
79
			TaskAttribute.TYPE_DATETIME),
80
	LASTMODIFIER(
81
			SBMStaticFields.LASTMODIFIER.getValue(),
82
			"label_last modifier",
83
			SBMFieldTypes.USER,
84
			TaskAttribute.PERSON_NAME,
85
			TaskAttribute.TYPE_PERSON),
86
	LASTMODIFIEDDATE(
87
			SBMStaticFields.LASTMODIFIEDDATE.getValue(),
88
			"label_modifieddate",
89
			SBMFieldTypes.DATETIME,
90
			TaskAttribute.DATE_MODIFICATION,
91
			TaskAttribute.TYPE_DATETIME),
92
	ITEMURL(
93
			SBMStaticFields.ITEMURL.getValue(),
94
			"Item Link:",
95
			SBMFieldTypes.SYSTEM,
96
			TaskAttribute.TASK_URL,
97
			TaskAttribute.TYPE_URL,
98
			SBMTicketAttribute.HIDDEN),
99
	TITLE(
100
			"TITLE",
101
			"label_title",
102
			SBMFieldTypes.TEXT,
103
			TaskAttribute.SUMMARY,
104
			TaskAttribute.TYPE_SHORT_TEXT,
105
			SBMTicketAttribute.HIDDEN),	//hidden because has extra part
106
	ACTIVEINACTIVE(
107
			SBMStaticFields.ACTIVEINACTIVE.getValue(),
108
			"label_activeinactive",
109
			SBMFieldTypes.BINARY,
110
			null,
111
			TaskAttribute.TYPE_BOOLEAN),
112
	ISSUETYPE(
113
			"ISSUETYPE",
114
			"label_itemtype",
115
			SBMFieldTypes.SELECTION,
116
			TaskAttribute.TASK_KIND,
117
			TaskAttribute.TYPE_SHORT_TEXT);
118
 
119
	private String sbm_name;
120
	private String task_name;
121
	private String sbm_type;
122
	private String sbm_label;
123
	private String task_type;
124
	private boolean visible;
125
 
126
	public static final boolean VISIBLE = true;
127
	public static final boolean HIDDEN = false;
128
 
129
	private SBMTicketAttribute(String sbm_name, String sbm_label, SBMFieldTypes sbm_type, String task_name, String task_type) {
130
		this(sbm_name,sbm_label,sbm_type,task_name,task_type, SBMTicketAttribute.VISIBLE);
131
	}
132
 
133
	private SBMTicketAttribute(String sbm_name, String sbm_label, SBMFieldTypes sbm_type,
134
			String task_name, String task_type, boolean visible) {
135
		this.sbm_name = sbm_name;
136
		this.sbm_label = sbm_label;
137
		this.sbm_type = sbm_type.getValue();
138
		this.task_name = task_name;
139
		this.task_type = task_type;
140
		this.visible = visible;
141
	}
142
 
143
	public String getSBMName() {
144
		return this.sbm_name;
145
	}
146
	public String getSBMLabel() {
147
		return this.sbm_label;
148
	}
149
	public String getTaskName() {
150
		return this.task_name;
151
	}
152
	public String getTaskType() {
153
		return this.task_type;
154
	}
155
	public String getSBMType() {
156
		return this.sbm_type;
157
	}
158
 
159
	public boolean isVisible() {
160
		return this.visible;
161
	}
162
 
163
	public static SBMTicketAttribute getSBMAttributeByName(String sbm_fieldname) {
164
		for (SBMTicketAttribute attribute : values()) {
165
			if (sbm_fieldname.equals(attribute.getSBMName())) {
166
				return attribute;
167
			}
168
		}
169
		return null;
170
	}
171
 
172
	public static SBMTicketAttribute getSBMAttributeByTaskName(String task_fieldname) {
173
		for (SBMTicketAttribute attribute : values()) {
174
			if (task_fieldname.equals(attribute.getTaskName())) {
175
				return attribute;
176
			}
177
		}
178
		return null;
179
	}
180
}