Hi List,
We here seem to be unable to use the up and down arrows of the edit page in Geonetwork to reorder the elements of a metadata record (ISO19115). Clicking on the order buttons produces an out-of-bounds-error, a little investigating and I came across this section of code in org.fao.geonet.kernel.DataManager:
…
700 List list = ((Element) elSwap.getParent()).getChildren(elSwap.getName());
701
702 for(int i=0; i<list.size(); i++)
703 if (list.get(i) == elSwap)
704 {
705 iSwapIndex = i;
706 break;
707 }
708
709 if (iSwapIndex == -1)
710 throw new IllegalStateException("Index not found for element --> " + elSwap);
711
712 if (down) swapElements(elSwap, (Element) list.get(iSwapIndex +1));
713 else swapElements(elSwap, (Element) list.get(iSwapIndex -1));
…
Wont line 700 create a list of exactly **one** element? And if so lines 712 and 713 are doomed to always fail, shouldn’t line 700 instead read:
…
700 List list = ((Element) elSwap.getParent()).getChildren();
…
Such that it returns the list of children from **its parent** and the order can be manipulated.
Making this change allows the code to run without error, however the result produces no change after calling swapElements(Element el1, Element el2), I’m not sure that the switching of children elements (as I read from the swapElements() method) will produce the required changes, which leads me to my next question. Assuming all is well with this code, wouldn’t it be better to manipulate the in memory style sheet rather than the DOM of the metadata to produce the same effect?
Cheers,
Michael Gannon.