Exemplo n.º 1
0
  /** Load local dataset into TDB */
  private void TDBloading(String fileDump) {

    logger.info("TDB creation");

    // create tdb from .nt local file
    FileManager fm = FileManager.get();
    fm.addLocatorClassLoader(RDFTripleExtractor.class.getClassLoader());
    InputStream in = fm.open(fileDump);

    Location location = new Location(tdbDirectory);

    // load some initial data
    try {
      TDBLoader.load(
          TDBInternal.getBaseDatasetGraphTDB(TDBFactory.createDatasetGraph(location)), in, true);
    } catch (Exception e) {
      logger.error("TDB loading error: " + e.getMessage());
    }

    logger.info("TDB loading");

    // create model from tdb
    Dataset dataset = TDBFactory.createDataset(tdbDirectory);

    // assume we want the default model, or we could get a named model here
    dataset.begin(ReadWrite.READ);
    model = dataset.getDefaultModel();
    dataset.end();
  }
Exemplo n.º 2
0
  /* loads sample data from a file */
  protected Model loadInstanceData(String dataFile) {

    FileManager fileManager = new FileManager();
    fileManager.addLocatorClassLoader(this.getClass().getClassLoader());
    fileManager.addLocatorFile();

    Model inputModel = fileManager.loadModel(dataFile);

    return inputModel;
  }