Subversion Repositories XServices

Rev

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

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