Database Reference
In-Depth Information
essCube.dimensions.all.each { doMbrThing(essCube,
it.name) }
}
essCube.clearActive()
}
}
essSvr.disconnect()
essHome.signOff()
println writer.toString()
This produces:
<application name='Sample'>
<cube name='Basic'>
<member name='Year'>
<member name='Qtr1'>
<member name='Jan' />
<member name='Feb' />
...
At this point, developers coming to groovy from other languages may have inky
mouths from biting straight through their pens. how can outputting xmL be that easy?
With groovy, it just is. Every call into the builder is saying, “make a tag here, and here is
what it should look like.” The builder calls are nested in the code loops, so we can see the
structure of the intended xmL mirrored in the structure of the code that produces it.
9.3.7 Step Seven: More Details in the XML
Currently, we are only outputting member names. one last change we will want to make
here is to output more details. unfortunately, as you will have learned in the previous
chapter, not all instances of IEssmember are built the same, and, in our case, we cannot
even get an alias from the member objects we have created. Such is the case with mem-
bers retrieved through the IEssCube.getmember method. In order to get the details we
want, we will open the outline of each database and use that as the source of our mem-
ber objects. This will slow the code down, but we are scripting here, and speed is less of
a concern.
import com.essbase.api.session.Iessbase
doMbrThing = { essOtl, mbrName ->
if (mbrName.size() == 0 ) return
essMbr = essOtl.findMember(mbrName)
xml.member(name:essMbr.name, alias:essMbr.getAlias(null),
consolidation:essMbr.consolidationType.toString()[0],
storage:essMbr.shareOption, twopass:essMbr.
twoPassCalculationMember, formula:essMbr.formula) {
doMbrThing(essOtl, essMbr.firstChildMemberName)
}
doMbrThing(essOtl, essMbr.nextSiblingMemberName)
}
writer = new StringWriter()
xml = new groovy.xml.MarkupBuilder(writer)
essHome = IEssbase.Home.create(IEssbase.JAPI_VERSION)
Search WWH ::




Custom Search