public Graph getContentGraph() { configLock.readLock().lock(); try { Graph[] united = new Graph[additions.length + 1]; int i = 0; united[i++] = tcManager.getGraph(Constants.CONTENT_GRAPH_URI); for (IRI uriRef : additions) { united[i++] = tcManager.getGraph(uriRef); } return new UnionGraph(united); } finally { configLock.readLock().unlock(); } }
/** * Constructs a UnionGraph over the specified baseTripleCollections. Write * and delete operations are forwarded to the first baseTripleCollections. * * @param baseTripleCollections the baseTripleCollections */ public UnionGraph(Graph... baseTripleCollections) { this.baseTripleCollections = baseTripleCollections; readLock = getPartialReadLock(0); writeLock = createWriteLock(); }
private Lock createWriteLock() { Lock partialReadLock = getPartialReadLock(1); Lock baseWriteLock = (baseTripleCollections[0]).getLock().writeLock(); return new UnionLock(baseWriteLock, partialReadLock); }
private Lock createWriteLock() { Lock partialReadLock = getPartialReadLock(1); Lock baseWriteLock = (baseTripleCollections[0]).getLock().writeLock(); return new UnionLock(baseWriteLock, partialReadLock); }
private void createUnionGraph() { Graph[] docGraphs = bundle2DocGraphMap.values(). toArray(new Graph[bundle2DocGraphMap.size()]); if (docGraphs.length > 0) { unitedDocumentations = new SimpleImmutableGraph(new UnionGraph(docGraphs), true); } else { unitedDocumentations = new SimpleImmutableGraph(new SimpleGraph(), true); } } }
/** * Constructs a UnionGraph over the specified baseTripleCollections. Write * and delete operations are forwarded to the first baseTripleCollections. * * @param baseTripleCollections the baseTripleCollections */ public UnionGraph(Graph... baseTripleCollections) { this.baseTripleCollections = baseTripleCollections; readLock = getPartialReadLock(0); writeLock = createWriteLock(); }
/** * expands a node dereferencing its rdfs:seeAlso references using the * tcManager associated to this instance. If the added TripleCollections * also associate rdfs:seeAlso properties to node this are expanded till * the maximum recursion depth specified. * * @param node the node to be expanded * @param recursion the maximum recursion depth * @return a new GraphNode over the union of the original and all expansion graphs */ public GraphNode expand(GraphNode node, int recursion) { Set<IRI> alreadyVisited = new HashSet(); Set<Graph> resultTripleCollections = new HashSet<Graph>(); resultTripleCollections.add(node.getGraph()); for (IRI uriRef : expand(node, alreadyVisited, recursion)) { try { resultTripleCollections.add(tcManager.getGraph(uriRef)); } catch (NoSuchEntityException e) { //ignore } } return new GraphNode(node.getNode(), new UnionGraph(resultTripleCollections.toArray( new Graph[resultTripleCollections.size()]))); }
/** * expands a node dereferencing its rdfs:seeAlso references using the * tcManager associated to this instance. If the added TripleCollections * also associate rdfs:seeAlso properties to node this are expanded till * the maximum recursion depth specified. * * @param node the node to be expanded * @param recursion the maximum recursion depth * @return a new GraphNode over the union of the original and all expansion graphs */ public GraphNode expand(GraphNode node, int recursion) { Set<IRI> alreadyVisited = new HashSet(); Set<Graph> resultTripleCollections = new HashSet<Graph>(); resultTripleCollections.add(node.getGraph()); for (IRI uriRef : expand(node, alreadyVisited, recursion)) { try { resultTripleCollections.add(tcManager.getGraph(uriRef)); } catch (NoSuchEntityException e) { //ignore } } return new GraphNode(node.getNode(), new UnionGraph(resultTripleCollections.toArray( new Graph[resultTripleCollections.size()]))); }
/** * Creates a {@link RDFBackend} over the {@link ContentItem#getMetadata() * metadata} and all {@link ContentItem#getPart(int, Class) content parts} * compatible to {@link Graph} * @param ci the content item * @param includeAdditionalMetadata if <code>true</code> the {@link RDFBackend} * will also include RDF data stored in content parts */ public ContentItemBackend(ContentItem ci, boolean includeAdditionalMetadata){ included = includeAdditionalMetadata ? unmodifiableMap(getContentParts(ci, Graph.class)) : EMPTY_INCLUDED; Graph graph; if(included.isEmpty()){ graph = ci.getMetadata(); } else { Graph[] tcs = new Graph[included.size()+1]; tcs[0] = ci.getMetadata(); System.arraycopy(included.values().toArray(), 0, tcs, 1, included.size()); graph = new UnionGraph(tcs); } backend = new ClerezzaBackend(graph); this.ci = ci; this.readLock = ci.getLock().readLock(); } /**
tcs[0] = ci.getMetadata(); System.arraycopy(tcs, 1, included.values().toArray(), 0, included.size()); graph = new UnionGraph(tcs);
/** * Redirects to the overview page * * @return {@link Response} * */ @GET public GraphNode documentationPage(@Context UriInfo uriInfo) { TrailingSlash.enforcePresent(uriInfo); ImmutableGraph documentations = tcManager.getImmutableGraph( DocumentationProvider.DOCUMENTATION_GRAPH_URI); Collection<DocumentationItem> docItems = getDocItems(documentations); List<DocumentationItem> sortedDocItems = sortDocItems(docItems); Graph mGraph = new SimpleGraph(); BlankNode orderedContent = createOrderedContent(sortedDocItems, mGraph); BlankNode titledContent = createTitledContent(orderedContent, mGraph); Graph resultGraph = new UnionGraph(mGraph, documentations); GraphNode resultNode = new GraphNode(titledContent, resultGraph); return resultNode; }
UnionGraph unionGraph = new UnionGraph(tripleCollections);
UnionGraph unionGraph = new UnionGraph(tripleCollections);
UnionGraph unionGraph = new UnionGraph(tripleCollections);
UnionGraph unionGraph = new UnionGraph(tripleCollections);