use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class GetOperationsCommand method doGet.
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Project project = getProject(request);
HistoryEntries entries = new HistoryEntries(project.history.getLastPastEntries(-1));
respondJSON(response, entries);
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class SplitMultiValueCellsCommand method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!hasValidCSRFToken(request)) {
respondCSRFError(response);
return;
}
try {
Project project = getProject(request);
String columnName = request.getParameter("columnName");
String keyColumnName = request.getParameter("keyColumnName");
String separator = request.getParameter("separator");
String mode = request.getParameter("mode");
Boolean regex = Boolean.parseBoolean(request.getParameter("regex"));
AbstractOperation op;
if ("lengths".equals(mode)) {
String s = request.getParameter("fieldLengths");
int[] fieldLengths = ParsingUtilities.mapper.readValue(s, new TypeReference<int[]>() {
});
op = new MultiValuedCellSplitOperation(columnName, keyColumnName, fieldLengths);
} else {
op = new MultiValuedCellSplitOperation(columnName, keyColumnName, separator, regex);
}
Process process = op.createProcess(project, new Properties());
performProcessAndRespond(request, response, project, process);
} catch (Exception e) {
respondException(response, e);
}
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class RemoveColumnCommand method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!hasValidCSRFToken(request)) {
respondCSRFError(response);
return;
}
try {
Project project = getProject(request);
String columnName = request.getParameter("columnName");
AbstractOperation op = new ColumnRemovalOperation(columnName);
Process process = op.createProcess(project, new Properties());
performProcessAndRespond(request, response, project, process);
} catch (Exception e) {
respondException(response, e);
}
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class ExportProjectCommand method doPost.
/**
* This command uses POST but is left CSRF-unprotected as it does not incur a state change.
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
Project project = getProject(request);
ProjectManager.singleton.ensureProjectSaved(project.id);
response.setHeader("Content-Type", "application/x-gzip");
OutputStream os = response.getOutputStream();
try {
FileProjectManager.gzipTarToOutputStream(project, os);
} finally {
os.close();
}
} catch (Exception e) {
respondException(response, e);
}
}
use of com.google.refine.model.Project 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);
}
response.setHeader("Cache-Control", "no-cache");
Map<String, LanguageInfo> prefixesMap = new HashMap<>();
for (String languagePrefix : MetaParser.getLanguagePrefixes()) {
LanguageInfo info = MetaParser.getLanguageInfo(languagePrefix);
prefixesMap.put(languagePrefix, info);
}
Map<String, HttpHeaderInfo> headersMap = new HashMap<>();
for (String headerLabel : HttpHeadersSupport.getHttpHeaderLabels()) {
HttpHeaderInfo info = HttpHeadersSupport.getHttpHeaderInfo(headerLabel);
headersMap.put(headerLabel, info);
}
respondJSON(response, new ModelsResponse(project.columnModel, project.recordModel, project.overlayModels, prefixesMap, headersMap));
}
Aggregations