/** * Getter for the IRI representing the ID of this Representation. * @return The IRI representing the ID of this Representation. */ public IRI getNode(){ return (IRI)graphNode.getNode(); }
private Graph getExpandedContext(GraphNode node) { final Graph result = new SimpleGraph(node.getNodeContext()); final Set<RDFTerm> expandedResources = new HashSet<RDFTerm>(); expandedResources.add(node.getNode()); while (true) { Set<RDFTerm> additionalExpansionRes = getAdditionalExpansionResources(result); additionalExpansionRes.removeAll(expandedResources); if (additionalExpansionRes.size() == 0) { return result; } for (RDFTerm resource : additionalExpansionRes) { final GraphNode additionalNode = new GraphNode(resource, node.getGraph()); result.addAll(additionalNode.getNodeContext()); expandedResources.add(resource); } } }
/** * Getter for the IRI representing the ID of this Representation. * @return The IRI representing the ID of this Representation. */ public IRI getNode(){ return (IRI)graphNode.getNode(); }
private Graph getExpandedContext(GraphNode node, GraphNode recipe) { final Graph result = new SimpleGraph(node.getNodeContext()); final Set<RDFTerm> expandedResources = new HashSet<RDFTerm>(); expandedResources.add(node.getNode()); while (true) { Set<RDFTerm> additionalExpansionRes = getAdditionalExpansionResources(result, recipe); additionalExpansionRes.removeAll(expandedResources); if (additionalExpansionRes.size() == 0) { return result; } for (RDFTerm resource : additionalExpansionRes) { final GraphNode additionalNode = new GraphNode(resource, node.getGraph()); result.addAll(additionalNode.getNodeContext()); expandedResources.add(resource); } } }
/** * Get a list for the specified resource node. * * @param listNode */ public RdfList(GraphNode listNode) { this((BlankNodeOrIRI)listNode.getNode(), listNode.getGraph()); }
private Graph getExpandedContext(GraphNode node) { final Graph result = new SimpleGraph(node.getNodeContext()); final Set<RDFTerm> expandedResources = new HashSet<RDFTerm>(); expandedResources.add(node.getNode()); while (true) { Set<RDFTerm> additionalExpansionRes = getAdditionalExpansionResources(result); additionalExpansionRes.removeAll(expandedResources); if (additionalExpansionRes.size() == 0) { return result; } for (RDFTerm resource : additionalExpansionRes) { final GraphNode additionalNode = new GraphNode(resource, node.getGraph()); result.addAll(additionalNode.getNodeContext()); expandedResources.add(resource); } } }
@Override public int hashCode() { return 13 * getNode().hashCode() + getGraph().hashCode(); }
@Override public GraphNode getUserGraphNode(final String name) { Graph systemGraph = getSystemGraph(); BlankNodeOrIRI user = getUserByUserName(name); if (user != null) { GraphNode userNodeInSystemGraph = new GraphNode(getUserByUserName(name), systemGraph); Graph copiedUserContext = new SimpleGraph(userNodeInSystemGraph.getNodeContext()); return new GraphNode(userNodeInSystemGraph.getNode(), copiedUserContext); } else { return null; } }
/** * Get a list for the specified resource node. * * @param listNode */ public RdfList(GraphNode listNode) { this((BlankNodeOrIRI)listNode.getNode(), listNode.getGraph()); }
/** * Constructor. * * @param node An RDF resource. */ public GraphNodeDataFieldResolver(GraphNode node, RenderingFunctions renderingFunctions) { expandedNode = new ExpandedNode(node, node.getNode()); this.renderingFunctions = renderingFunctions; }
@Override public NonLiteral run() { return (NonLiteral) platformConfig.getPlatformInstance().getNode(); } });
@Override public int hashCode() { return 13 * getNode().hashCode() + getGraph().hashCode(); }
/** * * @param obj * @return true if obj is an instance of the same class represening the same * node in the same graph, subclasses may have different identity criteria. */ @Override public boolean equals(Object obj) { if (obj == null || !(obj.getClass().equals(getClass()))) { return false; } GraphNode other = (GraphNode) obj; return getNode().equals(other.getNode()) && getGraph().equals(other.getGraph()); }
/** * * @param obj * @return true if obj is an instance of the same class represening the same * node in the same graph, subclasses may have different identity criteria. */ @Override public boolean equals(Object obj) { if (obj == null || !(obj.getClass().equals(getClass()))) { return false; } GraphNode other = (GraphNode) obj; return getNode().equals(other.getNode()) && getGraph().equals(other.getGraph()); }
private void addAvailableRoles(GraphNode result) { Iterator<NonLiteral> roles = userManager.getRoles(); while (roles.hasNext()) { GraphNode role = new GraphNode(roles.next(), systemGraph); result.addProperty(USERMANAGER.role, role.getNode()); addCustomPropertiesOfRole(role, 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; }
private void addBaseRoles(GraphNode result) { Lock readLock = systemGraph.getLock().readLock(); readLock.lock(); try { Iterator<Triple> baseRoles = systemGraph.filter(null, RDF.type, PERMISSION.BaseRole); if (baseRoles.hasNext()) { GraphNode baseRole = new GraphNode(baseRoles.next().getSubject(), systemGraph); result.addProperty(USERMANAGER.role, baseRole.getNode()); addCustomPropertiesOfRole(baseRole, result); } } finally { readLock.unlock(); } } private void addCustomPropertiesOfRole(GraphNode role, GraphNode result) {
private Set<String> retrieveAllPermissionEntriesFromUser(String userName) { Set<String> permissionEntries = new HashSet<String>(); NonLiteral currentUser = (NonLiteral) userManager.getUserInSystemGraph(userName).getNode(); Iterator<NonLiteral> roles = userManager.getRolesOfUser(currentUser); while(roles.hasNext()) { Iterator<NonLiteral> permissions = userManager.getPermissionsOfRole(roles.next()); retrievePermissionEntries(permissionEntries, permissions); } Iterator<NonLiteral> permissions = userManager.getPermissionsOfUser(currentUser); retrievePermissionEntries(permissionEntries, permissions); return permissionEntries; }
private void addCustomPropertiesOfRole(GraphNode role, GraphNode result) { Iterator<Literal> titles = role.getLiterals(DC.title); String title = ""; if(titles.hasNext()) { title = titles.next().getLexicalForm(); } NonLiteral customFieldCollection = customPropertyManager.getCustomPropertyCollection(PERMISSION.Role, title); result.getGraph().add(new TripleImpl((NonLiteral) role.getNode(), USERMANAGER.custominformation, customFieldCollection)); } }
private GraphNode addPermission(GraphNode subjectNode, String permissionString) { if (hasPermission(subjectNode, permissionString)) { return subjectNode; } GraphNode permissionNode = new GraphNode(new BlankNode(), systemGraph); permissionNode.addProperty(RDF.type, PERMISSION.Permission); // permissionNode.addProperty(DC.title, new PlainLiteralImpl(permissionName)); subjectNode.addProperty(PERMISSION.hasPermission, permissionNode.getNode()); permissionNode.addProperty(PERMISSION.javaPermissionEntry, new PlainLiteralImpl(permissionString)); return subjectNode; }