@Test public void buildForStringProperty() throws Exception { listClass.setMultiSelect(false); Query query = mock(Query.class); when(this.queryManager.createQuery( "select prop.value, count(*) as unfilterable0 " + "from BaseObject as obj, StringProperty as prop " + "where obj.className = :className and obj.name <> :templateName" + " and prop.id.id = obj.id and prop.id.name = :propertyName " + "group by prop.value " + "order by count(*) desc", Query.HQL)).thenReturn(query); assertSame(query, this.usedValuesListQueryBuilder.build(listClass)); verify(query).bindValue("className", "Blog.BlogPostClass"); verify(query).bindValue("propertyName", "category"); verify(query).bindValue("templateName", "Blog.BlogPostTemplate"); verify(query).setWiki("apps"); }
@Override public Query build(ListClass listClass) throws QueryException { String statement = String.format("select %1$s, count(*) as unfilterable0 " + "from BaseObject as obj, %2$s " + "where obj.className = :className and obj.name <> :templateName" + " and prop.id.id = obj.id and prop.id.name = :propertyName " + "group by %1$s " + "order by count(*) desc", getSelectColumnAndFromTable(listClass)); Query query = this.queryManager.createQuery(statement, Query.HQL); bindParameterValues(query, listClass); query.addFilter(new ViewableValueFilter(listClass)); query.setWiki(listClass.getReference().extractReference(EntityType.WIKI).getName()); return query; }
UsedValuesListQueryBuilder implements QueryBuilder<ListClass> { @Override public Query build(ListClass listClass) throws QueryException { String statement = String.format("select %1$s, count(*) as unfilterable0 " + "from BaseObject as obj, %2$s " + "where obj.className = :className and obj.name <> :templateName" + " and prop.id.id = obj.id and prop.id.name = :propertyName " + "group by %1$s " + "order by count(*) desc", getSelectColumnAndFromTable(listClass)); Query query = this.queryManager.createQuery(statement, Query.HQL); bindParameterValues(query, listClass); query.addFilter(new ViewableValueFilter(listClass)); query.setWiki(listClass.getReference().extractReference(EntityType.WIKI).getName()); return query; } }
UsedValuesListQueryBuilder implements QueryBuilder<ListClass> { @Override public Query build(ListClass listClass) throws QueryException { String statement = String.format("select %1$s, count(*) as unfilterable0 " + "from BaseObject as obj, %2$s " + "where obj.className = :className and obj.name <> :templateName" + " and prop.id.id = obj.id and prop.id.name = :propertyName " + "group by %1$s " + "order by count(*) desc", getSelectColumnAndFromTable(listClass)); Query query = this.queryManager.createQuery(statement, Query.HQL); bindParameterValues(query, listClass); query.addFilter(new ViewableValueFilter(listClass)); query.setWiki(listClass.getReference().extractReference(EntityType.WIKI).getName()); return query; }  }
UsedValuesListQueryBuilder implements QueryBuilder<ListClass> { @Override public Query build(ListClass listClass) throws QueryException { String statement = String.format("select %1$s, count(*) as unfilterable0 " + "from BaseObject as obj, %2$s " + "where obj.className = :className and obj.name <> :templateName" + " and prop.id.id = obj.id and prop.id.name = :propertyName " + "group by %1$s " + "order by count(*) desc", getSelectColumnAndFromTable(listClass)); Query query = this.queryManager.createQuery(statement, Query.HQL); bindParameterValues(query, listClass); query.addFilter(new ViewableValueFilter(listClass)); query.setWiki(listClass.getReference().extractReference(EntityType.WIKI).getName()); return query; }  @Override Query build(ListClass listClass); }
UsedValuesListQueryBuilder implements QueryBuilder<ListClass> { @Override public Query build(ListClass listClass) throws QueryException { String statement = String.format("select %1$s, count(*) as unfilterable0 " + "from BaseObject as obj, %2$s " + "where obj.className = :className and obj.name <> :templateName" + " and prop.id.id = obj.id and prop.id.name = :propertyName " + "group by %1$s " + "order by count(*) desc", getSelectColumnAndFromTable(listClass)); Query query = this.queryManager.createQuery(statement, Query.HQL); bindParameterValues(query, listClass); query.addFilter(new ViewableValueFilter(listClass)); query.setWiki(listClass.getReference().extractReference(EntityType.WIKI).getName()); return query; }  @Override Query build(ListClass listClass);  }