/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/SBMClient.java |
---|
0,0 → 1,551 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core; |
import java.math.BigInteger; |
import java.net.URL; |
import java.util.ArrayList; |
import java.util.Date; |
import java.util.HashMap; |
import java.util.Iterator; |
import java.util.List; |
import java.util.Map; |
import java.util.StringTokenizer; |
import javax.xml.namespace.QName; |
import javax.xml.ws.BindingProvider; |
import net.brutex.mylyn.sbmconnector.SBMConnectorPlugin; |
import net.brutex.mylyn.sbmconnector.core.model.SBMField; |
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldTypes; |
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldValue; |
import net.brutex.mylyn.sbmconnector.core.model.SBMNote; |
import net.brutex.mylyn.sbmconnector.core.model.SBMStaticFields; |
import net.brutex.sbm.wsclient.AEWebservicesFaultFault; |
import net.brutex.sbm.wsclient.Aewebservices71; |
import net.brutex.sbm.wsclient.Aewebservices71PortType; |
import net.brutex.sbm.wsclient.Auth; |
import net.brutex.sbm.wsclient.Field; |
import net.brutex.sbm.wsclient.NameValue; |
import net.brutex.sbm.wsclient.Note; |
import net.brutex.sbm.wsclient.ObjectFactory; |
import net.brutex.sbm.wsclient.ReportCategory; |
import net.brutex.sbm.wsclient.ReportInfo; |
import net.brutex.sbm.wsclient.ReportResult; |
import net.brutex.sbm.wsclient.ReportsFilter; |
import net.brutex.sbm.wsclient.RunReportResult; |
import net.brutex.sbm.wsclient.TTItem; |
import net.brutex.sbm.wsclient.TableData; |
import net.brutex.sbm.wsclient.TableType; |
import net.brutex.sbm.wsclient.Value; |
import org.eclipse.core.runtime.CoreException; |
import org.eclipse.mylyn.commons.net.AuthenticationCredentials; |
import org.eclipse.mylyn.commons.net.AuthenticationType; |
import org.eclipse.mylyn.tasks.core.RepositoryStatus; |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
public class SBMClient { |
private Aewebservices71PortType port; |
private static final QName SERVICE_NAME = new QName("http://localhost:80/gsoap/aewebservices71.wsdl", "aewebservices71"); |
private TaskRepository repository; |
private ObjectFactory of; |
private List<TableData> tables = new ArrayList<TableData>(); |
private Map<String, List<SBMFieldValue>> validsets = new HashMap<String, List<SBMFieldValue>>(); |
/** |
* Instantiates a new SBM client. |
* Creates new instance of the aewebservices71 {@link net.brutex.sbm.wsclient.ObjectFactory} and |
* initializes web service endpoint from repository url. |
* |
* @param repository the repository |
*/ |
public SBMClient(TaskRepository repository) { |
this.repository = repository; |
this.of = new ObjectFactory(); |
URL wsdlURL = Aewebservices71.WSDL_LOCATION; |
wsdlURL = this.getClass().getResource("/META-INF/aewebservices71.wsdl"); |
Aewebservices71 ss = new Aewebservices71(wsdlURL, SERVICE_NAME); |
port = ss.getAewebservices71(); |
((BindingProvider)port).getRequestContext().put( |
BindingProvider.ENDPOINT_ADDRESS_PROPERTY, |
repository.getRepositoryUrl()); |
} |
/** |
* Can authenticate checks if this SBMClient instance has proper authentication details |
* set in its related repository. The check is done by invoking the GetUser web service. |
* |
* @return true, if successful |
* @throws CoreException the core exception |
*/ |
public boolean canAuthenticate() throws CoreException { |
try { |
port.getUser(getAuth(), repository.getCredentials(AuthenticationType.REPOSITORY).getUserName()); |
} catch (AEWebservicesFaultFault e) { |
new CoreException(RepositoryStatus.createLoginError( |
repository.getRepositoryUrl(), SBMConnectorPlugin.PLUGIN_ID)); |
return false; |
} |
return true; |
} |
public List<TTItem> getTTItemsByTable(String tablename, String sql_where) throws CoreException { |
return getTTItemsByTable(tablename, sql_where, false); |
} |
/** |
* Gets the SBM items from a table. The result size is limited to 500 and the sorting is done |
* by TS_ID descending. |
* |
* @param tablename the tablename |
* @param sql_where the sql_where |
* @return the tT items by table |
* @throws CoreException the core exception |
*/ |
public List<TTItem> getTTItemsByTable(String tablename, String sql_where, boolean getFullData) throws CoreException { |
List<TTItem> list = new ArrayList<TTItem>(); |
String sections = "SECTION:FIXED"; |
if(getFullData) sections = "SECTION:ALL"; |
if(sql_where==null || sql_where.isEmpty()) sql_where = "TS_ID>0"; |
try { |
list = port.getItemsByQueryWithName( |
getAuth(), |
tablename, |
"("+sql_where+")", |
"TS_ID desc", |
null, |
sections); |
} catch (AEWebservicesFaultFault e) { |
throw new CoreException( |
RepositoryStatus.createInternalError( |
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e)); |
} |
return list; |
} |
public List<TTItem> getTTItemsByReport(String reportuuid) throws CoreException { |
List<TTItem> list = new ArrayList<TTItem>(); |
try { |
RunReportResult result = port.runReport( |
getAuth(), of.createQueryRange(), reportuuid, null, null, null, null, null, null, |
null, null, null, null, null); |
List<ReportResult> resultlist = result.getResult(); |
for(ReportResult r : resultlist) { |
list.add(port.getItem( getAuth(), r.getItemId().getValue(), null)); |
} |
} catch (AEWebservicesFaultFault e) { |
throw new CoreException( |
RepositoryStatus.createInternalError( |
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e)); |
} |
return list; |
} |
public List<ReportInfo> getReportList(String solutionname) throws CoreException { |
ReportsFilter filter = of.createReportsFilter(); |
List<ReportInfo> reportlist = new ArrayList<ReportInfo>(); |
filter.setSolutionName(of.createSolutionDataName(solutionname)); |
filter.setReportCategory(ReportCategory.USERREPORTS); //Limit this for now, because we execute by uuid only |
try { |
reportlist = port.getReports(getAuth(), null, filter).getReport(); |
} catch (AEWebservicesFaultFault e) { |
throw new CoreException( |
RepositoryStatus.createInternalError( |
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e)); |
} |
return reportlist; |
} |
public List<String> getResultCount(String tablename, String sql) throws CoreException { |
List<TTItem> list = new ArrayList<TTItem>(); |
List<String> idlist = new ArrayList<String>(); |
try { |
list = port.getItemsByQueryWithName( |
getAuth(), |
tablename, |
"("+sql+")", |
"TS_ID desc", |
null, |
"SECTION:NONE"); |
} catch (AEWebservicesFaultFault e) { |
throw new CoreException( |
RepositoryStatus.createInternalError( |
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e)); |
} |
for (TTItem item : list) { |
idlist.add(item.getGenericItem().getValue().getItemID().getValue()); |
} |
return idlist; |
} |
/** |
* Gets a SBM item specified by its internal identifier ([tableid:recordid]) |
* |
* @param itemid the itemid |
* @return the tT item |
*/ |
public TTItem getTTItem(String itemid) { |
int pos1; |
int pos2; |
pos1 = itemid.lastIndexOf("[")+1; |
pos2 = itemid.lastIndexOf("]"); |
itemid = itemid.substring(pos1, pos2); |
TTItem item = of.createTTItem(); |
try { |
item = port.getItem(getAuth(), itemid, null); |
} catch (AEWebservicesFaultFault e) { |
new CoreException( |
RepositoryStatus.createInternalError( |
SBMConnectorPlugin.PLUGIN_ID, e.getFaultInfo(), e)); |
} |
return item; |
} |
private Auth getAuth() { |
Auth auth = of.createAuth(); |
AuthenticationCredentials credentials = repository.getCredentials(AuthenticationType.REPOSITORY); |
auth.setUserId(of.createAuthUserId(credentials.getUserName())); |
auth.setPassword(of.createAuthPassword(credentials.getPassword())); |
return auth; |
} |
/** |
* Gets the field value for a system generic field. |
* |
* @param ttitem the ttitem |
* @param fieldname the fieldname |
* @return the static field value |
*/ |
public String getStaticFieldValue(TTItem ttitem, String fieldname) { |
if(fieldname.equals(SBMStaticFields.SUBMITDATE.getValue())) { |
Date date = ttitem.getCreateDate().getValue().toGregorianCalendar().getTime(); |
return String.valueOf(date.getTime()); |
} |
if(fieldname.equals(SBMStaticFields.LASTMODIFIEDDATE.getValue())) { |
return String.valueOf(ttitem.getModifiedDate().getValue().toGregorianCalendar().getTimeInMillis()); |
} |
if(fieldname.equals("TITLE")) { |
if(ttitem.getTitle()==null || ttitem.getTitle().isNil()) return ""; |
return ttitem.getTitle().getValue(); |
} |
if(fieldname.equals(SBMStaticFields.ISSUEID.getValue())) { |
if(ttitem.getGenericItem()==null || ttitem.getGenericItem().getValue().getItemName()==null) { |
return ""; |
} |
return ttitem.getGenericItem().getValue().getItemName().getValue(); |
} |
if(fieldname.equals("ISSUETYPE")) { |
if(ttitem.getItemType()==null || ttitem.getItemType().isNil()) return ""; |
return ttitem.getItemType().getValue(); |
} |
if(fieldname.equals(SBMStaticFields.STATE.getValue())) { |
if(ttitem.getState()==null || ttitem.getState().isNil()) return ""; |
return ttitem.getState().getValue(); |
} |
if(fieldname.equals(SBMStaticFields.ID.getValue())) { |
return ttitem.getGenericItem().getValue().getItemName().getValue()+ |
" ["+ttitem.getGenericItem().getValue().getItemID().getValue()+"]"; |
} |
if(fieldname.equals(SBMStaticFields.PROJECTID.getValue())) { |
if(ttitem.getClassification() ==null || ttitem.getClassification().isNil()) return ""; |
return ttitem.getClassification().getValue(); |
} |
if(fieldname.equals(SBMStaticFields.PROJECTUUID.getValue())) { |
if(ttitem.getClassificationUUID()==null || ttitem.getClassificationUUID().isNil()) return ""; |
return ttitem.getClassificationUUID().getValue(); |
} |
if(fieldname.equals("DESCRIPTION")) { |
if(ttitem.getDescription() == null || ttitem.getDescription().isNil()) return ""; |
return ttitem.getDescription().getValue(); |
} |
if(fieldname.equals(SBMStaticFields.SUBMITTER.getValue())) { |
if(ttitem.getCreatedBy()==null || ttitem.getCreatedBy().isNil()) return ""; |
return ttitem.getCreatedBy().getValue(); |
} |
if(fieldname.equals(SBMStaticFields.SUBMITDATE.getValue())) { |
return String.valueOf(ttitem.getCreateDate().getValue().toGregorianCalendar().getTimeInMillis()); |
} |
if(fieldname.equals(SBMStaticFields.LASTMODIFIER.getValue())) { |
if(ttitem.getModifiedBy()==null || ttitem.getModifiedBy().isNil()) return ""; |
return ttitem.getModifiedBy().getValue(); |
} |
if(fieldname.equals(SBMStaticFields.LASTMODIFIEDDATE.getValue())) { |
return String.valueOf(ttitem.getModifiedDate().getValue().toGregorianCalendar().getTimeInMillis()); |
} |
if(fieldname.equals(SBMStaticFields.ACTIVEINACTIVE.getValue())) { |
return ttitem.getActiveInactive().getValue(); |
} |
if(fieldname.equals(SBMStaticFields.OWNER.getValue())) { |
return ttitem.getOwner().getValue(); |
} |
if(fieldname.equals(SBMStaticFields.ITEMURL.getValue())) { |
return ttitem.getUrl().getValue(); |
} |
if(fieldname.equals(SBMStaticFields.UUID.getValue())) { |
return ttitem.getGenericItem().getValue().getItemUUID().getValue(); |
} |
if(fieldname.equals(SBMStaticFields.CLOSEDATE.getValue())) { |
Iterator<NameValue> list = ttitem.getExtendedFieldList().iterator(); |
while (list.hasNext()) { |
NameValue field = list.next(); |
if(field.getName().getValue().equals("CLOSEDATE")) { |
return field.getValue().getValue().getInternalValue().getValue(); |
} |
} |
} |
if(fieldname.equals(SBMStaticFields.LASTSTATECHANGEDATE.getValue())) { |
Iterator<NameValue> list = ttitem.getExtendedFieldList().iterator(); |
while (list.hasNext()) { |
NameValue field = list.next(); |
if(field.getName().getValue().equals("LASTSTATECHANGEDATE")) { |
return field.getValue().getValue().getInternalValue().getValue(); |
} |
} |
} |
if(fieldname.equals(SBMStaticFields.SECONDARYOWNER.getValue())) { |
Iterator<NameValue> list = ttitem.getExtendedFieldList().iterator(); |
while (list.hasNext()) { |
NameValue field = list.next(); |
if(field.getName().getValue().equals("SECONDARYOWNER")) { |
return field.getValue().getValue().getInternalValue().getValue(); |
} |
} |
} |
if(fieldname.equals(SBMStaticFields.LASTSTATECHANGER.getValue())) { |
Iterator<NameValue> list = ttitem.getExtendedFieldList().iterator(); |
while (list.hasNext()) { |
NameValue field = list.next(); |
if(field.getName().getValue().equals("LASTSTATECHANGER")) { |
return field.getValue().getValue().getDisplayValue().getValue(); |
} |
} |
} |
return "UNKNOWN"; |
} |
/** |
* Gets the field label. The SBM item is used to determine the table id of |
* the table where this field is in. |
* |
* @param ttitem the ttitem |
* @param fieldname the fieldname |
* @return the field label |
*/ |
public String getFieldLabel(TTItem ttitem, String fieldname) { |
refreshTables(); |
String itemid = ttitem.getGenericItem().getValue().getItemID().getValue(); |
String tableid = new StringTokenizer(itemid, ":").nextToken(); |
for (TableData table : tables) { |
if (String.valueOf(table.getTableID().intValue()).equals(tableid)) { |
Iterator<Field> iter = table.getFieldList().iterator(); |
while(iter.hasNext()) { |
Field f = iter.next(); |
if(f.getName().getValue().equals(fieldname)) { |
return f.getDisplayName().getValue(); |
} |
} |
break; |
} |
} |
return fieldname; //field has not been found |
} |
/** |
* Gets the table database name. |
* |
* @param ttitem the ttitem |
* @return the table name or null in case table is not found |
*/ |
public String getTableName(TTItem ttitem) { |
refreshTables(); |
String itemid = ttitem.getGenericItem().getValue().getItemID().getValue(); |
String tableid = new StringTokenizer(itemid, ":").nextToken(); |
for (TableData table : tables) { |
if (String.valueOf(table.getTableID().intValue()).equals(tableid)) { |
return table.getName().getValue(); |
} |
} |
return null; |
} |
/** |
* Gets the notes attached to a SBM item. |
* |
* @param ttitem the ttitem |
* @return the notes |
*/ |
public List<SBMNote> getNotes(TTItem ttitem) { |
List<SBMNote> notes = new ArrayList<SBMNote>(); |
Iterator<Note> iter = ttitem.getNoteList().iterator(); |
while(iter.hasNext()) { |
Note n = iter.next(); |
SBMNote note = new SBMNote("sbm_user", |
n.getTitle().getValue()+"\n"+n.getNote().getValue(), |
n.getModificationDateTime().toGregorianCalendar().getTime(), |
n.getId().toString()); |
notes.add(note); |
} |
return notes; |
} |
/** |
* Gets the names of all available primary tables. |
* A table name is a unique reference within one SBM environment, thus can be |
* used as a key. |
* |
* @return the primary table names as a list |
*/ |
public List<String> getPrimaryTables() { |
refreshTables(); |
List<String> table_names = new ArrayList<String>(); |
for (TableData table : tables) { |
table_names.add(table.getName().getValue()); |
} |
return table_names; |
} |
/** |
* Refresh table specifications from SBM web service. This |
* is only done once per SBMClient instance. |
*/ |
private void refreshTables() { |
if (tables.isEmpty()) { |
try { |
//currently we limit this to primary tables |
tables = port.getTables(getAuth(), null, TableType.PRIMARY_TABLE); |
} catch (AEWebservicesFaultFault e) { |
new CoreException( |
RepositoryStatus.createInternalError( |
SBMConnectorPlugin.PLUGIN_ID, e.getFaultInfo(), e)); |
} |
} |
} |
/** |
* Gets the fields for a primary table |
* |
* @param tablename the table database name |
* @return the fields, empty when table does not exist |
*/ |
public List<SBMField> getFields(String tablename) { |
refreshTables(); |
List<SBMField> fields = new ArrayList<SBMField>(); |
for (TableData table : tables) { |
if(table.getName().getValue().equals(tablename)) { |
Iterator<Field> iter = table.getFieldList().iterator(); |
while(iter.hasNext()) { |
Field f = iter.next(); |
SBMField nf = new SBMField( |
SBMFieldTypes.fromValue(f.getFieldType().value()), |
tablename, |
f.getDisplayName().getValue(), |
f.getName().getValue()); |
fields.add(nf); |
} |
break; |
} |
} |
return fields; |
} |
/** |
* Gets the field value for custom defined field. |
* (those from <extendedFieldList>) |
* |
* @param ttitem the ttitem |
* @param fieldname the fieldname |
* @return the field value or null if the field is not found |
*/ |
public SBMFieldValue getFieldValue(TTItem ttitem, String fieldname) { |
SBMFieldValue value; |
Iterator<NameValue> fs = ttitem.getExtendedFieldList().iterator(); |
while(fs.hasNext()) { |
NameValue nv = fs.next(); |
if(nv.getName().getValue().equals(fieldname)) { |
if (nv.getValue()!=null && !nv.getValue().isNil()) { |
value = new SBMFieldValue( |
nv.getValue().getValue().getInternalValue().getValue(), |
nv.getValue().getValue().getDisplayValue().getValue()); |
return value; |
} |
} |
} |
return null; |
} |
/** |
* Gets the field values for custom defined, multi type field. |
* (those from <extendedFieldList>) |
* |
* @param ttitem the ttitem |
* @param fieldname the fieldname |
* @return the list of field values |
*/ |
public List<SBMFieldValue> getFieldValues(TTItem ttitem, String fieldname) { |
List<SBMFieldValue> values = new ArrayList<SBMFieldValue>(); |
Iterator<NameValue> fs = ttitem.getExtendedFieldList().iterator(); |
while(fs.hasNext()) { |
NameValue nv = fs.next(); |
if(nv.getName().getValue().equals(fieldname)) { |
if (nv.getValues()!=null && !nv.getValues().isEmpty()) { |
Iterator<Value> nvv = nv.getValues().iterator(); |
while(nvv.hasNext()) { |
Value nvv_value = nvv.next(); |
SBMFieldValue value = new SBMFieldValue( |
nvv_value.getInternalValue().getValue(), |
nvv_value.getDisplayValue().getValue()); |
values.add(value); |
} |
return values; |
} |
} |
} |
return values; |
} |
public List<SBMFieldValue> getValidSet(String tablename, String fieldname) { |
if(validsets.containsKey(tablename+":"+fieldname)) return validsets.get(tablename+":"+fieldname); |
List<SBMFieldValue> list = new ArrayList<SBMFieldValue>(); |
List<TTItem> ttlist = new ArrayList<TTItem>(); |
String sql = "TS_ID in (select max(TS_ID) from "+tablename+" group by ts_"+fieldname+")"; |
try { |
ttlist = getTTItemsByTable(tablename, sql); |
} catch (CoreException e) { |
new CoreException( |
RepositoryStatus.createInternalError( |
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e)); |
} |
for(TTItem ttitem : ttlist) { |
list.add(getFieldValue(ttitem, fieldname)); |
} |
validsets.put(tablename+":"+fieldname, list); |
return list; |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/SBMTicketAttribute.java |
---|
0,0 → 1,197 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core; |
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldTypes; |
import net.brutex.mylyn.sbmconnector.core.model.SBMStaticFields; |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
/** |
* Map the Mylyn TaskAttributes to SBMTicket Attributes and vice versa. |
* @author Brian Rosenberger |
* |
*/ |
public enum SBMTicketAttribute { |
DESCRIPTION( |
"DESCRIPTION", |
"label_description", |
SBMFieldTypes.TEXT, |
TaskAttribute.DESCRIPTION, |
TaskAttribute.TYPE_LONG_RICH_TEXT, |
false), //hidden because has extra part |
ID( |
SBMStaticFields.ID.getValue(), |
"ts_id", |
SBMFieldTypes.SYSTEM, |
TaskAttribute.TASK_KEY, |
TaskAttribute.TYPE_SHORT_TEXT, |
false), |
UUID( |
SBMStaticFields.UUID.getValue(), |
"ts_uuid", |
SBMFieldTypes.SYSTEM, |
TaskAttribute.KIND_DEFAULT, |
TaskAttribute.TYPE_SHORT_TEXT, |
false), |
PROJECT( |
SBMStaticFields.PROJECTID.getValue(), |
"label_project", |
SBMFieldTypes.SYSTEM, |
TaskAttribute.PRODUCT, |
TaskAttribute.TYPE_SHORT_TEXT), |
STATE( |
SBMStaticFields.STATE.getValue(), |
"label_state", |
SBMFieldTypes.SYSTEM, |
TaskAttribute.STATUS, |
TaskAttribute.TYPE_SHORT_TEXT, |
false), //hidden because has extra part |
SUBMITTER( |
SBMStaticFields.SUBMITTER.getValue(), |
"label_submitter", |
SBMFieldTypes.USER, |
TaskAttribute.USER_REPORTER, |
TaskAttribute.TYPE_PERSON, |
false), //hidden because has extra part |
SUBMITDATE( |
SBMStaticFields.SUBMITDATE.getValue(), |
"label_submitdate", |
SBMFieldTypes.DATETIME, |
TaskAttribute.DATE_CREATION, |
TaskAttribute.TYPE_DATETIME), |
LASTMODIFIER( |
SBMStaticFields.LASTMODIFIER.getValue(), |
"label_last modifier", |
SBMFieldTypes.USER, |
TaskAttribute.PERSON_NAME, |
TaskAttribute.TYPE_PERSON), |
LASTMODIFIEDDATE( |
SBMStaticFields.LASTMODIFIEDDATE.getValue(), |
"label_modifieddate", |
SBMFieldTypes.DATETIME, |
TaskAttribute.DATE_MODIFICATION, |
TaskAttribute.TYPE_DATETIME, |
false), //hidden because has extra part |
CLOSEDATE( |
SBMStaticFields.CLOSEDATE.getValue(), |
"label_closedate", |
SBMFieldTypes.DATETIME, |
TaskAttribute.DATE_DUE, |
TaskAttribute.TYPE_DATETIME), |
ITEMURL( |
SBMStaticFields.ITEMURL.getValue(), |
"Item Link:", |
SBMFieldTypes.SYSTEM, |
TaskAttribute.TASK_URL, |
TaskAttribute.TYPE_URL, |
false), |
TITLE( |
"TITLE", |
"label_title", |
SBMFieldTypes.TEXT, |
TaskAttribute.SUMMARY, |
TaskAttribute.TYPE_SHORT_TEXT, |
false), //hidden because has extra part |
ACTIVEINACTIVE( |
SBMStaticFields.ACTIVEINACTIVE.getValue(), |
"label_activeinactive", |
SBMFieldTypes.BINARY, |
null, |
TaskAttribute.TYPE_BOOLEAN), |
ISSUETYPE( |
"ISSUETYPE", |
"label_itemtype", |
SBMFieldTypes.SELECTION, |
TaskAttribute.TASK_KIND, |
TaskAttribute.TYPE_SHORT_TEXT); |
private String sbm_name; |
private String task_name; |
private String sbm_type; |
private String sbm_label; |
private String task_type; |
private boolean visible; |
public static final boolean VISIBLE = true; |
public static final boolean HIDDEN = false; |
private SBMTicketAttribute(String sbm_name, String sbm_label, SBMFieldTypes sbm_type, String task_name, String task_type) { |
this(sbm_name,sbm_label,sbm_type,task_name,task_type, SBMTicketAttribute.VISIBLE); |
} |
private SBMTicketAttribute(String sbm_name, String sbm_label, SBMFieldTypes sbm_type, |
String task_name, String task_type, boolean visible) { |
this.sbm_name = sbm_name; |
this.sbm_label = sbm_label; |
this.sbm_type = sbm_type.getValue(); |
this.task_name = task_name; |
this.task_type = task_type; |
this.visible = visible; |
} |
public String getSBMName() { |
return this.sbm_name; |
} |
public String getSBMLabel() { |
return this.sbm_label; |
} |
public String getTaskName() { |
return this.task_name; |
} |
public String getTaskType() { |
return this.task_type; |
} |
public String getSBMType() { |
return this.sbm_type; |
} |
public boolean isVisible() { |
return this.visible; |
} |
public static SBMTicketAttribute getSBMAttributeBySBMName(String sbm_fieldname) { |
for (SBMTicketAttribute attribute : values()) { |
if (sbm_fieldname.equals(attribute.getSBMName())) { |
return attribute; |
} |
} |
return null; |
} |
public static SBMTicketAttribute getSBMAttributeByTaskName(String task_fieldname) { |
for (SBMTicketAttribute attribute : values()) { |
if (task_fieldname.equals(attribute.getTaskName())) { |
return attribute; |
} |
} |
return null; |
} |
public static boolean hasSBMField(String fieldname) { |
for (SBMTicketAttribute attribute : values()) { |
if (attribute.getSBMName().equals(fieldname)) { |
return true; |
} |
} |
return false; |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/SBMRepositoryConnector.java |
---|
0,0 → 1,256 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core; |
import java.util.Date; |
import java.util.HashMap; |
import java.util.List; |
import java.util.Map; |
import net.brutex.mylyn.sbmconnector.SBMConnectorPlugin; |
import net.brutex.mylyn.sbmconnector.core.model.SBMStaticFields; |
import net.brutex.mylyn.sbmconnector.ui.SBMQueryComposite; |
import net.brutex.mylyn.sbmconnector.ui.SBMRepositoryQueryPage; |
import net.brutex.mylyn.sbmconnector.ui.SBMRepositorySettingsPage; |
import net.brutex.sbm.wsclient.TTItem; |
import org.eclipse.core.runtime.CoreException; |
import org.eclipse.core.runtime.IProgressMonitor; |
import org.eclipse.core.runtime.IStatus; |
import org.eclipse.core.runtime.Status; |
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; |
import org.eclipse.mylyn.tasks.core.IRepositoryQuery; |
import org.eclipse.mylyn.tasks.core.ITask; |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler; |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
import org.eclipse.mylyn.tasks.core.data.TaskData; |
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector; |
import org.eclipse.mylyn.tasks.core.data.TaskMapper; |
import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession; |
public class SBMRepositoryConnector extends AbstractRepositoryConnector { |
private SBMTicketDataHandler datahandler; |
private static Map<TaskRepository, SBMClient> clients = new HashMap<TaskRepository, SBMClient>(); |
public SBMRepositoryConnector() { |
this.datahandler = new SBMTicketDataHandler(this); |
} |
public static synchronized SBMClient getClient(TaskRepository repository) { |
SBMClient client = clients.get(repository); |
if (client == null) { |
client = new SBMClient(repository); |
clients.put(repository, client); |
} |
return client; |
} |
@Override |
public boolean canCreateNewTask(TaskRepository repository) { |
return false; |
} |
@Override |
public boolean canCreateTaskFromKey(TaskRepository repository) { |
return false; |
} |
@Override |
public boolean canSynchronizeTask(TaskRepository taskRepository, ITask task) { |
return true; |
} |
@Override |
public String getConnectorKind() { |
return SBMConnectorPlugin.CONNECTOR_KIND; |
} |
@Override |
public String getLabel() { |
return SBMConnectorPlugin.LABEL; |
} |
@Override |
public String getRepositoryUrlFromTaskUrl(String taskFullUrl) { |
// TODO Auto-generated method stub |
return null; |
} |
@Override |
public TaskData getTaskData(TaskRepository taskRepository, String taskId, |
IProgressMonitor monitor) throws CoreException { |
monitor.beginTask("Loading SBM Ticket", IProgressMonitor.UNKNOWN); |
TaskData data = null; |
try { |
SBMClient client = getClient(taskRepository); |
TTItem item = client.getTTItem(taskId); |
data = datahandler.convert(taskRepository, item, monitor, null); |
} finally { |
monitor.done(); |
} |
return data; |
} |
@Override |
public String getTaskIdFromTaskUrl(String taskFullUrl) { |
// TODO Auto-generated method stub |
return null; |
} |
@Override |
public String getTaskUrl(String repositoryUrl, String taskId) { |
// TODO Auto-generated method stub |
return "http://something/I/havent/implemented/yet?"+taskId; |
} |
@Override |
public boolean hasTaskChanged(TaskRepository taskRepository, ITask task, |
TaskData taskData) { |
TaskAttribute attribute = taskData.getRoot().getAttribute( |
SBMStaticFields.LASTMODIFIEDDATE.getValue()); |
if (attribute != null) { |
Date dataModificationDate = taskData.getAttributeMapper() |
.getDateValue(attribute); |
if (dataModificationDate != null) { |
Date taskModificationDate = task.getModificationDate(); |
if (taskModificationDate != null) { |
return !taskModificationDate.equals(dataModificationDate); |
} |
} |
} |
return true; |
} |
@Override |
public IStatus performQuery(TaskRepository repository, |
IRepositoryQuery query, TaskDataCollector collector, |
ISynchronizationSession session, IProgressMonitor monitor) { |
SBMClient client = new SBMClient(repository); |
// do we use a report or a query? |
if (query.getAttribute(SBMRepositoryQueryPage.SQL_QUERY_NAME).equals( |
query.getAttribute(SBMRepositoryQueryPage.REPORT_OR_QUERY))) { |
monitor.subTask("Calculating query result size ..."); |
try { |
List<String> idlist = client.getResultCount( |
getQueryTable(repository), |
query.getAttribute("sql_where")); |
int countItem = idlist.size(); |
monitor.beginTask("", countItem); |
monitor.subTask("Loading " + countItem + " items ..."); |
// List<TTItem> list = client.getTTItemsByTable( |
// getQueryTable(repository), query.getAttribute("sql_where"), |
// true); |
monitor.worked(1); |
int i = 1; |
for (String id : idlist) { |
if (id != null) { |
monitor.subTask("Loading item " + i + "/" + countItem |
+ " ..."); |
TTItem ttitem = client.getTTItem("[" + id + "]"); |
TaskData data = datahandler.convert(repository, ttitem, |
monitor, query); |
collector.accept(data); |
} |
monitor.worked(1); |
if (monitor.isCanceled()) |
return Status.CANCEL_STATUS; |
i++; |
} |
} catch (CoreException e) { |
IStatus status = new Status(IStatus.ERROR, |
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e); |
// StatusManager.getManager().handle(status, |
// StatusManager.BLOCK); |
return status; |
} finally { |
monitor.done(); |
} |
} else { |
// use report |
monitor.beginTask("Loading Report", 0); |
try { |
List<TTItem> list = client.getTTItemsByReport(query |
.getAttribute(SBMRepositoryQueryPage.REPORT)); |
for(TTItem i:list) { |
TaskData data = datahandler.convert(repository, i, |
monitor, query); |
collector.accept(data); |
} |
} catch (CoreException e) { |
IStatus status = new Status(IStatus.ERROR, |
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e); |
// StatusManager.getManager().handle(status, |
// StatusManager.BLOCK); |
return status; |
} finally { |
monitor.done(); |
} |
} |
return Status.OK_STATUS; |
} |
@Override |
public void updateRepositoryConfiguration(TaskRepository taskRepository, |
IProgressMonitor monitor) throws CoreException { |
// TODO Auto-generated method stub |
} |
@Override |
public void updateTaskFromTaskData(TaskRepository taskRepository, |
ITask task, TaskData taskData) { |
getTaskMapping(taskData).applyTo(task); |
} |
@Override |
public TaskMapper getTaskMapping(TaskData taskData) { |
return new TaskMapper(taskData); |
} |
@Override |
public AbstractTaskDataHandler getTaskDataHandler() { |
return datahandler; |
} |
public boolean canDeleteTask(TaskRepository repository, ITask task) { |
return false; |
} |
@Override |
public boolean hasRepositoryDueDate(TaskRepository taskRepository, |
ITask task, TaskData taskData) { |
// TODO Auto-generated method stub |
return false; |
} |
private String getQueryTable(TaskRepository repository) { |
return repository |
.getProperty(SBMRepositorySettingsPage.STRING_SOLUTIONTABLE); |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/SBMTicketDataHandler.java |
---|
0,0 → 1,297 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core; |
import java.util.Date; |
import java.util.GregorianCalendar; |
import java.util.List; |
import java.util.Set; |
import javax.xml.datatype.DatatypeConfigurationException; |
import javax.xml.datatype.DatatypeFactory; |
import javax.xml.datatype.XMLGregorianCalendar; |
import net.brutex.mylyn.sbmconnector.SBMConnectorPlugin; |
import net.brutex.mylyn.sbmconnector.core.model.SBMField; |
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldAttributes; |
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldTypes; |
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldValue; |
import net.brutex.mylyn.sbmconnector.core.model.SBMNote; |
import net.brutex.mylyn.sbmconnector.core.model.SBMStaticFields; |
import net.brutex.mylyn.sbmconnector.core.model.SBMSystemFields; |
import net.brutex.mylyn.sbmconnector.ui.SBMRepositorySettingsPage; |
import net.brutex.sbm.wsclient.TTItem; |
import org.eclipse.core.runtime.CoreException; |
import org.eclipse.core.runtime.IProgressMonitor; |
import org.eclipse.mylyn.tasks.core.IRepositoryQuery; |
import org.eclipse.mylyn.tasks.core.ITaskMapping; |
import org.eclipse.mylyn.tasks.core.RepositoryResponse; |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
import org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler; |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper; |
import org.eclipse.mylyn.tasks.core.data.TaskCommentMapper; |
import org.eclipse.mylyn.tasks.core.data.TaskData; |
/** |
* The Class SBMTicketDataHandler. |
*/ |
public class SBMTicketDataHandler extends AbstractTaskDataHandler { |
/** The connector. */ |
private final SBMRepositoryConnector connector; |
/** |
* Instantiates a new SBM ticket data handler. |
* |
* @param connector |
* the connector |
*/ |
public SBMTicketDataHandler(SBMRepositoryConnector connector) { |
this.connector = connector; |
} |
/* |
* (non-Javadoc) |
* |
* @see |
* org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler#getAttributeMapper |
* (org.eclipse.mylyn.tasks.core.TaskRepository) |
*/ |
@Override |
public TaskAttributeMapper getAttributeMapper(TaskRepository taskRepository) { |
return new SBMTicketAttributeMapper(taskRepository); |
} |
/* |
* (non-Javadoc) |
* |
* @see |
* org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler#initializeTaskData |
* (org.eclipse.mylyn.tasks.core.TaskRepository, |
* org.eclipse.mylyn.tasks.core.data.TaskData, |
* org.eclipse.mylyn.tasks.core.ITaskMapping, |
* org.eclipse.core.runtime.IProgressMonitor) |
*/ |
@Override |
public boolean initializeTaskData(TaskRepository repository, |
TaskData taskData, ITaskMapping initializationData, |
IProgressMonitor monitor) throws CoreException { |
monitor.subTask("Initialising task ..."); |
taskData.setPartial(true); |
return true; |
} |
/* |
* (non-Javadoc) |
* |
* @see |
* org.eclipse.mylyn.tasks.core.data.AbstractTaskDataHandler#postTaskData |
* (org.eclipse.mylyn.tasks.core.TaskRepository, |
* org.eclipse.mylyn.tasks.core.data.TaskData, java.util.Set, |
* org.eclipse.core.runtime.IProgressMonitor) |
*/ |
@Override |
public RepositoryResponse postTaskData(TaskRepository repository, |
TaskData taskData, Set<TaskAttribute> oldAttributes, |
IProgressMonitor monitor) throws CoreException { |
// TODO Auto-generated method stub |
return null; |
} |
/** |
* Convert. |
* |
* @param repository the repository |
* @param ttitem |
* the ttitem |
* @param monitor |
* the monitor |
* @return the task data |
* @throws CoreException |
* the core exception |
*/ |
public TaskData convert(TaskRepository repository, TTItem ttitem, |
IProgressMonitor monitor, IRepositoryQuery query) |
throws CoreException { |
SBMClient client = SBMRepositoryConnector.getClient(repository); |
TaskData data = new TaskData(new SBMTicketAttributeMapper(repository), |
SBMConnectorPlugin.CONNECTOR_KIND, repository |
.getRepositoryUrl(), ttitem.getGenericItem().getValue() |
.getItemName().getValue() |
+ " [" |
+ ttitem.getGenericItem().getValue().getItemID() |
.getValue() + "]"); |
initializeTaskData(repository, data, null, monitor); |
String fieldlist = ""; |
if (repository |
.hasProperty(SBMRepositorySettingsPage.STRING_TABLEFIELDLIST)) { |
fieldlist = repository |
.getProperty(SBMRepositorySettingsPage.STRING_TABLEFIELDLIST); |
} |
// Create Fields for all the generic SBM (system) fields |
monitor.subTask("Creating generic SBM fields..."); |
for (SBMSystemFields sysfield : SBMSystemFields.values()) { |
if(!sysfield.hasTaskAttribute()) { |
// skip the field here, because we do not have a |
// matching task attribute to map. The field |
// will be processed in the custom field section |
continue; |
} |
if (!fieldlist.contains("," + sysfield.getValue() + ",")) { |
// do not process custom field when it has not |
// been selected by user in repository settings page |
continue; |
} |
// try to initialize the SBM attribute |
SBMTicketAttribute f = null; |
TaskAttribute attr = null; |
try { |
f = SBMTicketAttribute.valueOf(sysfield.getValue()); |
} catch (IllegalArgumentException e) { |
// the field is a valid sbm system field and is set up to |
// have an equivalent in the task attributes. It must have an |
// entry in the SBMTicketAttribute class ! |
continue; // we just skip the field |
} |
if (f.getTaskName() != null) { |
attr = data.getRoot().createMappedAttribute(f.getTaskName()); |
} else { |
// again the field is set up to have an task attribute |
// equivalent, but it is not set up in SBMAttributes correctly |
continue; |
} |
attr.getMetaData().setReadOnly(true); //we do not support writing yet |
attr.getMetaData().setType(f.getTaskType()); // set the mapped field type |
attr.getMetaData().setLabel(client.getFieldLabel(ttitem, f.getSBMName())); // get and set the field label |
if (f.isVisible()) { |
// field is not hidden, display it by setting KIND_DEFAULT |
attr.getMetaData().setKind(TaskAttribute.KIND_DEFAULT); |
} else { |
// field is hidden |
attr.getMetaData().setKind(null); |
} |
attr.setValue(client.getStaticFieldValue(ttitem, f.getSBMName())); // get and set the field value |
} |
monitor.worked(1); |
//-------------- |
// Custom fields |
//-------------- |
List<SBMField> customfields = client.getFields(client |
.getTableName(ttitem)); |
for (SBMField f : customfields) { |
if (!fieldlist.contains("," + f.getName() + ",")) { |
// do not process custom field when it has not |
// been selected by user in repository settings page |
continue; |
} |
try { |
SBMSystemFields sysfield = SBMSystemFields.valueOf(f.getName()); |
if( sysfield.hasTaskAttribute()) { |
// the field has an equivalent in the task attribute |
// mappings and therefore it can be skipped in the custom |
// fields section |
continue; |
} |
} catch (IllegalArgumentException e) { |
//field is not a system field, do nothing |
} |
monitor.subTask("Read custom field [" + f.getName() + "]"); |
TaskAttribute custom = data.getRoot().createAttribute(f.getName()); |
custom.getMetaData().setType( |
new SBMTicketAttributeMapper(repository).mapToTaskKey(f |
.getType())); |
custom.getMetaData().setLabel(f.getLabel()); |
custom.getMetaData().setKind(TaskAttribute.KIND_DEFAULT); |
custom.getMetaData().setReadOnly(true); |
//set value/ values depending on field type |
// single selection |
if (f.getType() == SBMFieldTypes.SELECTION |
&& client.getFieldValue(ttitem, f.getName()) != null) { |
//List<SBMFieldValue> options = client.getValidSet(client |
// .getTableName(ttitem), f.getName()); |
//for (SBMFieldValue optionvalue : options) { |
// custom.putOption(optionvalue.getInternalValue(), |
// optionvalue.getValue()); |
//} |
String val = client.getFieldValue(ttitem, f.getName()) |
.getValue(); |
custom.setValue(val); |
// Multi-Type fields |
} else if (f.getType() == SBMFieldTypes.MULTIPLE_SELECTION |
|| f.getType() == SBMFieldTypes.MULTIPLE_RELATIONAL |
|| f.getType() == SBMFieldTypes.MULTIPLE_GROUP |
|| f.getType() == SBMFieldTypes.MULTIPLE_USERGROUP) { |
List<SBMFieldValue> values = client.getFieldValues(ttitem, f |
.getName()); |
for (SBMFieldValue val : values) { |
custom.putOption(val.getInternalValue(), val.getValue()); |
custom.addValue(val.getValue()); |
} |
//Date fields |
} else if (f.getType() == SBMFieldTypes.DATETIME) { |
String datestring = client.getFieldValue(ttitem, f.getName()).getValue(); |
long timestamp; |
try { |
timestamp = DatatypeFactory.newInstance().newXMLGregorianCalendar(datestring).toGregorianCalendar().getTimeInMillis(); |
custom.setValue(String.valueOf(timestamp)); |
} catch (DatatypeConfigurationException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} catch (IllegalArgumentException e) { |
//date field is probably empty |
custom.setValue(""); |
} |
// any other field type |
} else if (client.getFieldValue(ttitem, f.getName()) != null) { |
custom.setValue(client.getFieldValue(ttitem, f.getName()) |
.getValue()); |
} |
} |
monitor.worked(1); |
// ---------- |
// Notes |
// ---------- |
monitor.subTask("Read notes."); |
for (SBMNote n : client.getNotes(ttitem)) { |
TaskCommentMapper mapper = new TaskCommentMapper(); |
mapper.setCommentId(n.getId()); |
mapper.setNumber(Integer.valueOf(n.getId())); |
mapper.setText(n.getText()); |
mapper.setCreationDate(n.getCreation()); |
TaskAttribute a = data.getRoot() |
.createAttribute("NOTE" + n.getId()); |
mapper.applyTo(a); |
} |
monitor.worked(1); |
data.setPartial(false); |
return data; |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/model/SBMSystemFields.java |
---|
0,0 → 1,120 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core.model; |
/** |
* System DBFieldnames for SBM/ TeamTrack. |
* |
* @author Brian Rosenberger |
*/ |
public enum SBMSystemFields { |
/** The internal item id in [tableid:recordid] format. */ |
ID("ID", true), |
/** The internal uuid. */ |
UUID("UUID", false), |
/** Whether the item is active or inactive in its current state */ |
ACTIVEINACTIVE("ACTIVEINACTIVE", false), |
/** The date that the item was closed */ |
CLOSEDATE("CLOSEDATE", true), |
/** Used for Partner Access to CRs They Submit */ |
COMPANY("COMPANY", false), |
/** Used for Partner Access to CRs They Submit */ |
CONTACT("CONTACT", false), |
/** Detailed information about the item */ |
DESCRIPTION("DESCRIPTION", true), |
/** The displayed identifier of the item */ |
ISSUEID("ISSUEID", true), |
/** The type of the item */ |
ISSUETYPE("ISSUETYPE", true), |
/** The last time the item's data was changed */ |
LASTMODIFIEDDATE("LASTMODIFIEDDATE", true), |
/** The last person to change the data in this item */ |
LASTMODIFIER("LASTMODIFIER", true), |
/** The last time the state of this item was changed */ |
LASTSTATECHANGEDATE("LASTSTATECHANGEDATE", false), |
/** The last person to change the state of this item */ |
LASTSTATECHANGER("LASTSTATECHANGER", false), |
/** The primary person who currently owns the item */ |
OWNER("OWNER", false), |
/** The project in which this item resides */ |
PROJECTID("PROJECTID", false), |
/** Detailed information about the resolution */ |
RESOLUTIONDESC("RESOLUTIONDESC", false), |
/** Summary description of the resolution */ |
RESOLUTIONSUMMARY("RESOLUTIONSUMMARY", false), |
/** The secondary people who currently own the item */ |
SECONDARYOWNER("SECONDARYOWNER", false), |
/** The current state of the item */ |
STATE("STATE", true), |
/** The date that the item was created/submitted */ |
SUBMITDATE("SUBMITDATE", true), |
/** The person who created/submitted the item */ |
SUBMITTER("SUBMITTER", true), |
/** Summary description of the item */ |
TITLE("TITLE", true); |
private final String value; |
private final boolean hasTaskAttribute; |
SBMSystemFields(String v, boolean hasTaskAttribute) { |
value = v; |
this.hasTaskAttribute = hasTaskAttribute; |
} |
public String getValue() { |
return value; |
} |
public boolean hasTaskAttribute() { |
return this.hasTaskAttribute; |
} |
public static SBMSystemFields fromValue(String v) { |
for (SBMSystemFields c: SBMSystemFields.values()) { |
if (c.value.equals(v)) { |
return c; |
} |
} |
throw new IllegalArgumentException(v); |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/model/SBMFieldValue.java |
---|
0,0 → 1,24 |
package net.brutex.mylyn.sbmconnector.core.model; |
import org.eclipse.core.runtime.Assert; |
public class SBMFieldValue { |
private String internalValue; |
private String value; |
public SBMFieldValue(String internalValue, String value) { |
Assert.isNotNull(internalValue); |
Assert.isNotNull(value); |
this.internalValue = internalValue; |
this.value = value; |
} |
public String getInternalValue() { |
return internalValue; |
} |
public String getValue() { |
return value; |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/model/SBMField.java |
---|
0,0 → 1,139 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core.model; |
// TODO: Auto-generated Javadoc |
/** |
* The Class SBMField. |
* @author Brian Rosenberger, bru@brutex.de |
*/ |
public class SBMField { |
/** The type. */ |
private SBMFieldTypes type; |
/** The value. */ |
private String value; |
/** The internal value. */ |
private Object internalValue; |
/** The parent table. */ |
private String parentTable; |
/** The label. */ |
private String label; |
/** The name. */ |
private String name; |
/** |
* Instantiates a new SBM field. |
* |
* @param type the type |
* @param parentTable the parent table |
* @param label the label |
* @param name the name |
*/ |
public SBMField(SBMFieldTypes type, String parentTable, String label, |
String name) { |
super(); |
this.type = type; |
this.parentTable = parentTable; |
this.label = label; |
this.name = name; |
} |
/** |
* Gets the value. |
* |
* @return the value |
*/ |
public String getValue() { |
return value; |
} |
/** |
* Sets the value. |
* |
* @param value the new value |
*/ |
public void setValue(String value) { |
this.value = value; |
} |
/** |
* Gets the internal value. |
* |
* @return the internal value |
*/ |
public Object getInternalValue() { |
return internalValue; |
} |
/** |
* Sets the internal value. |
* |
* @param internalValue the new internal value |
*/ |
public void setInternalValue(Object internalValue) { |
this.internalValue = internalValue; |
} |
/** |
* Gets the type. |
* |
* @return the type |
*/ |
public SBMFieldTypes getType() { |
return type; |
} |
/** |
* Gets the parent table. |
* |
* @return the parent table |
*/ |
public String getParentTable() { |
return parentTable; |
} |
/** |
* Gets the label. |
* |
* @return the label |
*/ |
public String getLabel() { |
return label; |
} |
/** |
* Gets the name. |
* |
* @return the name |
*/ |
public String getName() { |
return name; |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/model/SBMFieldTypes.java |
---|
0,0 → 1,63 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core.model; |
public enum SBMFieldTypes { |
UNKNOWN("UNKNOWN"), |
NUMERIC("FLDTYPE-NUMERIC"), |
TEXT("FLDTYPE-TEXT"), |
DATETIME("FLDTYPE-DATETIME"), |
SELECTION("FLDTYPE-SELECTION"), |
BINARY("FLDTYPE-BINARY"), |
STATE("FLDTYPE-STATE"), |
USER("FLDTYPE-USER"), |
PROJECT("FLDTYPE-PROJECT"), |
SUMMATION("FLDTYPE-SUMMATION"), |
MULTIPLE_SELECTION("FLDTYPE-MULTIPLE-SELECTION"), |
CONTACT("FLDTYPE-CONTACT"), |
INCIDENT("FLDTYPE-INCIDENT"), |
FOLDER("FLDTYPE-FOLDER"), |
RELATIONAL("FLDTYPE-RELATIONAL"), |
SUBRELATIONAL("FLDTYPE-SUBRELATIONAL"), |
SYSTEM("FLDTYPE-SYSTEM"), |
MULTIPLE_RELATIONAL("FLDTYPE-MULTIPLE-RELATIONAL"), |
MULTIPLE_GROUP("FLDTYPE-MULTIPLE-GROUP"), |
MULTIPLE_USERGROUP("FLDTYPE-MULTIPLE-USERGROUP"); |
private final String value; |
SBMFieldTypes(String v) { |
value = v; |
} |
public String getValue() { |
return value; |
} |
public static SBMFieldTypes fromValue(String v) { |
for (SBMFieldTypes c: SBMFieldTypes.values()) { |
if (c.value.equals(v)) { |
return c; |
} |
} |
throw new IllegalArgumentException(v); |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/model/SBMStaticFields.java |
---|
0,0 → 1,101 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core.model; |
/** |
* Static DBFieldnames for SBM/ TeamTrack system fields |
* which are not intended to be changed by a user directly |
* (auto-resolved by the system). |
* |
* @author Brian Rosenberger |
*/ |
public enum SBMStaticFields { |
/** The internal item id in [tableid:recordid] format. */ |
ID("ID"), |
/** The internal uuid. */ |
UUID("UUID"), |
/** The Constant ISSUEID. */ |
ISSUEID("ISSUEID"), |
/** The project name (integer in DB, but name here). |
* because this is driven by the sbm web service */ |
PROJECTID("PROJECTID"), |
/** The project uuid (not found in primary table). */ |
PROJECTUUID("PROJECTUUID"), |
/** The submitter (id reference, but user login name here). */ |
SUBMITTER("SUBMITTER"), |
/** The submit date/time. */ |
SUBMITDATE("SUBMITDATE"), |
/** The LASTMODIFIEDDATE date/time. */ |
LASTMODIFIEDDATE("LASTMODIFIEDDATE"), |
/** The LASTMODIFIER. */ |
LASTMODIFIER("LASTMODIFIER"), |
/** The ACTIVEINACTIVE flag.*/ |
ACTIVEINACTIVE("ACTIVEINACTIVE"), |
/** The Constant STATE. */ |
STATE("STATE"), |
/** The ITEMURL (not present in DB) */ |
ITEMURL("ITEMURL"), |
/** The owner of an item (id reference, but name here). */ |
OWNER("OWNER"), |
/** The LASTSTATECHANGEDATE. */ |
LASTSTATECHANGEDATE("LASTSTATECHANGEDATE"), |
/** The LASTSTATECHANGER (id reference, but name here). */ |
LASTSTATECHANGER("LASTSTATECHANGER"), |
/** The SECONDARYOWNER (id reference, but name here). */ |
SECONDARYOWNER("SECONDARYOWNER"), |
/** The CLOSEDATE. */ |
CLOSEDATE("CLOSEDATE"); |
private final String value; |
SBMStaticFields(String v) { |
value = v; |
} |
public String getValue() { |
return value; |
} |
public static SBMStaticFields fromValue(String v) { |
for (SBMStaticFields c: SBMStaticFields.values()) { |
if (c.value.equals(v)) { |
return c; |
} |
} |
throw new IllegalArgumentException(v); |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/model/SBMNote.java |
---|
0,0 → 1,69 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core.model; |
import java.util.Date; |
public class SBMNote { |
private String author; |
private String text; |
private Date creation; |
private String id; |
public SBMNote(String author, String text, Date creation, String id) { |
this.author = author; |
this.text = text; |
this.creation = creation; |
this.id = id; |
} |
public String getAuthor() { |
return author; |
} |
public void setAuthor(String author) { |
this.author = author; |
} |
public String getText() { |
return text; |
} |
public void setText(String text) { |
this.text = text; |
} |
public Date getCreation() { |
return creation; |
} |
public void setCreation(Date creation) { |
this.creation = creation; |
} |
public String getId() { |
return id; |
} |
public void setId(String id) { |
this.id = id; |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/model/SBMFieldAttributes.java |
---|
0,0 → 1,46 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core.model; |
public enum SBMFieldAttributes { |
READ_ONLY("read-only"), |
REQUIRED("required"), |
HIDDEN("hidden"); |
private final String value; |
SBMFieldAttributes(String v) { |
value = v; |
} |
public String getValue() { |
return value; |
} |
public static SBMFieldAttributes fromValue(String v) { |
for (SBMFieldAttributes c: SBMFieldAttributes.values()) { |
if (c.value.equals(v)) { |
return c; |
} |
} |
throw new IllegalArgumentException(v); |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/model/package.html |
---|
0,0 → 1,7 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
<html> |
<head></head> |
<body> |
Provides... |
</body> |
</html> |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/SBMTicketAttributeMapper.java |
---|
0,0 → 1,81 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core; |
import net.brutex.mylyn.sbmconnector.core.model.SBMFieldTypes; |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper; |
public class SBMTicketAttributeMapper extends TaskAttributeMapper { |
public SBMTicketAttributeMapper(TaskRepository taskRepository) { |
super(taskRepository); |
} |
@Override |
public String mapToRepositoryKey(TaskAttribute parent, String key) { |
SBMTicketAttribute attribute = SBMTicketAttribute.getSBMAttributeByTaskName(key); |
if(attribute != null) { |
return attribute.getSBMName(); |
} |
return super.mapToRepositoryKey(parent, key); //just returns key |
} |
@Override |
public TaskAttribute getAssoctiatedAttribute(TaskAttribute taskAttribute) { |
return super.getAssoctiatedAttribute(taskAttribute); |
} |
/** |
* Map SBM field type to task field type. This mapping is a hint only because |
* SBM allows fields to have a type and subtype, but the subtype is not returned |
* by the SBM web service. |
* |
* @param sbmtype the SBM field type (unfortunately without field subtype) |
* @return the mylyn task field type |
*/ |
public String mapToTaskKey(SBMFieldTypes sbmtype) { |
String tasktype = TaskAttribute.TYPE_SHORT_TEXT; |
switch(sbmtype) { |
case NUMERIC: tasktype = TaskAttribute.TYPE_LONG; break; |
case TEXT: tasktype = TaskAttribute.TYPE_LONG_TEXT; break; |
case DATETIME: tasktype = TaskAttribute.TYPE_DATETIME; break; |
case SELECTION: tasktype = TaskAttribute.TYPE_SINGLE_SELECT; break; |
case BINARY: tasktype = TaskAttribute.TYPE_BOOLEAN; break; |
case STATE: tasktype = TaskAttribute.TYPE_SINGLE_SELECT; break; |
case USER: tasktype = TaskAttribute.TYPE_PERSON; break; |
case PROJECT: tasktype = TaskAttribute.TYPE_SINGLE_SELECT; break; |
case SUMMATION: tasktype = TaskAttribute.TYPE_INTEGER; break; |
case MULTIPLE_SELECTION: tasktype = TaskAttribute.TYPE_MULTI_SELECT; break; |
case CONTACT: tasktype = TaskAttribute.TYPE_PERSON; break; |
case INCIDENT: tasktype = TaskAttribute.TYPE_TASK_DEPENDENCY; break; |
case FOLDER: tasktype = TaskAttribute.TYPE_SINGLE_SELECT; break; |
case RELATIONAL: tasktype = TaskAttribute.TYPE_SINGLE_SELECT; break; |
case SUBRELATIONAL: tasktype = TaskAttribute.TYPE_SHORT_TEXT; break; |
case SYSTEM: tasktype = TaskAttribute.TYPE_SHORT_TEXT; break; |
case MULTIPLE_RELATIONAL: tasktype = TaskAttribute.TYPE_MULTI_SELECT; break; |
case MULTIPLE_GROUP: tasktype = TaskAttribute.TYPE_MULTI_SELECT; break; |
case MULTIPLE_USERGROUP: tasktype = TaskAttribute.TYPE_MULTI_SELECT; break; |
} |
return tasktype; |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/SBMTaskDataCollector.java |
---|
0,0 → 1,53 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core; |
import java.util.HashSet; |
import java.util.Set; |
import org.eclipse.mylyn.tasks.core.data.TaskData; |
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector; |
public class SBMTaskDataCollector extends TaskDataCollector { |
final Set<TaskData> taskDataCollected = new HashSet<TaskData>(); |
String queryTimestamp = null; |
@Override |
public void accept(TaskData taskData) { |
taskDataCollected.add(taskData); |
} |
public Set<TaskData> getTaskData() { |
return taskDataCollected; |
} |
public String getQueryTimestamp() { |
return queryTimestamp; |
} |
public void setQueryTimestamp(String queryTimestamp) { |
this.queryTimestamp = queryTimestamp; |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/SBMTicket.java |
---|
0,0 → 1,35 |
/* |
* Mylyn Connector for Serena Business Mashups |
* Copyright 2010 Brian Rosenberger (Brutex Network) |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
* |
* Serena, TeamTrack and Serena Business Mashup are |
* registered trademarks of SERENA Software Inc. |
*/ |
package net.brutex.mylyn.sbmconnector.core; |
import org.eclipse.mylyn.tasks.core.data.TaskData; |
import org.eclipse.mylyn.tasks.core.data.TaskMapper; |
public class SBMTicket extends TaskMapper { |
public SBMTicket(TaskData taskData) { |
super(taskData); |
} |
} |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/sbm4mylyn/branches/V2009R2-maintenance/src/net/brutex/mylyn/sbmconnector/core/package.html |
---|
0,0 → 1,7 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
<html> |
<head></head> |
<body> |
Provides... |
</body> |
</html> |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |