Subversion Repositories XServices

Rev

Rev 31 | Rev 39 | 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,
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),
33 brianR 92
	CLOSEDATE(
93
			SBMStaticFields.CLOSEDATE.getValue(),
94
			"label_closedate",
95
			SBMFieldTypes.DATETIME,
96
			TaskAttribute.DATE_DUE,
97
			TaskAttribute.TYPE_DATETIME),
30 brianR 98
	ITEMURL(
99
			SBMStaticFields.ITEMURL.getValue(),
100
			"Item Link:",
101
			SBMFieldTypes.SYSTEM,
102
			TaskAttribute.TASK_URL,
103
			TaskAttribute.TYPE_URL,
104
			SBMTicketAttribute.HIDDEN),
105
	TITLE(
106
			"TITLE",
107
			"label_title",
108
			SBMFieldTypes.TEXT,
109
			TaskAttribute.SUMMARY,
110
			TaskAttribute.TYPE_SHORT_TEXT,
111
			SBMTicketAttribute.HIDDEN),	//hidden because has extra part
112
	ACTIVEINACTIVE(
113
			SBMStaticFields.ACTIVEINACTIVE.getValue(),
114
			"label_activeinactive",
115
			SBMFieldTypes.BINARY,
116
			null,
117
			TaskAttribute.TYPE_BOOLEAN),
118
	ISSUETYPE(
119
			"ISSUETYPE",
120
			"label_itemtype",
121
			SBMFieldTypes.SELECTION,
122
			TaskAttribute.TASK_KIND,
123
			TaskAttribute.TYPE_SHORT_TEXT);
124
 
125
	private String sbm_name;
126
	private String task_name;
127
	private String sbm_type;
128
	private String sbm_label;
129
	private String task_type;
130
	private boolean visible;
131
 
132
	public static final boolean VISIBLE = true;
133
	public static final boolean HIDDEN = false;
134
 
135
	private SBMTicketAttribute(String sbm_name, String sbm_label, SBMFieldTypes sbm_type, String task_name, String task_type) {
136
		this(sbm_name,sbm_label,sbm_type,task_name,task_type, SBMTicketAttribute.VISIBLE);
137
	}
138
 
139
	private SBMTicketAttribute(String sbm_name, String sbm_label, SBMFieldTypes sbm_type,
140
			String task_name, String task_type, boolean visible) {
141
		this.sbm_name = sbm_name;
142
		this.sbm_label = sbm_label;
143
		this.sbm_type = sbm_type.getValue();
144
		this.task_name = task_name;
145
		this.task_type = task_type;
146
		this.visible = visible;
147
	}
148
 
149
	public String getSBMName() {
150
		return this.sbm_name;
151
	}
152
	public String getSBMLabel() {
153
		return this.sbm_label;
154
	}
155
	public String getTaskName() {
156
		return this.task_name;
157
	}
158
	public String getTaskType() {
159
		return this.task_type;
160
	}
161
	public String getSBMType() {
162
		return this.sbm_type;
163
	}
164
 
165
	public boolean isVisible() {
166
		return this.visible;
167
	}
168
 
31 brianR 169
	public static SBMTicketAttribute getSBMAttributeBySBMName(String sbm_fieldname) {
30 brianR 170
		for (SBMTicketAttribute attribute : values()) {
171
			if (sbm_fieldname.equals(attribute.getSBMName())) {
172
				return attribute;
173
			}
174
		}
175
		return null;
176
	}
177
 
178
	public static SBMTicketAttribute getSBMAttributeByTaskName(String task_fieldname) {
179
		for (SBMTicketAttribute attribute : values()) {
180
			if (task_fieldname.equals(attribute.getTaskName())) {
181
				return attribute;
182
			}
183
		}
184
		return null;
185
	}
186
}