Subversion Repositories XServices

Rev

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

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