Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 38 → Rev 39

/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMClient.java
24,8 → 24,10
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;
63,6 → 65,7
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.
102,9 → 105,13
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 submit date descending.
* by TS_ID descending.
*
* @param tablename the tablename
* @param sql_where the sql_where
111,8 → 118,10
* @return the tT items by table
* @throws CoreException the core exception
*/
public List<TTItem> getTTItemsByTable(String tablename, String sql_where) throws CoreException {
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(
119,16 → 128,35
getAuth(),
tablename,
"("+sql_where+")",
"TS_SUBMITDATE desc",
BigInteger.valueOf(500l), null);
"TS_ID desc",
null,
sections);
} catch (AEWebservicesFaultFault e) {
new CoreException(
throw new CoreException(
RepositoryStatus.createInternalError(
SBMConnectorPlugin.PLUGIN_ID, e.getFaultInfo(), e));
}
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
}
return list;
}
public int getResultCount(String tablename, String sql) throws CoreException {
List<TTItem> list = new ArrayList<TTItem>();
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));
}
return list.size();
}
/**
* Gets a SBM item specified by its internal identifier ([tableid:recordid])
*
136,6 → 164,11
* @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);
296,7 → 329,7
break;
}
}
return "label_UNKNOWN";
return fieldname; //field has not been found
}
/**
454,6 → 487,7
}
 
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+")";
467,7 → 501,7
for(TTItem ttitem : ttlist) {
list.add(getFieldValue(ttitem, fieldname));
}
validsets.put(tablename+":"+fieldname, list);
return list;
}
}