Revision 465
Added by berkley over 23 years ago
QuerySpecification.java | ||
---|---|---|
296 | 296 |
* This method prints sql based upon the <returnfield> tag in the |
297 | 297 |
* pathquery document. This allows for customization of the |
298 | 298 |
* returned fields |
299 |
* @param doclist the list of document ids to search by |
|
299 | 300 |
*/ |
300 |
public String printExtendedSQL() |
|
301 |
public String printExtendedSQL(String doclist)
|
|
301 | 302 |
{ |
302 | 303 |
StringBuffer self = new StringBuffer(); |
303 | 304 |
self.append("select xml_nodes.docid, xml_index.path, xml_nodes.nodedata "); |
... | ... | |
322 | 323 |
} |
323 | 324 |
} |
324 | 325 |
self.append(") AND xml_nodes.docid in ("); |
325 |
self.append(query.printSQL()); |
|
326 |
//self.append(query.printSQL()); |
|
327 |
self.append(doclist); |
|
326 | 328 |
self.append(")"); |
327 | 329 |
self.append(" AND xml_nodes.nodetype = 'TEXT'"); |
328 | 330 |
|
329 | 331 |
//System.out.println(self.toString()); |
330 | 332 |
return self.toString(); |
331 | 333 |
} |
334 |
|
|
335 |
public static String printRelationSQL(String docid) |
|
336 |
{ |
|
337 |
StringBuffer self = new StringBuffer(); |
|
338 |
self.append("select subject, relationship, object from xml_relation "); |
|
339 |
self.append("where subject like '").append(docid).append("'"); |
|
340 |
return self.toString(); |
|
341 |
} |
|
332 | 342 |
|
333 | 343 |
/** |
334 |
* |
|
344 |
* Prints sql that returns all relations in the database.
|
|
335 | 345 |
*/ |
336 | 346 |
public static String printPackageSQL() |
337 | 347 |
{ |
... | ... | |
356 | 366 |
} |
357 | 367 |
|
358 | 368 |
/** |
369 |
* Prints sql that returns all relations in the database that were input |
|
370 |
* under a specific docid |
|
371 |
* @param docid the docid to search for. |
|
372 |
*/ |
|
373 |
public static String printPackageSQL(String docid) |
|
374 |
{ |
|
375 |
StringBuffer self = new StringBuffer(); |
|
376 |
self.append("select z.nodedata, x.nodedata, y.nodedata from "); |
|
377 |
self.append("(select nodeid, parentnodeid from xml_index where path like "); |
|
378 |
self.append("'package/relation/subject') s, (select nodeid, parentnodeid "); |
|
379 |
self.append("from xml_index where path like "); |
|
380 |
self.append("'package/relation/relationship') rel, "); |
|
381 |
self.append("(select nodeid, parentnodeid from xml_index where path like "); |
|
382 |
self.append("'package/relation/object') o, "); |
|
383 |
self.append("xml_nodes x, xml_nodes y, xml_nodes z "); |
|
384 |
self.append("where s.parentnodeid = rel.parentnodeid "); |
|
385 |
self.append("and rel.parentnodeid = o.parentnodeid "); |
|
386 |
self.append("and x.parentnodeid in rel.nodeid "); |
|
387 |
self.append("and y.parentnodeid in o.nodeid "); |
|
388 |
self.append("and z.parentnodeid in s.nodeid "); |
|
389 |
self.append("and z.docid like '").append(docid).append("'"); |
|
390 |
|
|
391 |
return self.toString(); |
|
392 |
} |
|
393 |
|
|
394 |
/** |
|
395 |
* Returns all of the relations that has a certain docid in the subject |
|
396 |
* or the object. |
|
397 |
* |
|
398 |
* @param docid the docid to search for |
|
399 |
*/ |
|
400 |
public static String printPackageSQL(String subDocidURL, String objDocidURL) |
|
401 |
{ |
|
402 |
StringBuffer self = new StringBuffer(); |
|
403 |
self.append("select z.nodedata, x.nodedata, y.nodedata from "); |
|
404 |
self.append("(select nodeid, parentnodeid from xml_index where path like "); |
|
405 |
self.append("'package/relation/subject') s, (select nodeid, parentnodeid "); |
|
406 |
self.append("from xml_index where path like "); |
|
407 |
self.append("'package/relation/relationship') rel, "); |
|
408 |
self.append("(select nodeid, parentnodeid from xml_index where path like "); |
|
409 |
self.append("'package/relation/object') o, "); |
|
410 |
self.append("xml_nodes x, xml_nodes y, xml_nodes z "); |
|
411 |
self.append("where s.parentnodeid = rel.parentnodeid "); |
|
412 |
self.append("and rel.parentnodeid = o.parentnodeid "); |
|
413 |
self.append("and x.parentnodeid in rel.nodeid "); |
|
414 |
self.append("and y.parentnodeid in o.nodeid "); |
|
415 |
self.append("and z.parentnodeid in s.nodeid "); |
|
416 |
self.append("and (z.nodedata like '"); |
|
417 |
self.append(subDocidURL); |
|
418 |
self.append("' or y.nodedata like '"); |
|
419 |
self.append(objDocidURL); |
|
420 |
self.append("')"); |
|
421 |
return self.toString(); |
|
422 |
} |
|
423 |
|
|
424 |
public static String printGetDocByDoctypeSQL(String docid) |
|
425 |
{ |
|
426 |
StringBuffer self = new StringBuffer(); |
|
427 |
|
|
428 |
self.append("SELECT docid,docname,doctype,doctitle,"); |
|
429 |
self.append("date_created, date_updated "); |
|
430 |
self.append("FROM xml_documents WHERE docid IN ("); |
|
431 |
self.append(docid).append(")"); |
|
432 |
return self.toString(); |
|
433 |
} |
|
434 |
|
|
435 |
/** |
|
359 | 436 |
* create a String description of the query that this instance represents. |
360 | 437 |
* This should become a way to get the XML serialization of the query. |
361 | 438 |
*/ |
... | ... | |
578 | 655 |
|
579 | 656 |
/** |
580 | 657 |
* '$Log$ |
658 |
* 'Revision 1.15 2000/09/15 19:52:12 berkley |
|
659 |
* 'Added functionality for package specifications. metacatservlet now contains a new action called getrelateddocument that handles retrieving related documents using the metacatURL specification (metacatURL.java). DBQuery contains new code in runQuery that embeds relation tags in the returned hashtable describing the documents related to each docid. querySpecification contains a new method which prints the sql that does the relation query. |
|
660 |
* ' |
|
581 | 661 |
* 'Revision 1.14 2000/08/31 21:20:39 berkley |
582 | 662 |
* 'changed xslf for new returnfield scheme. the returnfields are now returned as <param name="<returnfield>"> tags. |
583 | 663 |
* 'hThe sql for the returnfield query was redone to fix a previous problem with slow queries |
Also available in: Unified diff
Added backtrack functionality. Backtracking works by passing a returndoc parameter. There can be more than one. If a document that is hit by a query is not of type returndoc then it searches the database for a related file of type returndoc. If one is found it is displayed, if no relation is found, the original is displayed.
Support was also added for an index of relations. the table xml_relation handles the all of the relation indexing.