/** Answer an iterator that contains the elements of the given list, but sorted by URI */ protected ExtendedIterator<? extends RDFNode> sorted( ExtendedIterator<? extends RDFNode> i ) { return sorted( i.toList() ); }
@Override public int size() { int size = find(null, null, null).toList().size(); return size; }
public List<Individual> getIndividualsOfClass(Resource clazz) { return model.listIndividuals(clazz).toList(); }
public SpecCommon(Resource root) { this.root = root; for (RDFNode x: root.listProperties(ELDA_API.license).mapWith(Statement.Util.getObject).toList()) { licences.add(x); } }
protected static RDFNode getUnique( Resource root, Property property ) { List<RDFNode> nodes = root.listProperties( property ) .mapWith( getObject ).toList(); if (nodes.size() == 0) return null; if (nodes.size() == 1) return nodes.get(0); throw new NotUniqueException( root, property ); }
/** Answer the list of sources that may be used to enhance the view of the selected items. Always contains at least the given source. */ private List<Source> extractDescribeSources( FileManager fm, AuthMap am, Resource specification, Source dataSource ) { List<Source> result = new ArrayList<Source>(); result.add( dataSource ); result.addAll( specification.listProperties( ELDA_API.enhanceViewWith ).mapWith( toSource( fm, am ) ).toList() ); return result; }
/** remove all bindings which map to this triple. */ public static void remove(Graph graph, Triple triple) { // Materialize the nodes to delete - avoid ConcurrentModificationException. for ( Node n : allNodes(graph, triple).toList() ) remove(graph, n, triple) ; }
public Set<Resource> getNotices() { Set<Resource> result = new HashSet<Resource>(); for (RDFNode x: root.listProperties(ELDA_API.notice).mapWith(Statement.Util.getObject).toList()) { result.add(x.asResource()); } return result; } }
private List<RDFNode> getEntryAuthors(Resource r) { for (Property p: getAuthorProperties()) { List<RDFNode> candidates = r.listProperties(p).mapWith(Statement.Util.getObject).toList(); if (candidates.size() > 0) return candidates; } return new ArrayList<RDFNode>(); }
public static void addLoadedFrom( Model m, String name ) { List<Statement> toAdd = new ArrayList<Statement>(); List<Resource> apis = m .listStatements( null, RDF.type, API.API ) .mapWith(Statement.Util.getSubject) .toList() ; for (Resource api: apis) toAdd.add( m.createStatement( api, ELDA_API.loadedFrom, name ) ); m.add( toAdd ); }
/** ep is a resource of type Combiner. It has multiple elements, each of which themselves represent sub-sources. */ public CombinedSource( FileManager fm, AuthMap am, Resource ep ) { constructs = ep.listProperties( ELDA_API.construct ).mapWith( toString ).toList(); matches = ep.listProperties( ELDA_API.match ).mapWith( toString ).toList(); sources = ep.listProperties( ELDA_API.element ).mapWith( toSource( fm, am ) ).toList(); }
protected Set<Couple<String, Resource>> allFiltersOf( Set<Couple<String, Resource>> them, Resource sel) { for (RDFNode p: sel.listProperties( API.parent ).mapWith( Statement.Util.getObject ).toList()) { allFiltersOf( them, (Resource) p ); } for (RDFNode f: sel.listProperties( API.filter ).mapWith( Statement.Util.getObject).toList()) { String pvs = ((Literal) f).getLexicalForm(); for (String filter: pvs.split( "&" )) them.add( new Couple<String, Resource>( filter, sel ) ); } return them; }
private void addLocal() { TurtleInputPanel turtlePanel = new TurtleInputPanel(rangeClass); if (showConfirmDialog(null, turtlePanel, "Turtle input", OK_CANCEL_OPTION, QUESTION_MESSAGE) == OK_OPTION) { OntModel addedModel = turtlePanel.getContentAsModel(); for (Individual i : addedModel.listIndividuals(rangeClass) .toList()) resources.addItem(i); localWorld.addModelFromString(turtlePanel.getContentAsString()); } }
private void addLocal() { TurtleInputPanel turtlePanel = new TurtleInputPanel(rangeClass); if (showConfirmDialog(null, turtlePanel, "Turtle input", OK_CANCEL_OPTION, QUESTION_MESSAGE) == OK_OPTION) { OntModel addedModel = turtlePanel.getContentAsModel(); for (Individual i : addedModel.listIndividuals(rangeClass) .toList()) resources.addItem(i); localWorld.addModelFromString(turtlePanel.getContentAsString()); } }
@Override public void clear() { ExtendedIterator<Triple> allTriples = getMatches(Node.ANY, Node.ANY, Node.ANY); for (Triple t : allTriples.toList()) { this.delete(t); } getEventManager().notifyEvent(this, GraphEvents.removeAll); }
private static Resource getRendererType( Resource r ) { for (RDFNode tn: r.listProperties( RDF.type ).mapWith( Statement.Util.getObject ).toList()) { Resource t = tn.asResource(); if (BuiltinRendererTable.isRendererType( t )) return t; } return null; }
/** * The list of NdlCommons.computeElementClass includes both the actual node elements, and each unique domain for * those node elements. In #157, a domain with both VM and BareMetal node elements would "lose" track of one of * those type of elements, which was exhibited in the domain for the "missing" one to not be present in this list. * * @param manifestModel * @param expectedComputeElements */ protected static void assertManifestHasNumberOfComputeElements(OntModel manifestModel, int expectedComputeElements) { final List<Individual> individuals = manifestModel.listIndividuals(NdlCommons.computeElementClass).toList(); assertEquals("List of Compute Elements did not match expected size.", expectedComputeElements, individuals.size()); } }
@Override public void remove(Node s, Node p, Node o) { ExtendedIterator<Triple> allTriples = find(s, p, o); for (Triple t : allTriples.toList()) { this.delete(t); } getEventManager().notifyEvent(this, GraphEvents.remove(s, p, o)); }
/** Add properties to the view, setting the property chains and possibly the labelled-describe label property URI. */ private View addViewProperties( Model m, Set<Resource> seen, Resource tRes, View v ) { setDescribeLabelIfPresent( tRes, v ); addViewPropertiesByString( v, m.listObjectsOfProperty( tRes, API.properties ).toList() ); addViewPropertiesByResource( v, m.listObjectsOfProperty( tRes, API.property ).toList() ); for (RDFNode n: tRes.listProperties( API.include ).mapWith( Statement.Util.getObject ).toList()) { if (n.isResource() && seen.add( (Resource) n )) addViewProperties( m, seen, (Resource) n, v ); } return v; }
private void extractDatatypes( Model m ) { List<Resource> dataTypes = m.listStatements( null, RDF.type, RDFS.Datatype ).mapWith( Statement.Util.getSubject ).toList(); for (Resource t: dataTypes) declareDatatype( t.getURI() ); for (Resource p: m.listSubjectsWithProperty( RDF.type, OWL.DatatypeProperty ).toList()) { for (RDFNode t: m.listObjectsOfProperty( p, RDFS.range ).toList()) { declareDatatype( t.asResource().getURI() ); } } }