Database Reference
In-Depth Information
Measures
Product
Market
...
here we have a loop within a loop, so we have started using named parameter lists
(the part between the opening curly brace and the arrow) in our closure definitions
instead of the default every time. This is really helpful when a closure's code gets com-
plex enough to contain additional closures. It is still okay to use it within the innermost
closure, but we are better off using named parameters in the outer closures. Some may
prefer to eliminate it entirely when working with nested closures.
Another thing to note is the clearActive call that we have added. We did not need this
before, but now that we are digging around inside the cube objects we are retrieving, the
Java API is calling an implicit setActive on the cube for us (thanks, JAPI), and we will
get an error if we try to move on and access another cube unless we release the one that
has been set as active.
9.3.5 Step Five: Retrieving Members
We are getting close to our planned outline extractor. The next step is to dive deeper
into our dimensions and pull out the members. There is a close relationship between a
“dimension” and the root member of that dimension. For now we will use this knowl-
edge and pass the name of each dimension on to the code we have outputting member
names. Because the number of levels can vary throughout an outline, our method of
nesting loops ever deeper will not work this time. We will have to extract the code that
processes members so that it can make calls back to itself.
import com.essbase.api.session.IEssbase
doMbrThing = { essCube, mbrName ->
if (mbrName.size() == 0 ) return
essMbr = essCube.getMember(mbrName)
println '--' * essMbr.generationNumber + essMbr.name
doMbrThing(essCube, essMbr.firstChildMemberName)
if (!essMbr.isDimensionRootMember()) doMbrThing(essCube,
essMbr.nextSiblingMemberName)
}
essHome = IEssbase.Home.create(IEssbase.JAPI_VERSION)
essSvr = essHome.signOn('user', 'pass', false, null,
'http://aps_server:13080/aps/JAPI', 'ess_server')
essSvr.getApplication('Sample').cubes.all.each { essCube ->
println "\n${essCube.name}\n${'-' * essCube.name.size()}"
essCube.dimensions.all.each { doMbrThing(essCube, it.name) }
essCube.clearActive()
}
essSvr.disconnect()
essHome.signOff()
This produces:
Basic
-----
--Year
Search WWH ::




Custom Search