use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.
the class FileProjectManager method saveToFile.
protected boolean saveToFile(File file) throws IOException, JSONException {
FileWriter writer = new FileWriter(file);
boolean saveWasNeeded = false;
try {
JSONWriter jsonWriter = new JSONWriter(writer);
jsonWriter.object();
jsonWriter.key("projectIDs");
jsonWriter.array();
for (Long id : _projectsMetadata.keySet()) {
ProjectMetadata metadata = _projectsMetadata.get(id);
if (metadata != null) {
jsonWriter.value(id);
if (metadata.isDirty()) {
ProjectMetadataUtilities.save(metadata, getProjectDir(id));
saveWasNeeded = true;
}
}
}
jsonWriter.endArray();
writer.write('\n');
jsonWriter.key("preferences");
saveWasNeeded |= _preferenceStore.isDirty();
_preferenceStore.write(jsonWriter, new Properties());
jsonWriter.endObject();
} finally {
writer.close();
}
return saveWasNeeded;
}
use of com.google.refine.ProjectMetadata 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.ProjectMetadata 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();
}
use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.
the class FunctionTests method SetUp.
@BeforeMethod
public void SetUp() throws IOException, ModelException {
bindings = new Properties();
File dir = TestUtils.createTempDirectory("openrefine-test-workspace-dir");
FileProjectManager.initialize(dir);
project = new Project();
ProjectMetadata pm = new ProjectMetadata();
pm.setName("TNG Test Project");
ProjectManager.singleton.registerProject(project, pm);
int index = project.columnModel.allocateNewCellIndex();
Column column = new Column(index, "Column A");
project.columnModel.addColumn(index, column, true);
options = mock(Properties.class);
bindings.put("project", project);
// Five rows of a's and five of 1s
for (int i = 0; i < 10; i++) {
Row row = new Row(1);
row.setCell(0, new Cell(i < 5 ? "a" : new Integer(1), null));
project.rows.add(row);
}
}
use of com.google.refine.ProjectMetadata in project OpenRefine by OpenRefine.
the class ImporterTest method setUp.
public void setUp() {
//FIXME - should we try and use mock(Project.class); - seems unnecessary complexity
servlet = new RefineServletStub();
ImportingManager.initialize(servlet);
project = new Project();
metadata = new ProjectMetadata();
job = ImportingManager.createJob();
options = Mockito.mock(JSONObject.class);
}
Aggregations