List<CoselmarUser> coselmarUsers = forHql(hqlBuilder.toString(), args).findAll();
List<CoselmarUser> coselmarUsers = forHql(hqlBuilder.toString(), args).find(paginationParameter);
List<Document> documents = forHql(hqlBuilder.toString(), args).findAll();
public List<Question> findForExpert(CoselmarUser expert, QuestionSearchBean searchBean, PaginationParameter page) { StringBuilder hqlBuilder = new StringBuilder("SELECT Q FROM " + Question.class.getName() + " Q " + " INNER JOIN Q." + Question.PROPERTY_PARTICIPANTS + " CUG "); Map<String, Object> args = new HashMap<>(); String publicCondition = DaoUtils.getQueryForAttributeEquals("Q", Question.PROPERTY_PRIVACY, args, Privacy.PUBLIC, ""); hqlBuilder.append(" WHERE ( (" + publicCondition + " ) "); String privateCondition = DaoUtils.getQueryForAttributeEquals("Q", Question.PROPERTY_PRIVACY, args, Privacy.PRIVATE, ""); hqlBuilder.append(" OR (" + privateCondition); String participantCondition = DaoUtils.andAttributeContains("CUG", CoselmarUserGroup.PROPERTY_MEMBERS, args, expert); hqlBuilder.append(participantCondition); String clientCondition = DaoUtils.andAttributeContains("Q", Question.PROPERTY_CLIENTS, args, expert); hqlBuilder.append(clientCondition + ") )"); String finerHql = refineSearch(searchBean, "Q", args); hqlBuilder.append(" AND (" + finerHql + ")" ); List<Question> questions; if (page != null) { questions = forHql(hqlBuilder.toString(), args).find(page); } else { questions = forHql(hqlBuilder.toString(), args).findAll(); } return questions; }
@Override public PaginationResult<E> findPage(PaginationParameter page) { PaginationResult<E> result; if (!Strings.isNullOrEmpty(hqlForFetchStep1) && !Strings.isNullOrEmpty(hqlForFetchStep2)) { PaginationResult<String> pageResult = topiaDao.findPage(hqlForFetchStep1, hqlParameters, page); List<String> step1ResultTopiaIds = pageResult.getElements(); List<E> sortedEntities; if (CollectionUtils.isEmpty(step1ResultTopiaIds)) { sortedEntities = Lists.newArrayList(); } else { Map<String, Object> step2Args = Maps.newHashMap(); step2Args.put("topiaIdsForFetch_", step1ResultTopiaIds); List<E> entities = topiaDao.forHql(hqlForFetchStep2, step2Args).findAll(); sortedEntities = sortAccordingToIds(entities, step1ResultTopiaIds); } result = PaginationResult.of(sortedEntities, pageResult.getCount(), pageResult.getCurrentPage()); } else { result = topiaDao.findPage(hql, hqlParameters, page); } return result; }
@Override public List<E> find(int startIndex, int endIndex) { List<E> result; if (!Strings.isNullOrEmpty(hqlForFetchStep1) && !Strings.isNullOrEmpty(hqlForFetchStep2)) { List<String> step1ResultTopiaIds = topiaDao.find(hqlForFetchStep1, hqlParameters, startIndex, endIndex); if (CollectionUtils.isEmpty(step1ResultTopiaIds)) { result = Lists.newArrayList(); } else { Map<String, Object> step2Args = Maps.newHashMap(); step2Args.put("topiaIdsForFetch_", step1ResultTopiaIds); List<E> entities = topiaDao.forHql(hqlForFetchStep2, step2Args).findAll(); result = sortAccordingToIds(entities, step1ResultTopiaIds); } } else { result = topiaDao.find(hql, hqlParameters, startIndex, endIndex); } return result; }
public List<Document> findAllContainingAllKeywords(List<String> keywords) { StringBuilder hqlBuilder = new StringBuilder("FROM " + Document.class.getName() + " D"); Map<String, Object> args = new HashMap<>(); if (keywords != null) { hqlBuilder.append(" WHERE ( 1 = 0 "); for (String keyword : keywords) { String nameClause = DaoUtils.orAttributeLike("D", Document.PROPERTY_NAME, args, keyword); String summaryClause = DaoUtils.orAttributeLike("D", Document.PROPERTY_SUMMARY, args, keyword); String authorsClause = DaoUtils.orAttributeLike("D", Document.PROPERTY_AUTHORS, args, keyword); String containsKeyword = DaoUtils.orAttributeContains("D", Document.PROPERTY_KEYWORDS, args, keyword); hqlBuilder.append(nameClause); hqlBuilder.append(summaryClause); hqlBuilder.append(authorsClause); hqlBuilder.append(containsKeyword); } hqlBuilder.append(" )"); } List<Document> documents = forHql(hqlBuilder.toString(), args).findAll(); return documents; }
public List<Question> findForExpert(CoselmarUser expert, List<String> topiaIds, PaginationParameter page) { StringBuilder hqlBuilder = new StringBuilder("SELECT Q FROM " + Question.class.getName() + " Q " + " INNER JOIN Q." + Question.PROPERTY_PARTICIPANTS + " CUG "); Map<String, Object> args = new HashMap<>(); String publicCondition = DaoUtils.getQueryForAttributeEquals("Q", Question.PROPERTY_PRIVACY, args, Privacy.PUBLIC, ""); hqlBuilder.append(" WHERE ( (" + publicCondition + " ) "); String privateCondition = DaoUtils.getQueryForAttributeEquals("Q", Question.PROPERTY_PRIVACY, args, Privacy.PRIVATE, ""); hqlBuilder.append(" OR (" + privateCondition + " AND ( 0 = 1 "); String participantCondition = DaoUtils.orAttributeContains("CUG", CoselmarUserGroup.PROPERTY_MEMBERS, args, expert); hqlBuilder.append(participantCondition); String clientCondition = DaoUtils.orAttributeContains("Q", Question.PROPERTY_CLIENTS, args, expert); hqlBuilder.append(clientCondition + ") ) )"); String topiaIdsCondition = DaoUtils.andAttributeIn("Q", Question.PROPERTY_TOPIA_ID, args, topiaIds); hqlBuilder.append(topiaIdsCondition); List<Question> questions; if (page != null) { questions = forHql(hqlBuilder.toString(), args).find(page); } else { questions = forHql(hqlBuilder.toString(), args).findAll(); } return questions; }
public List<Question> findForClient(CoselmarUser client, QuestionSearchBean searchBean, PaginationParameter page) { StringBuilder hqlBuilder = new StringBuilder("SELECT Q FROM " + Question.class.getName() + " Q "); Map<String, Object> args = new HashMap<>(); String clientCondition = DaoUtils.andAttributeContains("Q", Question.PROPERTY_CLIENTS, args, client); hqlBuilder.append(" WHERE 1=1 AND (" + clientCondition + " ) "); if (searchBean != null) { String finerHql = refineSearch(searchBean, "Q", args); hqlBuilder.append(" AND (" + finerHql + ")" ); } List<Question> questions; if (page != null) { questions = forHql(hqlBuilder.toString(), args).find(page); } else { questions = forHql(hqlBuilder.toString(), args).findAll(); } return questions; }
protected InnerTopiaQueryBuilderRunQueryStep<E> getNextStep() { String hql = hqlAndParametersBuilder.getHql(); Map<String, Object> hqlParameters = hqlAndParametersBuilder.getHqlParameters(); boolean withOrderByClause = hqlAndParametersBuilder.isOrderByClausePresent(); InnerTopiaQueryBuilderRunQueryStep<E> nextStep; if (hqlAndParametersBuilder.hasFetchProperties()) { String hqlForFetchStep1 = hqlAndParametersBuilder.getHqlForFetchStep1(); String hqlForFetchStep2 = hqlAndParametersBuilder.getHqlForFetchStep2(); nextStep = new InnerTopiaQueryBuilderRunQueryStep<E>(topiaDao, false, withOrderByClause, hql, hqlParameters, hqlForFetchStep1, hqlForFetchStep2); } else { nextStep = new InnerTopiaQueryBuilderRunQueryStep<E>(topiaDao, false, withOrderByClause, hql, hqlParameters); } return nextStep; }
public List<Question> findWithSearchBean(QuestionSearchBean searchBean, PaginationParameter page) { StringBuilder hqlBuilder = new StringBuilder("SELECT Q FROM " + Question.class.getName() + " Q "); Map<String, Object> args = new HashMap<>(); if (searchBean != null) { String finerHql = refineSearch(searchBean, "Q", args); hqlBuilder.append(" WHERE (" + finerHql + ")" ); } List<Question> questions; if (page != null) { questions = forHql(hqlBuilder.toString(), args).find(page); } else { questions = forHql(hqlBuilder.toString(), args).findAll(); } return questions; }
public List<Question> findForExpert(CoselmarUser expert) { StringBuilder hqlBuilder = new StringBuilder("SELECT Q FROM " + Question.class.getName() + " Q " + " INNER JOIN Q." + Question.PROPERTY_PARTICIPANTS + " CUG "); Map<String, Object> args = new HashMap<>(); String publicCondition = DaoUtils.getQueryForAttributeEquals("Q", Question.PROPERTY_PRIVACY, args, Privacy.PUBLIC, ""); hqlBuilder.append(" WHERE ( (" + publicCondition + " ) "); String privateCondition = DaoUtils.getQueryForAttributeEquals("Q", Question.PROPERTY_PRIVACY, args, Privacy.PRIVATE, ""); hqlBuilder.append(" OR (" + privateCondition); String participantCondition = DaoUtils.andAttributeContains("CUG", CoselmarUserGroup.PROPERTY_MEMBERS, args, expert); hqlBuilder.append(participantCondition); String clientCondition = DaoUtils.andAttributeContains("Q", Question.PROPERTY_CLIENTS, args, expert); hqlBuilder.append(clientCondition + ") )"); List<Question> questions = forHql(hqlBuilder.toString(), args).findAll(); return questions; }
@Override public List<E> findAll() { return getNextStep().findAll(); }
@Override public List<E> find(int startIndex, int endIndex) { return getNextStep().find(startIndex, endIndex); }
public List<Company> findWithFetchHql(String ... names) { String hql = "SELECT DISTINCT c FROM " + Company.class.getName() + " as c " + "LEFT JOIN FETCH c." + Company.PROPERTY_DEPARTMENT + " dept " + "WHERE c." + Company.PROPERTY_NAME + " IN ( :n ) "; return forHql(hql, "n", Arrays.asList(names)).findAll(); }
@Override public Iterable<E> findAllLazy(int batchSize) { return getNextStep().findAllLazy(batchSize); }
@Override public Iterable<E> findAllLazy() { return getNextStep().findAllLazy(); }
@Override public E findAny() { return getNextStep().findAny(); }
@Override public boolean exists() { return getNextStep().exists(); }
@Override public long count() { return getNextStep().count(); }