Search in sources :

Example 6 with SeparatorBasedImporter

use of com.google.refine.importers.SeparatorBasedImporter in project OpenRefine by OpenRefine.

the class WikidataRefineTest method createCSVProject.

protected Project createCSVProject(String projectName, String input) {
    Project project = new Project();
    ProjectMetadata metadata = new ProjectMetadata();
    metadata.setName(projectName);
    ObjectNode options = mock(ObjectNode.class);
    RefineTest.prepareImportOptions(options, ",", -1, 0, 0, 1, false, false);
    ImportingJob job = ImportingManager.createJob();
    SeparatorBasedImporter importer = new SeparatorBasedImporter();
    List<Exception> exceptions = new ArrayList<Exception>();
    importer.parseOneFile(project, metadata, job, "filesource", new StringReader(input), -1, options, exceptions);
    project.update();
    ProjectManager.singleton.registerProject(project, metadata);
    projects.add(project);
    importingJobs.add(job);
    return project;
}
Also used : Project(com.google.refine.model.Project) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProjectMetadata(com.google.refine.ProjectMetadata) ArrayList(java.util.ArrayList) StringReader(java.io.StringReader) ImportingJob(com.google.refine.importing.ImportingJob) SeparatorBasedImporter(com.google.refine.importers.SeparatorBasedImporter)

Aggregations

SeparatorBasedImporter (com.google.refine.importers.SeparatorBasedImporter)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 Project (com.google.refine.model.Project)4 ProjectMetadata (com.google.refine.ProjectMetadata)3 ArrayList (java.util.ArrayList)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 ImportingJob (com.google.refine.importing.ImportingJob)2 File (java.io.File)2 IOException (java.io.IOException)2 StringReader (java.io.StringReader)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 RefineServletStub (com.google.refine.RefineServletStub)1 ParsingException (com.google.refine.expr.ParsingException)1 ImporterTest (com.google.refine.importers.ImporterTest)1 ImportingParserBase (com.google.refine.importers.ImportingParserBase)1 Progress (com.google.refine.importing.ImportingUtilities.Progress)1 ModelException (com.google.refine.model.ModelException)1 ProjectManagerStub (com.google.refine.tests.ProjectManagerStub)1 RefineServletStub (com.google.refine.tests.RefineServletStub)1 JSONObject (org.json.JSONObject)1