@Test public void selectTwoFromBalancedHierarchy() throws UnknownPoiCategoryException { PoiCategoryFilter filter = new WhitelistPoiCategoryFilter(); filter.addCategory(this.balancedCm.getPoiCategoryByTitle("l1_1")); filter.addCategory(this.balancedCm.getPoiCategoryByTitle("l1_2")); String query = PoiCategoryRangeQueryGenerator.getSQLSelectString(filter, 0, POI_VERSION); System.out.println("Query: " + query); }
public static String getSQLSelectString(PoiCategoryFilter filter, int count, int version) { StringBuilder sb = new StringBuilder(); sb.append(DbConstants.FIND_IN_BOX_CLAUSE_SELECT); if (version < 2) { sb.append(DbConstants.JOIN_DATA_CLAUSE); } else { sb.append(DbConstants.JOIN_CATEGORY_CLAUSE); if (count > 0) { sb.append(DbConstants.JOIN_DATA_CLAUSE); } } sb.append(DbConstants.FIND_IN_BOX_CLAUSE_WHERE); sb.append(getSQLWhereClauseString(filter, version)); for (int i = 0; i < count; i++) { sb.append(DbConstants.FIND_BY_DATA_CLAUSE); } return (sb.append(" LIMIT ?;").toString()); }
PoiCategoryRangeQueryGenerator { public static String getSQLSelectString(PoiCategoryFilter filter, int count, int version) { StringBuilder sb = new StringBuilder(); sb.append(DbConstants.FIND_IN_BOX_CLAUSE_SELECT); if (version < 2) { sb.append(DbConstants.JOIN_DATA_CLAUSE); } else { sb.append(DbConstants.JOIN_CATEGORY_CLAUSE); if (count > 0) { sb.append(DbConstants.JOIN_DATA_CLAUSE); } } sb.append(DbConstants.FIND_IN_BOX_CLAUSE_WHERE); sb.append(getSQLWhereClauseString(filter, version)); for (int i = 0; i < count; i++) { sb.append(DbConstants.FIND_BY_DATA_CLAUSE); } return (sb.append(" LIMIT ?;").toString()); } }
PoiCategoryRangeQueryGenerator { public static String getSQLSelectString(PoiCategoryFilter filter, int count, int version) { StringBuilder sb = new StringBuilder(); sb.append(DbConstants.FIND_IN_BOX_CLAUSE_SELECT); if (version < 2) { sb.append(DbConstants.JOIN_DATA_CLAUSE); } else { sb.append(DbConstants.JOIN_CATEGORY_CLAUSE); if (count > 0) { sb.append(DbConstants.JOIN_DATA_CLAUSE); } } sb.append(DbConstants.FIND_IN_BOX_CLAUSE_WHERE); sb.append(getSQLWhereClauseString(filter, version)); for (int i = 0; i < count; i++) { sb.append(DbConstants.FIND_BY_DATA_CLAUSE); } return (sb.append(" LIMIT ?;").toString()); } private  PoiCategoryRangeQueryGenerator(); }
PoiCategoryRangeQueryGenerator { public static String getSQLSelectString(PoiCategoryFilter filter, int count, int version) { StringBuilder sb = new StringBuilder(); sb.append(DbConstants.FIND_IN_BOX_CLAUSE_SELECT); if (version < 2) { sb.append(DbConstants.JOIN_DATA_CLAUSE); } else { sb.append(DbConstants.JOIN_CATEGORY_CLAUSE); if (count > 0) { sb.append(DbConstants.JOIN_DATA_CLAUSE); } } sb.append(DbConstants.FIND_IN_BOX_CLAUSE_WHERE); sb.append(getSQLWhereClauseString(filter, version)); for (int i = 0; i < count; i++) { sb.append(DbConstants.FIND_BY_DATA_CLAUSE); } return (sb.append(" LIMIT ?;").toString()); } private  PoiCategoryRangeQueryGenerator(); static String getSQLSelectString(PoiCategoryFilter filter, int count, int version); }
PoiCategoryRangeQueryGenerator { public static String getSQLSelectString(PoiCategoryFilter filter, int count, int version) { StringBuilder sb = new StringBuilder(); sb.append(DbConstants.FIND_IN_BOX_CLAUSE_SELECT); if (version < 2) { sb.append(DbConstants.JOIN_DATA_CLAUSE); } else { sb.append(DbConstants.JOIN_CATEGORY_CLAUSE); if (count > 0) { sb.append(DbConstants.JOIN_DATA_CLAUSE); } } sb.append(DbConstants.FIND_IN_BOX_CLAUSE_WHERE); sb.append(getSQLWhereClauseString(filter, version)); for (int i = 0; i < count; i++) { sb.append(DbConstants.FIND_BY_DATA_CLAUSE); } return (sb.append(" LIMIT ?;").toString()); } private  PoiCategoryRangeQueryGenerator(); static String getSQLSelectString(PoiCategoryFilter filter, int count, int version);  }