Subversion Repositories XServices

Rev

Rev 52 | Go to most recent revision | 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
 
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,
52 brianR 40
			false),	//hidden because has extra part
30 brianR 41
	ID(
42
			SBMStaticFields.ID.getValue(),
43
			"ts_id",
44
			SBMFieldTypes.SYSTEM,
45
			TaskAttribute.TASK_KEY,
46
			TaskAttribute.TYPE_SHORT_TEXT,
52 brianR 47
			false),
30 brianR 48
	UUID(
49
			SBMStaticFields.UUID.getValue(),
50
			"ts_uuid",
51
			SBMFieldTypes.SYSTEM,
52
			TaskAttribute.KIND_DEFAULT,
53
			TaskAttribute.TYPE_SHORT_TEXT,
52 brianR 54
			false),
30 brianR 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,
52 brianR 67
			false),	//hidden because has extra part
30 brianR 68
	SUBMITTER(
69
			SBMStaticFields.SUBMITTER.getValue(),
70
			"label_submitter",
71
			SBMFieldTypes.USER,
72
			TaskAttribute.USER_REPORTER,
39 brianR 73
			TaskAttribute.TYPE_PERSON,
52 brianR 74
			false), //hidden because has extra part
30 brianR 75
	SUBMITDATE(
76
			SBMStaticFields.SUBMITDATE.getValue(),
77
			"label_submitdate",
78
			SBMFieldTypes.DATETIME,
79
			TaskAttribute.DATE_CREATION,
80
			TaskAttribute.TYPE_DATETIME),
81
	LASTMODIFIER(
82
			SBMStaticFields.LASTMODIFIER.getValue(),
83
			"label_last modifier",
84
			SBMFieldTypes.USER,
85
			TaskAttribute.PERSON_NAME,
86
			TaskAttribute.TYPE_PERSON),
87
	LASTMODIFIEDDATE(
88
			SBMStaticFields.LASTMODIFIEDDATE.getValue(),
89
			"label_modifieddate",
90
			SBMFieldTypes.DATETIME,
91
			TaskAttribute.DATE_MODIFICATION,
39 brianR 92
			TaskAttribute.TYPE_DATETIME,
52 brianR 93
			false), //hidden because has extra part
33 brianR 94
	CLOSEDATE(
95
			SBMStaticFields.CLOSEDATE.getValue(),
96
			"label_closedate",
97
			SBMFieldTypes.DATETIME,
98
			TaskAttribute.DATE_DUE,
99
			TaskAttribute.TYPE_DATETIME),
30 brianR 100
	ITEMURL(
101
			SBMStaticFields.ITEMURL.getValue(),
102
			"Item Link:",
103
			SBMFieldTypes.SYSTEM,
104
			TaskAttribute.TASK_URL,
105
			TaskAttribute.TYPE_URL,
52 brianR 106
			false),
30 brianR 107
	TITLE(
108
			"TITLE",
109
			"label_title",
110
			SBMFieldTypes.TEXT,
111
			TaskAttribute.SUMMARY,
112
			TaskAttribute.TYPE_SHORT_TEXT,
52 brianR 113
			false),	//hidden because has extra part
30 brianR 114
	ACTIVEINACTIVE(
115
			SBMStaticFields.ACTIVEINACTIVE.getValue(),
116
			"label_activeinactive",
117
			SBMFieldTypes.BINARY,
118
			null,
119
			TaskAttribute.TYPE_BOOLEAN),
120
	ISSUETYPE(
121
			"ISSUETYPE",
122
			"label_itemtype",
123
			SBMFieldTypes.SELECTION,
124
			TaskAttribute.TASK_KIND,
125
			TaskAttribute.TYPE_SHORT_TEXT);
126
 
127
	private String sbm_name;
128
	private String task_name;
129
	private String sbm_type;
130
	private String sbm_label;
131
	private String task_type;
132
	private boolean visible;
133
 
134
	public static final boolean VISIBLE = true;
135
	public static final boolean HIDDEN = false;
136
 
137
	private SBMTicketAttribute(String sbm_name, String sbm_label, SBMFieldTypes sbm_type, String task_name, String task_type) {
138
		this(sbm_name,sbm_label,sbm_type,task_name,task_type, SBMTicketAttribute.VISIBLE);
139
	}
140
 
141
	private SBMTicketAttribute(String sbm_name, String sbm_label, SBMFieldTypes sbm_type,
142
			String task_name, String task_type, boolean visible) {
143
		this.sbm_name = sbm_name;
144
		this.sbm_label = sbm_label;
145
		this.sbm_type = sbm_type.getValue();
146
		this.task_name = task_name;
147
		this.task_type = task_type;
148
		this.visible = visible;
149
	}
150
 
151
	public String getSBMName() {
152
		return this.sbm_name;
153
	}
154
	public String getSBMLabel() {
155
		return this.sbm_label;
156
	}
157
	public String getTaskName() {
158
		return this.task_name;
159
	}
160
	public String getTaskType() {
161
		return this.task_type;
162
	}
163
	public String getSBMType() {
164
		return this.sbm_type;
165
	}
166
 
167
	public boolean isVisible() {
168
		return this.visible;
169
	}
170
 
31 brianR 171
	public static SBMTicketAttribute getSBMAttributeBySBMName(String sbm_fieldname) {
30 brianR 172
		for (SBMTicketAttribute attribute : values()) {
173
			if (sbm_fieldname.equals(attribute.getSBMName())) {
174
				return attribute;
175
			}
176
		}
177
		return null;
178
	}
179
 
180
	public static SBMTicketAttribute getSBMAttributeByTaskName(String task_fieldname) {
181
		for (SBMTicketAttribute attribute : values()) {
182
			if (task_fieldname.equals(attribute.getTaskName())) {
183
				return attribute;
184
			}
185
		}
186
		return null;
187
	}
39 brianR 188
 
189
	public static boolean hasSBMField(String fieldname) {
190
		for (SBMTicketAttribute attribute : values()) {
191
			if (attribute.getSBMName().equals(fieldname)) {
192
				return true;
193
			}
194
		}
195
		return false;
196
	}
30 brianR 197
}