root/lex/trunk/jsp/clause.jsp

Revision 394, 7.2 kB (checked in by chris, 3 years ago)

Fix problem with being unable to create an LS for clauses with no
predicate, e.g. Gen 3,5(f).

Reorganised jsp directory to separate includes and css from jsp pages.

Renamed lsedit.jsp to lexicon.jsp.

Added a controller for lexicon.jsp.

Moved tests into their own package.

Separated finished and unfinished tests to make it easier to run all the
finished and working ones.

Line 
1 <% String pageTitle = "Text Browser"; %>
2
3 <%@ page import="java.util.*" %>
4 <%@ page import="java.util.regex.*" %>
5 <%@ page import="java.net.*" %>
6 <%@ page import="java.sql.*" %>
7 <%@ page import="jemdros.*" %>
8 <%@ page import="com.qwirx.lex.controller.*" %>
9 <%@ page import="com.qwirx.lex.hebrew.*" %>
10 <%@ page import="com.qwirx.lex.lexicon.*" %>
11 <%@ page import="com.qwirx.lex.morph.*" %>
12 <%@ page import="com.qwirx.lex.parser.*" %>
13 <%@ page import="com.qwirx.crosswire.kjv.KJV" %>
14 <%@ page import="org.aptivate.web.utils.EditField" %>
15 <%@ page import="org.crosswire.jsword.book.*" %>
16 <%@ page import="net.didion.jwnl.data.POS" %>
17 <%@ page import="net.didion.jwnl.data.Synset" %>
18
19 <%@ include file="include/setup.jsp" %>
20 <%@ include file="include/auth.jsp" %>
21 <%@ include file="include/navclause_head.jsp" %>
22
23 <%
24         ClauseController controller = new ClauseController(request, emdros, sql,
25                 navigator);     
26         if (controller.processRedirects(response))
27         {
28                 return;
29         }
30 %>
31 <%@ include file="include/header.jsp" %>
32
33 <script type="text/javascript" src="js/clause.js"></script>
34
35 <style type="text/css">
36         TABLE.tree TD
37         {
38                 text-align: center;
39         }
40 </style>
41
42 <%@ include file="include/navclause_body.jsp" %>
43
44 <%
45         controller.processBody();
46        
47         MatchedObject clause = controller.getClause();
48                  
49         if (clause == null)
50         {
51                 %><p>Selected clause not found or access denied.</p><%
52         }
53         else
54         {
55                 %>
56                 <span class="hebrew"><%= controller.getHebrewText() %></span>
57                 <table><%= controller.getGlossTable() %></table>
58                 <p><%= controller.getKingJamesVerse() %></p>
59
60                 <p>Predicate text is:
61                 <%
62                 String predicate = controller.getPredicateText();
63                 if (predicate != null)
64                 {
65                         %><%= controller.getPredicateText()
66                                 .replaceAll("<", "&lt;")
67                                 .replaceAll(">", "&gt;") %><%
68                 }
69                 else
70                 {
71                         %>Not found<%
72                 }
73                 %>
74                 </p>
75                 <p>
76                 <table border>
77                         <%= controller.getWordTable() %>
78                 </table>
79                 </p>
80                 <%
81                
82                 {
83                         Parser p = new Parser(sql);
84                         p.setVerbose(true);
85                         List sentences = p.parseFor(controller.getMorphEdges(), "SENTENCE");
86                        
87                         if (sentences.size() == 0)
88                         {
89                                 %>
90                                 <p>
91                                 Parse failed. Click <a href="parse.jsp">here</a> to fix it.
92                                 </p>
93                                 <%
94                         }
95                         else
96                         {
97                                 %>
98                                 <p>
99                                 Parse finished with <%= sentences.size() %> possible trees.
100                                 Showing the first
101                                 <%= sentences.size() > 3 ? 3 : sentences.size() %>:
102                                 </p>
103                                 <%
104                                 for (int i = 0; i < sentences.size() && i < 3; i++)
105                                 {
106                                         Edge sentence = (Edge)( sentences.get(i) );
107                                        
108                                         %><%= sentence.toTree().toHtml(new
109                                                 ClauseController.BorderTableRenderer()) %><%
110                                 }
111                                
112                                 %><p>
113                                 Click
114                                 <a href="parse.jsp">here</a>
115                                 to see and edit all <%= sentences.size() %> parses.
116                                 </p><%
117                         }
118                 }
119                
120                 %>
121
122                 <p>
123                 <%
124                 String selLsIdString = request.getParameter("lsid");
125                
126                 if (!emdros.canWriteTo(clause))
127                 {
128                         String structure = controller.getUnlinkedLogicalStructure();
129                         %>
130                         Selected lexicon entry logical structure:
131                         <%=
132                                 structure.equals("") ? "none" : structure
133                                                 .replaceAll("<", "&lt;")
134                                                 .replaceAll(">", "&gt;")
135                         %>
136                         <%
137                 }
138                 else if (selLsIdString != null && selLsIdString.equals("add"))
139                 {
140                         // Change button clicked and "Add..." selected,
141                         // show LS entry box
142                         %>
143                 <form name="changels" method="POST">
144                 Enter new logical structure:
145                 <input name="newls"/>
146                 <input type="submit" name="create" value="Create"/>
147                 <input type="submit" name="cancel" value="Cancel"/>
148                 </form>
149                         <%
150                 }
151                 else
152                 {
153                         // Show LS selector box, Change button, and maybe Edit button
154
155                         %>
156                 <table><tr><td>
157                         <form name="changels" method="POST">
158                         Choose logical structure:
159                         <%= controller.getLogicalStructureSelector().toString() %>
160                         <input type="submit" name="lssave" value="Change">
161                         </form>
162                         <script type="text/javascript"><!--
163                         enableChangeButton(document.forms.changels.lssave,<%=
164                                 controller.getSelectedLogicalStructureId()
165                         %>, document.forms.changels.lsid);
166                         //--></script>
167                 </td>
168                         <%
169                        
170                         if (controller.getSelectedLogicalStructureId() == 0)
171                         {
172                                 %>
173                 <td>
174                         <form name="editls" method="get" action="lexicon.jsp">
175                         <input type="hidden" name="lsid" value="<%=
176                                 controller.getSelectedLogicalStructureId()
177                         %>" />
178                         <input type="submit" name="submit" value="Edit..." />
179                         </form>
180                 </td>
181                                 <%
182                         }
183
184                         %>
185                 </table>
186                         <%
187                 }
188                 %>
189                 </p>
190                                
191                 <script type="text/javascript"><!--
192                         enableEditButton();
193                 //--></script>
194                
195                 <% EditField form = new EditField(request); %>
196                
197                 <p>Linked logical structure: <%=
198                         form.escapeEntities(controller.getLinkedLogicalStructure())
199                 %></p>
200
201                 <h3>Notes</h3>
202                
203                 <%
204                
205                 if (request.getParameter("nd") != null &&
206                         request.getParameter("ni") != null)
207                 {
208                         %><table border><%
209                        
210                         boolean foundNotes = false;
211        
212                         String editNoteIdString = request.getParameter("ni");
213                         int editNoteId = -1;
214                         if (editNoteIdString != null)
215                         {
216                                 editNoteId = Integer.parseInt(editNoteIdString);
217                         }
218                
219                         Sheaf clauseSheaf = emdros.getSheaf
220                                 ("SELECT ALL OBJECTS IN { "+min_m+" - "+max_m+"} "+
221                                  "WHERE [clause self = "+navigator.getClauseId()+
222                                  " [note GET text]"+
223                                  "]");
224        
225                         SheafConstIterator sci = clauseSheaf.const_iterator();
226                         while (sci.hasNext())
227                         {
228                                 Straw straw = sci.next();
229                                 clause = straw.const_iterator().next();
230                                
231                                 Sheaf noteSheaf = clause.getSheaf();
232                                 SheafConstIterator nsci = noteSheaf.const_iterator();
233                                 while (nsci.hasNext())
234                                 {
235                                         Straw ns = nsci.next();
236                                         MatchedObject note = ns.const_iterator().next();
237                                
238                                         String noteText = note.getEMdFValue("text").getString();
239                                         if (!foundNotes)
240                                         {
241                                                 foundNotes = true;
242                                         }
243                                        
244                                         %><tr><%
245        
246                                         if (request.getParameter("ne") != null &&
247                                                 editNoteId == note.getID_D())
248                                         {
249                                                 %>
250         <form method="POST" action="clause.jsp">
251         <input type="hidden" name="ni" value="<%= note.getID_D() %>" />
252         <td>
253                 <input name="nt" size="80" value="<%= form.escapeEntities(noteText) %>" />
254         </td>
255         <td>
256                 <input type="submit" name="nu" value="Update" />
257                 <input type="submit" name="nd" value="Delete" />
258         </td>
259         </form>
260                                                 <%
261                                         }
262                                         else
263                                         {
264                                                 %>                                     
265         <td><%= form.escapeEntities(noteText) %></td>
266         <td>
267                 <a href="clause.jsp?ni=<%= note.getID_D() %>&ne=1">Edit</a>
268         </td>
269                                                 <%
270                                         }
271        
272                                         %></tr><%
273                                 }
274                         }
275                        
276                         if (!foundNotes)
277                         {
278                                 %><tr><td>No notes for this clause</td></tr><%
279                         }
280                 }
281                        
282                 %>
283 </table>
284
285 <p><form method="POST">
286 <table>
287 <tr>
288 <td>Add note:</td>
289 <td><input name="nt" size="80"></td>
290 <td><input type="submit" name="nc" value="Create"></td>
291 </tr>
292 </table>
293 </form></p>
294        
295 <p>Download clause in GEN format for LTC:</p>
296 <ul>
297         <li><a href="gen-export.jsp?clause=<%= navigator.getClauseId() %>&hebrew=y">With
298                 Hebrew (right-to-left)</a></li>
299         <li><a href="gen-export.jsp?clause=<%= navigator.getClauseId() %>&hebrew=n">Without
300                 Hebrew (left-to-right)</a></li>
301 </ul>
302
303 <%
304                 if (emdros.canWriteTo(clause))
305                 {
306                         %>
307                         <form method="POST">
308                                 <% if (controller.isPublished(clause)) { %>
309                                 <input type="submit" name="unpublish" value="Unpublish" />
310                                 <% } else { %>
311                                 <input type="submit" name="publish" value="Publish" />
312                                 <% } %>
313                         </form>
314                         <%
315                 }
316         }
317 %>
318        
319 <hr>
320         <%= navigator.getLabel("book") %>,
321 Chapter <%= navigator.getLabel("chapter") %>,
322 Verse   <%= navigator.getLabel("verse") %>,
323 Clause  <%= navigator.getClauseId() %>
324 </form>
325
326 <%@ include file="include/footer.jsp" %>
Note: See TracBrowser for help on using the browser.