I have a uniqueName of a member that I got from getUniqueName(), but I can't
seem to figure out to find that member instance using the API. If I pass
uniqueName directly to IdentifierNode.ofNames() it throws an exception saying
it can't find it. Is there a way to find the member given the uniqueName? I'm
using the following code:
Parsing the unique name will give you a list of name segments (a form of parse
tree node), but it doesn't give you the actual member. Remember that unique
names are officially "black boxes" -- you can't reliably interpret them, only
the engine can.
To ask the engine for a member given its unique name, the simplest thing is to
execute a query:
Member getMember(OlapConnection connection, String memberUniqueName) {
// FIXME close connection, stmt, cellset, and handle errors
CellSet cset = connection.createStatement().executeOlapQuery("select " + uniqueName + " on 0 from [" + cubeName + "]");
return cset.getAxes().get(0).getPositions().get(0).getMembers().get(0);
}
The method Cube.lookupMember(List<NameSegment>) should also
work. The documentation says it will work for a fully-qualified member name
but it should also work for a member's unique name.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a uniqueName of a member that I got from getUniqueName(), but I can't
seem to figure out to find that member instance using the API. If I pass
uniqueName directly to IdentifierNode.ofNames() it throws an exception saying
it can't find it. Is there a way to find the member given the uniqueName? I'm
using the following code:
IdentifierNode.ofNames( uniqueName ).getSegmentList()
I don't really understand the syntax Identifier.ofNames() after reading the
javadoc and spec.
You can use it like that:
List<IdentifierSegment> segments =
IdentifierParser.parseIdentifier(member.getUniqueName());
Parsing the unique name will give you a list of name segments (a form of parse
tree node), but it doesn't give you the actual member. Remember that unique
names are officially "black boxes" -- you can't reliably interpret them, only
the engine can.
To ask the engine for a member given its unique name, the simplest thing is to
execute a query:
The method Cube.lookupMember(List<NameSegment>) should also
work. The documentation says it will work for a fully-qualified member name
but it should also work for a member's unique name.