List of usage examples for com.google.gwt.json.client JSONObject containsKey
public native boolean containsKey(String key) ;
From source file:com.audata.client.admin.RecTypeHandler.java
License:Open Source License
/** * Extracts data from JSONObject and added * it to parent//from w w w. j av a2 s. c o m * @param types A JSON array of Record Types */ private void addRecTypes(JSONArray types) { for (int i = 0; i < types.size(); i++) { JSONObject rtype = types.get(i).isObject(); if (rtype != null) { String name = ""; if (rtype.containsKey("Name")) { name = rtype.get("Name").isString().stringValue(); } String uuid = ""; if (rtype.containsKey("uuid")) { uuid = rtype.get("uuid").isString().stringValue(); } String desc = ""; if (rtype.containsKey("Description")) { desc = rtype.get("Description").isString().stringValue(); } ArrayList udfs = new ArrayList(); if (rtype.containsKey("UDFs")) { JSONArray us = rtype.get("UDFs").isArray(); if (us != null) { for (int j = 0; j < us.size(); j++) { JSONObject u = us.get(j).isObject(); if (u != null) { if (u.containsKey("Name")) { udfs.add(u.get("Name").isString().stringValue()); } } } } } this.parent.addRecType(uuid, name, desc, udfs); } } }
From source file:com.audata.client.admin.RecTypeUDFHandler.java
License:Open Source License
/** * Extract data from the parsed response and add * it to the parent panel//from w ww . j a va 2 s .c o m * @param udfs An JSONArray of UDFDefinition */ private void addUDFs(JSONArray udfs) { String[] names = new String[udfs.size()]; for (int i = 0; i < udfs.size(); i++) { JSONObject udf = udfs.get(i).isObject(); if (udf != null) { String name = ""; if (udf.containsKey("Name")) { name = udf.get("Name").isString().stringValue(); } names[i] = name; } } this.parent.addUDFs(names); }
From source file:com.audata.client.admin.UDFResponseHandler.java
License:Open Source License
private void update(JSONArray udfs) { for (int i = 0; i < udfs.size(); i++) { JSONObject udf = udfs.get(i).isObject(); String uuid = ""; if (udf.containsKey("uuid")) { uuid = udf.get("uuid").isString().stringValue(); }/*from ww w. ja v a 2s . c om*/ String name = ""; if (udf.containsKey("Name")) { name = udf.get("Name").isString().stringValue(); } int type = 0; if (udf.containsKey("Type")) { type = (int) udf.get("Type").isNumber().getValue(); } String kwh = null; if (udf.containsKey("KeywordHierarchy")) { kwh = udf.get("KeywordHierarchy").isString().stringValue(); } this.parent.addUDF(uuid, name, type, kwh); } }
From source file:com.audata.client.admin.UserResponseHandler.java
License:Open Source License
private void addUsers(JSONArray users) { if (users != null) { for (int i = 0; i < users.size(); i++) { JSONObject user = (JSONObject) users.get(i); String fname = ""; if (user.containsKey("Forename")) { fname = user.get("Forename").isString().stringValue(); }//from w ww. ja v a2s.c o m String sname = ""; if (user.containsKey("Surname")) { sname = user.get("Surname").isString().stringValue(); } String uuid = ""; if (user.containsKey("uuid")) { uuid = user.get("uuid").isString().stringValue(); } String uname = ""; if (user.containsKey("UserName")) { uname = user.get("UserName").isString().stringValue(); } boolean isAdmin = false; if (user.containsKey("isAdmin")) { isAdmin = user.get("isAdmin").isBoolean().booleanValue(); } String secLevel = ""; if (user.containsKey("SecLevel")) { secLevel = user.get("SecLevel").isString().stringValue(); } ArrayList caveats = new ArrayList(); if (user.containsKey("Caveats")) { JSONArray cavs = user.get("Caveats").isArray(); for (int j = 0; j < cavs.size(); j++) { JSONObject cav = cavs.get(j).isObject(); String c = cav.get("Name").isString().stringValue(); caveats.add(c); } } this.parent.addUser(uuid, fname, sname, uname, isAdmin, secLevel, caveats); } } }
From source file:com.audata.client.newRecord.NewRecordResponseHandler.java
License:Open Source License
public void onResponseReceived(Request request, Response response) { JSONObject jObj = this.parseJSON(response); if (jObj.containsKey("result")) { JSONObject result = jObj.get("result").isObject(); if (result != null) { String uuid = result.get("uuid").isString().stringValue(); if (this.filename.equals("")) { // no upload -> go straight to form this.wizard.reset(); } else { // upload the file this.upload.submit(uuid); }/*from w w w. j a v a2s . c o m*/ } } }
From source file:com.audata.client.newRecord.RecTypeResponseHandler.java
License:Open Source License
private void addRecTypes(JSONArray types) { for (int i = 0; i < types.size(); i++) { JSONObject rtype = types.get(i).isObject(); if (rtype != null) { String name = ""; if (rtype.containsKey("Name")) { name = rtype.get("Name").isString().stringValue(); }//from w ww. j ava 2 s. c o m String uuid = ""; if (rtype.containsKey("uuid")) { uuid = rtype.get("uuid").isString().stringValue(); } String desc = ""; if (rtype.containsKey("Description")) { desc = rtype.get("Description").isString().stringValue(); } ArrayList udfs = new ArrayList(); if (rtype.containsKey("UDFs")) { JSONArray us = rtype.get("UDFs").isArray(); if (us != null) { for (int j = 0; j < us.size(); j++) { JSONObject u = us.get(j).isObject(); if (u != null) { String uName = ""; if (u.containsKey("Name")) { uName = u.get("Name").isString().stringValue(); } int type = FieldTypes.TYPE_STRING; if (u.containsKey("Type")) { Double t = new Double(u.get("Type").isNumber().getValue()); type = t.intValue(); } String kwh = null; if (type == 4) { kwh = u.get("KeywordHierarchy").isString().stringValue(); } udfs.add(new Field(uName, type, true, kwh)); } } } } this.parent.addRecType(uuid, name, desc, udfs); } } }
From source file:com.audata.client.rapidbooking.UserResponseHandler.java
License:Open Source License
private void addUsers(JSONArray users) { if (users != null) { for (int i = 0; i < users.size(); i++) { JSONObject user = (JSONObject) users.get(i); String fname = ""; if (user.containsKey("Forename")) { fname = user.get("Forename").isString().stringValue(); }// w ww . j a v a2s. c om String sname = ""; if (user.containsKey("Surname")) { sname = user.get("Surname").isString().stringValue(); } String uname = ""; if (user.containsKey("UserName")) { uname = user.get("UserName").isString().stringValue(); } this.parent.addUser(uname, fname, sname); } } }
From source file:com.audata.client.record.RecordListPanel.java
License:Open Source License
protected void addRecords(JSONArray records) { for (int i = 0; i < records.size(); i++) { JSONObject rObj = records.get(i).isObject(); HashMap custom = new HashMap(); String uuid = rObj.get("uuid").isString().stringValue(); String title = rObj.get("Title").isString().stringValue(); String cls = rObj.get("ClassPath").isString().stringValue(); String cot = ""; if (rObj.containsKey("CheckedOutTo")) { cot = rObj.get("CheckedOutTo").isString().stringValue(); }// ww w . ja va 2s.c om String checkDate = rObj.get("CheckedOutDate").isString().stringValue(); String date = rObj.get("DateCreated").isString().stringValue(); String recNum = rObj.get("RecordNumber").isString().stringValue(); String recType = rObj.get("RecordType").isString().stringValue(); Double documents = new Double(rObj.get("Documents").isNumber().getValue()); //invotec specific bit String user1 = AuDoc.getConfigItem("user1"); if (user1.equals("binnum")) { JSONArray udfs = rObj.get("UDFs").isArray(); for (int j = 0; j < udfs.size(); j++) { JSONObject u = udfs.get(j).isObject(); String name = u.get("Name").isString().stringValue(); if (name.equals("Bin Number")) { Double b = new Double(u.get("Value").isNumber().getValue()); cls = "Bin Number: " + b.intValue(); } if (name.equals("MBin Number")) { Double b = new Double(u.get("Value").isNumber().getValue()); cls = "MBin Number: " + b.intValue(); } } } date = date.substring(0, 10); custom.put("uuid", uuid); custom.put("Title", title); custom.put("class", cls); custom.put("DateCreated", date); custom.put("CheckedOutTo", cot); custom.put("CheckedOutDate", checkDate); custom.put("RecordNumber", recNum); custom.put("RecordType", recType); custom.put("Documents", documents); String[] cap = new String[4]; cap[0] = title; cap[1] = recNum; cap[2] = cls; if (!cot.equals("")) { cap[3] = cot; } else { cap[3] = LANG.no_one_Text(); } this.rList.addItem(cap, null, custom); } }
From source file:com.audata.client.record.RecTypeCallback.java
License:Open Source License
public void onResponseReceived(Request request, Response response) { JSONObject rObj = this.parseJSON(response); if (rObj != null) { JSONObject rType = rObj.get("result").isObject(); if ((rType != null) && (rType.containsKey("UDFs"))) { JSONArray udfs = rType.get("UDFs").isArray(); Field[] ret = new Field[udfs.size()]; for (int i = 0; i < udfs.size(); i++) { JSONObject u = udfs.get(i).isObject(); String name = u.get("Name").isString().stringValue(); int type = (int) u.get("Type").isNumber().getValue(); String kwh = null; if (type == FieldTypes.TYPE_KEYWORD) { kwh = u.get("KeywordHierarchy").isString().stringValue(); }//from ww w . j a v a2 s.co m ret[i] = new Field(name, type, true, kwh); } this.parent.addUdfs(ret); } } this.parent.paint(); }
From source file:com.audata.client.search.UDFResponseHandler.java
License:Open Source License
public void onResponseReceived(Request request, Response response) { JSONObject jObj = this.parseJSON(response); if (jObj != null) { JSONArray udfs = jObj.get("result").isArray(); if (udfs != null) { for (int i = 0; i < udfs.size(); i++) { JSONObject u = udfs.get(i).isObject(); if (u != null) { String name = u.get("Name").isString().stringValue(); int type = new Double(u.get("Type").isNumber().getValue()).intValue(); String kwh = null; if (u.containsKey("KeywordHierarchy")) { kwh = u.get("KeywordHierarchy").isString().stringValue(); }//w ww . j a va 2s . c om this.parent.addField(name, name, type, true, kwh); } } } } }