use of com.google.refine.model.OverlayModel in project OpenRefine by OpenRefine.
the class GetModelsCommand method internalRespond.
protected void internalRespond(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Project project = null;
// This command also supports retrieving rows for an importing job.
String importingJobID = request.getParameter("importingJobID");
if (importingJobID != null) {
long jobID = Long.parseLong(importingJobID);
ImportingJob job = ImportingManager.getJob(jobID);
if (job != null) {
project = job.project;
}
}
if (project == null) {
project = getProject(request);
}
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Type", "application/json");
response.setHeader("Cache-Control", "no-cache");
Properties options = new Properties();
JSONWriter writer = new JSONWriter(response.getWriter());
writer.object();
writer.key("columnModel");
project.columnModel.write(writer, options);
writer.key("recordModel");
project.recordModel.write(writer, options);
writer.key("overlayModels");
writer.object();
for (String modelName : project.overlayModels.keySet()) {
OverlayModel overlayModel = project.overlayModels.get(modelName);
if (overlayModel != null) {
writer.key(modelName);
project.overlayModels.get(modelName).write(writer, options);
}
}
writer.endObject();
writer.key("scripting");
writer.object();
for (String languagePrefix : MetaParser.getLanguagePrefixes()) {
LanguageInfo info = MetaParser.getLanguageInfo(languagePrefix);
writer.key(languagePrefix);
writer.object();
writer.key("name");
writer.value(info.name);
writer.key("defaultExpression");
writer.value(info.defaultExpression);
writer.endObject();
}
writer.endObject();
writer.endObject();
} catch (JSONException e) {
HttpUtilities.respondException(response, e);
}
}
Aggregations