use of com.intuit.quickbase.util.QuickBaseException in project opennms by OpenNMS.
the class QuickBaseAPITest method XXXtestCreateLead.
public void XXXtestCreateLead() {
PrintWriter out = null;
try {
out = new PrintWriter(System.out);
out.println("Welcome to QuickBase\n");
QuickBaseClient qdb = createClient();
qdb.findDbByName("TPMG Support");
HashMap tables = (HashMap) qdb.grantedDBs(false, false, true);
if (tables == null) {
out.println("No tables belong to this user.");
}
Set tableNames = tables.keySet();
String tableName = "";
String tableDbid = "";
for (Iterator it = tableNames.iterator(); it.hasNext(); ) {
tableName = (String) it.next();
tableDbid = (String) tables.get(tableName);
out.println("Name: " + tableName + " DBID: " + tableDbid);
Document schema = qdb.getSchema(tableDbid);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(new DOMSource(schema), new StreamResult(out));
NodeList fields = schema.getElementsByTagName("field");
out.println("The QuickBase application " + tableName + " has " + fields.getLength() + " fields.");
out.println("The fields are listed below.");
for (int i = 0; i < fields.getLength(); i++) {
out.println("Field ID: " + fields.item(i).getAttributes().getNamedItem("id").getNodeValue());
out.println("Field Type: " + fields.item(i).getAttributes().getNamedItem("type").getNodeValue());
out.println("Field Label: " + fields.item(i).getChildNodes().item(0).getNodeValue());
}
}
} catch (QuickBaseException qdbe) {
System.err.println("Exception in main " + qdbe.toString() + " error code: " + qdbe.getErrorCode());
qdbe.printStackTrace();
} catch (Throwable e) {
System.err.println("Exception in main " + e.toString());
e.printStackTrace();
} finally {
if (null != out) {
out.flush();
out.close();
}
}
}
Aggregations