String title = parameters.getTitle();
String author = parameters.getAuthor();
Integer publisherId = parameters.getPublisherId();
Integer ownerId = parameters.getOwnerId();
StatementAssembly assembly = buildBaseBookQuery();
addSubstringSearch(assembly, "book.TITLE", title);
addSubstringSearch(assembly, "book.AUTHOR", author);
// Hide books that are not visible to the master query.
assembly.addSep(" AND ");
assembly.add("book.HIDDEN = 0");
if (publisherId != null)
{
assembly.addSep(" AND ");
assembly.add("book.PUBLISHER_ID = ");
assembly.addParameter(publisherId);
}
if (ownerId != null)
{
assembly.addSep(" AND ");
assembly.add("book.OWNER_ID = ");
assembly.addParameter(ownerId);
}
addSortOrdering(assembly, ordering);
return assembly.createStatement(connection);
}