public String toString() { return "{licence " + wrapped.toString() + "}"; } }
final @Override public String toString() { return "JenaResourceItem[res=" + myResource.toString() + "]"; }
private void addUriForResource() { ArrayList<Object> results = new ArrayList<Object>(); if(addUriForResource) { results.add( rs.toString() ); if(results.size() == 1) jsonMap.put("about", results.get(0)); else jsonMap.put("about", results); } }
public void ndlNetworkConnection(Resource l, OntModel om, long bandwidth, long latency, List<Resource> interfaces) { //should be sliceGraph.add... and/or manifestGraph.add... //manifest.addNetworkConnection(l.toString()); String printStr = "ndlManifest_NetworkConnection: \n\tName: " + l.toString() + " (" + l.getLocalName() + ")"; printStr += "\n\tInterfaces:"; for (Resource r : interfaces){ printStr += "\n\t\t " + r; } LIBNDL.logger().debug(printStr); } public void ndlParseComplete() {
/** * @return Returns the Object to be Cached */ public TemporaryGraphMetadataCacheObject getCachingObject(){ if (_temp == null) return null; if (this.temporaryResources.containsKey(_temp.getGraphURI().toString())){ _temp.addModelToMetadata(this.temporaryResources.get(_temp.getGraphURI())); } return _temp; }
/** * <p>Check that every member of the given list has the given rdf:type, and throw an exception if not.</p> * @param list The list to be checked * @param rdfType The rdf:type value to check for * @exception LanguageConsistencyException if any member of the list does not have <code>rdf:type <i>rdfType</i></code> */ protected void checkListMembersRdfType( RDFList list, Resource rdfType ) { if (strictMode() && ! ((Boolean) list.reduce( new RdfTypeTestFn( rdfType), Boolean.TRUE )).booleanValue()) { // not all of the members of the list are of the given type throw new LanguageConsistencyException( "The members of the given list are expected to be of rdf:type " + rdfType.toString() ); } }
@Override protected void processSolution() { this.builder.add(resource("resource").toString()); } @Override
/** Answer a string describing this Statement in a vagely pretty way, with the representations of the subject, predicate, and object in that order. */ @Override public String toString() { return "[" + getSubject().toString() + ", " + getPredicate().toString() + ", " + objectString( getObject() ) + "]"; }
/** * Given a query result from a SPARQL query, obtain the given variable value * as a URL * * @param resultRow the result from a SPARQL query * @param variableName the name of the variable to obtain * @return the value or null if it could not be obtained */ private static URL getUrlValueFromRow(QuerySolution resultRow, String variableName) { // Check the input and exit immediately if null if (resultRow == null) { return null; } URL result = null; Resource res = resultRow.getResource(variableName); // Ignore and track services that are blank nodes if (res.isAnon()) { log.warn("Blank node found and ignored " + res.toString()); } else if (res.isURIResource()) { try { result = new URL(res.getURI()); } catch (MalformedURLException e) { log.error("Malformed URL for node", e); } catch (ClassCastException e) { log.error("The node is not a URI", e); } } return result; }
private String resource(Resource rsrc) { if (rsrc.isAnon()) { return "http://marklogic.com/semantics/blank/" + Long.toHexString( fuse(scramble((long)rsrc.hashCode()),fuse(scramble(milliSecs),randomValue))); } else { return escapeXml(rsrc.toString()); } }
try { ontR = (OntResource)r;} catch(Exception e) {} if (ontR == null) { logger.error("No rdfs:label and rdfs:comment for resource:" + r.toString()); return new Label(r.getURI(), ns, prefix); rdfsLabel = ontR.getLabel(null); } catch(Exception e) { logger.error("No rdfs:label for resource:" + r.toString()); rdfsLabel = ""; rdfsComment = ontR.getComment(null); } catch(Exception e) { logger.error("No Comment for resource:" + r.toString()); rdfsComment = "";
private static List<MetricDescription> getMetricsUsed(){ String selectQuery = ""; URL url = Resources.getResource("facets.sparql"); try { selectQuery = Resources.toString(url, Charsets.UTF_8); } catch (IOException e) { logger.error("Error: {}",e.getMessage()); } QueryExecution exec = QueryExecutionFactory.create(QueryFactory.create(selectQuery), getFlatModel()); ResultSet set = exec.execSelect(); List<MetricDescription> retSet = new ArrayList<MetricDescription>(); while(set.hasNext()){ QuerySolution qs = set.next(); String metURI = qs.get("metric").asResource().toString(); String met = qs.get("metric_name").asLiteral().toString(); MetricDescription md = new MetricDescription(); md.uri = metURI; md.name = met; retSet.add(md); } return retSet; }
@Deprecated private static int getNumberOfMetricsInDataSet(Model m, String extraSPARQLstmt){ Integer total = 0; Model internal = InternalModelConf.getFlatModel(); Dataset _temp = new DatasetImpl(internal); String _tempGraph = Commons.generateURI().toString(); _temp.addNamedModel(_tempGraph, m); String whereDefaultGraphClause = "?metricTypeURI " + SPARQLHelper.toSPARQL(RDFS.subClassOf) + " " + SPARQLHelper.toSPARQL(DAQ.Metric) + " ."; whereDefaultGraphClause = whereDefaultGraphClause + extraSPARQLstmt; String graphClause = "GRAPH <"+_tempGraph+"> { [where] }"; String whereNamedGraphClause = "?typeURI " + SPARQLHelper.toSPARQL(RDF.type) + " ?metricTypeURI . "; graphClause = graphClause.replace("[where]", whereNamedGraphClause); String whereClause = whereDefaultGraphClause + graphClause; String query = SPARQLHelper.SELECT_STATEMENT.replace("[variables]", "(count(?typeURI) as ?count)").replace("[whereClauses]", whereClause); Query qry = QueryFactory.create(query); QueryExecution qe = QueryExecutionFactory.create(qry, _temp); ResultSet rs = qe.execSelect(); while (rs.hasNext()){ QuerySolution soln = rs.next(); total = new Integer(soln.getResource("count").toString()); } return total.intValue(); } }
public static String getAllDatasets(){ String selectQuery = "SELECT DISTINCT ?dataset { ?x " + SPARQLHelper.toSPARQL(DAQ.computedOn) +" ?dataset . }"; QueryExecution exec = QueryExecutionFactory.create(QueryFactory.create(selectQuery), getFlatModel()); String json = "["; ResultSet set = exec.execSelect(); while(set.hasNext()){ QuerySolution sol = set.next(); json += "\""+sol.get("dataset").asResource().toString() + "\""+","; } json = json.substring(0, json.length()-1); json += "]"; return json; }
public static String getDisplayName(RDFNode node) { if (node == null) return "unknown"; else if (node.isAnon()) return "anon"; else if (node.isLiteral()) return node.asLiteral().getLexicalForm(); else if (node.isResource()) { Resource resource = node.asResource(); if (resource instanceof OntResource) { String label = ((OntResource) resource).getLabel(null); if (label != null) return label; } String localName = resource.getLocalName(); if ((localName != null) && !localName.isEmpty()) return localName; return resource.toString(); } else return "unknown"; }
public static String getDisplayName(RDFNode node) { if (node == null) return "unknown"; else if (node.isAnon()) return "anon"; else if (node.isLiteral()) return node.asLiteral().getLexicalForm(); else if (node.isResource()) { Resource resource = node.asResource(); if (resource instanceof OntResource) { String label = ((OntResource) resource).getLabel(null); if (label != null) return label; } String localName = resource.getLocalName(); if ((localName != null) && !localName.isEmpty()) return localName; return resource.toString(); } else return "unknown"; }
private static void addEntry( Factories result, Resource r, boolean isDefault ) { String name = getName( r ); String className = getClassName( r ); MediaType mt = getMimeType( r ); Resource type = getRendererType( r ); boolean jsonUsesISOdate = getJSONUseISOFormatting( r ); if (type == null) EldaException.BadSpecification ( "no renderer type for " + (name != null ? name : mt != null ? ("spec with mime type " + mt) : "node " + r.toString() ) ); RendererFactory rfx = BuiltinRendererTable.getFactory( type ); RendererFactory fac = pickFactory( className, rfx ); result.putFactory( name, r, mt, fac, isDefault, jsonUsesISOdate ); }
private void createGraphNodeToTriplesNodeMap(KR2RMLMapping kr2rmlMapping) throws FileNotFoundException, UnsupportedEncodingException{ StmtIterator itr = model.listStatements(null, model.getProperty(Uris.KM_NODE_ID_URI), (RDFNode)null); Resource subject; Map<String,String> graphNodeIdToTriplesMapIdMap = kr2rmlMapping.getAuxInfo().getGraphNodeIdToTriplesMapIdMap(); while (itr.hasNext()) { Statement subjMapToNodeIdStmt = itr.next(); String nodeId = subjMapToNodeIdStmt.getObject().toString(); subject = subjMapToNodeIdStmt.getSubject(); if (subject != null) { StmtIterator itr2 = model.listStatements(null, model.getProperty(Uris.RR_SUBJECTMAP_URI), subject); while (itr2.hasNext()) { String triplesMapId = itr2.next().getSubject().toString(); graphNodeIdToTriplesMapIdMap.put(nodeId, triplesMapId); } } } }
@Test public void testRendersFeedAuthorsIfPresent() { Resource a = configModel.createProperty( "eh:/author_A" ); RDFNode b = configModel.createLiteral( "author_B" ); // RDFNode[] properties = new RDFNode[] {a, b}; RDFList authors = configModel.createList( properties ); config.addProperty( ELDA_API.feedAuthors, authors ); // String rendering = renderFeed(); // if (!rendering.contains( "<author>" + a.toString() + "</author>" )) { fail( "rendering\n" + rendering + "\nshould contain author\n" + a ); } // if (!rendering.contains( "<author>" + b.toString() + "</author>" )) { fail( "rendering\n" + rendering + "\nshould contain author\n" + b ); } }
private void checkRelative(Model model) { assertEquals(1, model.size()); final Statement statement = model.listStatements().next(); assertEquals("http://example.com/value", statement.getPredicate().toString()); assertEquals("Test", statement.getString()); assertEquals("http://example.com/test", statement.getSubject().toString()); }