- 更新日時:
- 2014/01/30 10:50:28 (11 年 前)
- ファイル:
-
- 1 変更
凡例:
- 変更なし
- 追加
- 削除
-
BH13SPARQLBuilder/src/org/biohackathon/SPARQLBuilder/OWL/OWLQueryBuilderImpl.java
r2 r5 15 15 import org.apache.http.client.entity.UrlEncodedFormEntity; 16 16 import org.apache.http.client.methods.HttpPost; 17 import org.apache.http.impl.client.HttpClientBuilder;17 //import org.apache.http.impl.client.HttpClientBuilder; 18 18 import org.apache.http.message.BasicNameValuePair; 19 19 import org.apache.http.util.EntityUtils; … … 26 26 import com.hp.hpl.jena.query.ResultSet; 27 27 import com.hp.hpl.jena.rdf.model.Resource; 28 28 29 /** 29 30 * 繧ッ繧ィ繝ェ繧堤函謌舌☆繧九◆繧√�讖溯�繧呈署萓帙☆繧区ク繧ッ繝ゥ繧ケ … … 269 270 queryStr.append("PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"); 270 271 queryStr.append("PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"); 271 queryStr.append("SELECT DISTINCT ?p ?pDirection ?c \n");272 queryStr.append("SELECT DISTINCT ?p ?pDirection ?c (COUNT(?s) AS ?numOfLinks) \n"); 272 273 if (graphURIs != null) { 273 274 for (String graphURI : graphURIs) { … … 281 282 queryStr.append(" { ?p rdfs:domain <"); 282 283 queryStr.append(originClass); 283 queryStr.append(">.\n ?p rdfs:range ?c. }\n UNION\n");284 queryStr.append(">.\n ?p rdfs:range ?c.\n ?o ?p ?s.}\n UNION\n"); 284 285 queryStr.append(" { ?p rdfs:range <"); 285 286 queryStr.append(originClass); 286 queryStr.append(">.\n ?p rdfs:domain ?c.}\n"); 287 queryStr.append(" ?p ?pDirection ?c.\n"); 288 queryStr.append("}\n"); 287 queryStr.append(">.\n"); 288 queryStr.append(" ?p rdfs:domain ?c.\n"); 289 queryStr.append(" ?s ?p ?o.}\n"); 290 291 queryStr.append(" ?p ?pDirection ?c.\n"); 292 293 294 queryStr.append(" ?s rdf:type ?c.\n"); 295 queryStr.append(" ?o rdf:type <"); 296 queryStr.append(originClass); 297 queryStr.append(">.\n"); 298 queryStr.append("}\nGROUP BY ?p ?pDirection ?c\n"); 289 299 if (limit > 0) { 290 300 queryStr.append("limit "); … … 293 303 } 294 304 295 //System.out.println(queryStr.toString());305 System.out.println(queryStr.toString()); 296 306 297 307 Query query = QueryFactory.create(queryStr.toString()); … … 325 335 } 326 336 // System.out.println(direction); 327 ClassLink cl = new ClassLink(proURI, clsURI, direction, 0); 337 int numOfLinks = sol.getLiteral("numOfLinks").getInt(); 338 // System.out.println(numOfLinks); 339 ClassLink cl = new ClassLink(proURI, clsURI, direction, numOfLinks); 328 340 solCLs.add(cl); 329 341 }