private Member findMember(final Hierarchy hierarchy,
final Cube cube,
final String parameter) throws ReportDataFactoryException, SQLException
{
Member memberById = null;
Member memberByUniqueId = null;
final boolean searchForNames = "true".equals(configuration.getConfigProperty
("org.pentaho.reporting.engine.classic.extensions.datasources.olap4j.NeedDimensionPrefix")) == false;
final boolean missingMembersIsFatal = "true".equals(configuration.getConfigProperty
("org.pentaho.reporting.engine.classic.extensions.datasources.olap4j.IgnoreInvalidMembersDuringQuery")) == false;
try
{
final Member directValue = lookupDirectly(hierarchy, cube, parameter, searchForNames);
if (directValue != null)
{
return directValue;
}
}
catch (Exception e)
{
// It is non fatal if that fails. Invalid input has this effect.
}
final OlapStatement statement = connection.createStatement();
try
{
final CellSet result = statement.executeOlapQuery("SELECT " + hierarchy.getUniqueName() +
".AllMembers 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 (parameter.equals(Olap4jUtil.getUniqueMemberName(member)))
{
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());
}
}
}
}
}