merged -r1409:1414 from stabilization to func_type_check
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_stabilization_func_type_check@1415 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
index 58c896d..894747c 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
@@ -313,7 +313,17 @@
}
response.put("results", results);
}
- out.print(response);
+ switch (pdf) {
+ case HTML:
+ out.println("<pre>");
+ ResultUtils.prettyPrintHTML(out, response);
+ out.println("</pre>");
+ break;
+ case TEXT:
+ case JSON:
+ out.print(response);
+ break;
+ }
}
hcc.waitForCompletion(jobId);
}
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultUtils.java b/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultUtils.java
index e923821..dec3128 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultUtils.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/result/ResultUtils.java
@@ -15,6 +15,7 @@
package edu.uci.ics.asterix.result;
import java.io.IOException;
+import java.io.PrintWriter;
import java.nio.ByteBuffer;
import org.json.JSONArray;
@@ -62,4 +63,20 @@
}
return errorResp;
}
+
+ public static void prettyPrintHTML(PrintWriter out, JSONObject jsonResultObj) {
+ JSONArray resultsWrapper;
+ JSONArray resultsArray;
+ try {
+ resultsWrapper = jsonResultObj.getJSONArray("results");
+ for (int i = 0; i < resultsWrapper.length(); i++) {
+ resultsArray = resultsWrapper.getJSONArray(i);
+ for (int j = 0; j < resultsArray.length(); j++) {
+ out.print(resultsArray.getString(j));
+ }
+ }
+ } catch (JSONException e) {
+ // TODO(madhusudancs): Figure out what to do when JSONException occurs while building the results.
+ }
+ }
}