Search in sources :

Example 11 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();
    parser.parseOneFile(project, metadata, job, "file-source", reader, rootColumnGroup, -1, options, new ArrayList<Exception>());
    XmlImportUtilities.createColumnsFromImport(project, rootColumnGroup);
    project.columnModel.update();
}
Also used : ImportColumnGroup(com.google.refine.importers.tree.ImportColumnGroup) IOException(java.io.IOException)

Example 12 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, JSONObject 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 13 with ImportColumnGroup

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

the class XmlImportUtilitiesTests method processSubRecordTestXml.

@Test
public void processSubRecordTestXml() {
    loadData("<?xml version=\"1.0\"?><library><book id=\"1\"><author>author1</author><genre>genre1</genre></book></library>");
    createXmlParser();
    ParserSkip();
    try {
        SUT.ProcessSubRecordWrapper(project, parser, columnGroup, record, 0, new ImportParameters(false, false, false));
    } catch (Exception e) {
        Assert.fail();
    }
    log(project);
    Assert.assertEquals(columnGroup.subgroups.size(), 1);
    Assert.assertEquals(columnGroup.name, "");
    Assert.assertNotNull(columnGroup.subgroups.get("library"));
    Assert.assertEquals(columnGroup.subgroups.get("library").subgroups.size(), 1);
    ImportColumnGroup book = columnGroup.subgroups.get("library").subgroups.get("book");
    Assert.assertNotNull(book);
    Assert.assertEquals(book.subgroups.size(), 2);
    Assert.assertNotNull(book.subgroups.get("author"));
    Assert.assertNotNull(book.subgroups.get("genre"));
//TODO check record
}
Also used : ImportColumnGroup(com.google.refine.importers.tree.ImportColumnGroup) ImportParameters(com.google.refine.importers.tree.ImportParameters) TreeReaderException(com.google.refine.importers.tree.TreeReaderException) IOException(java.io.IOException) XMLStreamException(javax.xml.stream.XMLStreamException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

Example 14 with ImportColumnGroup

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

the class XmlImportUtilitiesTests method SetUp.

@BeforeMethod
public void SetUp() {
    SUT = new XmlImportUtilitiesStub();
    project = new Project();
    columnGroup = new ImportColumnGroup();
    record = new ImportRecord();
}
Also used : Project(com.google.refine.model.Project) ImportColumnGroup(com.google.refine.importers.tree.ImportColumnGroup) ImportRecord(com.google.refine.importers.tree.ImportRecord) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 15 with ImportColumnGroup

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

the class XmlImportUtilitiesTests method importXmlWithVaryingStructureTest.

@Test
public void importXmlWithVaryingStructureTest() {
    loadData(XmlImporterTests.getSampleWithVaryingStructure());
    String[] recordPath = new String[] { "library", "book" };
    XmlImportUtilitiesStub.importTreeData(createXmlParser(), project, recordPath, columnGroup, -1, new ImportParameters(false, true, false));
    log(project);
    assertProjectCreated(project, 0, 6);
    Assert.assertEquals(project.rows.get(0).cells.size(), 4);
    Assert.assertEquals(project.rows.get(5).cells.size(), 5);
    Assert.assertEquals(columnGroup.subgroups.size(), 1);
    Assert.assertEquals(columnGroup.name, "");
    ImportColumnGroup book = columnGroup.subgroups.get("book");
    Assert.assertNotNull(book);
    Assert.assertEquals(book.columns.size(), 1);
    Assert.assertEquals(book.subgroups.size(), 4);
    Assert.assertNotNull(book.subgroups.get("author"));
    Assert.assertEquals(book.subgroups.get("author").columns.size(), 1);
    Assert.assertNotNull(book.subgroups.get("title"));
    Assert.assertNotNull(book.subgroups.get("publish_date"));
    Assert.assertNotNull(book.subgroups.get("genre"));
}
Also used : ImportColumnGroup(com.google.refine.importers.tree.ImportColumnGroup) ImportParameters(com.google.refine.importers.tree.ImportParameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

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