private boolean isType(Resource r, Resource resourceClass){ return r.hasProperty(NdlCommons.RDF_TYPE, resourceClass); //Test for type of subject (if any) // Resource candidateResourceClass = getType(r); //r.getProperty(new PropertyImpl("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")).getResource(); //if(candidateResourceClass != null && candidateResourceClass.equals(resourceClass)){ // return true; //} //return false; }
@Override public Resource accept(Resource o) { Resource r = o; return (r.hasProperty(RDF.subject) && r.hasProperty(RDF.object) && r .hasProperty(RDF.predicate)) ? r : null; } }, model.listResourcesWithProperty(RDF.type, RDF.Statement));
protected void reportObsoleteDescribeThreshold(Resource endpoint) { if (endpoint.hasProperty(ELDA_API.describeThreshold)) { log.warn("endpoint '{}': elda:describeThreshold is no longer required/used.", endpoint); } }
private static boolean testResourceCovered( List< ? extends Resource> l, Property rel, boolean inverse, Resource r ) { boolean rCovered = false; for (Iterator< ? extends Resource> i = l.iterator(); !rCovered && i.hasNext(); ) { Resource next = i.next(); rCovered = inverse ? r.hasProperty( rel, next ) : next.hasProperty( rel, r ); } return rCovered; }
private void checkEndpointType(Resource endpoint) { boolean isList = endpoint.hasProperty( RDF.type, API.ListEndpoint ); boolean isItem = endpoint.hasProperty( RDF.type, API.ItemEndpoint ); if (isList || isItem) return; throw new EldaException("endpoint " + endpoint + " is not declared as ListEndpoint or ItemEndpoint"); }
private static void removeElementsWithoutType( Set<Resource> candidates, Resource type ) { for (Iterator<Resource> it = candidates.iterator(); it.hasNext();) { Resource candidate = it.next(); if (!candidate.hasProperty( RDF.type, type )) it.remove(); } }
protected void checkType( Resource root, Resource type ) { if (!root.hasProperty( RDF.type, type )) throw new CannotConstructException( this.getClass(), root, type ); }
private static boolean hasNoCompetingSubclass( List<RDFNode> types, Resource candidate ) { for (int j = 0; j < types.size(); j += 1) { Resource other = (Resource) types.get( j ); if (other.hasProperty( RDFS.subClassOf, candidate ) && !candidate.equals( other )) return false; } return true; }
public SourceBase( Resource endpoint ) { this.textSearchConfig = new TextSearchConfig( endpoint ); if (endpoint.hasProperty(ELDA_API.supportsNestedSelect)) { log.warn("'{}' supportsNestedSelect is no longer used or needed.", endpoint); log.info("Elda assumes and requires SPARQL 1.1 support"); } }
/** * @return True if the page denotes a single item, or false for a list * endpoint */ public boolean isItemEndpoint() { return asResource().hasProperty( FOAF.primaryTopic ); }
protected Resource parseSubject(Model m, Resource subject, String dsoIRI, String name, String value) { if (subject.hasProperty(RDF.type, DMRM.ResourceGenerator)) { String generatedIRI = parseResourceGenerator(subject, value, dsoIRI); if (generatedIRI == null) { log.debug("Generated subject IRI is null."); return null; } log.debug("Subject ResourceGenerator generated '" + generatedIRI + "'."); return m.createResource(generatedIRI); } return subject; }
private boolean isInstanceOfTheClass(Resource resource, Resource class_resource) { Property type_property = ResourceFactory.createProperty(Namespaces.RDF + "type"); if (resource == null || !resource.isResource()) return true; if (resource.hasProperty(type_property, class_resource)) return true; else return false; }
private boolean isInstanceOfTheClass(Resource resource, Resource class_resource) { Property type_property = ResourceFactory.createProperty(Namespaces.RDF + "type"); if (resource == null || !resource.isResource()) return true; if (resource.hasProperty(type_property, class_resource)) return true; else return false; }
private View getDefaultView( Resource root, View ifAbsent ) { if (root.hasProperty( API.defaultViewer )) { Resource x = getResourceValue( root, API.defaultViewer ); return getView( x ); } else return ifAbsent; }
public static void setDefaultSuffixName(Bindings b, Resource ep) { if (ep.hasProperty( API.defaultFormatter)) { Resource r = ep.getProperty( API.defaultFormatter ).getObject().asResource(); if (r.hasProperty( API.name )) { String name = r.getProperty( API.name ).getString(); b.put("_defaultSuffix", name); } } }
private void visitAggregatedResources(Resource agg, File base_dir, Model model, List<String> visitedRems) throws PackageValidationException { NodeIterator iter = model.listObjectsOfProperty(agg, AGGREGATES_PROPERTY); while (iter.hasNext()) { Resource res = iter.next().asResource(); if (res.hasProperty(IS_DESCRIBED_BY_PROPERTY)) { validateResourceMap(res.getPropertyResourceValue(IS_DESCRIBED_BY_PROPERTY), base_dir, model, visitedRems.toArray(new String[0])); } } }
private static void setSimplePrefixes( Resource root, PrefixMapping result ) { if (root.hasProperty( JA.prefix )) { Literal prefix = getUniqueLiteral( root, JA.prefix ); Literal namespace = getUniqueLiteral( root, JA.namespace ); result.setNsPrefix( prefix.getLexicalForm(), namespace.getLexicalForm() ); } } }
@Test public void testAbsentTotalCount() throws URISyntaxException { Integer totalResults = null; Resource thisMetaPage = createMetadata(true, totalResults); assertFalse( thisMetaPage.hasProperty(OpenSearch.totalResults)); }
@Test public void testListEndpointHasCorrectType() throws URISyntaxException { Integer totalResults = null; Resource thisMetaPage = createMetadata(true, totalResults); assertTrue(thisMetaPage.hasProperty(RDF.type, API.ListEndpoint)); }
@Test public void testItemEndpointHasCorrectType() throws URISyntaxException { Integer totalResults = null; Resource thisMetaPage = createMetadata(false, totalResults); assertTrue(thisMetaPage.hasProperty(RDF.type, API.ItemEndpoint)); }