Package no.priv.garshol.duke.datasources

Examples of no.priv.garshol.duke.datasources.Column


    out.close();

    CSVDataSource csv = new CSVDataSource();
    csv.setSeparator(';');
    csv.setInputFile(outfile.getAbsolutePath());
    csv.addColumn(new Column("id", null, null, null));
    csv.addColumn(new Column("name", null, null, null));
    csv.addColumn(new Column("age", null, null, null));

    ConfigurationImpl cfg = new ConfigurationImpl();
    cfg.addDatabase(new InMemoryDatabase());
    cfg.addDataSource(0, csv);
View Full Code Here


    }
  }

  @Test
  public void testTripleModeFourColumns() {
    source.addColumn(new Column("?uri", "ID", null, null));
    source.addColumn(new Column("http://a/name", "NAME", null, null));
    source.addColumn(new Column("http://a/age", "AGE", null, null));
    source.addColumn(new Column("http://a/blubb", "BLUBB", null, null));

    source.setVariables(new String[] {"S", "P", "O", "C"});
    source.setRows(new String[][] {
        {"http://a/1", "http://a/name", "1", "blubb"}});
View Full Code Here

  }
 
  // ===== TRIPLE MODE, CONFIG 1
 
  private void setupTripleConfig1(String urlcol) {
    source.addColumn(new Column(urlcol, "ID", null, null));
    source.addColumn(new Column("http://a/name", "NAME", null, null));
    source.addColumn(new Column("http://a/age", "AGE", null, null));

    source.setVariables(new String[] {"S", "P", "O"});
  }
View Full Code Here

 
  // ===== TABULAR MODE, CONFIG 1
 
  private void setupTabularConfig1() {
    source.setTripleMode(false);
    source.addColumn(new Column("ID", "ID", null, null));
    source.addColumn(new Column("NAME", "NAME", null, null));
    source.addColumn(new Column("AGE", "AGE", null, null));

    source.setVariables(new String[] {"ID", "NAME", "AGE"});
  }
View Full Code Here

        String property = attributes.getValue("property");
        String prefix = attributes.getValue("prefix");
        String cleanername = attributes.getValue("cleaner");
        Cleaner cleaner = makeCleaner(cleanername);

        Column c = new Column(name, property, prefix, cleaner);
        String spliton = attributes.getValue("split-on");
        if (spliton != null)
          c.setSplitOn(spliton);

        ((ColumnarDataSource) datasource).addColumn(c);
      } else if (localName.equals("param")) {
        String param = attributes.getValue("name");
        String value = attributes.getValue("value");
View Full Code Here

    ((ConfigurationImpl) config).setThreshold(0.85);
    ((ConfigurationImpl) config).setMaybeThreshold(0.7);

    CSVDataSource csv = new CSVDataSource();
    csv.setInputFile("test.csv");
    csv.addColumn(new Column("id", "ID", null, null));
    csv.addColumn(new Column("name", "NAME", null, null));
    Column emailCol = new Column("email", "EMAIL", null, null);
    emailCol.setSplitOn(";");
    csv.addColumn(emailCol);
    ((ConfigurationImpl) config).addDataSource(0, csv);
   
    // --- write and reload
    File outfile = tmpdir.newFile("config.xml");           
    ConfigWriter.write(config, outfile.getAbsolutePath());
    config = ConfigLoader.load(outfile.getAbsolutePath());
   
    // --- verify loaded correctly   
    assertEquals(1, config.getDataSources().size());

    csv = (CSVDataSource) config.getDataSources().iterator().next();
    assertTrue(csv.getInputFile().endsWith("test.csv"));
    assertEquals(3, csv.getColumns().size());
    Collection<Column> csvEmailColList = csv.getColumn("email");
    Column csvEmailCol = (Column) csvEmailColList.toArray()[0];
    assertTrue(csvEmailCol.isSplit());
    // FIXME: check the columns (kind of hard given lack of ordering)
   
    assertTrue(config.getDataSources(1).isEmpty());
    assertTrue(config.getDataSources(2).isEmpty());
    assertEquals(config.getThreshold(), 0.85);
View Full Code Here

    jdbc.setDriverClass("klass");
    jdbc.setConnectionString("konnection");
    jdbc.setUserName("user");
    jdbc.setPassword("secret");
    jdbc.setQuery("select");
    jdbc.addColumn(new Column("id", "ID", null, null));
    jdbc.addColumn(new Column("name", "NAME", null, null));
    jdbc.addColumn(new Column("email", "EMAIL", null, null));
    ((ConfigurationImpl) config).addDataSource(0, jdbc);
   
    // --- write and reload
    File outfile = tmpdir.newFile("config.xml");           
    ConfigWriter.write(config, outfile.getAbsolutePath());
View Full Code Here

    ((ConfigurationImpl) config).setMaybeThreshold(0.7);

    JNDIDataSource jndi = new JNDIDataSource();
    jndi.setJndiPath("path");
    jndi.setQuery("select");
    jndi.addColumn(new Column("id", "ID", null, null));
    jndi.addColumn(new Column("name", "NAME", null, null));
    jndi.addColumn(new Column("email", "EMAIL", null, null));
    ((ConfigurationImpl) config).addDataSource(0, jndi);
   
    // --- write and reload
    File outfile = tmpdir.newFile("config.xml");           
    ConfigWriter.write(config, outfile.getAbsolutePath());
View Full Code Here

    testEmptyBlank();
  }

  @Test
  public void testSingleRecord() {
    source.addColumn(new Column("?uri", "ID", null, null));
    source.addColumn(new Column("http://b", "PROP", null, null));
   
    RecordIterator it = read("<http://a> <http://b> \"foo\" .\n");

    Record r = it.next();
    assertEquals("http://a", r.getValue("ID"));
View Full Code Here

    testSingleRecord();
  }

  @Test
  public void testSingleRecord2() {
    source.addColumn(new Column("?uri", "ID", null, null));
    source.addColumn(new Column("http://b", "PROP", null, null));
   
    RecordIterator it = read("<http://a> <http://b> \"foo\" .\n" +
                             "<http://a> <http://c> \"foo\" .\n");

    Record r = it.next();
View Full Code Here

TOP

Related Classes of no.priv.garshol.duke.datasources.Column

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.