Bug #2999
closedonly one attribute per element returned with pathquery results
0%
Description
when a path query requests that multiple attributes for the same element are returned, only one is actually present in the results.
example:
<returnfield>assessment/@assessmentTitle</returnfield> <returnfield>assessment/@assessmentId</returnfield>
only @assessmentId is given in results.
Updated by ben leinfelder about 17 years ago
Jing,
In regards to the bug where only one attribute per element is returned
in a metacat pathquery, I found a fix that I want to run by you. I'm
not sure if there was a reason that this limitation was coded, but it
seems like an unreasonable thing to enforce.
In the method putInArray(...) I've commented out the for loop that
checks if there is already an entry with the same parentId. This allows
multiple ReturnFieldValues with the same parent to be included in the
results. The method is only called on line 1178 of
edu.ucsb.nceas.metacat.DBQuery in metacat. I've included it below (with
my change).
Do you think this is an appropriate solution? I'll wait to check it
into cvs until I hear back.
Thanks,
-ben
Method starting on line 1404:
/*
* A method to put key and value in Vector
*/
private void putInArray(Vector parentidList, String key,
ReturnFieldValue value)
{
Vector tempVector = null;
// for (int count = 0; count < parentidList.size(); count++) {
// tempVector = (Vector) parentidList.get(count);
//
//
// if (key.compareTo((String) tempVector.get(0)) == 0) {
// tempVector.remove(1);
// tempVector.add(1, value);
// return;
// }
// }
tempVector = new Vector();
tempVector.add(0, key);
tempVector.add(1, value);
parentidList.add(tempVector);
return;
}
Updated by ben leinfelder about 17 years ago
when looking at this fix, it's important to remember to clear out the xml_queryresult table since old results will be cached there.
i've been going one step further and clearing it all out with:
TRUNCATE table xml_returnfield cascade;
the cascade flows into xml_queryresult. it's squeaky clean after that!
Updated by Jing Tao about 17 years ago
<jing> hi, ben
<jing> I took a look and refreshed my memory.
<jing> The reason we did this is before our xml_nodes table only can handle 4000 characters for text data.
<jing> if a text node is more than 4000 characters, we split it into different row in xml_node table.
<jing> So that method will merge the splited node into one.
<jing> Since some old docs in knb production server are still stored in this way, we should keep the method as before.
Updated by Jing Tao almost 17 years ago
Talked with ben and he suggested to move to 1.9 release.
Updated by ben leinfelder almost 17 years ago
added change to handle ATTRIBUTE nodes differently than TEXT nodes so that all attributes of an element are returned in the resultset document.
also added code to concatenate large text elements that may have been split into separate nodes when stored in the xml_nodes table.
changed files:
metacat/src/edu/ucsb/nceas/metacat/DBQuery.java (rev 1.157)
metacat/src/edu/ucsb/nceas/metacat/QuerySpecification.java (rev 1.90)
Updated by ben leinfelder almost 17 years ago
have tested on two local installs of metacat and am happy with what i see.
releasing it into the wild.