Subversion Repositories XServices

Compare Revisions

Regard whitespace Rev 31 → Rev 30

/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/model/SBMFieldValue.java
File deleted
Property changes:
Deleted: svn:mime-type
-text/plain
\ No newline at end of property
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/model/SBMField.java
File deleted
Property changes:
Deleted: svn:mime-type
-text/plain
\ No newline at end of property
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/model/SBMFieldTypes.java
21,25 → 21,25
 
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");
NUMERIC("NUMERIC"),
TEXT("TEXT"),
DATETIME("DATETIME"),
SELECTION("SELECTION"),
BINARY("BINARY"),
STATE("STATE"),
USER("USER"),
PROJECT("PROJECT"),
SUMMATION("SUMMATION"),
MULTIPLE_SELECTION("MULTIPLE-SELECTION"),
CONTACT("CONTACT"),
INCIDENT("INCIDENT"),
FOLDER("FOLDER"),
RELATIONAL("RELATIONAL"),
SUBRELATIONAL("SUBRELATIONAL"),
SYSTEM("SYSTEM"),
MULTIPLE_RELATIONAL("MULTIPLE-RELATIONAL"),
MULTIPLE_GROUP("MULTIPLE-GROUP"),
MULTIPLE_USERGROUP("MULTIPLE-USERGROUP");
 
private final String value;
 
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMClient.java
32,9 → 32,6
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;
48,7 → 45,6
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;
128,14 → 124,7
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) {
public String getFieldValue(TTItem ttitem, String fieldname) {
if(fieldname.equals(SBMStaticFields.SUBMITDATE.getValue())) {
Date date = ttitem.getCreateDate().getValue().toGregorianCalendar().getTime();
return String.valueOf(date.getTime());
242,10 → 231,20
return "UNKNOWN";
}
//Todo caching
public String getFieldLabel(TTItem ttitem, String fieldname) {
refreshTables();
String itemid = ttitem.getGenericItem().getValue().getItemID().getValue();
String tableid = new StringTokenizer(itemid, ":").nextToken();
if (tables.isEmpty()) {
try {
tables = port.getTables(getAuth(), null, TableType.PRIMARY_TABLE);
} catch (AEWebservicesFaultFault e) {
new CoreException(
RepositoryStatus.createInternalError(
SBMConnectorPlugin.PLUGIN_ID, e.getFaultInfo(), e));
}
}
for (TableData table : tables) {
if (String.valueOf(table.getTableID().intValue()).equals(tableid)) {
Iterator<Field> iter = table.getFieldList().iterator();
261,24 → 260,6
return "label_UNKNOWN";
}
/**
* 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;
}
public List<SBMNote> getNotes(TTItem ttitem) {
List<SBMNote> notes = new ArrayList<SBMNote>();
Iterator<Note> iter = ttitem.getNoteList().iterator();
293,31 → 274,10
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(
325,87 → 285,9
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);
table_names.add(table.getName().getValue());
}
break;
return table_names;
}
}
return fields;
}
/**
* Gets the field value for custom defined field.
* (those from &lt;extendedFieldList&gt;)
*
* @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 &lt;extendedFieldList&gt;)
*
* @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;
}
}
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMTicketAttribute.java
160,7 → 160,7
return this.visible;
}
public static SBMTicketAttribute getSBMAttributeBySBMName(String sbm_fieldname) {
public static SBMTicketAttribute getSBMAttributeByName(String sbm_fieldname) {
for (SBMTicketAttribute attribute : values()) {
if (sbm_fieldname.equals(attribute.getSBMName())) {
return attribute;
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMRepositoryConnector.java
189,12 → 189,6
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;
}
 
}
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMTicketDataHandler.java
19,14 → 19,9
*/
package net.brutex.mylyn.sbmconnector.core;
 
import java.util.List;
import java.util.Set;
 
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.sbm.wsclient.TTItem;
126,7 → 121,6
*/
public TaskData convert(TaskRepository repository, TTItem ttitem, IProgressMonitor monitor)
throws CoreException {
SBMClient client = SBMRepositoryConnector.getClient(repository);
TaskData data = new TaskData(new SBMTicketAttributeMapper(repository),
SBMConnectorPlugin.CONNECTOR_KIND,
repository.getRepositoryUrl(),
147,48 → 141,24
attr.getMetaData().setReadOnly(false);
}
attr.getMetaData().setType(f.getTaskType());
attr.getMetaData().setLabel(client.getFieldLabel(ttitem, f.getSBMName()));
attr.getMetaData().setLabel(SBMRepositoryConnector.getClient(repository).getFieldLabel(ttitem, f.getSBMName()));
if(f.isVisible()) {
attr.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
} else {
attr.getMetaData().setKind(null);
}
attr.setValue(client.getStaticFieldValue(ttitem, f.getSBMName()));
attr.setValue(SBMRepositoryConnector.getClient(repository).getFieldValue(ttitem, f.getSBMName()));
}
//Custom fields
List<SBMField> customfields = client.getFields(client.getTableName(ttitem));
for(SBMField f : customfields) {
if(SBMTicketAttribute.getSBMAttributeBySBMName(f.getName())!=null) {
continue;
}
TaskAttribute custom = data.getRoot().createAttribute(f.getName());
custom.getMetaData().setType(
new SBMTicketAttributeMapper(repository).mapToTaskKey(f.getType()));
custom.getMetaData().setLabel(f.getLabel());
TaskAttribute custom = data.getRoot().createAttribute("BLIBLABLUB");
custom.getMetaData().setType(TaskAttribute.TYPE_BOOLEAN);
custom.getMetaData().setLabel("BIILLALLLLLLLL");
custom.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
custom.getMetaData().setReadOnly(true);
if(f.getType()==SBMFieldTypes.SELECTION &&
client.getFieldValue(ttitem, f.getName())!=null) {
String val = client.getFieldValue(ttitem, f.getName()).getValue();
custom.putOption(val, val);
custom.setValue(val);
} 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());
}
} else if(client.getFieldValue(ttitem, f.getName())!=null) {
custom.setValue(client.getFieldValue(ttitem, f.getName()).getValue());
}
}
custom.setValue("roger");
//Notes
for(SBMNote n : client.getNotes(ttitem)) {
for(SBMNote n : SBMRepositoryConnector.getClient(repository).getNotes(ttitem)) {
TaskCommentMapper mapper = new TaskCommentMapper();
mapper.setCommentId(n.getId());
mapper.setNumber(Integer.valueOf(n.getId()));
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMTicketAttributeMapper.java
19,8 → 19,6
*/
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;
42,40 → 40,7
@Override
public TaskAttribute getAssoctiatedAttribute(TaskAttribute taskAttribute) {
// TODO Auto-generated method stub
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;
}
}