public void deleteStatementsByResource(Resource res) { ontModel.remove(ontModel.listStatements(res, null, (RDFNode) null)); ontModel.remove(ontModel.listStatements(null, null, res)); }
/** * First find the URI of actual resource represented with <i>reference</i> parameter. Then deletes all * statements where it is a subject or object * * @param reference */ public void deleteStatementsByReference(String reference) { List<Statement> refStatement = ontModel.listStatements(null, CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP, reference).toList(); if (refStatement.size() == 0) { log.warn("There is no resource having CMSAdapterVocabulary.CMSAD_RESOURCE_REF_PROP {}", reference); return; } Resource subject = refStatement.get(0).getSubject(); deleteStatementsByResource(subject); }
public void deleteObjectTypeProperties(String objectTypeRef) { List<Statement> props = ontModel.listStatements(null, CMSAdapterVocabulary.CMSAD_PROPERTY_SOURCE_OBJECT_PROP, objectTypeRef).toList(); for (Statement s : props) { deleteStatementsByResource(s.getSubject()); } }
final StmtIterator iterator = input.listStatements(); return new Iterator<T>(){
} else if (type.isAssignableFrom(Statement.class)) { final OntModel input = new JenaToOwlConvert().ModelOwlToJenaConvert(o, "RDF/XML"); final StmtIterator iterator = input.listStatements(); return new Iterator<T>() {
return jenamodel.listStatements(); } catch (OWLOntologyCreationException eoc) { System.err.print("AxiomOwlToJenaResource::: ");
private Collection<Resource> getVLANsFromLink(Resource l){ LIBNDL.logger().debug("getVLANsFromLink:BEGIN"); ArrayList<Resource> rtnList = new ArrayList<Resource>(); Iterator i = null; OntModel om = this.getJenaModel(); LIBNDL.logger().debug("om = " + om); i = om.listStatements(null, NdlCommons.inRequestNetworkConnection, (RDFNode) l); LIBNDL.logger().debug("i = " + i); for (i = om.listStatements(null, NdlCommons.inRequestNetworkConnection, (RDFNode) l); i.hasNext();){ Statement st = (Statement) i.next(); LIBNDL.logger().debug("FOUND Statement subject: " + st.getSubject() + ", predicate: " + st.getPredicate() + ", resource " + st.getResource()); LIBNDL.logger().debug("resource type: " + getType(st.getSubject())); if (isType(st.getSubject(),NdlCommons.topologyCrossConnectClass)) { LIBNDL.logger().debug("adding vlan: " + st.getSubject()); rtnList.add(st.getSubject()); } } LIBNDL.logger().debug("getVLANsFromLink:END"); return rtnList; }
private Collection<Resource> getVLANsFromBroadcastLink(Resource l){ LIBNDL.logger().debug("getVLANsFromBroadcastLink:BEGIN. l = " + l + ", type = " + getType(l)); ArrayList<Resource> rtnList = new ArrayList<Resource>(); Iterator i = null; OntModel om = (OntModel) l.getModel(); for (i = om.listStatements(null, NdlCommons.inRequestNetworkConnection, (RDFNode) l); i.hasNext();){ Statement st = (Statement) i.next(); LIBNDL.logger().debug("FOUND Statement subject: " + st.getSubject() + ", predicate: " + st.getPredicate() + ", resource " + st.getResource()); LIBNDL.logger().debug("resource type: " + getType(st.getSubject())); if (isType(st.getSubject(),NdlCommons.topologyCrossConnectClass)) { LIBNDL.logger().debug("adding vlan: " + st.getSubject()); rtnList.add(st.getSubject()); } } LIBNDL.logger().debug("getVLANsFromBroadcastLink:END"); return rtnList; }
final StmtIterator iterator = input.listStatements(); return new Iterator<T>(){
/** Write any vanilla RDF properties in the vocabulary */ protected void writeRDFProperties( boolean useOntProperty ) { String template = m_options.hasPropTemplateOption() ? m_options.getPropTemplateOption() : DEFAULT_TEMPLATE; String propType = useOntProperty ? "OntProperty" : "Property"; // select the appropriate properties based on the language choice Resource[] props; if (m_options.hasLangOwlOption()) { props = new Resource[] {OWL.ObjectProperty, OWL.DatatypeProperty, RDF.Property}; } else { props = new Resource[] {RDF.Property}; } // collect the properties to be written List<Resource> propertyResources = new ArrayList<Resource>(); for (int j = 0; j < props.length; j++) { for (StmtIterator i = m_source.listStatements( null, RDF.type, props[j] ); i.hasNext(); ) { propertyResources.add( i.nextStatement().getSubject() ); } } // now write the properties for (Iterator<? extends RDFNode> i = sorted( propertyResources ); i.hasNext(); ) { writeValue( (Resource) i.next(), template, propType, "create" + propType, "_PROP" ); } }
for (StmtIterator i = m_source.listStatements(); i.hasNext(); ) { Statement s = i.next(); countNamespace( s.getSubject(), nsCount );
/** Write classes as vanilla RDF terms */ protected void writeRDFClasses() { String template = m_options.hasClassTemplateOption() ? m_options.getClassTemplateOption() : DEFAULT_TEMPLATE; // make sure we're looking for the appropriate type of class Resource cls = OWL.Class; if (m_options.hasLangRdfsOption()) { cls = RDFS.Class; } // collect the classes to list List<Resource> classes = m_source.listStatements( null, RDF.type, cls ).mapWith( new Map1<Statement, Resource>() { @Override public Resource map1( Statement s ) { return s.getSubject(); }} ).toList(); for (Iterator<? extends RDFNode> i = sorted( classes ); i.hasNext(); ) { writeValue( (Resource) i.next(), template, "Resource", "createResource", "_CLASS" ); } }
for (i = om.listStatements(sp, new PropertyImpl("http://geni-orca.renci.org/owl/topology.owl#hasInterface"), (RDFNode) null); i.hasNext();){ Statement st = (Statement) i.next(); LIBNDL.logger().debug("FOUND Statement subject: " + st.getSubject() + ", predicate: " + st.getPredicate() + ", resource " + st.getResource()); for (i = om.listStatements(null, new PropertyImpl("http://geni-orca.renci.org/owl/topology.owl#hasInterface"), (RDFNode) spIface); i.hasNext();){ Statement st = (Statement) i.next(); LIBNDL.logger().debug("FOUND Statement subject: " + st.getSubject() + ", predicate: " + st.getPredicate() + ", resource " + st.getResource());
Profile prof = mOnt.getProfile(); ExtendedIterator<Statement> pi = mOnt.listStatements( null, RDF.type, getProfile().PROPERTY() ); pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.OBJECT_PROPERTY() ) ); pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.DATATYPE_PROPERTY() ) ); pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.FUNCTIONAL_PROPERTY() ) ); pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.INVERSE_FUNCTIONAL_PROPERTY() ) ); pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.SYMMETRIC_PROPERTY() ) ); pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.TRANSITIVE_PROPERTY() ) ); pi = pi.andThen( mOnt.listStatements( null, RDF.type, prof.ANNOTATION_PROPERTY() ) );
/** Answer an iterator over the individuals selected for output */ protected ExtendedIterator<? extends RDFNode> selectIndividuals() { List<Resource> candidates = new ArrayList<Resource>(); for (StmtIterator i = m_source.listStatements( null, RDF.type, (RDFNode) null ); i.hasNext(); ) { Statement candidate = i.nextStatement(); if (candidate.getObject().isResource()) { Resource candObj = candidate.getResource(); Resource candSubj = candidate.getSubject(); // ignore RDFS and OWL builtins if (!candObj.isAnon()) { String candTypeURI = candObj.getURI(); if (candTypeURI.startsWith( RDF.getURI() ) || candTypeURI.startsWith( OWL.getURI() ) || candTypeURI.startsWith( RDFS.getURI() )) { continue; } } // note that whether candSubj is included is tested later on by {@link #filter} if (!candSubj.isAnon() && (isIncluded( candObj ) || isIncluded( candSubj )) && !candidates.contains( candSubj )) { candidates.add( candSubj ); } } } return sorted( candidates ); }
for (StmtIterator i = model.listStatements( null, model.getProfile().IMPORTS(), (RDFNode) null ); i.hasNext(); ) { imports.remove( i.nextStatement().getResource().getURI() );
StmtIterator itr = ontHandler.getOntModel().listStatements();
String state = "Active"; Iterator i = null; for (i = om.listStatements(null, NdlCommons.inRequestNetworkConnection, (RDFNode) l); i.hasNext();){ Statement st = (Statement) i.next(); LIBNDL.logger().debug("FOUND Statement subject: " + st.getSubject() + ", predicate: " + st.getPredicate() + ", resource " + st.getResource());
public RDFModel read(String uri, boolean loadImports) { RDFModel m = new RDFModel(); OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); model.getDocumentManager().setProcessImports( loadImports ); FileManager.get().readModel( model, uri ); StmtIterator stmtIter = model.listStatements(); while( stmtIter.hasNext() ) { Statement stmt = stmtIter.nextStatement(); m.addStatement( stmt ); } return m; } }
public RDFModel read(String uri, boolean loadImports) { RDFModel m = new RDFModel(); OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); model.getDocumentManager().setProcessImports( loadImports ); FileManager.get().readModel( model, uri ); StmtIterator stmtIter = model.listStatements(); while( stmtIter.hasNext() ) { Statement stmt = stmtIter.nextStatement(); m.addStatement( stmt ); } return m; } }