コード例 #1
0
ファイル: Utils.java プロジェクト: retog/clerezza-rdf-core
 private static boolean isGrounded(Triple triple) {
   if (triple.getSubject() instanceof BlankNode) {
     return false;
   }
   if (triple.getObject() instanceof BlankNode) {
     return false;
   }
   return true;
 }
コード例 #2
0
 // called withiong write-lock
 private void removeExistingRequiredReadPermissions(IRI GraphUri, Graph permissionMGraph) {
   try {
     Triple t = permissionMGraph.filter(GraphUri, readPermissionListProperty, null).next();
     RDFTerm list = t.getObject();
     removeList((BlankNodeOrIRI) list, permissionMGraph);
     permissionMGraph.remove(t);
   } catch (NoSuchElementException e) {
     // There was no existing to remove
   }
 }
コード例 #3
0
 private void readList(BlankNodeOrIRI list, Graph permissionMGraph, LinkedList<String> target) {
   if (list.equals(rdfNil)) {
     return;
   }
   Triple restTriple = permissionMGraph.filter(list, rest, null).next();
   BlankNodeOrIRI restList = (BlankNodeOrIRI) restTriple.getObject();
   readList(restList, permissionMGraph, target);
   Triple firstTriple = permissionMGraph.filter(list, first, null).next();
   Literal firstValue = (Literal) firstTriple.getObject();
   String value = LiteralFactory.getInstance().createObject(String.class, firstValue);
   target.addFirst(value);
 }
コード例 #4
0
ファイル: Utils.java プロジェクト: retog/clerezza-rdf-core
 static Set<BlankNode> getBNodes(Collection<Triple> s) {
   Set<BlankNode> result = new HashSet<BlankNode>();
   for (Triple triple : s) {
     if (triple.getSubject() instanceof BlankNode) {
       result.add((BlankNode) triple.getSubject());
     }
     if (triple.getObject() instanceof BlankNode) {
       result.add((BlankNode) triple.getObject());
     }
   }
   return result;
 }
コード例 #5
0
 private void removeList(BlankNodeOrIRI list, Graph permissionMGraph) {
   try {
     Triple t = permissionMGraph.filter(list, rest, null).next();
     RDFTerm restList = t.getObject();
     removeList((BlankNodeOrIRI) restList, permissionMGraph);
     permissionMGraph.remove(t);
     Iterator<Triple> iter = permissionMGraph.filter(list, first, null);
     iter.next();
     iter.remove();
   } catch (NoSuchElementException e) {
     // if it has no rest its rdf:NIL and has no first
   }
 }
コード例 #6
0
 private Collection<String> getRequiredPermissionStrings(final IRI GraphUri, IRI property) {
   try {
     final Graph permissionMGraph = tcManager.getMGraph(permissionGraphName);
     Lock l = permissionMGraph.getLock().readLock();
     l.lock();
     try {
       Triple t = permissionMGraph.filter(GraphUri, property, null).next();
       BlankNodeOrIRI list = (BlankNodeOrIRI) t.getObject();
       LinkedList<String> result = new LinkedList<String>();
       readList(list, permissionMGraph, result);
       return result;
     } catch (NoSuchElementException e) {
       return new ArrayList<String>(0);
     } finally {
       l.unlock();
     }
   } catch (NoSuchEntityException e) {
     return new ArrayList<String>(0);
   }
 }