Package com.google.refine.browsing

Examples of com.google.refine.browsing.FilteredRows


protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
        Engine engine = createEngine(project);
       
        List<Integer> rowIndices = new ArrayList<Integer>();
       
        FilteredRows filteredRows = engine.getAllFilteredRows();
        filteredRows.accept(project, createRowVisitor(project, rowIndices));
       
        return new HistoryEntry(
            historyEntryID,
            project,
            "Remove " + rowIndices.size() + " rows",
View Full Code Here


            }
           
            _entries = new ArrayList<ReconEntry>(_project.rows.size());
            _cellIndex = column.getCellIndex();
           
            FilteredRows filteredRows = engine.getAllFilteredRows();
            filteredRows.accept(_project, new RowVisitor() {
                @Override
                public void start(Project project) {
                    // nothing to do
                }
View Full Code Here

protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
        Engine engine = createEngine(project);
       
        List<Change> changes = new ArrayList<Change>(project.rows.size());
       
        FilteredRows filteredRows = engine.getAllFilteredRows();
        filteredRows.accept(project, createRowVisitor(project, changes));
       
        return new HistoryEntry(
            historyEntryID,
            project,
            (_flagged ? "Flag" : "Unflag") + " " + changes.size() + " rows",
View Full Code Here

                return;
            }
           
            List<CellAtRow> urls = new ArrayList<CellAtRow>(_project.rows.size());
           
            FilteredRows filteredRows = _engine.getAllFilteredRows();
            filteredRows.accept(_project, createRowVisitor(urls));
           
            List<CellAtRow> responseBodies = new ArrayList<CellAtRow>(urls.size());
            for (int i = 0; i < urls.size(); i++) {
                CellAtRow urlData = urls.get(i);
                CellAtRow cellAtRow = fetch(urlData);
View Full Code Here

            throw new Exception("Another column already named " + _newColumnName);
        }
       
        List<CellAtRow> cellsAtRows = new ArrayList<CellAtRow>(project.rows.size());
       
        FilteredRows filteredRows = engine.getAllFilteredRows();
        filteredRows.accept(project, createRowVisitor(project, cellsAtRows));
       
        String description = createDescription(column, cellsAtRows);
       
        Change change = new ColumnAdditionChange(_newColumnName, _columnInsertIndex, cellsAtRows);
       
View Full Code Here

        final List<CellChange> cellChanges = new ArrayList<CellChange>(project.rows.size());
       
        if (fromColumn != null && toColumns.size() > 0) {
            final Map<Object, Recon> cellValueToRecon = new HashMap<Object, Recon>();
           
            FilteredRows filteredRows = engine.getAllFilteredRows();
            try {
                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) {
                        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
                    }
                   
View Full Code Here

       
        List<String> columnNames = new ArrayList<String>();
        List<Integer> rowIndices = new ArrayList<Integer>(project.rows.size());
        List<List<Serializable>> tuples = new ArrayList<List<Serializable>>(project.rows.size());
       
        FilteredRows filteredRows = engine.getAllFilteredRows();
        RowVisitor rowVisitor;
        if ("lengths".equals(_mode)) {
            rowVisitor = new ColumnSplitRowVisitor(column.getCellIndex(), columnNames, rowIndices, tuples) {
                @Override
                protected java.util.List<Serializable> split(String s) {
                    List<Serializable> results = new ArrayList<Serializable>(_fieldLengths.length + 1);
                   
                    int lastIndex = 0;
                    for (int length : _fieldLengths) {
                        int from = lastIndex;
                        int to = Math.min(from + length, s.length());
                       
                        results.add(stringToValue(s.substring(from, to)));
                       
                        lastIndex = to;
                    }
                   
                    return results;
                };
            };
        } else if (_regex) {
            Pattern pattern = Pattern.compile(_separator);
           
            rowVisitor = new ColumnSplitRowVisitor(column.getCellIndex(), columnNames, rowIndices, tuples) {
                Pattern _pattern;
               
                @Override
                protected java.util.List<Serializable> split(String s) {
                    return stringArrayToValueList(_pattern.split(s, _maxColumns));
                };
               
                public RowVisitor init(Pattern pattern) {
                    _pattern = pattern;
                    return this;
                }
            }.init(pattern);
        } else {
            rowVisitor = new ColumnSplitRowVisitor(column.getCellIndex(), columnNames, rowIndices, tuples) {
                @Override
                protected java.util.List<Serializable> split(String s) {
                    return stringArrayToValueList(
                            StringUtils.splitByWholeSeparatorPreserveAllTokens(s, _separator, _maxColumns));
                };
            };
        }
       
        filteredRows.accept(project, rowVisitor);
       
        String description =
            "Split " + rowIndices.size() +
            " cell(s) in column " + _columnName +
            " into several columns" +
View Full Code Here

        return model;
    }
   
    public static Repository buildModel(Project project, Engine engine, RdfRowVisitor visitor) {
//      RdfSchema schema = Util.getProjectSchema(project);
        FilteredRows filteredRows = engine.getAllFilteredRows();
        filteredRows.accept(project, visitor);
        return visitor.getModel();
       
    }
View Full Code Here

                // ignore
            }

            engine.initializeFromJSON(engineConfig);

            FilteredRows filteredRows = engine.getAllFilteredRows();
            filteredRows.accept(project, createRowVisitor(project, values));
           
            JSONArray stuff = new JSONArray();

            for (Column col : project.columnModel.columns) {
              columns.add(col.getName());
View Full Code Here

TOP

Related Classes of com.google.refine.browsing.FilteredRows

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.