At any rate, I changed my controller to something like this:
def loadTree = {
def parent = params['dir']
log.info "loading tree for parent path: ${parent}"
def collectionAndDataObjectListAndSearchAO = irodsAccessObjectFactory.getCollectionAndDataObjectListAndSearchAO(irodsAccount)
def collectionAndDataObjectList = collectionAndDataObjectListAndSearchAO.listDataObjectsAndCollectionsUnderPath(parent)
log.debug("retrieved collectionAndDataObjectList: ${collectionAndDataObjectList}")
render(view:"loadTree",model:[collectionAndDataObjectList:collectionAndDataObjectList, parent:parent])
}
I altered my unit test, per the docs, to inspect the model and view. I attempted to get at the model entry for 'parent', which contained the parent dir, like this:
def parent = mav.model.parent
It turns out that that does not work anymore, instead, you need to interpose a reference to linkedHasMap like so:
void testBrowse() {
controller.params.dir = "/"
controller.irodsAccessObjectFactory = irodsAccessObjectFactory
controller.irodsAccount = irodsAccount
controller.loadTree()
def mav = controller.modelAndView
def name = mav.viewName
assertNotNull("null mav", mav)
assertEquals("view name should be loadTree", "loadTree", name)
def parent = mav.model.linkedHashMap.parent
assertEquals("parent dir not found", "/", parent)
}
Now my Grails controller and test are working again. My next step is to create a decent JavaScript object that can bridge between methods in this BrowseController and a lazy-loadable JQuery JSTree. Maybe the next post can share some developments there.
No comments:
Post a Comment