@Test public void filterStatementWithWhere() { String result = this.queryFilter.filterStatement( "select doc.fullName from XWikiDocument doc where attachment.mimeType like 'image/%'", Query.HQL); assertEquals("select doc.fullName, attachment.filename " + "from XWikiDocument doc, XWikiAttachment attachment " + "where doc.id = attachment.docId and (attachment.mimeType like 'image/%')", result); }
@Override public String filterStatement(String statement, String language) { if (Query.HQL.equals(language)) { int selectEnd = statement.indexOf(" from "); if (selectEnd > 0) { StringBuilder filteredStatement = new StringBuilder(statement); filteredStatement.insert(selectEnd, ", attachment.filename"); int fromDocTable = filteredStatement.indexOf(FROM_DOC_TABLE); if (fromDocTable > 0) { filteredStatement.insert(fromDocTable + FROM_DOC_TABLE.length(), ", XWikiAttachment attachment"); return insertWhereClause("doc.id = attachment.docId", filteredStatement.toString(), language); } } } return statement; }
AttachmentQueryFilter extends AbstractWhereQueryFilter { @Override public String filterStatement(String statement, String language) { if (Query.HQL.equals(language)) { int selectEnd = statement.indexOf(" from "); if (selectEnd > 0) { StringBuilder filteredStatement = new StringBuilder(statement); filteredStatement.insert(selectEnd, ", attachment.filename"); int fromDocTable = filteredStatement.indexOf(FROM_DOC_TABLE); if (fromDocTable > 0) { filteredStatement.insert(fromDocTable + FROM_DOC_TABLE.length(), ", XWikiAttachment attachment"); return insertWhereClause("doc.id = attachment.docId", filteredStatement.toString(), language); } } } return statement; } }
AttachmentQueryFilter extends AbstractWhereQueryFilter { @Override public String filterStatement(String statement, String language) { if (Query.HQL.equals(language)) { int selectEnd = statement.indexOf(" from "); if (selectEnd > 0) { StringBuilder filteredStatement = new StringBuilder(statement); filteredStatement.insert(selectEnd, ", attachment.filename"); int fromDocTable = filteredStatement.indexOf(FROM_DOC_TABLE); if (fromDocTable > 0) { filteredStatement.insert(fromDocTable + FROM_DOC_TABLE.length(), ", XWikiAttachment attachment"); return insertWhereClause("doc.id = attachment.docId", filteredStatement.toString(), language); } } } return statement; }  }
AttachmentQueryFilter extends AbstractWhereQueryFilter { @Override public String filterStatement(String statement, String language) { if (Query.HQL.equals(language)) { int selectEnd = statement.indexOf(" from "); if (selectEnd > 0) { StringBuilder filteredStatement = new StringBuilder(statement); filteredStatement.insert(selectEnd, ", attachment.filename"); int fromDocTable = filteredStatement.indexOf(FROM_DOC_TABLE); if (fromDocTable > 0) { filteredStatement.insert(fromDocTable + FROM_DOC_TABLE.length(), ", XWikiAttachment attachment"); return insertWhereClause("doc.id = attachment.docId", filteredStatement.toString(), language); } } } return statement; }  @Override String filterStatement(String statement, String language); @Override List filterResults(List results); }
AttachmentQueryFilter extends AbstractWhereQueryFilter { @Override public String filterStatement(String statement, String language) { if (Query.HQL.equals(language)) { int selectEnd = statement.indexOf(" from "); if (selectEnd > 0) { StringBuilder filteredStatement = new StringBuilder(statement); filteredStatement.insert(selectEnd, ", attachment.filename"); int fromDocTable = filteredStatement.indexOf(FROM_DOC_TABLE); if (fromDocTable > 0) { filteredStatement.insert(fromDocTable + FROM_DOC_TABLE.length(), ", XWikiAttachment attachment"); return insertWhereClause("doc.id = attachment.docId", filteredStatement.toString(), language); } } } return statement; }  @Override String filterStatement(String statement, String language); @Override List filterResults(List results);  }