/** * creates and returns an <code>RdfList</code> for the node and * Graph represented by this object. * * @return a List to easy access the rdf:List represented by this node */ public List<RDFTerm> asList() { if (resource instanceof BlankNodeOrIRI) { return new RdfList((BlankNodeOrIRI) resource, graph); } else { throw new RuntimeException("Literals cannot be the subject of a List"); } }
/** * creates and returns an <code>RdfList</code> for the node and * Graph represented by this object. * * @return a List to easy access the rdf:List represented by this node */ public List<RDFTerm> asList() { if (resource instanceof BlankNodeOrIRI) { return new RdfList((BlankNodeOrIRI) resource, graph); } else { throw new RuntimeException("Literals cannot be the subject of a List"); } }
private List<Resource> getPropertyList(GraphNode r) { Iterator<GraphNode> propertyLists = r.getObjectNodes(CRIS.propertyList); if (propertyLists.hasNext()) { List<Resource> rdfList = new RdfList(propertyLists.next()); return rdfList; } throw new RuntimeException("There is no propertyList on this definition."); }
/** * Returns the rdf lists of which the specified <code>GraphNode</code> is * an element of. Sublists of other lists are not returned. * * @param element * @return */ public static Set<RdfList> findContainingLists(GraphNode element) { Set<GraphNode> listNodes = findContainingListNodes(element); if (listNodes.isEmpty()) { return null; } Set<RdfList> rdfLists = new HashSet<RdfList>(); for (Iterator<GraphNode> it = listNodes.iterator(); it.hasNext();) { GraphNode listNode = it.next(); rdfLists.add(new RdfList(listNode)); } return rdfLists; }
/** * Returns the rdf lists of which the specified <code>GraphNode</code> is * an element of. Sublists of other lists are not returned. * * @param element * @return */ public static Set<RdfList> findContainingLists(GraphNode element) { Set<GraphNode> listNodes = findContainingListNodes(element); if (listNodes.isEmpty()) { return null; } Set<RdfList> rdfLists = new HashSet<RdfList>(); for (Iterator<GraphNode> it = listNodes.iterator(); it.hasNext();) { GraphNode listNode = it.next(); rdfLists.add(new RdfList(listNode)); } return rdfLists; }
/** if value id an rdf:list in tc, initialize list * @param tc */ private void doListInitialization(Graph tc) { if (value instanceof BlankNodeOrIRI) { if ((tc.filter((BlankNodeOrIRI) value, RDF.rest, null).hasNext()) || (tc.filter((BlankNodeOrIRI) value, OWL.sameAs, RDF_NIL).hasNext())) { list = new RdfList((BlankNodeOrIRI) value, tc); } } }
/** * Creates an empty RdfList by writing a triple * "{@code listRDFTerm} owl:sameAs rdf.nil ." to {@code tc}. * * @param listRDFTerm * @param tc * @return an empty rdf:List. * @throws IllegalArgumentException * if the provided {@code listRDFTerm} is a non-empty rdf:List. */ public static RdfList createEmptyList(BlankNodeOrIRI listRDFTerm, Graph tc) throws IllegalArgumentException { if (!tc.filter(listRDFTerm, RDF.first, null).hasNext()) { RdfList list = new RdfList(listRDFTerm, tc); list.tc.add(new TripleImpl(listRDFTerm, OWL.sameAs, RDF_NIL)); return list; } else { throw new IllegalArgumentException(listRDFTerm + "is a non-empty rdf:List."); } }
private NonLiteral getConceptProviderListNode(MGraph contentGraph) { Iterator<Triple> triples = contentGraph.filter(null, RDF.type, CONCEPTS.ConceptProviderList); if (triples.hasNext()) { return triples.next().getSubject(); } NonLiteral cplNode = new BNode(); new RdfList(cplNode, contentGraph); contentGraph.add(new TripleImpl(cplNode, RDF.type, CONCEPTS.ConceptProviderList)); return cplNode; }
/** * Creates an empty RdfList by writing a triple * "{@code listRDFTerm} owl:sameAs rdf.nil ." to {@code tc}. * * @param listRDFTerm * @param tc * @return an empty rdf:List. * @throws IllegalArgumentException * if the provided {@code listRDFTerm} is a non-empty rdf:List. */ public static RdfList createEmptyList(BlankNodeOrIRI listRDFTerm, Graph tc) throws IllegalArgumentException { if (!tc.filter(listRDFTerm, RDF.first, null).hasNext()) { RdfList list = new RdfList(listRDFTerm, tc); list.tc.add(new TripleImpl(listRDFTerm, OWL.sameAs, RDF_NIL)); return list; } else { throw new IllegalArgumentException(listRDFTerm + "is a non-empty rdf:List."); } }
/** * The activate method is called when SCR activates the component configuration. * * @param componentContext */ protected void activate(ComponentContext componentContext) { LockableMGraph systemGraph = getSystemGraph(); NonLiteral listNode = getListNode(systemGraph); Lock writeLock = systemGraph.getLock().writeLock(); writeLock.lock(); try { // the constructor of RdfList might write to the graph! => requires a write lock final RdfList rdfList = new RdfList(listNode, systemGraph); languageList = Collections.synchronizedList(rdfList); //access to languages should not require access to system graph, //so copying the resources to an ArrayList languageListCache = Collections.synchronizedList( new ArrayList<Resource>(rdfList)); if (languageListCache.size() == 0) { addLanguage(new UriRef("http://www.lingvoj.org/lang/en")); } //this is to make sure the content graph contains the relevant data synchronizeContentGraph(); } finally { writeLock.unlock(); } }
BNode listBNode = new BNode(); definitionGraph.add(new TripleImpl(virtualProperty, CRIS.propertyList, listBNode)); List rdfList = new RdfList(listBNode, definitionGraph); for (VirtualProperty uri : joinVirtualProperty.properties) { rdfList.add(asResource(uri)); BNode listBNode = new BNode(); definitionGraph.add(new TripleImpl(virtualProperty, CRIS.propertyList, listBNode)); List rdfList = new RdfList(listBNode, definitionGraph); for (UriRef uri : pathVirtualProperty.properties) { rdfList.add(uri);
private void instantiateConceptProviders() { conceptProviderList.clear(); MGraph contentGraph = cgProvider.getContentGraph(); NonLiteral cplNode = getConceptProviderListNode(contentGraph); RdfList cpl = new RdfList(cplNode, contentGraph); for (int i = 0; i < cpl.size(); i++) { NonLiteral conceptProvider = (NonLiteral) cpl.get(i); Iterator<Triple> conceptProviderTypes = contentGraph.filter( conceptProvider, RDF.type, null); if (conceptProviderTypes.hasNext()) { UriRef conceptProviderType = (UriRef) conceptProviderTypes.next().getObject(); if (conceptProviderType.equals(CONCEPTS.LocalConceptProvider)) { instantiateLocalConceptProvider(contentGraph, conceptProvider); } else { instantiateRemoteConceptProvider(contentGraph, conceptProvider); } } } }
List<Resource> resultList = new RdfList(userOverviewPage, resultGraph); for (int i = from; i < to; i++) { resultList.add(userList.get(i).getNode());
RdfList cpl = new RdfList(cplNode, contentGraph);
private GraphNode addLanguages(GraphNode node, NonLiteral platformInstance, List<LanguageDescription> languages, boolean copyToNode) { TripleCollection graph = node.getGraph(); BNode listNode = new BNode(); RdfList list = new RdfList(listNode, graph); LockableMGraph configGraph = getConfigGraph(); Lock readLock = configGraph.getLock().readLock(); for (LanguageDescription languageDescription : languages) { NonLiteral languageUri = (NonLiteral) languageDescription.getResource().getNode(); list.add(languageUri); if (copyToNode) { readLock.lock(); try { graph.addAll(new GraphNode(languageUri, configGraph).getNodeContext()); } finally { readLock.unlock(); } } } node.addProperty(PLATFORM.instance, platformInstance); graph.add(new TripleImpl(platformInstance, RDF.type, PLATFORM.Instance)); graph.add(new TripleImpl(platformInstance, PLATFORM.languages, listNode)); graph.add(new TripleImpl(listNode, RDF.type, LANGUAGE.LanguageList)); if (!copyToNode) { node = new GraphNode(node.getNode(), new UnionMGraph(graph, configGraph)); } return node; }
private NonLiteral asRdfList(SortedSet<Menu> menus, TripleCollection mGraph) { NonLiteral result = new BNode(); RdfList list = new RdfList(result, mGraph); for (Menu menu : menus) { BNode node = new BNode();
private NonLiteral itemsAsRdfList(SortedSet<GlobalMenuItem> menus, TripleCollection mGraph) { NonLiteral result = new BNode(); RdfList list = new RdfList(result, mGraph); for (GlobalMenuItem item : menus) { BNode node = new BNode(); final String label = item.getLabel(); Literal labelLiteral = new PlainLiteralImpl(label); mGraph.add(new TripleImpl(node, RDFS.label,labelLiteral)); final String description = item.getDescription(); if (description != null) { Literal descLiteral = new PlainLiteralImpl(description); mGraph.add(new TripleImpl(node, DCTERMS.description, descLiteral)); } final String path = item.getPath(); if (path != null) { Literal pathLiteral = LiteralFactory.getInstance(). createTypedLiteral(path); mGraph.add(new TripleImpl(node, GLOBALMENU.path, pathLiteral)); } mGraph.add(new TripleImpl(node, RDF.type, GLOBALMENU.MenuItem)); list.add(node); } return result; } }