PropertyVetoException,
IllegalArgumentException,
WrappedTargetException
{
final ParameterDefinition paramDef = new ParameterDefinition();
final XSingleSelectQueryComposer composer = getComposer(tools, rowSetProps.command, rowSetProps.commandType);
if (composer != null)
{
final XPropertySet rowSetProp = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, rowSet);
if ((Boolean) rowSetProp.getPropertyValue(APPLY_FILTER))
{
composer.setFilter((String) rowSetProp.getPropertyValue("Filter"));
}
// get old parameter count
final ArrayList detailColumns = (ArrayList) parameters.get(DETAIL_COLUMNS);
final ArrayList handledColumns = new ArrayList();
final XParametersSupplier paraSup = (XParametersSupplier) UnoRuntime.queryInterface(XParametersSupplier.class, composer);
if (paraSup != null)
{
final XIndexAccess params = paraSup.getParameters();
if (params != null)
{
final int oldParameterCount = params.getCount();
paramDef.parameterCount = oldParameterCount;
if (detailColumns != null)
{
for (int i = 0; i < oldParameterCount; i++)
{
try
{
final XPropertySet parameter = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, params.getByIndex(i));
if (parameter != null)
{
final String name = (String) parameter.getPropertyValue("Name");
for (int j = 0; j < detailColumns.size(); j++)
{
if (name.equals(detailColumns.get(j)))
{
handledColumns.add(name);
paramDef.parameterIndex.add(i);
--paramDef.parameterCount;
break;
}
}
}
}
catch (IndexOutOfBoundsException ex)
{
Logger.getLogger(SDBCReportDataFactory.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
}
final ArrayList masterValues = (ArrayList) parameters.get(MASTER_VALUES);
if (masterValues != null && !masterValues.isEmpty() && paramDef.parameterIndex.size() != detailColumns.size())
{
// Vector masterColumns = (Vector) parameters.get("master-columns");
// create the new filter
final String quote = connection.getMetaData().getIdentifierQuoteString();
final StringBuffer oldFilter = new StringBuffer();
oldFilter.append(composer.getFilter());
if (oldFilter.length() != 0)
{
oldFilter.append(" AND ");
}
int newParamterCounter = 1;
for (final Iterator it = detailColumns.iterator(); it.hasNext();
++newParamterCounter)
{
final String detail = (String) it.next();
if (!handledColumns.contains(detail))
{
//String master = (String) masterIt.next();
oldFilter.append(quote);
oldFilter.append(detail);
oldFilter.append(quote);
oldFilter.append(" = :link_");
oldFilter.append(newParamterCounter);
if (it.hasNext())
{
oldFilter.append(" AND ");
}
paramDef.parameterIndex.add(newParamterCounter + paramDef.parameterCount - 1);
}
}
composer.setFilter(oldFilter.toString());
final String sQuery = composer.getQuery();
rowSetProp.setPropertyValue(UNO_COMMAND, sQuery);
rowSetProp.setPropertyValue(UNO_COMMAND_TYPE, Integer.valueOf(CommandType.COMMAND));
}
}
return paramDef;