- 更新日時:
- 2016/06/14 13:23:04 (8 年 前)
- ファイル:
-
- 1 変更
凡例:
- 変更なし
- 追加
- 削除
-
SPARQLBuilderWWW/src/java/org/biohackathon/SPARQLBuilder/www/EPServlet.java
r228 r285 7 7 package org.biohackathon.SPARQLBuilder.www; 8 8 9 import java.io. IOException;10 import java. io.PrintWriter;9 import java.io.*; 10 import java.math.BigDecimal; 11 11 import javax.servlet.ServletException; 12 12 import javax.servlet.annotation.WebServlet; … … 80 80 response.setHeader("Access-Control-Max-Age", "-1"); 81 81 PrintWriter out = response.getWriter(); 82 82 83 String ds = request.getParameter("ds"); 84 83 85 String[] elist = qpg.getFactory().getEndpointURIList(); 84 86 SortedSet<String> sortedelist = new TreeSet<String>(); 85 87 for (int i = 0; i < elist.length; i++ ){ 86 88 sortedelist.add(elist[i]); 87 } 89 } 88 90 JsonBuilderFactory jbfactory = Json.createBuilderFactory(null); 89 91 JsonArrayBuilder jab = jbfactory.createArrayBuilder(); 90 Iterator<String> eit = sortedelist.iterator(); 91 while( eit.hasNext() ){ 92 jab.add(eit.next()); 92 if ( ds == null ){ 93 Iterator<String> eit = sortedelist.iterator(); 94 while( eit.hasNext() ){ 95 jab.add(eit.next()); 96 } 97 JsonArray ja = jab.build(); 98 out.print(ja); 99 }else{ 100 File dsf = new File("dstable.txt"); 101 HashMap<String, String> demap = new HashMap<String, String>(); 102 try{ 103 BufferedReader br = new BufferedReader(new FileReader(dsf)); 104 String buf; 105 while ( (buf = br.readLine()) != null ){ 106 String[] data = buf.split(","); 107 if (data.length != 2 ){ continue; } 108 demap.put(data[0],data[1]); 109 } 110 }catch(IOException e){ 111 e.printStackTrace(); 112 } 113 Iterator<String> eit = sortedelist.iterator(); 114 while( eit.hasNext() ){ 115 JsonObjectBuilder job = jbfactory.createObjectBuilder(); 116 String duri = eit.next(); 117 String euri = duri; 118 String ep = demap.get(duri); 119 if ( ep != null ){ 120 euri = ep; 121 } 122 job.add("label", duri); 123 job.add("uri", euri); 124 jab.add(job); 125 } 126 JsonArray ja = jab.build(); 127 out.print(ja); 93 128 } 94 JsonArray ja = jab.build();95 out.print(ja);96 129 session.setAttribute("qpg", qpg); 97 130 } 98 99 131 /** 100 132 * Handles the HTTP <code>POST</code> method.