Search in sources :

Example 1 with TransposeColumnsIntoRowsOperation

use of com.google.refine.operations.cell.TransposeColumnsIntoRowsOperation in project OpenRefine by OpenRefine.

the class TransposeColumnsIntoRowsCommand method doPost.

@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try {
        Project project = getProject(request);
        AbstractOperation op;
        String startColumnName = request.getParameter("startColumnName");
        int columnCount = Integer.parseInt(request.getParameter("columnCount"));
        boolean ignoreBlankCells = Boolean.parseBoolean(request.getParameter("ignoreBlankCells"));
        boolean fillDown = Boolean.parseBoolean(request.getParameter("fillDown"));
        String combinedColumnName = request.getParameter("combinedColumnName");
        if (combinedColumnName != null) {
            boolean prependColumnName = Boolean.parseBoolean(request.getParameter("prependColumnName"));
            String separator = request.getParameter("separator");
            op = new TransposeColumnsIntoRowsOperation(startColumnName, columnCount, ignoreBlankCells, fillDown, combinedColumnName, prependColumnName, separator);
        } else {
            String keyColumnName = request.getParameter("keyColumnName");
            String valueColumnName = request.getParameter("valueColumnName");
            op = new TransposeColumnsIntoRowsOperation(startColumnName, columnCount, ignoreBlankCells, fillDown, keyColumnName, valueColumnName);
        }
        Process process = op.createProcess(project, new Properties());
        performProcessAndRespond(request, response, project, process);
    } catch (Exception e) {
        respondException(response, e);
    }
}
Also used : Project(com.google.refine.model.Project) TransposeColumnsIntoRowsOperation(com.google.refine.operations.cell.TransposeColumnsIntoRowsOperation) AbstractOperation(com.google.refine.model.AbstractOperation) Process(com.google.refine.process.Process) Properties(java.util.Properties) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Aggregations

AbstractOperation (com.google.refine.model.AbstractOperation)1 Project (com.google.refine.model.Project)1 TransposeColumnsIntoRowsOperation (com.google.refine.operations.cell.TransposeColumnsIntoRowsOperation)1 Process (com.google.refine.process.Process)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 ServletException (javax.servlet.ServletException)1