private boolean noPortalForNamespace(List<Resource> portals, String expectedNamespace) { for (Resource portal : portals) { if(expectedNamespace.equals(portal.getNameSpace())) { return false; } } return true; }
/** Record a use of the given namespace in the count map */ private void countNamespace( Resource r, Map<String,Integer> nsCount ) { if (!r.isAnon()) { String ns = r.getNameSpace(); // increment the count for this namespace Integer count = nsCount.containsKey( ns ) ? (Integer) nsCount.get( ns ) : new Integer( 0 ); Integer count1 = new Integer( count.intValue() + 1 ); nsCount.put( ns, count1 ); } }
/** Record a use of the given namespace in the count map */ private void countNamespace( Resource r, Map<String,Integer> nsCount ) { if (!r.isAnon()) { String ns = r.getNameSpace(); // increment the count for this namespace Integer count = nsCount.containsKey( ns ) ? (Integer) nsCount.get( ns ) : new Integer( 0 ); Integer count1 = new Integer( count.intValue() + 1 ); nsCount.put( ns, count1 ); } }
private static String guessNamespace(Model temp) { List<Resource> res = temp.listSubjectsWithProperty(RDF.type, OWL.Ontology).toList(); Map<String, Integer> tempMap = new HashMap<String, Integer>(); for (Resource r : res) { String ns = r.getNameSpace(); tempMap.put(ns, (tempMap.containsKey(ns)) ? (tempMap.get(ns) + 1) : 1); } if (tempMap.size() > 0) return (String) sortByValue(tempMap).keySet().toArray()[0]; else return null; }
/** * Returns the namespace associated with this resource. * * @return The namespace for this property. * @throws ReadDeniedException * @throws AuthenticationRequiredException */ @Override public String getNameSpace() throws ReadDeniedException, AuthenticationRequiredException { checkRead(); return holder.getBaseItem().getNameSpace(); }
@Override public Set<Resource> getUsedProperties() { Resource path = getPathAsRdf(); if (path.isURIResource()) { return ImmutableSet.of(path); } else { return path.getModel().listObjects() .toSet().stream() .filter(RDFNode::isURIResource) .map(RDFNode::asResource) .filter(r -> !r.getNameSpace().equals(RDF.getURI())) .filter(r -> !r.getNameSpace().equals(SHACL.namespace)) .collect(Collectors.toSet()); } }
@Override public Set<Resource> getUsedProperties() { Resource path = getPathAsRdf(); if (path.isURIResource()) { return ImmutableSet.of(path); } else { return path.getModel().listObjects() .toSet().stream() .filter(RDFNode::isURIResource) .map(RDFNode::asResource) .filter(r -> !r.getNameSpace().equals(RDF.getURI())) .filter(r -> !r.getNameSpace().equals(SHACL.namespace)) .collect(Collectors.toSet()); } }
private void buildLocalAndNS(String URI) { if (URI == null) { this.URI = null; this.namespace = null; this.localName = null; } else { this.URI = URI; Resource uri = ResourceFactory.createResource(URI); this.namespace = uri.getNameSpace(); this.localName = uri.getLocalName(); } }
/** * Attempts to add an extra prefix for a given Resource. * This does nothing if the prefix does not exist or is empty. * @param resource the resource to get the namespace of */ public static void add(Resource resource) { String ns = resource.getNameSpace(); String prefix = resource.getModel().getNsURIPrefix(ns); if(prefix != null && prefix.length() > 0) { add(prefix, ns); } }
/** * Attempts to add an extra prefix for a given Resource. * This does nothing if the prefix does not exist or is empty. * @param resource the resource to get the namespace of */ public static void add(Resource resource) { String ns = resource.getNameSpace(); String prefix = resource.getModel().getNsURIPrefix(ns); if(prefix != null && prefix.length() > 0) { add(prefix, ns); } }
private void makeNewNamespaces(Statement s) { List<String> namespacesToCheck = new LinkedList<String>(); Resource subj = s.getSubject(); if ( (!subj.isAnon()) && (subj.getNameSpace() != null) ) { namespacesToCheck.add(subj.getNameSpace()); } Property pred = s.getPredicate(); if (pred.getNameSpace() != null) { namespacesToCheck.add(pred.getNameSpace()); } if ( s.getObject().isResource() ) { if ( ((Resource)s.getObject()).getNameSpace() != null ) { namespacesToCheck.add( ((Resource)s.getObject()).getNameSpace() ); } } processPossibleNewNamespaces(namespacesToCheck); }
private void copyStatements(Model src, Model dest, Resource subj, Property pred, RDFNode obj) { for (Statement stmt : src.listStatements(subj,pred,obj).toList()) { String subjNs = stmt.getSubject().getNameSpace(); if (subjNs == null || (! (subjNs.equals(VITRO) || subjNs.equals(AKT_SUPPORT) || subjNs.equals(AKT_PORTAL) ) ) ) { if (stmt.getObject().isLiteral()) { dest.add(stmt); } else if (stmt.getObject().isResource()) { String objNs = ((Resource)stmt.getObject()).getNameSpace(); if (objNs == null || (! (objNs.equals(VITRO) || objNs.equals(AKT_SUPPORT) || objNs.equals(AKT_PORTAL) ) ) ) { dest.add(stmt); } } } } }
public IndividualStub(String uri) { this.uri = uri; Resource r = ResourceFactory.createResource(uri); this.namespace = r.getNameSpace(); this.localName = r.getLocalName(); }
public void testNameSpace() { Assert.assertEquals("eh:", ModelHelper.resource("eh:xyz") .getNameSpace()); Assert.assertEquals("http://d/", ModelHelper.resource("http://d/stuff") .getNameSpace()); Assert.assertEquals("ftp://dd.com/12345", ModelHelper.resource("ftp://dd.com/12345").getNameSpace()); Assert.assertEquals("http://domain/spoo#", ModelHelper.resource("http://domain/spoo#anchor") .getNameSpace()); Assert.assertEquals("ftp://abd/def#ghi#", ModelHelper.resource("ftp://abd/def#ghi#e11-2").getNameSpace()); } }
public void testNameSpace() { Assert.assertEquals("eh:", ModelHelper.resource("eh:xyz") .getNameSpace()); Assert.assertEquals("http://d/", ModelHelper.resource("http://d/stuff") .getNameSpace()); Assert.assertEquals("ftp://dd.com/12345", ModelHelper.resource("ftp://dd.com/12345").getNameSpace()); Assert.assertEquals("http://domain/spoo#", ModelHelper.resource("http://domain/spoo#anchor") .getNameSpace()); Assert.assertEquals("ftp://abd/def#ghi#", ModelHelper.resource("ftp://abd/def#ghi#e11-2").getNameSpace()); } }
/** Answer the default OntModelSpec for this root, which will be <code>DEFAULT</code> unless <code>root</code> has the JA namespace and a local name which is the name of an OntModelSpec constant (in OntModelSpec), in which case it's that constant's value. */ private OntModelSpec getDefault( Resource root ) { OntModelSpec DEFAULT = OntModelAssembler.defaultSpec(); if (root.isURIResource() && root.getNameSpace().equals( JA.uri )) { OntModelSpec oms = getOntModelSpecField( root.getLocalName() ); return oms == null ? DEFAULT : oms; } else { Resource like = getUniqueResource( root, JA.likeBuiltinSpec ); return like == null ? DEFAULT : getRequiredOntModelSpecField( like.getLocalName() ); } }
public void testCreateAnonResourceWithNull() { final Resource r = model.createResource((String) null); Assert.assertTrue(r.isAnon()); Assert.assertNull(r.getURI()); Assert.assertNull(r.getNameSpace()); Assert.assertNull(r.getLocalName()); }
public void testCreateAnonResource() { final Resource r = model.createResource(); Assert.assertTrue(r.isAnon()); Assert.assertNull(r.getURI()); Assert.assertNull(r.getNameSpace()); Assert.assertNull(r.getLocalName()); }
public void testCreateAnonResource() { final Resource r = model.createResource(); Assert.assertTrue(r.isAnon()); Assert.assertNull(r.getURI()); Assert.assertNull(r.getNameSpace()); Assert.assertNull(r.getLocalName()); }
public void testCreateAnonResourceWithNull() { final Resource r = model.createResource((String) null); Assert.assertTrue(r.isAnon()); Assert.assertNull(r.getURI()); Assert.assertNull(r.getNameSpace()); Assert.assertNull(r.getLocalName()); }