チェンジセット 248 : SPARQLBuilderWWW/src/java
- 更新日時:
- 2015/03/24 18:18:00 (10 年 前)
- パス:
- SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder
- ファイル:
-
- 1 追加
- 6 変更
凡例:
- 変更なし
- 追加
- 削除
-
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/OWLClassGraph.java
r228 r248 19 19 List<String> nodeType; 20 20 ArrayList<HashSet<Integer>> connectionTable; 21 21 String sparqlEndpoint; 22 Set<Integer> visited; 23 boolean askcheck; 24 List<Map<Integer, Integer>> edgeweight; 25 List<Integer> nodeweight; 26 22 27 public class LinkAndPath{ 23 28 String originalClassURI; // originalClasssURI -classLink.propertyURI-> classLink.linkedClassURL … … 46 51 } 47 52 48 /* 49 public OWLClassGraph(String startClass, String endClass){ 50 super(); 51 52 // start & end 53 this.startClass = startClass; 54 this.endClass = endClass; 55 56 // parameters 57 nsteps = 3; 58 limit = 1000; 59 th = 5; 60 } 61 */ 62 63 /* 64 public OWLClassGraph(String startClass, String endClass, int th){ 65 super(); 66 67 // start & end 68 this.startClass = startClass; 69 this.endClass = endClass; 70 // th of instances 71 this.th = th; 72 73 // parameters 74 nsteps = 3; 75 limit = 1000; 76 } 77 */ 78 79 public OWLClassGraph(){ 53 public OWLClassGraph(){ // not used 80 54 super(); 81 55 nodeType = new LinkedList<String>(); 82 //setClassGraph(rdfsa); 83 //connectionTable = createConnectionTable(); 84 } 85 86 87 public OWLClassGraph(RDFSchemaAnalyzer rdfsa){ 56 } 57 58 public OWLClassGraph(RDFSchemaAnalyzer rdfsa){ // not used 88 59 super(); 89 60 nodeType = new LinkedList<String>(); 90 //setClassGraph(rdfsa); 91 //connectionTable = createConnectionTable(); 92 } 93 61 } 62 63 public OWLClassGraph(RDFSchemaAnalyzer rdfsa, String sparqlEndpoint, String startClass, boolean askcheck){ // used 64 super(); 65 nodeType = new LinkedList<String>(); 66 this.askcheck = askcheck; 67 setPartClassGraph(rdfsa, sparqlEndpoint, startClass); 68 } 69 94 70 public int getNumberOfEdge(String url){ 95 71 Integer node = labelednodes.get(url); … … 98 74 } 99 75 return adjlist.get(node).size(); 76 } 77 78 public boolean visitedNode(String classURI){ 79 if ( visited.contains(labelednodes.get(classURI)) ){ 80 return true; 81 } 82 return false; 100 83 } 101 84 … … 138 121 return connectionTable.get(node); 139 122 } 140 141 public Path[] getPaths_old(RDFSchemaAnalyzer rdfsa, boolean countLink, String startClass, String endClass){142 List<List<ClassLink>> paths = null;143 paths = searchPathsbyVisitingNodes(rdfsa, countLink, startClass, endClass);144 NavigableSet<Path> sortedpath = new TreeSet<Path>();145 ListIterator<List<ClassLink>> pit = paths.listIterator();146 int j = 0;147 while ( pit.hasNext() ){148 Path path = new Path();149 path.setStartClass(startClass);150 List<ClassLink> crrpath = pit.next();151 path.setClassLinks(crrpath);152 ListIterator<ClassLink> cit = crrpath.listIterator();153 int min = Integer.MAX_VALUE;154 while ( cit.hasNext() ){155 ClassLink cl = cit.next();156 if ( cl.getNumOfLinks() < min ){157 min = cl.getNumOfLinks();158 }159 }160 path.setWidth(min);161 sortedpath.add(path);162 j++;163 }164 Path[] patharray = new Path[paths.size()];165 Iterator<Path> pait = sortedpath.descendingIterator();166 int i = 0;167 while ( pait.hasNext() ){168 patharray[i] = pait.next();169 i++;170 }171 return patharray;172 }173 123 174 124 private List<List<ClassLink>> searchPaths(String startClass, String endClass){ 175 125 //int asked = 0; 126 Map<String,Boolean> checkedpaths = new HashMap<String, Boolean>(); 176 127 List<List<ClassLink>> paths = new ArrayList<>(); 177 128 List<List<Integer>> simplePaths = new LinkedList<>(); … … 195 146 List<Integer> nextpath = new LinkedList<Integer>(crrpath); // copy 196 147 nextpath.add(nextnode); 148 // tmp 149 if ( i >= 1 ){ 150 int wn = nodeweight.get(crrnode); 151 int in = edgeweight.get(crrpath.get(crrpath.size()-2)).get(crrnode); 152 int out = edgeweight.get(nextnode).get(crrnode); 153 if ( wn > in + out ){ 154 /* 155 String key1 = nextnode.toString().concat("-").concat(crrpath.get(crrpath.size()-1).toString()) 156 .concat("-").concat(crrpath.get(crrpath.size()-2).toString()); 157 String key2 = crrpath.get(crrpath.size()-2).toString().concat("-").concat(crrpath.get(crrpath.size()-1).toString()) 158 .concat("-").concat(nextnode.toString()); 159 if ( checkedpaths.containsKey(key1) ){ 160 if ( checkedpaths.get(key1) == false ){ 161 continue; 162 } 163 }else if ( checkedpaths.containsKey(key2) ){ 164 if ( checkedpaths.get(key2) == false ){ 165 continue; 166 } 167 }else{ 168 boolean chk = EndpointAccess.check3SimplePathwithJoin(nextnode, crrpath.get(crrpath.size()-1), 169 crrpath.get(crrpath.size()-2), this, sparqlEndpoint); 170 checkedpaths.put(key1, chk); 171 if ( chk == false ){ 172 continue; 173 } 174 } 175 */ 176 continue; 177 } 178 } 197 179 if ( nextnode.equals(enode) ){ 198 180 simplePaths.add(nextpath); … … 206 188 207 189 ListIterator<List<Integer>> pit = simplePaths.listIterator(); 190 //int i = 0; 191 //int j = 0; 192 System.out.println("SPATH:"); 193 System.out.println(simplePaths.size()); 208 194 while( pit.hasNext()){ 209 195 List<Integer> spath = pit.next(); … … 211 197 paths.addAll(convertedPaths); 212 198 } 199 System.out.println("PATH:"); 200 System.out.println(paths.size()); 213 201 return paths; 214 202 } 203 215 204 216 205 private List<List<ClassLink>> convertSimplePathToPaths(List<Integer> simplePath){ 217 206 List<List<ClassLink>> paths = new LinkedList<List<ClassLink>>(); 218 //List<List<LabeledEdge>> multiedges = new LinkedList<List<LabeledEdge>>();219 207 ListIterator<Integer> spit = simplePath.listIterator(); 220 208 Integer start = spit.next(); 209 String startClass = this.labels.get(start); 221 210 Integer end = spit.next(); 222 211 List<LabeledEdge> edges = gadjlist.get(start).get(end); … … 242 231 List<ClassLink> addedpath = new LinkedList<ClassLink>(basepath); 243 232 addedpath.add(cl); 244 tmppaths.add(addedpath); 233 // check 234 //if ( EndpointAccess.checkPath(startClass, addedpath, sparqlEndpoint) ){ 235 tmppaths.add(addedpath); 236 //} 245 237 } 246 238 } … … 252 244 253 245 /* 254 private List<List<ClassLink>> searchPaths(RDFSchemaAnalyzer rdfsa, boolean countLinks){255 List<List<ClassLink>> paths = new ArrayList<>();256 List<LinkAndPath> lp = new LinkedList<>();257 lp.add(new LinkAndPath(new ClassLink("",startClass,null,Direction.both,0,0,0,0,0,false,false), new LinkedList<ClassLink>(), ""));258 try{259 for ( int i = 0; i < nsteps; i++ ){260 ListIterator<LinkAndPath> lit = lp.listIterator();261 List<LinkAndPath> nextlp = new LinkedList<>();262 while ( lit.hasNext() ){263 LinkAndPath crrlp = lit.next();264 ClassLink[] classLinks = rdfsa.getNextClass(null, crrlp.classLink.getLinkedClassURI(), limit, countLinks);265 for ( int j = 0 ; j < classLinks.length; j++ ){266 List<ClassLink> crrpath = new LinkedList<>(crrlp.path);267 crrpath.add(classLinks[j]);268 if ( classLinks[j].getLinkedClassURI() == null ){ continue; }269 if ( classLinks[j].getLinkedClassURI().equals(endClass) ){270 paths.add(new LinkedList<>(crrpath));271 continue;272 }273 if ( countLinks == true && classLinks[j].getNumOfLinks() <= th){274 continue;275 }276 if ( i >= 2 ){277 if ( crrlp.classLink.getPropertyURI().equals(classLinks[j].getPropertyURI()) &&278 crrlp.classLink.getDirection() != classLinks[j].getDirection() &&279 crrlp.originalClassURI.equals( classLinks[j].getLinkedClassURI()) ){280 continue;281 }282 }283 nextlp.add(new LinkAndPath(classLinks[j], crrpath, crrlp.classLink.getLinkedClassURI()));284 }285 }286 lp = nextlp;287 }288 }catch(Exception e){289 System.err.println(e);290 }291 return paths;292 }293 */294 295 246 private List<List<ClassLink>> searchPathsbyVisitingNodes(RDFSchemaAnalyzer rdfsa, boolean countLinks, 296 247 String startClass, String endClass){ … … 365 316 } 366 317 addEdge(i, n, classLinks[j]); 367 /*368 ClassLink rev = new ClassLink( classLinks[j].getPropertyURI(),369 //classLinks[j].getLinkedClassURI(),370 classes[i].getClassURI(),371 classLinks[j].getLinkedLiteralDatatypeURI(),372 classLinks[j].getDirection(), classLinks[j].getNumOfLinks(),373 classLinks[j].getNumOfOriginInstances(), classLinks[j].getNumOfLinkedInstances(),374 classLinks[j].getNumOfOriginClassInstances(), classLinks[j].getNumOfLinkedClassInstances(),375 classLinks[j].isDomainClassLimitedQ(), classLinks[j].isRangeClassLimitedQ() );376 rev.setDirection(Direction.reverse);377 addEdge(n, i, rev);378 */379 318 } 380 319 } … … 383 322 } 384 323 } 385 } 386 387 public void setPartClassGraph(RDFSchemaAnalyzer rdfsa, String startClass){ 388 // setNodes 324 }*/ 325 326 public void setPartClassGraph(RDFSchemaAnalyzer rdfsa, String sparqlEndpoint, String startClass){ 327 // set endpoint 328 this.sparqlEndpoint = sparqlEndpoint; 329 330 visited = new HashSet<Integer>(); 331 edgeweight = new LinkedList<Map<Integer,Integer>>(); 332 nodeweight = new LinkedList<Integer>(); 333 // setNodes for all classes 389 334 SClass[] classes = null; 390 335 try{ … … 396 341 addNode(classes[i].getClassURI()); 397 342 nodeType.add("class"); 398 } 399 int nedge = 0; 343 edgeweight.add(new HashMap<Integer,Integer>()); 344 nodeweight.add(classes[i].getNumOfInstances()); 345 } 346 // setEdges 347 //int nedge = 0; 400 348 Integer snode = labelednodes.get(startClass); 401 349 Set<Integer> nodes = new HashSet<Integer>(); 402 350 nodes.add(snode); 403 Set<Integer> visited = new HashSet<Integer>();351 visited.add(snode); 404 352 for (int i = 0 ; i < nsteps; i++ ){ 405 353 Iterator<Integer> nit = nodes.iterator(); … … 407 355 while ( nit.hasNext() ){ 408 356 Integer crr = nit.next(); 409 visited.add(crr);410 357 try{ 411 358 ClassLink[] classLinks = rdfsa.getNextClass(null, labels.get(crr), limit, true); 412 359 for (int j = 0 ; j < classLinks.length; j++){ 413 360 Integer nn = labelednodes.get(classLinks[j].getLinkedClassURI()); 361 if ( nn == null ){ 362 continue; 363 } 414 364 if ( !visited.contains(nn) ){ 415 365 nextnodes.add(nn); 416 366 } 417 if ( nn != null ){ 418 addEdge(crr, nn, classLinks[j]); 419 /* 420 }else{ 421 nn = labelednodes.get(classLinks[j].getLinkedLiteralDatatypeURI()); 422 if ( nn == null ){ 423 addNode(classLinks[j].getLinkedLiteralDatatypeURI()); 424 n = nodeType.size(); 425 nodeType.add("literal"); 426 } 427 addEdge(i, n, classLinks[j]); 428 /* 429 ClassLink rev = new ClassLink( classLinks[j].getPropertyURI(), 430 //classLinks[j].getLinkedClassURI(), 431 classes[i].getClassURI(), 432 classLinks[j].getLinkedLiteralDatatypeURI(), 433 classLinks[j].getDirection(), classLinks[j].getNumOfLinks(), 434 classLinks[j].getNumOfOriginInstances(), classLinks[j].getNumOfLinkedInstances(), 435 classLinks[j].getNumOfOriginClassInstances(), classLinks[j].getNumOfLinkedClassInstances(), 436 classLinks[j].isDomainClassLimitedQ(), classLinks[j].isRangeClassLimitedQ() ); 437 rev.setDirection(Direction.reverse); 438 addEdge(n, i, rev); 439 */ 440 } 367 addEdge(crr, nn, classLinks[j]); 368 updateWeight(crr, nn, classLinks[j]); 441 369 } 442 370 }catch(Exception e){ … … 445 373 } 446 374 nodes = nextnodes; 375 visited.addAll(nodes); 447 376 } 448 377 } 449 378 450 private ArrayList<HashSet<Integer>> createConnectionTable(){ 379 private ArrayList<HashSet<Integer>> createConnectionTable(){ // not used 451 380 ArrayList<HashSet<Integer>> ct = new ArrayList<HashSet<Integer>>(); 452 381 for (int i = 0; i < labels.size(); i++ ){ // each node … … 457 386 } 458 387 459 private HashSet<Integer> createConnectionList(Integer node){ 388 private HashSet<Integer> createConnectionList(Integer node){ // not used 460 389 HashSet<Integer> cl = new HashSet<Integer>(); 461 390 HashSet<Integer> crrnodes = new HashSet<Integer>(); … … 482 411 return cl; 483 412 } 413 414 415 private void updateWeight(Integer node1, Integer node2, ClassLink edge){ 416 Map<Integer, Integer> weight = edgeweight.get(node1); 417 Integer crr = weight.get(node2); 418 if (crr == null ){ 419 crr = edge.getNumOfLinkedClassInstances(); 420 weight.put(node2, crr); 421 } 422 if ( crr < edge.getNumOfLinkedClassInstances() ){ 423 crr = edge.getNumOfLinkedClassInstances(); 424 weight.put(node2, crr); 425 } 426 weight = edgeweight.get(node2); 427 crr = weight.get(node1); 428 if (crr == null ){ 429 crr = edge.getNumOfOriginClassInstances(); 430 weight.put(node2, crr); 431 } 432 if ( crr < edge.getNumOfOriginClassInstances() ){ 433 crr = edge.getNumOfOriginInstances(); 434 weight.put(node1, crr); 435 } 436 } 437 438 // old codes 439 /* 440 public Path[] getPaths_old(RDFSchemaAnalyzer rdfsa, boolean countLink, String startClass, String endClass){ 441 List<List<ClassLink>> paths = null; 442 paths = searchPathsbyVisitingNodes(rdfsa, countLink, startClass, endClass); 443 NavigableSet<Path> sortedpath = new TreeSet<Path>(); 444 ListIterator<List<ClassLink>> pit = paths.listIterator(); 445 int j = 0; 446 while ( pit.hasNext() ){ 447 Path path = new Path(); 448 path.setStartClass(startClass); 449 List<ClassLink> crrpath = pit.next(); 450 path.setClassLinks(crrpath); 451 ListIterator<ClassLink> cit = crrpath.listIterator(); 452 int min = Integer.MAX_VALUE; 453 while ( cit.hasNext() ){ 454 ClassLink cl = cit.next(); 455 if ( cl.getNumOfLinks() < min ){ 456 min = cl.getNumOfLinks(); 457 } 458 } 459 path.setWidth(min); 460 sortedpath.add(path); 461 j++; 462 } 463 Path[] patharray = new Path[paths.size()]; 464 Iterator<Path> pait = sortedpath.descendingIterator(); 465 int i = 0; 466 while ( pait.hasNext() ){ 467 patharray[i] = pait.next(); 468 i++; 469 } 470 return patharray; 471 } 472 473 private List<List<ClassLink>> searchPaths_old(String startClass, String endClass){ 474 475 List<List<ClassLink>> paths = new ArrayList<>(); 476 List<List<Integer>> simplePaths = new LinkedList<>(); 477 Integer snode = labelednodes.get(startClass); 478 Integer enode = labelednodes.get(endClass); 479 List<List<Integer>> lp = new LinkedList<>(); 480 List<Integer> ini = new LinkedList<Integer>(); // initial path 481 ini.add(snode); 482 lp.add(ini); 483 for (int i = 0; i < nsteps; i++ ){ 484 ListIterator<List<Integer>> lit = lp.listIterator(); 485 List<List<Integer>> nextlp = new LinkedList<>(); 486 while ( lit.hasNext() ){ 487 List<Integer> crrpath = lit.next(); 488 Integer crrnode = crrpath.get(crrpath.size()-1); 489 Set<Integer> nexts = gadjlist.get(crrnode).keySet(); 490 Iterator<Integer> nit = nexts.iterator(); 491 while( nit.hasNext() ){ 492 Integer nextnode = nit.next(); 493 if ( crrpath.contains(nextnode) ){ continue; } 494 List<Integer> nextpath = new LinkedList<Integer>(crrpath); // copy 495 nextpath.add(nextnode); 496 if ( nextnode.equals(enode) ){ 497 simplePaths.add(nextpath); 498 continue; 499 } 500 nextlp.add(nextpath); 501 } 502 } 503 lp = nextlp; 504 } 505 506 ListIterator<List<Integer>> pit = simplePaths.listIterator(); 507 while( pit.hasNext()){ 508 List<Integer> spath = pit.next(); 509 List<List<ClassLink>> convertedPaths = convertSimplePathToPaths(spath); 510 paths.addAll(convertedPaths); 511 } 512 return paths; 513 } 514 */ 515 /* 516 private List<List<ClassLink>> searchPaths(RDFSchemaAnalyzer rdfsa, boolean countLinks){ 517 List<List<ClassLink>> paths = new ArrayList<>(); 518 List<LinkAndPath> lp = new LinkedList<>(); 519 lp.add(new LinkAndPath(new ClassLink("",startClass,null,Direction.both,0,0,0,0,0,false,false), new LinkedList<ClassLink>(), "")); 520 try{ 521 for ( int i = 0; i < nsteps; i++ ){ 522 ListIterator<LinkAndPath> lit = lp.listIterator(); 523 List<LinkAndPath> nextlp = new LinkedList<>(); 524 while ( lit.hasNext() ){ 525 LinkAndPath crrlp = lit.next(); 526 ClassLink[] classLinks = rdfsa.getNextClass(null, crrlp.classLink.getLinkedClassURI(), limit, countLinks); 527 for ( int j = 0 ; j < classLinks.length; j++ ){ 528 List<ClassLink> crrpath = new LinkedList<>(crrlp.path); 529 crrpath.add(classLinks[j]); 530 if ( classLinks[j].getLinkedClassURI() == null ){ continue; } 531 if ( classLinks[j].getLinkedClassURI().equals(endClass) ){ 532 paths.add(new LinkedList<>(crrpath)); 533 continue; 534 } 535 if ( countLinks == true && classLinks[j].getNumOfLinks() <= th){ 536 continue; 537 } 538 if ( i >= 2 ){ 539 if ( crrlp.classLink.getPropertyURI().equals(classLinks[j].getPropertyURI()) && 540 crrlp.classLink.getDirection() != classLinks[j].getDirection() && 541 crrlp.originalClassURI.equals( classLinks[j].getLinkedClassURI()) ){ 542 continue; 543 } 544 } 545 nextlp.add(new LinkAndPath(classLinks[j], crrpath, crrlp.classLink.getLinkedClassURI())); 546 } 547 } 548 lp = nextlp; 549 } 550 }catch(Exception e){ 551 System.err.println(e); 552 } 553 return paths; 554 } 555 */ 556 484 557 } -
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/Path.java
r221 r248 86 86 json_str+= classLinks.get(i).toJSONString3(classes); 87 87 } 88 json_str+="]"; 88 json_str+="]"; 89 89 } 90 json_str+="}"; 90 json_str += ","; 91 json_str +="\"score\":\""+width+"\""; 92 json_str +="}"; 91 93 92 94 return json_str; … … 139 141 //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 140 142 } 141 142 143 } -
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/OWL/QueryPathGenerator.java
r228 r248 18 18 private RDFSchemaAnalyzer analyzer = null; 19 19 private OWLClassGraph graph; 20 private boolean askcheck; 20 21 21 22 private static final String CDIR = "cdata"; … … 50 51 factory = new RDFSchemaAnalyzerFactory(CDIR); 51 52 } 52 53 53 54 public QueryPathGenerator(String sparqlEndpoint){ 54 55 factory = new RDFSchemaAnalyzerFactory(CDIR); 55 56 setSPARQLendpoint(sparqlEndpoint); 56 setOWLClassGraph();57 57 } 58 58 59 public void setOWLClassGraph(String startClass){ 60 graph = new OWLClassGraph(analyzer, sparqlEndpoint, startClass, askcheck); 61 } 62 63 /* 59 64 public QueryPathGenerator(String sparqlEndpoint, String crawlFileName){ 60 65 factory = new RDFSchemaAnalyzerFactory(crawlFileName); … … 62 67 setOWLClassGraph(); 63 68 } 69 */ 64 70 65 71 public SClass[] getClasses(String keyword){ … … 79 85 } 80 86 81 public Path[] getPaths(String startClass, String endClass, boolean countLink){ 87 public Path[] getPaths(String startClass, String endClass, boolean askcheck){ 88 this.askcheck = askcheck; 82 89 if ( graph == null ){ 83 setOWLClassGraph(); 90 //System.err.println("Class graph is null."); 91 setOWLClassGraph(startClass); 84 92 } 85 graph.setPartClassGraph(analyzer, startClass);86 93 return graph.getPaths(startClass, endClass); 87 //return graph.getPaths(startClass, endClass, analyzer);88 //return graph.getPaths_old(analyzer, true, startClass, endClass);89 94 } 90 95 … … 135 140 } 136 141 142 /* 137 143 private void setOWLClassGraph(){ 138 graph = new OWLClassGraph(analyzer); 139 } 144 //graph = new OWLClassGraph(analyzer); 145 graph = new OWLClassGraph(); 146 }*/ 140 147 141 148 public OWLClassGraph getOWLClassGraph(){ 142 if ( graph == null ){149 /*if ( graph == null ){ 143 150 graph = new OWLClassGraph(analyzer); 144 } 151 }*/ 145 152 return graph; 146 153 } -
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/www/CLServlet.java
r228 r248 74 74 PrintWriter out = response.getWriter(); 75 75 String ep = request.getParameter("ep"); 76 String classURI = request.getParameter("class"); 76 77 HttpSession session = request.getSession(); 77 78 QueryPathGenerator qpg = (QueryPathGenerator)session.getAttribute("qpg"); … … 82 83 qpg.setSPARQLendpoint(ep); 83 84 //OWLClassGraph ocg = qpg.getOWLClassGraph(); 85 if ( classURI != null ){ 86 qpg.setOWLClassGraph(classURI); 87 } 88 84 89 SClass[] classes = qpg.getClasses(null); 85 90 for (int i = 0 ; i < classes.length; i++ ){ … … 88 93 // continue; 89 94 //} 95 if ( classURI != null ){ 96 if ( qpg.getOWLClassGraph().visitedNode(classURI) == false ){ 97 continue; 98 } 99 } 90 100 Label[] labels = classes[i].getLabels(); 91 101 String label = null; … … 113 123 JsonArrayBuilder jab = jbfactory.createArrayBuilder(); 114 124 Iterator<String> cit = sortedClasses.iterator(); 125 List<String> tmpclasses = new LinkedList<String>(); 126 JsonObjectBuilder job = jbfactory.createObjectBuilder(); 115 127 while( cit.hasNext() ){ 116 JsonObjectBuilder job = jbfactory.createObjectBuilder(); 128 String classinfo = cit.next(); 129 String[] data = classinfo.split(" "); 130 if (data.length != 3 ){ 131 System.out.println("data is wrong?"); 132 } 133 if (data[0].matches("^[0-9]*$")){ 134 tmpclasses.add(classinfo); 135 }else{ 136 job.add("uri", data[2]); 137 job.add("label", data[0]); 138 job.add("number", data[1]); 139 jab.add(job); 140 } 141 } 142 cit = tmpclasses.iterator(); 143 while( cit.hasNext() ){ 117 144 String classinfo = cit.next(); 118 145 String[] data = classinfo.split(" "); … … 124 151 job.add("number", data[1]); 125 152 jab.add(job); 126 } 153 } 127 154 JsonArray ja = jab.build(); 128 155 out.print(ja); -
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/www/PLServlet.java
r221 r248 74 74 String st = request.getParameter("startclass"); 75 75 String en = request.getParameter("endclass"); 76 String ask = request.getParameter("ask"); 76 77 77 78 HttpSession session = request.getSession(); … … 81 82 } 82 83 SClass[] classes = qpg.getClasses(null); 83 Path[] paths = qpg.getPaths(st, en, true); 84 Path[] paths = null; 85 if ( ask == null ){ 86 paths = qpg.getPaths(st, en, false); 87 }else if ( ask.equalsIgnoreCase("true")){ 88 paths = qpg.getPaths(st, en, true); 89 }else{ 90 paths = qpg.getPaths(st, en, false); 91 } 92 84 93 String jsonstr = "["; 85 94 for(int i = 0; i< paths.length; i++){ -
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/www/SPServlet.java
r229 r248 179 179 180 180 private String convertPath2SPARQL(Path path) throws Exception{ 181 182 ArrayList<String> classname =new ArrayList<String>() ; 183 181 ArrayList<String> classname =new ArrayList<String>() ; 184 182 if( path == null ){ 185 183 throw new Exception("Path is null.");