/** * Returns the URI for a quality problem instance * * @param problemReport - A Problem Report Model * * @return The resource URI */ public List<Resource> getProblemURI(Model problemReport){ return problemReport.listSubjectsWithProperty(RDF.type, QPRO.QualityProblem).toList(); }
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; }
/** Filter the model m according to the view-languages rules of the LDA spec. <p> If the list of viewing languages contains some values, then the only untyped literal values of a property P for some subject S that will kept are those with a language in the list or, if there are none, those with no language. </p> */ public static void filterByLanguages( Model m, String[] split) { Set<String> allowed = new HashSet<String>( Arrays.asList( split ) ); if (allowed.contains( "none" )) allowed.add( "" ); for (Resource sub: m.listSubjects().toList()) { for (Property prop: sub.listProperties().mapWith( Statement.Util.getPredicate ).toSet()) removeUnwantedPropertyValues( allowed, sub, prop ); } }
RDFNode node = model.getResource(Uris.KM_R2RML_MAPPING_URI); ResIterator res = model.listResourcesWithProperty(rdfTypeProp, node); List<Resource> resList = res.toList(); for(Resource r: resList)
/** * @return A list of all resources in the current results model which each * have all of the given properties */ public List<DisplayRdfNode> resourcesWithAllProperties( List<Object> properties ) { List<DisplayRdfNode> rs = new ArrayList<DisplayRdfNode>(); if (!properties.isEmpty()) { Property p = toProperty( properties.get( 0 ) ); List<Resource> candidates = getModelW().getModel().listSubjectsWithProperty( p ).toList(); // test the remaining properties for (Object p1 : properties) { List<Resource> checked = new ArrayList<Resource>(); Property pp1 = toProperty( p1 ); for (Resource cand : candidates) { if (cand.hasProperty( pp1 )) { checked.add( cand ); } } candidates = checked; } for (Resource cand : candidates) { rs.add( new DisplayRdfNode( this, cand ) ); } } return rs; }
List<Resource> resList = res.toList(); for(Resource r: resList)
List<Resource> roots = init.listSubjectsWithProperty( RDF.type, API.API ).toList();
public static MapLookup createMapLookup(Resource root, final Source ds) { final Map<String, SPARQLMapLookup.Element> maps = new HashMap<String, SPARQLMapLookup.Element>(); // List<Resource> mapSpecs = root.getModel().listSubjectsWithProperty(RDF.type, ELDA_API.SPARQLMap).toList(); for (Resource mapSpec: mapSpecs) { String mapName = mapSpec.isURIResource() ? mapSpec.getURI() : getResourceValue(mapSpec, ELDA_API.mapName).getURI() ; String inName = getStringValue(mapSpec, ELDA_API.mapIn, "input"); String outName = getStringValue(mapSpec, ELDA_API.mapOut, "result"); String queryString = getStringValue(mapSpec,ELDA_API.mapQuery); maps.put(mapName, new Element(inName, queryString, outName)); } return new SPARQLMapLookup(ds, maps); }
private void extractDatatypes( Model m ) { List<Resource> dataTypes = m.listStatements( null, RDF.type, RDFS.Datatype ).mapWith( Statement.Util.getSubject ).toList(); for (Resource t: dataTypes) declareDatatype( t.getURI() ); for (Resource p: m.listSubjectsWithProperty( RDF.type, OWL.DatatypeProperty ).toList()) { for (RDFNode t: m.listObjectsOfProperty( p, RDFS.range ).toList()) { declareDatatype( t.asResource().getURI() ); } } }