本文整理汇总了Java中com.google.refine.history.HistoryEntry类的典型用法代码示例。如果您正苦于以下问题:Java HistoryEntry类的具体用法?Java HistoryEntry怎么用?Java HistoryEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HistoryEntry类属于com.google.refine.history包,在下文中一共展示了HistoryEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHistoryEntry
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
@Override
protected HistoryEntry createHistoryEntry(long historyEntryID) throws Exception {
Cell cell = _project.rows.get(rowIndex).getCell(cellIndex);
Column column = _project.columnModel.getColumnByCellIndex(cellIndex);
if (column == null) {
throw new Exception("No such column");
}
newCell = new Cell(
value,
cell != null ? cell.recon : null
);
String description =
"Edit single cell on row " + (rowIndex + 1) +
", column " + column.getName();
Change change = new CellChange(rowIndex, cellIndex, cell, newCell);
return new HistoryEntry(
historyEntryID, _project, description, null, change);
}
示例2: performProcessAndRespond
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
static protected void performProcessAndRespond(
HttpServletRequest request,
HttpServletResponse response,
Project project,
Process process
) throws Exception {
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Type", "application/json");
HistoryEntry historyEntry = project.processManager.queueProcess(process);
if (historyEntry != null) {
Writer w = response.getWriter();
JSONWriter writer = new JSONWriter(w);
Properties options = new Properties();
writer.object();
writer.key("code"); writer.value("ok");
writer.key("historyEntry"); historyEntry.write(writer, options);
writer.endObject();
w.flush();
w.close();
} else {
respond(response, "{ \"code\" : \"pending\" }");
}
}
示例3: createHistoryEntry
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
@Override
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,
(_starred ? "Star" : "Unstar") + " " + changes.size() + " rows",
this,
new MassChange(changes, false)
);
}
示例4: createHistoryEntry
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
@Override
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",
this,
new RowRemovalChange(rowIndices)
);
}
示例5: createHistoryEntry
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
@Override
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",
this,
new MassChange(changes, false)
);
}
示例6: createHistoryEntry
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
@Override
protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
Engine engine = createEngine(project);
Column column = project.columnModel.getColumnByName(_baseColumnName);
if (column == null) {
throw new Exception("No column named " + _baseColumnName);
}
if (project.columnModel.getColumnByName(_newColumnName) != null) {
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);
return new HistoryEntry(
historyEntryID, project, description, this, change);
}
示例7: createHistoryEntry
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
@Override
protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
Engine engine = createEngine(project);
Column column = project.columnModel.getColumnByName(_columnName);
if (column == null) {
throw new Exception("No column named " + _columnName);
}
List<CellChange> cellChanges = new ArrayList<CellChange>(project.rows.size());
FilteredRows filteredRows = engine.getAllFilteredRows();
try {
filteredRows.accept(project, createRowVisitor(project, cellChanges, historyEntryID));
} catch (Exception e) {
e.printStackTrace();
}
String description = createDescription(column, cellChanges);
return new HistoryEntry(
historyEntryID, project, description, this, createChange(project, column, cellChanges));
}
示例8: loadChange
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
protected void loadChange(HistoryEntry historyEntry, File file) throws Exception {
ZipFile zipFile = new ZipFile(file);
try {
Pool pool = new Pool();
ZipEntry poolEntry = zipFile.getEntry("pool.txt");
if (poolEntry != null) {
pool.load(new InputStreamReader(
zipFile.getInputStream(poolEntry)));
} // else, it's a legacy project file
historyEntry.setChange(History.readOneChange(
zipFile.getInputStream(zipFile.getEntry("change.txt")), pool));
} finally {
zipFile.close();
}
}
示例9: saveChange
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
protected void saveChange(HistoryEntry historyEntry, File file) throws Exception {
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(file));
try {
Pool pool = new Pool();
out.putNextEntry(new ZipEntry("change.txt"));
try {
History.writeOneChange(out, historyEntry.getChange(), pool);
} finally {
out.closeEntry();
}
out.putNextEntry(new ZipEntry("pool.txt"));
try {
pool.save(out);
} finally {
out.closeEntry();
}
} finally {
out.close();
}
}
示例10: EstrazProcess
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
/**
* Creates a new <tt>EstrazProcess</tt>
*
* @param project The project
* @param column The column on which named-entity recognition is performed
* @param parentOperation The operation that createStrings this process
* @param description The description of this operation
* @param engineConfig The faceted browsing engine configuration
*/
protected EstrazProcess(final Project project, final Column column,
final String operazione, final String prefisso,final String country,
final AbstractOperation parentOperation, final String description,
final JSONObject engineConfig) {
super(description);
this.project = project;
this.column = column;
this.operazione = operazione;
this.parentOperation = parentOperation;
this.engineConfig = engineConfig;
this.country = country;
historyEntryId = HistoryEntry.allocateID();
this.prefisso = prefisso;
}
示例11: run
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
@Override
public void run() {
final int columnIndex = project.columnModel.getColumnIndexByName(column.getName()) + 1;
final Oggetto[] namedEntities = performExtraction();
if (!_canceled) {
project.history.addEntry(new HistoryEntry(historyEntryId, project, _description, parentOperation, new EstrazChange(columnIndex, operazione, country, namedEntities)));
project.processManager.onDoneProcess(this);
}
}
示例12: createHistoryEntry
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
@Override
protected HistoryEntry createHistoryEntry(long historyEntryID) throws Exception {
return new HistoryEntry(
historyEntryID,
_project,
(starred ? "Star row " : "Unstar row ") + (rowIndex + 1),
null,
new RowStarChange(rowIndex, starred)
);
}
示例13: doGet
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Project project = getProject(request);
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Type", "application/json");
Properties options = new Properties();
JSONWriter writer = new JSONWriter(response.getWriter());
writer.object();
writer.key("entries"); writer.array();
for (HistoryEntry entry : project.history.getLastPastEntries(-1)) {
writer.object();
writer.key("description"); writer.value(entry.description);
if (entry.operation != null) {
writer.key("operation");
entry.operation.write(writer, options);
}
writer.endObject();
}
writer.endArray();
writer.endObject();
} catch (JSONException e) {
respondException(response, e);
}
}
示例14: createHistoryEntry
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
@Override
protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
List<Row> newRows = new ArrayList<Row>();
List<Row> oldRows = project.rows;
for (int r = 0; r < oldRows.size(); r++) {
Row oldRow = oldRows.get(r);
Row newRow = null;
RowDependency rd = project.recordModel.getRowDependency(r);
if (rd.cellDependencies != null) {
newRow = oldRow.dup();
for (CellDependency cd : rd.cellDependencies) {
if (cd != null) {
int contextRowIndex = cd.rowIndex;
int contextCellIndex = cd.cellIndex;
if (contextRowIndex >= 0 && contextRowIndex < oldRows.size()) {
Row contextRow = oldRows.get(contextRowIndex);
Cell contextCell = contextRow.getCell(contextCellIndex);
newRow.setCell(contextCellIndex, contextCell);
}
}
}
}
newRows.add(newRow != null ? newRow : oldRow);
}
return new HistoryEntry(
historyEntryID,
project,
getBriefDescription(project),
DenormalizeOperation.this,
new MassRowChange(newRows)
);
}
示例15: createHistoryEntry
import com.google.refine.history.HistoryEntry; //导入依赖的package包/类
@Override
protected HistoryEntry createHistoryEntry(Project project, long historyEntryID) throws Exception {
return new HistoryEntry(
historyEntryID,
project,
"Import Prests - Remove " + rowIndices.size() + " rows",
this,
new RowRemovalChange(rowIndices)
);
}