Search in sources :

Example 1 with ImportColumnGroup

use of com.google.refine.importers.tree.ImportColumnGroup in project OpenRefine by OpenRefine.

the class ImporterTest method parseOneInputStreamAsReader.

protected void parseOneInputStreamAsReader(TreeImportingParserBase parser, InputStream inputStream, JSONObject options) {
    ImportColumnGroup rootColumnGroup = new ImportColumnGroup();
    List<Exception> exceptions = new ArrayList<Exception>();
    Reader reader = new InputStreamReader(inputStream);
    parser.parseOneFile(project, metadata, job, "file-source", reader, rootColumnGroup, -1, options, exceptions);
    postProcessProject(project, rootColumnGroup, exceptions);
    try {
        reader.close();
    } catch (IOException e) {
    //ignore errors on close
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) ImportColumnGroup(com.google.refine.importers.tree.ImportColumnGroup) ArrayList(java.util.ArrayList) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) IOException(java.io.IOException)

Example 2 with ImportColumnGroup

use of com.google.refine.importers.tree.ImportColumnGroup in project OpenRefine by OpenRefine.

the class XmlImportUtilitiesTests method createColumnsFromImportTest.

@Test
public void createColumnsFromImportTest() {
    ImportColumnGroup columnGroup = new ImportColumnGroup();
    ImportColumnGroup subGroup = new ImportColumnGroup();
    columnGroup.columns.put("a", new ImportColumn("hello"));
    columnGroup.columns.put("b", new ImportColumn("world"));
    subGroup.columns.put("c", new ImportColumn("foo"));
    subGroup.columns.put("d", new ImportColumn("bar"));
    columnGroup.subgroups.put("e", subGroup);
    XmlImportUtilitiesStub.createColumnsFromImport(project, columnGroup);
    log(project);
    assertProjectCreated(project, 4, 0);
    Assert.assertEquals(project.columnModel.columns.get(0).getName(), "hello");
    Assert.assertEquals(project.columnModel.columns.get(1).getName(), "world");
    Assert.assertEquals(project.columnModel.columns.get(2).getName(), "foo");
    Assert.assertEquals(project.columnModel.columns.get(3).getName(), "bar");
    Assert.assertEquals(project.columnModel.columnGroups.get(0).keyColumnIndex, 2);
    Assert.assertEquals(project.columnModel.columnGroups.get(0).startColumnIndex, 2);
    Assert.assertEquals(project.columnModel.columnGroups.get(0).columnSpan, 2);
}
Also used : ImportColumnGroup(com.google.refine.importers.tree.ImportColumnGroup) ImportColumn(com.google.refine.importers.tree.ImportColumn) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

Example 3 with ImportColumnGroup

use of com.google.refine.importers.tree.ImportColumnGroup in project OpenRefine by OpenRefine.

the class ImporterTest method parseOneInputStream.

protected void parseOneInputStream(TreeImportingParserBase parser, InputStream inputStream, ObjectNode options) {
    ImportColumnGroup rootColumnGroup = new ImportColumnGroup();
    List<Exception> exceptions = new ArrayList<Exception>();
    parser.parseOneFile(project, metadata, job, "file-source", inputStream, rootColumnGroup, -1, options, exceptions);
    postProcessProject(project, rootColumnGroup, exceptions);
}
Also used : ImportColumnGroup(com.google.refine.importers.tree.ImportColumnGroup) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 4 with ImportColumnGroup

use of com.google.refine.importers.tree.ImportColumnGroup in project OpenRefine by OpenRefine.

the class ImporterTest method parseOneFile.

protected void parseOneFile(TreeImportingParserBase parser, Reader reader) {
    ImportColumnGroup rootColumnGroup = new ImportColumnGroup();
    List<Exception> exceptions = new ArrayList<Exception>();
    parser.parseOneFile(project, metadata, job, "file-source", reader, rootColumnGroup, -1, options, exceptions);
    assertEquals(exceptions.size(), 0);
    XmlImportUtilities.createColumnsFromImport(project, rootColumnGroup);
    project.columnModel.update();
}
Also used : ImportColumnGroup(com.google.refine.importers.tree.ImportColumnGroup) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 5 with ImportColumnGroup

use of com.google.refine.importers.tree.ImportColumnGroup in project OpenRefine by OpenRefine.

the class ImporterTest method parseOneInputStreamAsReader.

protected void parseOneInputStreamAsReader(TreeImportingParserBase parser, InputStream inputStream, ObjectNode options) {
    ImportColumnGroup rootColumnGroup = new ImportColumnGroup();
    List<Exception> exceptions = new ArrayList<Exception>();
    Reader reader = new InputStreamReader(inputStream);
    parser.parseOneFile(project, metadata, job, "file-source", reader, rootColumnGroup, -1, options, exceptions);
    postProcessProject(project, rootColumnGroup, exceptions);
    try {
        reader.close();
    } catch (IOException e) {
    // ignore errors on close
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) ImportColumnGroup(com.google.refine.importers.tree.ImportColumnGroup) ArrayList(java.util.ArrayList) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) IOException(java.io.IOException)

Aggregations

ImportColumnGroup (com.google.refine.importers.tree.ImportColumnGroup)16 IOException (java.io.IOException)10 BeforeTest (org.testng.annotations.BeforeTest)8 Test (org.testng.annotations.Test)8 ArrayList (java.util.ArrayList)6 RefineTest (com.google.refine.RefineTest)4 ImportParameters (com.google.refine.importers.tree.ImportParameters)4 TreeReaderException (com.google.refine.importers.tree.TreeReaderException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 RefineTest (com.google.refine.tests.RefineTest)3 ImportColumn (com.google.refine.importers.tree.ImportColumn)2 ImportRecord (com.google.refine.importers.tree.ImportRecord)2 Project (com.google.refine.model.Project)2 InputStreamReader (java.io.InputStreamReader)2 Reader (java.io.Reader)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1