Package com.google.refine.model

Examples of com.google.refine.model.Cell


                // nothing to do
            }
           
            @Override
            public boolean visit(Project project, int rowIndex, Row row) {
                Cell cell = row.getCell(cellIndex);
                Cell newCell = null;
               
                ExpressionUtils.bind(bindings, row, rowIndex, _columnName, cell);
               
                Object v = eval.evaluate(bindings);
                if (ExpressionUtils.isError(v)) {
                    if (fromErrorTo != null) {
                        newCell = new Cell(fromErrorTo, (cell != null) ? cell.recon : null);
                    }
                } else if (ExpressionUtils.isNonBlankData(v)) {
                    String from = v.toString();
                    Serializable to = fromTo.get(from);
                    if (to != null) {
                        newCell = new Cell(to, (cell != null) ? cell.recon : null);
                    }
                } else {
                    if (fromBlankTo != null) {
                        newCell = new Cell(fromBlankTo, (cell != null) ? cell.recon : null);
                    }
                }
               
                if (newCell != null) {
                    CellChange cellChange = new CellChange(rowIndex, cellIndex, cell, newCell);
View Full Code Here


                        // nothing to do
                    }
                   
                    @Override
                    public boolean visit(Project project, int rowIndex, Row row) {
                        Cell cell = row.getCell(fromColumn.getCellIndex());
                        if (cell != null && cell.value != null && cell.recon != null) {
                            if (judgments.contains(cell.recon.judgment)) {
                                cellValueToRecon.put(cell.value, cell.recon);
                            }
                        }
                        return false;
                    }
                });
               
                filteredRows.accept(project, new RowVisitor() {
                    @Override
                    public void start(Project project) {
                        // nothing to do
                    }
                   
                    @Override
                    public void end(Project project) {
                        // nothing to do
                    }
                   
                    @Override
                    public boolean visit(Project project, int rowIndex, Row row) {
                        for (Column column : toColumns) {
                            int cellIndex = column.getCellIndex();
                            Cell cell = row.getCell(cellIndex);
                            if (cell != null && cell.value != null) {
                                Recon reconToCopy = cellValueToRecon.get(cell.value);
                                boolean judged = cell.recon != null && cell.recon.judgment != Judgment.None;
                               
                                if (reconToCopy != null && (!judged || _applyToJudgedCells)) {
                                    Cell newCell = new Cell(cell.value, reconToCopy);
                                    CellChange cellChange = new CellChange(rowIndex, cellIndex, cell, newCell);
                                    cellChanges.add(cellChange);
                                }
                            }
                        }
View Full Code Here

           
            @Override
            public boolean visit(Project project, int rowIndex, Row row) {
                Object value = row.getCellValue(cellIndex);
                if (ExpressionUtils.isNonBlankData(value)) {
                    Cell cell = row.getCell(cellIndex);
                    if (previousCell != null && cell.value.equals(previousCell.value)) {
                        CellChange cellChange = new CellChange(rowIndex, cellIndex, cell, null);
                        cellChanges.add(cellChange);
                    }
                    previousCell = cell;
View Full Code Here

                // nothing to do
            }
           
            @Override
            public boolean visit(Project project, int rowIndex, Row row) {
                Cell cell = cellIndex < 0 ? null : row.getCell(cellIndex);
                if (cell != null && cell.recon != null) {
                    String value = cell.value instanceof String ?
                            ((String) cell.value) : cell.value.toString();
                           
                    if (_similarValue.equals(value)) {
                        Cell newCell = new Cell(cell.value, null);
                       
                        CellChange cellChange = new CellChange(rowIndex, cellIndex, cell, newCell);
                        cellChanges.add(cellChange);
                    }
                }
View Full Code Here

                    groupByCellValuesToRow.put(unchangedCellValues, reusableRow);
                    newRows.add(reusableRow);
                }
            }
           
            Cell cell = oldRow.getCell(valueColumn.getCellIndex());
            if (unchangedColumns.size() == 0) {
                int index = newColumn.getCellIndex();
                Row row = getAvailableRow(currentRows, newRows, index);
                row.setCell(index, cell);
            } else {
                // TODO: support repeating keys in this mode too
                reusableRow.setCell(newColumn.getCellIndex(), cell);
            }
           
            if (noteColumn != null) {
                Object noteValue = oldRow.getCellValue(noteColumn.getCellIndex());
                if (ExpressionUtils.isNonBlankData(noteValue)) {
                    Column newNoteColumn = keyValueToNoteColumn.get(keyString);
                    if (newNoteColumn == null) {
                        // Allocate new column
                        newNoteColumn = new Column(
                            project.columnModel.allocateNewCellIndex(),
                            project.columnModel.getUnduplicatedColumnName(
                                noteColumn.getName() + " : " + keyString));
                        keyValueToNoteColumn.put(keyString, newNoteColumn);
                        newNoteColumns.add(newNoteColumn);
                    }
                   
                    int newNoteCellIndex = newNoteColumn.getCellIndex();
                    Object existingNewNoteValue = reusableRow.getCellValue(newNoteCellIndex);
                    if (ExpressionUtils.isNonBlankData(existingNewNoteValue)) {
                        Cell concatenatedNoteCell = new Cell(
                            existingNewNoteValue.toString() + ";" + noteValue.toString(), null);
                        reusableRow.setCell(newNoteCellIndex, concatenatedNoteCell);
                    } else {
                        reusableRow.setCell(newNoteCellIndex, oldRow.getCell(noteColumn.getCellIndex()));
                    }
View Full Code Here

        for (String columnName : node2.columnNames) {
            Column column = project.columnModel.getColumnByName(columnName);
            if (column != null) {
                int cellIndex = column.getCellIndex();
               
                Cell cell = row.getCell(cellIndex);
                if (cell != null && ExpressionUtils.isNonBlankData(cell.value)) {
                    if (node2 instanceof CellTopicNode &&
                        (cell.recon == null || cell.recon.judgment == Judgment.None)) {
                            return false;
                    }
View Full Code Here

        public Object internalWrite(String subject, String predicate, Project project, int subjectRowIndex, int subjectCellIndex, Cell subjectCell) {
            String id = null;
            if (cell.recon != null && cell.recon.judgment != Recon.Judgment.None) {
                int objectRowIndex = rowIndex;
                int objectCellIndex = cellIndex;
                Cell objectCell = cell;
               
                String typeID = node.type.id;
               
                Column column = project.columnModel.getColumnByCellIndex(cellIndex);
                ReconConfig reconConfig = column.getReconConfig();
View Full Code Here

import com.google.refine.model.Row;

public class RdfExpressionUtil {

  public static Object evaluate(Evaluable eval,Properties bindings,Row row,int rowIndex,String columnName,int cellIndex){
    Cell cell;
    if(cellIndex<0){
           cell= new Cell(rowIndex,null);
         }else{
           cell= row.getCell(cellIndex);
         }
        ExpressionUtils.bind(bindings, row, rowIndex, columnName, cell);
    return eval.evaluate(bindings);
View Full Code Here

 
  static Project buildTheSampleProject(RdfSchema schema)throws Exception{
    Project project = new Project();
    buildColumnModel(project);
    Row row1= new Row(6);
    row1.cells.add(new Cell("Tim Finin",null));
    row1.cells.add(new Cell("finin@umbc.edu",null));
    row1.cells.add(new Cell("329",null));
    row1.cells.add(new Cell("Yes",null));
    row1.cells.add(new Cell("$10",null));
    row1.cells.add(new Cell("",null));
    project.rows.add(row1);
   
    Row row2= new Row(6);
    row2.cells.add(new Cell("Lushan Han",null));
    row2.cells.add(new Cell("lushan@umbc.edu",null));
    row2.cells.add(new Cell("377",null));
    row2.cells.add(new Cell("No",null));
    row2.cells.add(new Cell("",null));
    row2.cells.add(new Cell("Tim Finin",null));
    project.rows.add(row2);
   
    Row row3= new Row(6);
    row3.cells.add(new Cell("Wenjia Li",null));
    row3.cells.add(new Cell("wenjia@umbc.edu",null));
    row3.cells.add(new Cell("377",null));
    row3.cells.add(new Cell("No",null));
    row3.cells.add(new Cell("",null));
    row3.cells.add(new Cell("Anupam Joshi",null));
    project.rows.add(row3);
   
    project.update();
    //set model
    project.overlayModels.put("rdfSchema", schema );
View Full Code Here

  }
  void buildTheSampleProject()throws Exception{
    project = new Project();
    buildColumnModel();
    Row row1 = new Row(17);
    row1.cells.add(new Cell("101198", null));
    row1.cells.add(new Cell("Paula Freedman", null));
    row1.cells.add(new Cell("G5", null));
    row1.cells.add(new Cell("Deputy Director - International Group", null));
    row1.cells.add(new Cell("tbc", null));
    row1.cells.add(new Cell("BIS", null));
    row1.cells.add(new Cell("BIS", null));
    row1.cells.add(new Cell("UK Trade and Investment", null));
    row1.cells.add(new Cell("020 7215 4320", null));
    row1.cells.add(new Cell("paula.freedman@ukti.gsi.gov.uk", null));
    row1.cells.add(new Cell("127460", null));
    row1.cells.add(new Cell("Susan Haird", null));
    row1.cells.add(new Cell("Senior Civil Service.Pay Band 1", null));
    row1.cells.add(new Cell("Active Assignment", null));
    row1.cells.add(new Cell(null,null));
    row1.cells.add(new Cell(true, null));
    row1.cells.add(new Cell(true, null));
    row1.cells.add(new Cell(false, null));
   
    project.rows.add(row1);
   
    /*
     * 111912|  Bryan Welch|  G5|  Deputy Director - Legal Services Directorate B|  tbc|  BIS|  BIS|  Legal Services Group|  020 7215 3181|  bryan.welch@bis.gsi.gov.uk|  901575|  Stephen Braviner-Roman|  Senior Civil Service.Pay Band 1|  Active Assignment    TRUE  TRUE  FALSE
     */
    Row row2 = new Row(17);
    row2.cells.add(new Cell("111912", null));
    row2.cells.add(new Cell("Bryan Welch", null));
    row2.cells.add(new Cell("G5", null));
    row2.cells.add(new Cell("Deputy Director - Legal Services Directorate B", null));
    row2.cells.add(new Cell("tbc", null));
    row2.cells.add(new Cell("BIS", null));
    row2.cells.add(new Cell("BIS", null));
    row2.cells.add(new Cell("Legal Services Group", null));
    row2.cells.add(new Cell("020 7215 3181", null));
    row2.cells.add(new Cell("bryan.welch@bis.gsi.gov.uk", null));
    row2.cells.add(new Cell("901575", null));
    row2.cells.add(new Cell("Stephen Braviner-Roman", null));
    row2.cells.add(new Cell("Senior Civil Service.Pay Band 1", null));
    row2.cells.add(new Cell("Active Assignment", null));
    row2.cells.add(new Cell(null,null));
    row2.cells.add(new Cell(true, null));
    row2.cells.add(new Cell(true, null));
    row2.cells.add(new Cell(false, null));
   
    project.rows.add(row2);
   
    project.update();
    //set model
View Full Code Here

TOP

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

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.