/** * {@inheritDoc} */ @Override public void close() { super.object.close(); }
public static void closeModel() { persistentModel.close(); persistentModel = null; owlKB = null; }
public void close() { model.close(); }
Model model = VirtModel.openDatabaseModel("load:test", "jdbc:virtuoso://localhost:1111", "dba", "dba"); InputStream in = FileManager.get().open( nfile ); if (in == null) { throw new IllegalArgumentException( "File: " + nfile + " not found"); } model.read(new InputStreamReader(in), null, "N-TRIPLE"); model.close();
/** * closes this ModelGraph and frees up all Jena TDB related resources. */ public void close(){ this.graph = null; this.jenaAdapter = null; sync(); this.model.close(); } /**
try { String nfile = "1.nt"; Model model = VirtModel.openDatabaseModel("load:test", "jdbc:virtuoso://localhost:1111", "dba", "dba"); InputStream in = FileManager.get().open( nfile ); if (in == null) { throw new IllegalArgumentException( "File: " + nfile + " not found"); } model.read(new InputStreamReader(in), null, "N-TRIPLE"); model.close(); } catch (Exception e) { System.out.println("Ex="+e); }
@Override public void readASCII(final Scanner in) throws IOException { final StringBuffer b = new StringBuffer(); while (in.hasNext()) { b.append(in.next()); } final InputStream stream = new ByteArrayInputStream(b.toString().getBytes("UTF-8")); m = ModelFactory.createDefaultModel(); m.read(stream, "", "NTRIPLES"); m.close(); }
@Override public void readASCII(final Scanner in) throws IOException { final StringBuffer b = new StringBuffer(); while (in.hasNext()) { b.append(in.next()); } final InputStream stream = new ByteArrayInputStream(b.toString().getBytes("UTF-8")); m = ModelFactory.createDefaultModel(); m.read(stream, "", "NTRIPLES"); m.close(); }
// First create an empty tdb Dataset tdb = TDBFactory.createDataset(path2NewTdb); // Then get its Model Model tdbModel = tdb.getDefaultModel(); // Then update tdbModel. For example use the code you wrote // above or if you already have a model use tdbModel.add(anotherModel) // After that make sure to close everything tdbModel.close(); tdb.close();
public static void main (String [] args) throws IOException{ // Load HDT file using the hdt-java library HDT hdt = HDTManager.mapIndexedHDT("/Users/jeremy/Downloads/swdf-2012-11-28.hdt", null); // Create Jena Model on top of HDT. HDTGraph graph = new HDTGraph(hdt, true); Model model = ModelFactory.createModelForGraph(graph); Iterator<Statement> stmt = model.listStatements(); while(stmt.hasNext()){ System.out.println(stmt.next().toString()); } model.close(); // Close when it's no longer needed. } }
String qiry = "dbpedia query "; Dataset dataset = TDBFactory.createDataset(tdbDirectory); Model tdb = dataset.getDefaultModel(); Query query = QueryFactory.create(qiry); QueryExecution qexec = QueryExecutionFactory.create(query, tdb); /*Execute the Query*/ ResultSet results = qexec.execSelect(); while (results.hasNext()) { // Do something important } qexec.close(); tdb.close() ;
String directory = "D:\\Project\\Store_DB\\data1\\tdb"; Dataset dataset = TDBFactory.createDataset(directory); Model tdb = dataset.getDefaultModel(); // read the input file String source = "D:\\Project\\Store_DB\\tmp\\trail_1.rdf"; FileManager.get().readModel( tdb, source); dataset.commit();//INCLUDE THIS STAMEMENT tdb.close(); dataset.close();
@Override public void serialise(Service service, OutputStream out, Syntax syntax) { Model model = generateModel(service); model.setNsPrefixes(Vocabularies.prefixes); try { model.write(out, syntax.getName()); } finally { model.close(); } }
@Override public Model convert(Context context, DSpaceObject dso) throws SQLException, AuthorizeException { if (this.plugins.isEmpty()) { log.warn("No RDFConverterPlugins were loaded, cannot convert any data!"); return null; } Model model = ModelFactory.createDefaultModel(); for (ConverterPlugin plugin : this.plugins) { if (plugin.supports(dso.getType())) { Model convertedData = plugin.convert(context, dso); if (convertedData != null) { model.setNsPrefixes(convertedData); model.add(convertedData); convertedData.close(); } } } if (model.isEmpty()) { model.close(); return null; } else { return model; } } }
staticDataModel.close(); return null;
model.close(); String content = test.getBuffer().toString(); test.close();
@Override public Model convert(Context context, DSpaceObject dso) throws SQLException { // As we do not use data of any DSpaceObject, we do not have to check // permissions here. We provide only static data out of configuration // files. Model general = this.readFile(CONSTANT_DATA_GENERAL_KEY_SUFFIX, RDFUtil.generateIdentifier(context, dso)); Model typeSpecific = this .readFile(ContentServiceFactory.getInstance().getDSpaceObjectService(dso).getTypeText(dso), RDFUtil.generateIdentifier(context, dso)); if (general == null) { return typeSpecific; } if (typeSpecific == null) { return general; } typeSpecific.setNsPrefixes(general); typeSpecific.add(general); general.close(); return typeSpecific; }