本文整理汇总了Java中com.google.refine.model.Project类的典型用法代码示例。如果您正苦于以下问题:Java Project类的具体用法?Java Project怎么用?Java Project使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Project类属于com.google.refine.model包,在下文中一共展示了Project类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyTransform
import com.google.refine.model.Project; //导入依赖的package包/类
private void applyTransform(Project project, JSONArray transform)
throws JSONException {
for (int i = 0; i < transform.length(); i++) {
AbstractOperation operation = OperationRegistry.reconstruct(
project, transform.getJSONObject(i));
if (operation != null) {
try {
Process process = operation.createProcess(project,
new Properties());
project.processManager.queueProcess(process);
} catch (Exception ex) {
fLogger.error("Error applying operation.", ex);
}
} else {
fLogger.warn("Skipping unknown operation " + operation);
}
}
}
示例2: createOperation
import com.google.refine.model.Project; //导入依赖的package包/类
@Override
protected AbstractOperation createOperation(Project project, HttpServletRequest request, JSONObject engineConfig) throws Exception {
final String columnName = request.getParameter("column");
logger.debug("Starting createOperation");
final String parametri = request.getParameter("services");
final String prefisso = request.getParameter("prefix");
final String country = request.getParameter("country");
final Column column = project.columnModel.getColumnByName(columnName);
try {
return new EstrazOperation(column, parametri,prefisso,country, getEngineConfig(request));
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
示例3: computeChoices
import com.google.refine.model.Project; //导入依赖的package包/类
@Override
public void computeChoices(Project project, FilteredRecords filteredRecords) {
if (_eval != null && _errorMessage == null) {
RowEvaluable rowEvaluable = getRowEvaluable(project);
Column column = project.columnModel.getColumnByCellIndex(_cellIndex);
String key = "time-bin:record-based:" + _expression;
TimeBinIndex index = (TimeBinIndex) column.getPrecompute(key);
if (index == null) {
index = new TimeBinRecordIndex(project, rowEvaluable);
column.setPrecompute(key, index);
}
retrieveDataFromBaseBinIndex(index);
ExpressionTimeValueBinner binner = new ExpressionTimeValueBinner(rowEvaluable, index);
filteredRecords.accept(project, binner);
retrieveDataFromBinner(binner);
}
}
示例4: apply
import com.google.refine.model.Project; //导入依赖的package包/类
@Override
public void apply(Project project) {
synchronized (project) {
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);
}
}
_oldColumnGroups = new ArrayList<ColumnGroup>(project.columnModel.columnGroups);
}
project.columnModel.columns.clear();
project.columnModel.columns.addAll(_newColumns);
project.columnModel.columnGroups.clear();
project.update();
}
}
示例5: doPost
import com.google.refine.model.Project; //导入依赖的package包/类
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
Project project = getProject(request);
String columnName = request.getParameter("columnName");
String keyColumnName = request.getParameter("keyColumnName");
String separator = request.getParameter("separator");
AbstractOperation op = new MultiValuedCellJoinOperation(columnName, keyColumnName, separator);
Process process = op.createProcess(project, new Properties());
performProcessAndRespond(request, response, project, process);
} catch (Exception e) {
respondException(response, e);
}
}
示例6: reconstruct
import com.google.refine.model.Project; //导入依赖的package包/类
static public AbstractOperation reconstruct(Project project, JSONObject obj) throws Exception {
JSONObject engineConfig = obj.getJSONObject("engineConfig");
JSONObject match = obj.getJSONObject("match");
JSONArray types = obj.getJSONArray("types");
String[] typeIDs = new String[types.length()];
for (int i = 0; i < typeIDs.length; i++) {
typeIDs[i] = types.getString(i);
}
return new ReconMatchSpecificTopicOperation(
engineConfig,
obj.getString("columnName"),
new ReconCandidate(
match.getString("id"),
match.getString("name"),
typeIDs,
100
),
obj.getString("identifierSpace"),
obj.getString("schemaSpace")
);
}
示例7: apply
import com.google.refine.model.Project; //导入依赖的package包/类
@Override
public void apply(Project project) {
synchronized (project) {
_oldColumnIndex = project.columnModel.getColumnIndexByName(_columnName);
if (_oldColumnIndex < 0 || _newColumnIndex < 0
|| _newColumnIndex > project.columnModel.getMaxCellIndex()) {
throw new RuntimeException("Column index out of range");
}
if (_oldColumnGroups == null) {
_oldColumnGroups = new ArrayList<ColumnGroup>(project.columnModel.columnGroups);
}
Column column = project.columnModel.columns.remove(_oldColumnIndex);
project.columnModel.columns.add(_newColumnIndex, column);
project.columnModel.columnGroups.clear();
project.update();
}
}
示例8: loadFromFile
import com.google.refine.model.Project; //导入依赖的package包/类
static protected Project loadFromFile(
File file,
long id
) throws Exception {
ZipFile zipFile = new ZipFile(file);
try {
Pool pool = new Pool();
ZipEntry poolEntry = zipFile.getEntry("pool.txt");
if (poolEntry != null) {
pool.load(zipFile.getInputStream(poolEntry));
} // else, it's a legacy project file
return Project.loadFromInputStream(
zipFile.getInputStream(zipFile.getEntry("data.txt")),
id,
pool
);
} finally {
zipFile.close();
}
}
示例9: createOperation
import com.google.refine.model.Project; //导入依赖的package包/类
@Override
protected AbstractOperation createOperation(Project project,
HttpServletRequest request, JSONObject engineConfig) throws Exception {
String starredString = request.getParameter("starred");
if (starredString != null) {
boolean starred = "true".endsWith(starredString);
return new RowStarOperation(engineConfig, starred);
}
String flaggedString = request.getParameter("flagged");
if (flaggedString != null) {
boolean flagged = "true".endsWith(flaggedString);
return new RowFlagOperation(engineConfig, flagged);
}
return null;
}
示例10: parse
import com.google.refine.model.Project; //导入依赖的package包/类
@Override
public void parse(Project project, ProjectMetadata metadata,
final ImportingJob job, List<JSONObject> fileRecords, String format,
int limit, JSONObject options, List<Exception> exceptions) {
MultiFileReadingProgress progress = ImporterUtilities.createMultiFileReadingProgress(job, fileRecords);
for (JSONObject fileRecord : fileRecords) {
if (job.canceled) {
break;
}
try {
parseOneFile(project, metadata, job, fileRecord, limit, options, exceptions, progress);
} catch (IOException e) {
exceptions.add(e);
}
if (limit > 0 && project.rows.size() >= limit) {
break;
}
}
}
示例11: createOperation
import com.google.refine.model.Project; //导入依赖的package包/类
@Override
protected AbstractOperation createOperation(Project project,
HttpServletRequest request, JSONObject engineConfig) throws Exception {
String mode = request.getParameter("mode");
JSONObject sorting = null;
try{
String json = request.getParameter("sorting");
sorting = (json == null) ? null : ParsingUtilities.evaluateJsonStringToObject(json);
} catch (JSONException e) {
// ignore
}
return new RowReorderOperation(Engine.stringToMode(mode), sorting);
}
示例12: createHistoryEntry
import com.google.refine.model.Project; //导入依赖的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)
);
}
示例13: doPost
import com.google.refine.model.Project; //导入依赖的package包/类
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
Project project = getProject(request);
String columnName = request.getParameter("columnName");
int index = Integer.parseInt(request.getParameter("index"));
AbstractOperation op = new ColumnMoveOperation(columnName, index);
Process process = op.createProcess(project, new Properties());
performProcessAndRespond(request, response, project, process);
} catch (Exception e) {
respondException(response, e);
}
}
示例14: createOperation
import com.google.refine.model.Project; //导入依赖的package包/类
@Override
protected AbstractOperation createOperation(Project project,
HttpServletRequest request, JSONObject engineConfig) throws Exception {
String baseColumnName = request.getParameter("baseColumnName");
String urlExpression = request.getParameter("urlExpression");
String newColumnName = request.getParameter("newColumnName");
int columnInsertIndex = Integer.parseInt(request.getParameter("columnInsertIndex"));
int delay = Integer.parseInt(request.getParameter("delay"));
String onError = request.getParameter("onError");
return new ColumnAdditionByFetchingURLsOperation(
engineConfig,
baseColumnName,
urlExpression,
TextTransformOperation.stringToOnError(onError),
newColumnName,
columnInsertIndex,
delay
);
}
示例15: apply
import com.google.refine.model.Project; //导入依赖的package包/类
/**
* Apply a change to a project. In most cases you should already hold the Project lock
* before calling this method to prevent deadlocks.
*
* @param project the project the change should be applied to
*/
public void apply(Project project) {
if (getChange() == null) {
ProjectManager.getSingleton().getHistoryEntryManager().loadChange(this);
}
synchronized (project) {
getChange().apply(project);
// When a change is applied, it can hang on to old data (in order to be able
// to revert later). Hence, we need to save the change out.
try {
_manager.saveChange(this);
} catch (Exception e) {
e.printStackTrace();
getChange().revert(project);
throw new RuntimeException("Failed to apply change", e);
}
}
}