private Member lookupDirectly(final Hierarchy hierarchy,
final Cube cube,
final String parameter,
final boolean searchForNames) throws SQLException
{
Member memberById = null;
Member memberByUniqueId = null;
final OlapStatement statement = connection.createStatement();
try
{
final CellSet result = statement.executeOlapQuery("SELECT STRTOMEMBER(" + quote(parameter) +
") ON 0, {} ON 1 FROM " + cube.getUniqueName());
try
{
final List<CellSetAxis> setAxises = result.getAxes();
final List<Position> positionList = setAxises.get(0).getPositions();
for (int i = 0; i < positionList.size(); i++)
{
final Position position = positionList.get(i);
final List<Member> memberList = position.getMembers();
for (int j = 0; j < memberList.size(); j++)
{
final Member member = memberList.get(j);
// If the parameter starts with '[', we'll assume we have the full
// member specification specification. Otherwise, keep the funky lookup
// route. We do check whether we get a second member (heck, should not
// happen, but I've seen pigs fly already).
if (parameter.startsWith("["))
{
if (memberByUniqueId == null)
{
memberByUniqueId = member;
}
else
{
logger.warn("Encountered a member with a duplicate unique key: " + member.getUniqueName());
}
}
if (searchForNames == false)
{
continue;
}
if (parameter.equals(member.getName()))
{
if (memberById == null)
{
memberById = member;
}
else
{
logger.warn("Encountered a member with a duplicate name: " + member.getUniqueName());
}
}
}
}
}