24,10 → 24,8 |
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; |
65,7 → 63,6 |
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. |
105,13 → 102,9 |
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. |
* by submit date descending. |
* |
* @param tablename the tablename |
* @param sql_where the sql_where |
118,10 → 111,8 |
* @return the tT items by table |
* @throws CoreException the core exception |
*/ |
public List<TTItem> getTTItemsByTable(String tablename, String sql_where, boolean getFullData) throws CoreException { |
public List<TTItem> getTTItemsByTable(String tablename, String sql_where) 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( |
128,35 → 119,16 |
getAuth(), |
tablename, |
"("+sql_where+")", |
"TS_ID desc", |
null, |
sections); |
"TS_SUBMITDATE desc", |
BigInteger.valueOf(500l), null); |
} catch (AEWebservicesFaultFault e) { |
throw new CoreException( |
new CoreException( |
RepositoryStatus.createInternalError( |
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e)); |
} |
SBMConnectorPlugin.PLUGIN_ID, e.getFaultInfo(), 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]) |
* |
164,11 → 136,6 |
* @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); |
329,7 → 296,7 |
break; |
} |
} |
return fieldname; //field has not been found |
return "label_UNKNOWN"; |
} |
|
/** |
487,7 → 454,6 |
} |
|
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+")"; |
501,7 → 467,7 |
for(TTItem ttitem : ttlist) { |
list.add(getFieldValue(ttitem, fieldname)); |
} |
validsets.put(tablename+":"+fieldname, list); |
|
return list; |
} |
} |