protected static String anonName(AnonId id) { String name = "_:A"; String sid = id.toString(); for (int i = 0; i < sid.length(); i++) { char c = sid.charAt(i); if (c == 'X') { name = name + "XX"; } else if (Character.isLetterOrDigit(c)) { name = name + c; } else { name = name + "X" + Integer.toHexString(c) + "X"; } } return name; } }
protected static String anonName(AnonId id) { String name = "_:A"; String sid = id.toString(); for (int i = 0; i < sid.length(); i++) { char c = sid.charAt(i); if (c == 'X') { name = name + "XX"; } else if (Character.isLetterOrDigit(c)) { name = name + c; } else { name = name + "X" + Integer.toHexString(c) + "X"; } } return name; } }
@Override public String getAnonymousID() { return resource.getId().toString(); }
private String makeDescribe(org.apache.jena.rdf.model.Resource s) { StringBuilder query = new StringBuilder("DESCRIBE <") ; if (s.isAnon()) { query.append("_:").append(s.getId().toString()); } else { query.append(s.getURI()); } query.append(">"); return query.toString(); }
private String makeDescribe(Resource s) { StringBuilder query = new StringBuilder("DESCRIBE <") ; if (s.isAnon()) { query.append("_:").append(s.getId().toString()); } else { query.append(s.getURI()); } query.append(">"); return query.toString(); }
private String longAnonId(Resource r) { String rid = r.getId().toString(); return XMLChar.isValidNCName( rid ) ? rid : escapedId( rid ); }
protected String getClassURIStr(Resource cls) { if (cls.isAnon()) { return PSEUDO_BNODE_NS+cls.getId().toString(); } else { return cls.getURI(); } }
private String longAnonId(Resource r) { String rid = r.getId().toString(); return XMLChar.isValidNCName( rid ) ? rid : escapedId( rid ); }
private static List<Statement> getDependentResourceDeleteList ( Statement stmt, Model model, Set<String> visitedUris, boolean perviousWasDependentResource ){ if( stmt == null ) return Collections.emptyList(); List<Statement> toDelete = new LinkedList<Statement>(); toDelete.add(stmt); RDFNode obj = stmt.getObject(); if( ( obj.canAs(Resource.class) && isPredicateDependencyRelation(stmt.getPredicate(), model) ) || ( obj.isAnon() && perviousWasDependentResource ) ){ Resource res = obj.as(Resource.class); String id = res.isAnon()?res.getId().toString():res.getURI(); if( !visitedUris.contains(id) ){ visitedUris.add(id); for( Statement stubStmt : getAllStatements(res, model)){ toDelete.addAll( getDependentResourceDeleteList(stubStmt, model,visitedUris,true)); } } } return toDelete; }
/** * Test that creation of an AnonId from an AnonId string preserves that * string and is equal to the original AnonId. */ public void testAnonIdPreserved() { final AnonId anon = AnonId.create(); final String id = anon.toString(); Assert.assertEquals(anon, AnonId.create(id)); Assert.assertEquals(id, AnonId.create(id).toString()); }
/** * Test that creation of an AnonId from an AnonId string preserves that * string and is equal to the original AnonId. */ public void testAnonIdPreserved() { final AnonId anon = AnonId.create(); final String id = anon.toString(); Assert.assertEquals(anon, AnonId.create(id)); Assert.assertEquals(id, AnonId.create(id).toString()); }
private void setUpURIParts(OntResource ind) { if (ind != null) { if (ind.isAnon()) { this.setNamespace(VitroVocabulary.PSEUDO_BNODE_NS); this.setLocalName(ind.getId().toString()); } else { this.URI = ind.getURI(); this.namespace = ind.getNameSpace(); this.localName = ind.getLocalName(); } } else if (individualURI != null) { log.warn("Null individual returned for URI " + individualURI); } }
protected String getClassURIStr(Resource cls) { if (cls.isAnon()) { return VitroVocabulary.PSEUDO_BNODE_NS+cls.getId().toString(); } else { return cls.getURI(); } } }
/** * Get the local name, bnode or URI of the resource. */ protected String getLocalNameOrId(OntResource r){ String label = null; r.getOntModel().enterCriticalSection(Lock.READ); try { String localName = r.getLocalName(); if (localName != null) { if(localName.trim().length() > 0) { label = localName; } else { label = r.getURI(); } } else if (r.isAnon()) { label = r.getId().toString(); } else { label = r.getURI(); } } finally { r.getOntModel().leaveCriticalSection(); } return label; }
public VClassJena(OntClass cls, WebappDaoFactoryJena wadf) { this.cls = cls; if (cls.isAnon()) { this.setNamespace(VitroVocabulary.PSEUDO_BNODE_NS); this.setLocalName(cls.getId().toString()); } else { this.URI = cls.getURI(); this.namespace = cls.getNameSpace(); this.localName = cls.getLocalName(); } this.webappDaoFactory = wadf; }
public IndividualJena(OntResource ind, WebappDaoFactoryJena wadf) { this.ind = ind; if (ind.isAnon()) { this.setNamespace(VitroVocabulary.PSEUDO_BNODE_NS); this.setLocalName(ind.getId().toString()); } else { this.URI = ind.getURI(); this.namespace = ind.getNameSpace(); this.localName = ind.getLocalName(); } this.webappDaoFactory = wadf; }
private List<VClass> getMyVClasses(boolean direct) { List<VClass> vClassList = new ArrayList<VClass>(); OntModel ontModel = ind.getOntModel(); ontModel.enterCriticalSection(Lock.READ); try { ClosableIterator typeIt = ind.listRDFTypes(direct); try { for (Iterator it = typeIt; it.hasNext();) { Resource type = (Resource) typeIt.next(); String typeURI = (!type.isAnon()) ? type.getURI() : VitroVocabulary.PSEUDO_BNODE_NS + type.getId().toString(); if (type.getNameSpace() == null || (!webappDaoFactory.getNonuserNamespaces().contains(type.getNameSpace())) ) { VClass vc = webappDaoFactory.getVClassDao().getVClassByURI(typeURI); if (vc != null) { vClassList.add(vc); } } } } finally { typeIt.close(); } } finally { ontModel.leaveCriticalSection(); } try { Collections.sort(vClassList); } catch (Exception e) {} return vClassList; }
/** * Get the local name, bnode or URI of the resource. */ protected String getLocalNameOrId(OntResource r){ String label = null; r.getOntModel().enterCriticalSection(Lock.READ); try { String localName = r.getLocalName(); if (localName != null) { label = localName; } else if (r.isAnon()) { label = r.getId().toString(); } else { label = r.getURI(); } } finally { r.getOntModel().leaveCriticalSection(); } return label; }