@Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { NamespaceManager nsm = getNamespaceManager(); if (columnIndex == COL_PREFIX) { String value = (String) aValue; if (nsm.getNamespaceForPrefix(value) == null) { if (value.equals(AbstractNamespaceManager.DEFAULT_NAMESPACE_PREFIX) || AbstractNamespaceManager.isValidPrefix(value)) { String namespace = getNamespace(rowIndex); setPrefixOfNamespace(namespace, value); } } } else if (columnIndex == COL_NAMESPACE) { String value = (String) aValue; String defaultPrefix = nsm.getDefaultNamespace(); if (nsm.getPrefix(value) == null && (defaultPrefix == null || !defaultPrefix.equals(value))) { if (Jena.isNamespaceWithSeparator(value)) { String prefix = getPrefix(rowIndex); setNamespaceOfPrefix(prefix, value); } } } fill(); fireTableDataChanged(); }
@SuppressWarnings("unchecked") public JenaOWLModel reload(JenaOWLModel owlModel) throws Exception { Collection errors = new ArrayList(); OntModel ontModel = owlModel.getOntModel(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); Jena.dumpRDF(ontModel, stream); String str = stream.toString(); StringReader reader = new StringReader(str); if (log.isLoggable(Level.FINE)) { log.fine("Saved ontology to string"); log.fine(str); log.fine("reloading..."); } OwlProjectFromReaderCreator creator = new OwlProjectFromReaderCreator(); creator.setReader(reader); creator.create(errors); return creator.getOwlModel(); }
private void unifyRDFSVersion(String ns) { for (Iterator it = Jena.cloneIt(model.listStatements()); it.hasNext(); ) { Statement s = (Statement) it.next(); Resource newSubject = s.getSubject(); Property newPredicate = s.getPredicate(); RDFNode newObject = s.getObject(); boolean changed = false; if (ns.equals(newSubject.getNameSpace())) { changed = true; newSubject = model.getResource(RDFS.getURI() + newSubject.getLocalName()); } if (ns.equals(newPredicate.getNameSpace())) { changed = true; newPredicate = model.getProperty(RDFS.getURI() + newPredicate.getLocalName()); } if (newObject.canAs(Resource.class)) { Resource oldResource = (Resource) newObject.as(Resource.class); if (ns.equals(oldResource.getNameSpace())) { changed = true; newObject = model.getResource(RDFS.getURI() + oldResource.getLocalName()); } } if (changed) { model.add(newSubject, newPredicate, newObject); if (log.isLoggable(Level.FINE)) { log.fine( "Replaced deprecated triple " + s + " with " + newSubject + ", " + newPredicate + ", " + newObject); } it.remove(); } } }
public JenaOWLModel reloadWithJenaLoader(JenaOWLModel owlModel) throws Exception { ByteArrayOutputStream stream = new ByteArrayOutputStream(); Jena.dumpRDF(owlModel.getOntModel(), stream); String str = stream.toString(); return ProtegeOWL.createJenaOWLModelFromReader(new StringReader(str)); }