Package com.google.refine.model

Examples of com.google.refine.model.Column


    //helper methods

    protected void CreateColumns(int noOfColumns){
        for(int i = 0; i < noOfColumns; i++){
            try {
                project.columnModel.addColumn(i, new Column(i, "column" + i), true);
            } catch (ModelException e1) {
                Assert.fail("Could not create column");
            }
        }
    }
View Full Code Here


    //helper methods

    protected void CreateColumns(int noOfColumns){
        for(int i = 0; i < noOfColumns; i++){
            try {
                project.columnModel.addColumn(i, new Column(i, "column" + i), true);
            } catch (ModelException e1) {
                Assert.fail("Could not create column");
            }
        }
    }
View Full Code Here

    //helper methods

    protected void CreateColumns(int noOfColumns){
        for(int i = 0; i < noOfColumns; i++){
            try {
                project.columnModel.addColumn(i, new Column(i, "column" + i), true);
                project.columnModel.columns.get(i).getCellIndex();
            } catch (ModelException e1) {
                Assert.fail("Could not create column");
            }
        }
View Full Code Here

    //helper methods

    protected void CreateColumns(int noOfColumns){
        for(int i = 0; i < noOfColumns; i++){
            try {
                project.columnModel.addColumn(i, new Column(i, "column" + i), true);
            } catch (ModelException e1) {
                Assert.fail("Could not create column");
            }
        }
    }
View Full Code Here

    //helper methods

    protected void CreateColumns(int noOfColumns){
        for(int i = 0; i < noOfColumns; i++){
            try {
                project.columnModel.addColumn(i, new Column(i, "column" + i), true);
            } catch (ModelException e1) {
                Assert.fail("Could not create column");
            }
        }
    }
View Full Code Here

            if (_newColumns == null) {
                _newColumns = new ArrayList<Column>();
                _oldColumns = new ArrayList<Column>(project.columnModel.columns);
               
                for (String n : _columnNames) {
                    Column column = project.columnModel.getColumnByName(n);
                    if (column != null) {
                        _newColumns.add(column);
                    }
                }
               
View Full Code Here

    @Override
    public void apply(Project project) {
        synchronized (project) {
            super.apply(project);
           
            Column column = project.columnModel.getColumnByName(_commonColumnName);
           
            if (_newReconStats == null) {
                _newReconStats = ReconStats.create(project, column.getCellIndex());
            }
           
            _oldReconConfig = column.getReconConfig();
            _oldReconStats = column.getReconStats();
           
            column.setReconConfig(_newReconConfig);
            column.setReconStats(_newReconStats);
           
            column.clearPrecomputes();
            ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, _commonColumnName);
        }
    }
View Full Code Here

    @Override
    public void revert(Project project) {
        synchronized (project) {
            super.revert(project);
           
            Column column = project.columnModel.getColumnByName(_commonColumnName);
            column.setReconConfig(_oldReconConfig);
            column.setReconStats(_oldReconStats);
           
            column.clearPrecomputes();
            ProjectManager.singleton.getInterProjectModel().flushJoinsInvolvingProjectColumn(project.id, _commonColumnName);
        }
    }
View Full Code Here

        String fileNameColumnName = "File";
        if (includeFileSources) {
            if (project.columnModel.getColumnByName(fileNameColumnName) == null) {
                try {
                    project.columnModel.addColumn(
                        0, new Column(project.columnModel.allocateNewCellIndex(), fileNameColumnName), false);
                } catch (ModelException e) {
                    // Ignore: We already checked for duplicate name.
                    logger.info("ModelException",e);
                }
            }
        }
       
        List<String> columnNames = new ArrayList<String>();
        boolean hasOurOwnColumnNames = headerLines > 0;
       
        List<Object> cells = null;
        int rowsWithData = 0;
       
        try {
            while (!job.canceled && (cells = reader.getNextRowOfCells()) != null) {
                if (ignoreLines > 0) {
                    ignoreLines--;
                    continue;
                }
               
                if (headerLines > 0) { // header lines
                    for (int c = 0; c < cells.size(); c++) {
                        Object cell = cells.get(c);
                       
                        String columnName;
                        if (cell == null) {
                            // add column even if cell is blank
                            columnName = "";
                        } else if (cell instanceof Cell) {
                            columnName = ((Cell) cell).value.toString().trim();
                        } else {
                            columnName = cell.toString().trim();
                        }
                       
                        ImporterUtilities.appendColumnName(columnNames, c, columnName);
                    }
                   
                    headerLines--;
                    if (headerLines == 0) {
                        ImporterUtilities.setupColumns(project, columnNames);
                    }
                } else { // data lines
                    Row row = new Row(columnNames.size());
                   
                    if (storeBlankRows) {
                        rowsWithData++;
                    } else if (cells.size() > 0) {
                        rowsWithData++;
                    }
                   
                    if (skipDataLines <= 0 || rowsWithData > skipDataLines) {
                        boolean rowHasData = false;
                        for (int c = 0; c < cells.size(); c++) {
                            Column column = ImporterUtilities.getOrAllocateColumn(
                                project, columnNames, c, hasOurOwnColumnNames);
                           
                            Object value = cells.get(c);
                            if (value instanceof Cell) {
                                row.setCell(column.getCellIndex(), (Cell) value);
                                rowHasData = true;
                            } else if (ExpressionUtils.isNonBlankData(value)) {
                                Serializable storedValue;
                                if (value instanceof String) {
                                    storedValue = guessCellValueTypes ?
                                        ImporterUtilities.parseCellValue((String) value) : (String) value;
                                } else {
                                    storedValue = ExpressionUtils.wrapStorable(value);
                                }
                               
                                row.setCell(column.getCellIndex(), new Cell(storedValue, null));
                                rowHasData = true;
                            } else if (!storeBlankCellsAsNulls) {
                                row.setCell(column.getCellIndex(), new Cell("", null));
                            } else {
                                row.setCell(column.getCellIndex(), null);
                            }
                        }
                       
                        if (rowHasData || storeBlankRows) {
                            if (includeFileSources) {
View Full Code Here

            response.setHeader("Content-Type", "application/json");
           
            JSONWriter writer = new JSONWriter(response.getWriter());
            writer.object();
           
            Column column = project.columnModel.getColumnByName(columnName);
            if (column == null) {
                writer.key("code"); writer.value("error");
                writer.key("message"); writer.value("No such column");
            } else {
                try {
View Full Code Here

TOP

Related Classes of com.google.refine.model.Column

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.