use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class SortingRecordVisitor method end.
@Override
public void end(Project project) {
_visitor.start(project);
Collections.sort(_records, new Comparator<Record>() {
Project project;
Comparator<Record> init(Project project) {
this.project = project;
return this;
}
@Override
public int compare(Record o1, Record o2) {
return SortingRecordVisitor.this.compare(project, o1, o1.recordIndex, o2, o2.recordIndex);
}
}.init(project));
for (Record record : _records) {
_visitor.visit(project, record);
}
_visitor.end(project);
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class TimeRangeFacetTests method serializeTimeRangeFacet.
@Test
public void serializeTimeRangeFacet() throws JsonParseException, JsonMappingException, IOException {
Project project = createCSVProject("my column\n" + "placeholder\n" + "nontime\n" + "placeholder\n" + "placeholder\n");
project.rows.get(0).cells.set(0, new Cell(OffsetDateTime.parse("2018-01-03T08:09:10Z"), null));
project.rows.get(2).cells.set(0, new Cell(OffsetDateTime.parse("2008-01-03T03:04:05Z"), null));
project.rows.get(3).cells.set(0, new Cell(OffsetDateTime.parse("2012-04-05T02:00:01Z"), null));
Engine engine = new Engine(project);
TimeRangeFacetConfig config = ParsingUtilities.mapper.readValue(configJson, TimeRangeFacetConfig.class);
TimeRangeFacet facet = config.apply(project);
facet.computeChoices(project, engine.getAllFilteredRows());
TestUtils.isSerializedTo(facet, facetJson);
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class InterProjectModel method computeJoin.
protected void computeJoin(ProjectJoin join) {
if (join.fromProjectID < 0 || join.toProjectID < 0) {
return;
}
Project fromProject = ProjectManager.singleton.getProject(join.fromProjectID);
Project toProject = ProjectManager.singleton.getProject(join.toProjectID);
if (fromProject == null || toProject == null) {
return;
}
Column fromColumn = fromProject.columnModel.getColumnByName(join.fromProjectColumnName);
Column toColumn = toProject.columnModel.getColumnByName(join.toProjectColumnName);
if (fromColumn == null || toColumn == null) {
return;
}
for (Row fromRow : fromProject.rows) {
Object value = fromRow.getCellValue(fromColumn.getCellIndex());
if (ExpressionUtils.isNonBlankData(value) && !join.valueToRowIndices.containsKey(value)) {
join.valueToRowIndices.put(value, new ArrayList<Integer>());
}
}
int count = toProject.rows.size();
for (int r = 0; r < count; r++) {
Row toRow = toProject.rows.get(r);
Object value = toRow.getCellValue(toColumn.getCellIndex());
if (ExpressionUtils.isNonBlankData(value) && join.valueToRowIndices.containsKey(value)) {
join.valueToRowIndices.get(value).add(r);
}
}
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class TransposeTests method SetUp.
@BeforeMethod
public void SetUp() {
servlet = new RefineServletStub();
ProjectManager.singleton = new ProjectManagerStub();
ImportingManager.initialize(servlet);
project = new Project();
metadata = new ProjectMetadata();
job = ImportingManager.createJob();
options = mock(JSONObject.class);
importer = new SeparatorBasedImporter();
}
use of com.google.refine.model.Project in project OpenRefine by OpenRefine.
the class ProjectManagerTests method canSaveAllModified.
//TODO test ensureProjectSave in race condition
@Test
public void canSaveAllModified() {
//5 minute difference
whenGetSaveTimes(project, metadata);
registerProject(project, metadata);
//add a second project to the cache
Project project2 = spy(new ProjectStub(2));
ProjectMetadata metadata2 = mock(ProjectMetadata.class);
//not modified since the last save but within 30 seconds flush limit
whenGetSaveTimes(project2, metadata2, 10);
registerProject(project2, metadata2);
//check that the two projects are not the same
Assert.assertFalse(project.id == project2.id);
SUT.save(true);
verifySaved(project, metadata);
verifySaved(project2, metadata2);
verify(SUT, times(1)).saveWorkspace();
}
Aggregations