use of com.intuit.quickbase.util.QuickBaseClient 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();
}
}
}
use of com.intuit.quickbase.util.QuickBaseClient in project opennms by OpenNMS.
the class QuickBaseTicketerPlugin method saveOrUpdate.
public void saveOrUpdate(Ticket ticket) {
try {
Properties props = getProperties();
QuickBaseClient qdb = createClient(getUserName(props), getPassword(props), getUrl(props));
String dbId = qdb.findDbByName(getApplicationName(props));
HashMap<String, String> record = new HashMap<String, String>();
record.put(getSummaryField(props), ticket.getSummary());
record.put(getDetailsField(props), ticket.getDetails());
record.put(getStateField(props), getQuickBaseStateValue(ticket.getState(), props));
if (ticket.getId() == null) {
addAdditionCreationFields(record, props);
String recordId = qdb.addRecord(dbId, record);
ticket.setId(recordId);
} else {
Ticket oldTicket = get(ticket.getId());
if (ticket.getModificationTimestamp().equals(oldTicket.getModificationTimestamp())) {
qdb.editRecord(dbId, record, ticket.getId());
} else {
throw new OptimisticLockingFailureException("Ticket has been updated while this ticket was in memory! Reload and try again!");
}
}
} catch (Throwable e) {
throw new DataRetrievalFailureException("Failed to commit QuickBase transaction: " + e.getMessage(), e);
}
}
use of com.intuit.quickbase.util.QuickBaseClient in project opennms by OpenNMS.
the class QuickBaseAPITest method testCreateTicket.
public void testCreateTicket() throws QuickBaseException, Exception {
QuickBaseClient qdb = createClient();
String appName = "TPMG Support";
String dbId = qdb.findDbByName(appName);
System.out.println("dbId for " + appName + " is " + dbId);
HashMap record = new HashMap();
record.put("request_type", "OpenNMS Alarm");
record.put("summary", "ticket summary");
record.put("description", "ticket details");
record.put("status", "Reported");
String recordId = qdb.addRecord(dbId, record);
System.out.println("record Id is " + recordId);
}
Aggregations