public void redoInferred(String uri, Model m, boolean nonMon) throws DataException { log.info("Running inferences on " + uri); Data data = getData(); Model infData = data.getModel(uri + "-inferred"); if (nonMon) infData.removeAll(); // Truth maintenance grossly simplified InfModel inf = ModelFactory.createInfModel(reasoner, m); infData.add(inf.getDeductionsModel()); log.info("Inferencing done"); }
public boolean deleteAll(String uri) { try { log.info("Deleting model: " + uri + " " + reasoner); Data data = getData(); Model m = data.getModel(uri); m.removeAll(); if (reasoner != null) redoInferred(uri, m, true); m.close(); data.close(); return true; } catch (DataException e) { e.printStackTrace(); return false; } }
/** * @see org.caboto.jena.db.Database#addModel(java.lang.String, com.hp.hpl.jena.rdf.model.Model) */ public boolean addModel(String uri, Model model) { try { log.info("Adding data to model: " + uri + " " + reasoner); Data data = getData(); Model m = data.getModel(uri); m.withDefaultMappings(model); m.add(model); if (reasoner != null) redoInferred(uri, m, false); m.close(); data.close(); return true; } catch (DataException e) { e.printStackTrace(); return false; } }
/** * @see org.caboto.jena.db.Database#updateProperty(java.lang.String, java.lang.String, * com.hp.hpl.jena.rdf.model.Property, com.hp.hpl.jena.rdf.model.RDFNode) */ public boolean updateProperty(String uri, String resourceUri, Property property, RDFNode value) { try { log.info("Updting property in model: " + uri + " " + reasoner); Data data = getData(); Model m = data.getModel(uri); if (!m.containsResource(ResourceFactory.createResource(resourceUri))) { m.close(); data.close(); return false; } Resource resource = m.getResource(resourceUri); if (resource.hasProperty(property)) { resource.getProperty(property).changeObject(value); } else { resource.addProperty(property, value); } m.close(); data.close(); return true; } catch (DataException e) { e.printStackTrace(); return false; } }