@Override public Graph getRefactoredDataSet(IRI uriRef) { return tcManager.getGraph(uriRef); }
protected void activate(ComponentContext componentContext) { this.context = componentContext.getBundleContext(); try { tcManager.getGraph(Constants.CONFIG_GRAPH_URI); } catch (NoSuchEntityException nsee) { tcManager.createGraph(Constants.CONFIG_GRAPH_URI); } }
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(); } }
/** * Execute a sparql construct on Clerezza. * * @param sparql * @param datasetID * @return */ private ImmutableGraph sparqlConstruct(ConstructQuery constructQuery, IRI datasetID) { Graph graph = tcManager.getGraph(datasetID); return sparqlConstruct(constructQuery, graph); }
@Override public Graph exportRecipe(Recipe recipe) throws NoSuchRecipeException { try { return tcManager.getGraph(recipe.getRecipeID()); } catch (NoSuchEntityException e) { throw new NoSuchRecipeException(recipe.toString()); } }
@Override public Graph exportRecipe(Recipe recipe) throws NoSuchRecipeException { try { return tcManager.getGraph(recipe.getRecipeID()); } catch (NoSuchEntityException e) { throw new NoSuchRecipeException(recipe.toString()); } }
protected void activate(ComponentContext context) { try { tcManager.getGraph(Constants.CONTENT_GRAPH_URI); } catch (NoSuchEntityException nsee) { tcManager.createGraph(Constants.CONTENT_GRAPH_URI); } String[] additionUriStrings = (String[]) context.getProperties().get( CONTENT_ADDITIONS); additions = new IRI[additionUriStrings.length]; for (int i = 0; i < additionUriStrings.length; i++) { additions[i] = new IRI(additionUriStrings[i]); } }
@Override public boolean containsGraph(Node node) { try { tcManager.getGraph(new IRI(node.getURI())); return true; } catch (NoSuchEntityException e) { return false; } }
/** * Should be called within both OSGi and non-OSGi environments. * * @param configuration * @throws IOException */ protected void activate(Dictionary<String,Object> configuration) throws IOException { if (recipeIndexLocation == null || recipeIndexLocation.trim().isEmpty()) { String value = (String) configuration.get(RECIPE_INDEX_LOCATION); if (value != null && !value.trim().isEmpty()) recipeIndexLocation = value; else recipeIndexLocation = _RECIPE_INDEX_LOCATION_DEFAULT; } recipes = new ArrayList<IRI>(); Graph tripleCollection = null; try { tripleCollection = tcManager.getGraph(new IRI(recipeIndexLocation)); } catch (NoSuchEntityException e) { tripleCollection = tcManager.createGraph(new IRI(recipeIndexLocation)); } for (Triple triple : tripleCollection) { IRI recipeID = (IRI) triple.getSubject(); recipes.add(recipeID); } log.info("Rule Store activated. It contains " + recipes.size() + " recipes.", this); }
private Set<IRI> expand(GraphNode node, Set<IRI> alreadyVisited, int recursion) { Set<IRI> rdfSeeAlsoTargets = getSeeAlsoObjectUris(node); Set<IRI> result = new HashSet<IRI>(); result.addAll(rdfSeeAlsoTargets); recursion++; if (recursion > 0) { rdfSeeAlsoTargets.removeAll(alreadyVisited); alreadyVisited.addAll(rdfSeeAlsoTargets); for (IRI target : rdfSeeAlsoTargets) { try { result.addAll(expand(new GraphNode(node.getNode(), tcManager.getGraph(target)), alreadyVisited, recursion)); } catch (NoSuchEntityException e) { //ignore } } } return result; }
private Set<IRI> expand(GraphNode node, Set<IRI> alreadyVisited, int recursion) { Set<IRI> rdfSeeAlsoTargets = getSeeAlsoObjectUris(node); Set<IRI> result = new HashSet<IRI>(); result.addAll(rdfSeeAlsoTargets); recursion++; if (recursion > 0) { rdfSeeAlsoTargets.removeAll(alreadyVisited); alreadyVisited.addAll(rdfSeeAlsoTargets); for (IRI target : rdfSeeAlsoTargets) { try { result.addAll(expand(new GraphNode(node.getNode(), tcManager.getGraph(target)), alreadyVisited, recursion)); } catch (NoSuchEntityException e) { //ignore } } } return result; }
/** * 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()]))); }
@Override public com.hp.hpl.jena.graph.Graph getGraph(Node node) { final JenaGraph jenaGraph = new JenaGraph( tcManager.getGraph(new IRI(node.getURI()))); return jenaGraph; }
@Override public boolean removeRecipe(IRI recipeID) throws RecipeEliminationException { // remove the recipe from the TcManager try { tcManager.deleteGraph(recipeID); } catch (NoSuchEntityException e) { throw new RecipeEliminationException(e); } Graph recipeIndexGraph = tcManager.getGraph(new IRI(recipeIndexLocation)); Triple triple = new TripleImpl(recipeID, RDF.type, Symbols.Recipe); recipeIndexGraph.remove(triple); // System.out.println("Recipes: " +recipes.size()); // remove the recipe ID from in-memory list recipes.remove(recipeID); return true; }
@Override public boolean removeRecipe(IRI recipeID) throws RecipeEliminationException { // remove the recipe from the TcManager try { tcManager.deleteGraph(recipeID); } catch (NoSuchEntityException e) { throw new RecipeEliminationException(e); } Graph recipeIndexGraph = tcManager.getGraph(new IRI(recipeIndexLocation)); Triple triple = new TripleImpl(recipeID, RDF.type, Symbols.Recipe); recipeIndexGraph.remove(triple); // System.out.println("Recipes: " +recipes.size()); // remove the recipe ID from in-memory list recipes.remove(recipeID); return true; }
@Override public Recipe removeRule(Recipe recipe, Rule rule) { Graph tripleCollection = tcManager.getGraph(recipe.getRecipeID()); // remove from the graph recipe all the triples having the ruleID as subject. Iterator<Triple> triplesIterator = tripleCollection.filter(rule.getRuleID(), null, null); while (triplesIterator.hasNext()) { tripleCollection.remove(triplesIterator.next()); } // remove from the graph recipe the triple recipeID hasRule ruleID tripleCollection.remove(new TripleImpl(recipe.getRecipeID(), Symbols.hasRule, rule.getRuleID())); recipe.removeRule(rule); return recipe; }
@Override public Recipe removeRule(Recipe recipe, Rule rule) { Graph tripleCollection = tcManager.getGraph(recipe.getRecipeID()); // remove from the graph recipe all the triples having the ruleID as subject. Iterator<Triple> triplesIterator = tripleCollection.filter(rule.getRuleID(), null, null); while (triplesIterator.hasNext()) { tripleCollection.remove(triplesIterator.next()); } // remove from the graph recipe the triple recipeID hasRule ruleID tripleCollection.remove(new TripleImpl(recipe.getRecipeID(), Symbols.hasRule, rule.getRuleID())); recipe.removeRule(rule); return recipe; }
@Override public Recipe createRecipe(IRI recipeID, String recipeDescription) throws AlreadyExistingRecipeException { Graph tripleCollection; try { // create the Graph in the TcManager tripleCollection = tcManager.createGraph(recipeID); } catch (EntityAlreadyExistsException e) { throw new AlreadyExistingRecipeException(e.getMessage()); } Triple recipeTriple = new TripleImpl(recipeID, RDF.type, Symbols.Recipe); Graph recipeIndexGraph = tcManager.getGraph(new IRI(recipeIndexLocation)); recipeIndexGraph.add(recipeTriple); if (recipeDescription != null && !recipeDescription.isEmpty()) { Triple descriptionTriple = new TripleImpl(recipeID, Symbols.description, new PlainLiteralImpl( recipeDescription)); tripleCollection.add(descriptionTriple); recipeIndexGraph.add(descriptionTriple); } // add the recpe ID to the list of known recipes recipes.add(recipeID); return new RecipeImpl(recipeID, recipeDescription, null); }
@Override public Recipe createRecipe(IRI recipeID, String recipeDescription) throws AlreadyExistingRecipeException { Graph tripleCollection; try { // create the Graph in the TcManager tripleCollection = tcManager.createGraph(recipeID); } catch (EntityAlreadyExistsException e) { throw new AlreadyExistingRecipeException(e.getMessage()); } Triple recipeTriple = new TripleImpl(recipeID, RDF.type, Symbols.Recipe); Graph recipeIndexGraph = tcManager.getGraph(new IRI(recipeIndexLocation)); recipeIndexGraph.add(recipeTriple); if (recipeDescription != null && !recipeDescription.isEmpty()) { Triple descriptionTriple = new TripleImpl(recipeID, Symbols.description, new PlainLiteralImpl( recipeDescription)); tripleCollection.add(descriptionTriple); recipeIndexGraph.add(descriptionTriple); } // add the recpe ID to the list of known recipes recipes.add(recipeID); return new RecipeImpl(recipeID, recipeDescription, null); }