| 1 |
<%@ include file="include/setup.jsp" %> |
|---|
| 2 |
<%@ include file="include/auth.jsp" %> |
|---|
| 3 |
|
|---|
| 4 |
<% String pageTitle = "Parser Rules"; %> |
|---|
| 5 |
<%@ include file="include/header.jsp" %> |
|---|
| 6 |
|
|---|
| 7 |
<%@ page import="java.util.*" %> |
|---|
| 8 |
<%@ page import="java.sql.ResultSet" %> |
|---|
| 9 |
<%@ page import="com.qwirx.lex.ontology.*" %> |
|---|
| 10 |
<%@ page import="com.qwirx.lex.wordnet.*" %> |
|---|
| 11 |
<%@ page import="com.qwirx.lex.parser.*" %> |
|---|
| 12 |
<%@ page import="com.qwirx.lex.morph.*" %> |
|---|
| 13 |
|
|---|
| 14 |
<script language="javascript"> |
|---|
| 15 |
<!-- |
|---|
| 16 |
|
|---|
| 17 |
function confirm_delete() |
|---|
| 18 |
{ |
|---|
| 19 |
return confirm("Are you sure you want to delete this rule?"); |
|---|
| 20 |
} |
|---|
| 21 |
|
|---|
| 22 |
//--> |
|---|
| 23 |
</script> |
|---|
| 24 |
|
|---|
| 25 |
<% |
|---|
| 26 |
|
|---|
| 27 |
int editRuleId = -1; |
|---|
| 28 |
|
|---|
| 29 |
{ |
|---|
| 30 |
String editRuleIdParam = request.getParameter("erid"); |
|---|
| 31 |
if (editRuleIdParam != null) |
|---|
| 32 |
{ |
|---|
| 33 |
editRuleId = Integer.parseInt(editRuleIdParam); |
|---|
| 34 |
} |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
if (request.getParameter("save") != null) |
|---|
| 38 |
{ |
|---|
| 39 |
Change ch = sql.createChange(SqlChange.UPDATE, |
|---|
| 40 |
"lexicon_entries", "ID = " + editRuleId); |
|---|
| 41 |
ch.setString("Symbol", request.getParameter("lhs")); |
|---|
| 42 |
ch.setString("Lexeme", request.getParameter("rhs")); |
|---|
| 43 |
ch.execute(); |
|---|
| 44 |
} |
|---|
| 45 |
else if (request.getParameter("delete") != null) |
|---|
| 46 |
{ |
|---|
| 47 |
Change ch = sql.createChange(SqlChange.DELETE, |
|---|
| 48 |
"lexicon_entries", "ID = " + editRuleId); |
|---|
| 49 |
ch.execute(); |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
sql.prepareSelect |
|---|
| 53 |
("SELECT ID,Symbol,Lexeme FROM lexicon_entries " + |
|---|
| 54 |
"WHERE Symbol IS NOT NULL " + |
|---|
| 55 |
"AND Lexeme IS NOT NULL " + |
|---|
| 56 |
"ORDER BY Symbol, Lexeme"); |
|---|
| 57 |
|
|---|
| 58 |
ResultSet rs = sql.select(); |
|---|
| 59 |
|
|---|
| 60 |
if (rs.isLast()) |
|---|
| 61 |
{ |
|---|
| 62 |
%><h3>No rules found in database!</h3><% |
|---|
| 63 |
} |
|---|
| 64 |
else |
|---|
| 65 |
{ |
|---|
| 66 |
%> |
|---|
| 67 |
<form name="edit_rule_form" method="post" |
|---|
| 68 |
action="rules.jsp#rule_<%= editRuleId %>"> |
|---|
| 69 |
<table border="1"> |
|---|
| 70 |
<th>ID</th> |
|---|
| 71 |
<th>Left-Hand Side</th> |
|---|
| 72 |
<th>Right-Hand Side</th> |
|---|
| 73 |
<th>Actions</th> |
|---|
| 74 |
<% |
|---|
| 75 |
|
|---|
| 76 |
while (rs.next()) |
|---|
| 77 |
{ |
|---|
| 78 |
int ruleId = rs.getInt(1); |
|---|
| 79 |
|
|---|
| 80 |
if (ruleId == editRuleId) |
|---|
| 81 |
{ |
|---|
| 82 |
%> |
|---|
| 83 |
<tr class="hilite"> |
|---|
| 84 |
<% |
|---|
| 85 |
} |
|---|
| 86 |
else |
|---|
| 87 |
{ |
|---|
| 88 |
%> |
|---|
| 89 |
<tr> |
|---|
| 90 |
<% |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
%> |
|---|
| 94 |
<th id="rule_<%= ruleId %>"><%= ruleId %></th> |
|---|
| 95 |
<% |
|---|
| 96 |
|
|---|
| 97 |
if (ruleId == editRuleId) |
|---|
| 98 |
{ |
|---|
| 99 |
%> |
|---|
| 100 |
<td><input name="lhs" size="10" value="<%= rs.getString(2) %>" /></td> |
|---|
| 101 |
<td><input name="rhs" size="40" value="<%= rs.getString(3) %>" /></td> |
|---|
| 102 |
<td> |
|---|
| 103 |
<input type="hidden" name="erid" value="<%= ruleId %>" /> |
|---|
| 104 |
<input type="submit" name="save" value="Save" /> |
|---|
| 105 |
<input type="submit" name="delete" value="Delete" |
|---|
| 106 |
onClick="return confirm_delete()" /> |
|---|
| 107 |
</td> |
|---|
| 108 |
<% |
|---|
| 109 |
} |
|---|
| 110 |
else |
|---|
| 111 |
{ |
|---|
| 112 |
%> |
|---|
| 113 |
<td><%= rs.getString(2) %></td> |
|---|
| 114 |
<td><%= rs.getString(3) %></td> |
|---|
| 115 |
<td><a href="rules.jsp?erid=<%= rs.getInt(1) %>#rule_<%= |
|---|
| 116 |
ruleId %>">Edit</a></td> |
|---|
| 117 |
<% |
|---|
| 118 |
} |
|---|
| 119 |
|
|---|
| 120 |
%> |
|---|
| 121 |
</tr> |
|---|
| 122 |
<% |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
%> |
|---|
| 126 |
</table> |
|---|
| 127 |
</form> |
|---|
| 128 |
<% |
|---|
| 129 |
} |
|---|
| 130 |
%> |
|---|
| 131 |
|
|---|
| 132 |
<%@ include file="include/footer.jsp" %> |
|---|