| 1 |
<% String pageTitle = "Emdros Database Dump"; %> |
|---|
| 2 |
<%@ include file="header2.jsp" %> |
|---|
| 3 |
|
|---|
| 4 |
<%@ page import="java.util.Enumeration" %> |
|---|
| 5 |
<%@ page import="java.util.Hashtable" %> |
|---|
| 6 |
<%@ page import="java.util.Vector" %> |
|---|
| 7 |
<%@ page import="java.util.TreeSet" %> |
|---|
| 8 |
<%@ page import="java.util.SortedSet" %> |
|---|
| 9 |
<%@ page import="java.util.Iterator" %> |
|---|
| 10 |
<%@ page import="jemdros.*" %> |
|---|
| 11 |
<%@ page import="com.qwirx.lex.*" %> |
|---|
| 12 |
<%@ page import="com.qwirx.db.sql.*" %> |
|---|
| 13 |
<%@ page import="com.qwirx.lex.emdros.*" %> |
|---|
| 14 |
|
|---|
| 15 |
<%@ include file="auth.jsp" %> |
|---|
| 16 |
|
|---|
| 17 |
<%@ include file="navclause.jsp" %> |
|---|
| 18 |
|
|---|
| 19 |
<% |
|---|
| 20 |
if (username.equals("anonymous")) |
|---|
| 21 |
{ |
|---|
| 22 |
%>Sorry, you must log in to access this feature.<% |
|---|
| 23 |
return; |
|---|
| 24 |
} |
|---|
| 25 |
|
|---|
| 26 |
class MonadRange |
|---|
| 27 |
{ |
|---|
| 28 |
int first, last; |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
class DbObject |
|---|
| 32 |
{ |
|---|
| 33 |
String type; |
|---|
| 34 |
int id; |
|---|
| 35 |
int firstMonad, lastMonad; |
|---|
| 36 |
MonadRange [] monadRanges; |
|---|
| 37 |
Hashtable features; |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
int left = 728, right = 734; |
|---|
| 41 |
|
|---|
| 42 |
int clauseId = selClauseId; |
|---|
| 43 |
|
|---|
| 44 |
Sheaf sheaf = emdros.getSheaf |
|---|
| 45 |
( |
|---|
| 46 |
"SELECT ALL OBJECTS IN " + |
|---|
| 47 |
emdros.intersect(userTextAccessSet, min_m, max_m) + |
|---|
| 48 |
" WHERE [clause self = "+clauseId+"]" |
|---|
| 49 |
); |
|---|
| 50 |
|
|---|
| 51 |
MatchedObject clause = null; |
|---|
| 52 |
{ |
|---|
| 53 |
SheafConstIterator sci = sheaf.const_iterator(); |
|---|
| 54 |
if (sci.hasNext()) |
|---|
| 55 |
{ |
|---|
| 56 |
Straw straw = sci.next(); |
|---|
| 57 |
StrawConstIterator swci = straw.const_iterator(); |
|---|
| 58 |
if (swci.hasNext()) |
|---|
| 59 |
{ |
|---|
| 60 |
clause = swci.next(); |
|---|
| 61 |
} |
|---|
| 62 |
} |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
if (clause != null) |
|---|
| 66 |
{ |
|---|
| 67 |
Table monads = emdros.getTable |
|---|
| 68 |
("GET MONADS FROM OBJECT WITH ID_D = "+clause.getID_D()+" "+ |
|---|
| 69 |
"[clause]"); |
|---|
| 70 |
TableRow tr = monads.iterator().next(); |
|---|
| 71 |
left = Integer.parseInt(tr.getColumn(2)); |
|---|
| 72 |
right = Integer.parseInt(tr.getColumn(3)); |
|---|
| 73 |
} |
|---|
| 74 |
else |
|---|
| 75 |
{ |
|---|
| 76 |
%>Null clause!<% |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
Table objects = emdros.getTable("SELECT OBJECTS HAVING MONADS IN " + |
|---|
| 80 |
"{" + left + "-" + right + "} [ALL] GO"); |
|---|
| 81 |
|
|---|
| 82 |
int numObjects = objects.size(); |
|---|
| 83 |
DbObject [] dbObjects = new DbObject [numObjects]; |
|---|
| 84 |
TableIterator ti = objects.iterator(); |
|---|
| 85 |
|
|---|
| 86 |
// collect information about each object, specifically the set of monads |
|---|
| 87 |
// which fall within our range (between left and right borders) |
|---|
| 88 |
|
|---|
| 89 |
for (int objectNum = 0; objectNum < numObjects; objectNum++) |
|---|
| 90 |
{ |
|---|
| 91 |
TableRowIterator tri = ti.next().iterator(); |
|---|
| 92 |
|
|---|
| 93 |
DbObject object = new DbObject(); |
|---|
| 94 |
object.type = tri.next(); |
|---|
| 95 |
object.firstMonad = Integer.parseInt(tri.next()); |
|---|
| 96 |
|
|---|
| 97 |
String objectIdString = tri.next(); |
|---|
| 98 |
object.id = Integer.parseInt(objectIdString); |
|---|
| 99 |
|
|---|
| 100 |
Table monad_ranges = emdros.getTable("GET MONADS FROM OBJECTS " + |
|---|
| 101 |
"WITH ID_Ds = "+objectIdString+" ["+object.type+"] GO"); |
|---|
| 102 |
|
|---|
| 103 |
int numRanges = monad_ranges.size(); |
|---|
| 104 |
Vector monadRangeVector = new Vector(); |
|---|
| 105 |
|
|---|
| 106 |
TableIterator mi = monad_ranges.iterator(); |
|---|
| 107 |
for (int rangeNum = 0; rangeNum < numRanges; rangeNum++) |
|---|
| 108 |
{ |
|---|
| 109 |
TableRowIterator mri = mi.next().iterator(); |
|---|
| 110 |
mri.next(); // skip the object id_d, we know what it is |
|---|
| 111 |
MonadRange range = new MonadRange(); |
|---|
| 112 |
range.first = Integer.parseInt(mri.next()); |
|---|
| 113 |
range.last = Integer.parseInt(mri.next()); |
|---|
| 114 |
if (range.last >= left && range.first <= right) |
|---|
| 115 |
{ |
|---|
| 116 |
if (range.first < left) |
|---|
| 117 |
range.first = left; |
|---|
| 118 |
if (range.last > right) |
|---|
| 119 |
range.last = right; |
|---|
| 120 |
if (range.last - range.first >= 0) |
|---|
| 121 |
monadRangeVector.add(range); |
|---|
| 122 |
} |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
if (monadRangeVector.size() == 0) |
|---|
| 126 |
{ |
|---|
| 127 |
throw new RuntimeException("no valid ranges in object ["+ |
|---|
| 128 |
object.type+" "+object.id+"]"); |
|---|
| 129 |
} |
|---|
| 130 |
|
|---|
| 131 |
object.monadRanges = new MonadRange[monadRangeVector.size()]; |
|---|
| 132 |
monadRangeVector.copyInto(object.monadRanges); |
|---|
| 133 |
|
|---|
| 134 |
String query = "SELECT FEATURES FROM [" + |
|---|
| 135 |
object.type + "]"; |
|---|
| 136 |
|
|---|
| 137 |
%> |
|---|
| 138 |
<!-- <p><%= object.type %> '<%= query %>'</p> --> |
|---|
| 139 |
<% |
|---|
| 140 |
|
|---|
| 141 |
Table features = emdros.getTable(query); |
|---|
| 142 |
int numFeatures = features.size(); |
|---|
| 143 |
String [] featureNames = new String [numFeatures]; |
|---|
| 144 |
StringBuffer featureValueQuery = new StringBuffer("GET FEATURES "); |
|---|
| 145 |
|
|---|
| 146 |
{ |
|---|
| 147 |
TableIterator ti2 = features.iterator(); |
|---|
| 148 |
while (ti2.hasNext()) |
|---|
| 149 |
{ |
|---|
| 150 |
TableRow tr = ti2.next(); |
|---|
| 151 |
%> |
|---|
| 152 |
<!--<p><%= object.type %> <%= tr.getColumn(1) %></p>--> |
|---|
| 153 |
<% |
|---|
| 154 |
} |
|---|
| 155 |
} |
|---|
| 156 |
|
|---|
| 157 |
{ |
|---|
| 158 |
TableIterator fni = features.iterator(); |
|---|
| 159 |
int index = 0; |
|---|
| 160 |
for (int i = 0; i < numFeatures; i++) |
|---|
| 161 |
{ |
|---|
| 162 |
TableRowIterator fnri = fni.next().iterator(); |
|---|
| 163 |
String name = fnri.next(); |
|---|
| 164 |
if (i < numFeatures - 1) |
|---|
| 165 |
{ |
|---|
| 166 |
featureValueQuery.append(name+","); |
|---|
| 167 |
} |
|---|
| 168 |
else |
|---|
| 169 |
{ |
|---|
| 170 |
featureValueQuery.append(name); |
|---|
| 171 |
} |
|---|
| 172 |
} |
|---|
| 173 |
} |
|---|
| 174 |
|
|---|
| 175 |
featureValueQuery.append(" FROM OBJECTS WITH ID_DS = "+object.id+ |
|---|
| 176 |
" ["+object.type+"] GO"); |
|---|
| 177 |
object.features = new Hashtable(); |
|---|
| 178 |
Table featureValues = emdros.getTable(featureValueQuery.toString()); |
|---|
| 179 |
|
|---|
| 180 |
TableIterator fvi; |
|---|
| 181 |
TableIterator fni = features.iterator(); |
|---|
| 182 |
fvi = featureValues.iterator(); |
|---|
| 183 |
TableRowIterator fvri = fvi.next().iterator(); |
|---|
| 184 |
fvri.next(); // skip the id_d column of GET FEATURES result |
|---|
| 185 |
|
|---|
| 186 |
while (fni.hasNext()) |
|---|
| 187 |
{ |
|---|
| 188 |
TableRowIterator fnri = fni.next().iterator(); |
|---|
| 189 |
String name = fnri.next(); |
|---|
| 190 |
String value = fvri.next(); |
|---|
| 191 |
object.features.put(name, value); |
|---|
| 192 |
} |
|---|
| 193 |
|
|---|
| 194 |
dbObjects[objectNum] = object; |
|---|
| 195 |
} |
|---|
| 196 |
|
|---|
| 197 |
if (dbObjects.length > 0) |
|---|
| 198 |
{ |
|---|
| 199 |
%> |
|---|
| 200 |
<table border> |
|---|
| 201 |
<tr> |
|---|
| 202 |
<th>type</th> |
|---|
| 203 |
<% |
|---|
| 204 |
|
|---|
| 205 |
for (int i = left; i <= right; i++) |
|---|
| 206 |
{ |
|---|
| 207 |
%> |
|---|
| 208 |
<th><%= i %></th> |
|---|
| 209 |
<% |
|---|
| 210 |
} |
|---|
| 211 |
|
|---|
| 212 |
%> |
|---|
| 213 |
</tr> |
|---|
| 214 |
<% |
|---|
| 215 |
|
|---|
| 216 |
for (int objectNum = 0; objectNum < dbObjects.length; objectNum++) |
|---|
| 217 |
{ |
|---|
| 218 |
DbObject object = dbObjects[objectNum]; |
|---|
| 219 |
Object [] featureNames = new TreeSet(object.features.keySet()) |
|---|
| 220 |
.toArray(); |
|---|
| 221 |
MonadRange [] ranges = object.monadRanges; |
|---|
| 222 |
|
|---|
| 223 |
for (int featureNum = -1; featureNum < featureNames.length; featureNum++) |
|---|
| 224 |
{ |
|---|
| 225 |
String featureName; |
|---|
| 226 |
|
|---|
| 227 |
if (featureNum == -1) |
|---|
| 228 |
{ |
|---|
| 229 |
featureName = null; |
|---|
| 230 |
} |
|---|
| 231 |
else |
|---|
| 232 |
{ |
|---|
| 233 |
featureName = (String)( featureNames[featureNum] ); |
|---|
| 234 |
} |
|---|
| 235 |
|
|---|
| 236 |
/* |
|---|
| 237 |
if (featureName != null && |
|---|
| 238 |
! featureName.equals("lexeme")) { |
|---|
| 239 |
continue; |
|---|
| 240 |
} |
|---|
| 241 |
*/ |
|---|
| 242 |
|
|---|
| 243 |
if (featureName == null) |
|---|
| 244 |
{ |
|---|
| 245 |
%> |
|---|
| 246 |
<tr> |
|---|
| 247 |
<td><b><%= object.type %></b></td> |
|---|
| 248 |
<% |
|---|
| 249 |
} |
|---|
| 250 |
else |
|---|
| 251 |
{ |
|---|
| 252 |
%> |
|---|
| 253 |
<tr> |
|---|
| 254 |
<td> <i><%= featureName %></i></td> |
|---|
| 255 |
<% |
|---|
| 256 |
} |
|---|
| 257 |
|
|---|
| 258 |
String featureValue = null; |
|---|
| 259 |
if (featureNum >= 0) |
|---|
| 260 |
featureValue = |
|---|
| 261 |
((String)( object.features.get(featureName) )) |
|---|
| 262 |
.replaceAll("<", "<") |
|---|
| 263 |
.replaceAll(">", ">"); |
|---|
| 264 |
|
|---|
| 265 |
/* pad up to the first monad */ |
|---|
| 266 |
MonadRange firstRange = ranges[0]; |
|---|
| 267 |
if (firstRange.first > left) |
|---|
| 268 |
{ |
|---|
| 269 |
%> |
|---|
| 270 |
<td colspan="<%= firstRange.first - left %>"/> |
|---|
| 271 |
<% |
|---|
| 272 |
} |
|---|
| 273 |
|
|---|
| 274 |
for (int rangeNum = 0; rangeNum < ranges.length; rangeNum++) |
|---|
| 275 |
{ |
|---|
| 276 |
MonadRange range = ranges[rangeNum]; |
|---|
| 277 |
|
|---|
| 278 |
%> |
|---|
| 279 |
<td bgcolor="#E0E0E0" colspan="<%= range.last - range.first + 1 %>"><% |
|---|
| 280 |
if (featureNum >= 0) |
|---|
| 281 |
{ |
|---|
| 282 |
%><%= featureValue %><% |
|---|
| 283 |
} |
|---|
| 284 |
else |
|---|
| 285 |
{ |
|---|
| 286 |
%><%= object.id %><% |
|---|
| 287 |
} |
|---|
| 288 |
%></td> |
|---|
| 289 |
<% |
|---|
| 290 |
|
|---|
| 291 |
if (rangeNum < ranges.length - 1) |
|---|
| 292 |
{ |
|---|
| 293 |
%> |
|---|
| 294 |
<td colspan="<%= ranges[rangeNum+1].first - range.last - 1 %>"/> |
|---|
| 295 |
<% |
|---|
| 296 |
} |
|---|
| 297 |
} |
|---|
| 298 |
|
|---|
| 299 |
MonadRange lastRange = ranges[ranges.length-1]; |
|---|
| 300 |
if (lastRange.last < right) |
|---|
| 301 |
{ |
|---|
| 302 |
%> |
|---|
| 303 |
<td colspan="<%= right - lastRange.last %>"/> |
|---|
| 304 |
<% |
|---|
| 305 |
} |
|---|
| 306 |
} |
|---|
| 307 |
|
|---|
| 308 |
%> |
|---|
| 309 |
</tr> |
|---|
| 310 |
<% |
|---|
| 311 |
} |
|---|
| 312 |
|
|---|
| 313 |
%> |
|---|
| 314 |
</table> |
|---|
| 315 |
<% |
|---|
| 316 |
} |
|---|
| 317 |
else |
|---|
| 318 |
{ |
|---|
| 319 |
%>No objects found<% |
|---|
| 320 |
} |
|---|
| 321 |
%> |
|---|
| 322 |
</body></html> |
|---|
| 323 |
<%@ include file="cleanup.jsp" %> |
|---|