Same as {@link #selectByQuery(DbSession, String, ComponentQuery, int, int)} except
that the filter on organization is disabled.
185335
public List<ComponentDto> selectByQuery(DbSession session, ComponentQuery query, int offset, int limit) {
    return selectByQueryImpl(session, null, query, offset, limit);
  }
1117242
@Override
	public int filterCountByGroupId(long groupId) {
		if (!InlineSQLHelperUtil.isEnabled(groupId)) {
			return countByGroupId(groupId);
		}

		StringBundler query = new StringBundler(2);

		query.append(_FILTER_SQL_COUNT_COMMERCENOTIFICATIONTEMPLATE_WHERE);

		query.append(_FINDER_COLUMN_GROUPID_GROUPID_2);

		String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(),
				CommerceNotificationTemplate.class.getName(),
				_FILTER_ENTITY_TABLE_FILTER_PK_COLUMN, groupId);

		Session session = null;

		try {
			session = openSession();

			SQLQuery q = session.createSynchronizedSQLQuery(sql);

			q.addScalar(COUNT_COLUMN_NAME,
				com.liferay.portal.kernel.dao.orm.Type.LONG);

			QueryPos qPos = QueryPos.getInstance(q);

			qPos.add(groupId);

			Long count = (Long)q.uniqueResult();

			return count.intValue();
		}
		catch (Exception e) {
			throw processException(e);
		}
		finally {
			closeSession(session);
		}
	}
442513
private QueryImpl makeQuery(Session session) throws InvalidQueryException, RepositoryException
   {
      StatementContext context = new StatementContext();
      context.statement = new StringBuilder("SELECT * FROM ");
      context.statement.append(JCROrganizationServiceImpl.JOS_USERS_NODETYPE);

      if (query.getUserName() != null)
      {
         addStringStatement(context, UserProperties.JOS_USER_NAME, query.getUserName());
      }

      if (query.getFirstName() != null)
      {
         addStringStatement(context, UserProperties.JOS_FIRST_NAME, query.getFirstName());
      }

      if (query.getLastName() != null)
      {
         addStringStatement(context, UserProperties.JOS_LAST_NAME, query.getLastName());
      }

      if (query.getEmail() != null)
      {
         addStringStatement(context, UserProperties.JOS_EMAIL, query.getEmail());
      }

      if (query.getFromLoginDate() != null)
      {
         addDateStatement(context, UserProperties.JOS_LAST_LOGIN_TIME, ">=", query.getFromLoginDate());
      }

      if (query.getToLoginDate() != null)
      {
         addDateStatement(context, UserProperties.JOS_LAST_LOGIN_TIME, "<=", query.getToLoginDate());
      }

      if (status != UserStatus.ANY)
      {
         context.statement.append(" AND ").append(JCROrganizationServiceImpl.JOS_DISABLED);
         if (status == UserStatus.ENABLED)
            context.statement.append(" IS NULL");
         else
            context.statement.append(" IS NOT NULL");
      }

      return (QueryImpl)session.getWorkspace().getQueryManager().createQuery(context.statement.toString(), Query.SQL);
   }
876985
public static void checkQuery(Query<?> query, Set<String> whitelist,
                                  Set<String> blacklist, InjectionManager manager) {
        ResourceInfo resource = manager.getInstance(ResourceInfo.class);
        Class<?> rc = resource.getResourceClass();
        Set<String> wl = null, bl = null;
        if (rc != null) {
            Filter filter = rc.getAnnotation(Filter.class);

            if (filter != null) {
                if (filter.whitelist().length > 0) {
                    wl = Sets.newLinkedHashSet();
                    Collections.addAll(wl, filter.whitelist());
                }
                if (filter.blacklist().length > 0) {
                    bl = Sets.newLinkedHashSet();
                    Collections.addAll(bl, filter.blacklist());
                }
            }
        }

        if (whitelist != null) {
            if (wl == null) {
                wl = Sets.newLinkedHashSet();
            }
            wl.addAll(whitelist);
        }

        if (blacklist != null) {
            if (bl == null) {
                bl = Sets.newLinkedHashSet();
            }
            bl.addAll(blacklist);
        }
        checkQuery((SpiQuery) query, wl, bl, manager.getInstance(Application.Mode.class).isProd());
    }
429880
public <T> T queryForObject(String sql, Class<T> requiredType) throws SQLException {
		return queryForObject(sql, getSingleColumnRowMapper(requiredType));
	}
101125
public void filterUpdate(String columnId, int row, Integer maxSelections) {
        if (displayerSettings.isFilterEnabled()) {

            List<Interval> selectedIntervals = columnSelectionMap.get(columnId);
            Interval intervalFiltered = filterInterval(columnId, row);

            // Existing interval reset
            if (intervalFiltered != null) {
                selectedIntervals.remove(intervalFiltered);
                if (!selectedIntervals.isEmpty()) {
                    filterApply(columnId, selectedIntervals);
                }
                else {
                    filterReset(columnId);
                }
            }
            // No current filter => Add the selected interval
            else if (selectedIntervals == null) {
                Interval intervalSelected = dataSetHandler.getInterval(columnId, row);
                if (intervalSelected != null) {
                    selectedIntervals = new ArrayList<>();
                    selectedIntervals.add(intervalSelected);
                    columnSelectionMap.put(columnId, selectedIntervals);
                    filterApply(columnId, selectedIntervals);
                }
            }
            // Extra interval added to an already filtered column
            else {
                Interval intervalSelected = dataSetHandler.getInterval(columnId, row);
                if (intervalSelected != null) {
                    if (displayerSettings.isFilterSelfApplyEnabled()) {
                        selectedIntervals = new ArrayList<>();
                        columnSelectionMap.put(columnId, selectedIntervals);
                    }
                    selectedIntervals.add(intervalSelected);
                    if (maxSelections != null && maxSelections > 0 && selectedIntervals.size() >= maxSelections) {
                        filterReset(columnId);
                    } else {
                        filterApply(columnId, selectedIntervals);
                    }
                }
            }
        }
    }
252418
private void processQuery() throws SQLException {
		if (preparedStatement != null) {
			return;
		}

		if (query == null) {
			throw new RuntimeException("Invalid NamedParameterStatement: no query!");
		}

		logger.debug("Orig Query: {}", query);
		StringBuffer builder = new StringBuffer();

		String queryByPlugin = query;
		for (INpsPlugin plugin : plugins) {
			queryByPlugin = plugin.process(queryByPlugin, params);
			if (logger.isDebugEnabled()) {
				logger.debug("Apply plugin: name=[{}] query=[{}] params={}",
					plugin.getClass().getSimpleName(), queryByPlugin, params);
			}
		}

		Matcher matcher = PARAM_PATTERN.matcher(queryByPlugin);
		int noOfParams = 0;
		while (matcher.find()) {
			if (matcher.group(4) != null) {
				noOfParams++;
				String param = matcher.group("PARAM");
				logger.debug("Param: {}", param);
				if (!paramsPlacement.containsKey(param)) {
					paramsPlacement.put(param, new ArrayList<>());
				}
				paramsPlacement.get(param).add(noOfParams);

				Object paramValue = params.get(param);
				StringBuilder paramReplacementBuilder = new StringBuilder("?");
				if (paramValue != null && (paramValue instanceof Collection || paramValue.getClass().isArray())) {
					int size = paramValue instanceof Collection ?
						((Collection) paramValue).size() :
						((Object[]) paramValue).length;
					for (int i = 1; i < size; i++) {
						paramReplacementBuilder.append(",?");
					}
				}
				matcher.appendReplacement(builder, paramReplacementBuilder.toString());
			}
		}
		matcher.appendTail(builder);
		finalQuery = builder.toString();

		logger.debug("Final SQL: {}", finalQuery);
		logger.debug("Number of params: {}", noOfParams);

		if (!ignoreExtraPassedParam) {
			for (String param : params.keySet()) {
				if (!paramsPlacement.containsKey(param)) {
					throw new SQLException("Passed parameter not found: " + param);
				}
			}
		}

		preparedStatement = connection.prepareStatement(finalQuery);
		if (fetchSize != null) {
			preparedStatement.setFetchSize(fetchSize);
		}

		if (queryTimeout != null) {
			preparedStatement.setQueryTimeout(queryTimeout);
		}

		if (maxRows != null) {
			preparedStatement.setMaxRows(maxRows);
		}

		builder = new StringBuffer();
		matcher = PARAM_Q_MARK_PATTERN.matcher(finalQuery);
		int idx = 1;
		while (matcher.find()) {
			if (matcher.group("QMARK") != null) {
				String replacement = String.format(" ?%s ", idx++);
				matcher.appendReplacement(builder, replacement);
			}
		}
		matcher.appendTail(builder);

		finalIndexedQuery = builder.toString();
	}
455886
public void filter(ClientRequestContext request) throws IOException
    {
        if(!request.getHeaders().containsKey("X-Query-Key"))
            request.getHeaders().add("X-Query-Key", this.querykey);
    }
459622
public List<UserDto> selectByEmail(DbSession dbSession, String emailCaseInsensitive) {
    return mapper(dbSession).selectByEmail(emailCaseInsensitive.toLowerCase(ENGLISH));
  }
1303709
public List<UserDto> selectByIds(DbSession session, Collection<Integer> ids) {
    return executeLargeInputs(ids, mapper(session)::selectByIds);
  }
1320466
@Override
    public Cursor onQuery(T helper, SQLiteDatabase db, MatcherPattern target, QueryParameters parameter) {
        Cursor result = null;

        SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
        builder.setTables(target.getTableInfo().getName());
        builder.setProjectionMap(target.getTableInfo().getProjectionMap());

        // where
        switch (target.getMimeTypeVnd().getSubType()) {

            case ITEM:
                // Add item selection criteria (using StringBuilder via appendWhere)
                // URI parameter type not set at this level of the class hierarchy, but it is
                // assumed to be numeric so value not escaped.
                builder.appendWhere(target.getTableInfo().getIdColumnInfo().getColumnName());
                builder.appendWhere("=");
                builder.appendWhere(parameter.getUri().getPathSegments().get(1));
                break;

            case DIRECTORY:
            default:
                break;
        }

        // orderBy
        String orderBy = getSortOrderStringForQuery(target, parameter);

        result = builder.query(db, parameter.getProjection(), parameter.getSelection(), parameter.getSelectionArgs(),
            null, null, orderBy);
        return result;
    }
894347
public Query query(DataRange dataRange) {
        RowPosition startPosition = dataRange.startKey();
        RowPosition stopPosition = dataRange.stopKey();
        Token startToken = startPosition.getToken();
        Token stopToken = stopPosition.getToken();
        boolean isSameToken = startToken.compareTo(stopToken) == 0 && !tokenMapper.isMinimum(startToken);
        BooleanClause.Occur occur = isSameToken ? MUST : SHOULD;
        boolean includeStart = tokenMapper.includeStart(startPosition);
        boolean includeStop = tokenMapper.includeStop(stopPosition);

        SliceQueryFilter sqf;
        if (startPosition instanceof DecoratedKey) {
            sqf = (SliceQueryFilter) dataRange.columnFilter(((DecoratedKey) startPosition).getKey());
        } else {
            sqf = (SliceQueryFilter) dataRange.columnFilter(ByteBufferUtil.EMPTY_BYTE_BUFFER);
        }
        Composite startName = sqf.start();
        Composite stopName = sqf.finish();

        BooleanQuery query = new BooleanQuery();

        if (!startName.isEmpty()) {
            BooleanQuery q = new BooleanQuery();
            q.add(tokenMapper.query(startToken), MUST);
            q.add(clusteringKeyMapper.query(startName, null), MUST);
            query.add(q, occur);
            includeStart = false;
        }

        if (!stopName.isEmpty()) {
            BooleanQuery q = new BooleanQuery();
            q.add(tokenMapper.query(stopToken), MUST);
            q.add(clusteringKeyMapper.query(null, stopName), MUST);
            query.add(q, occur);
            includeStop = false;
        }

        if (!isSameToken) {
            Query rangeQuery = tokenMapper.query(startToken, stopToken, includeStart, includeStop);
            if (rangeQuery != null) query.add(rangeQuery, SHOULD);
        } else if (query.getClauses().length == 0) {
            return tokenMapper.query(startToken);
        }

        return query.getClauses().length == 0 ? null : query;
    }
714401
@Override
    public void onFilterEnabled(Displayer displayer, DataSetGroup groupOp) {
        String firstColumnId = dataSet.getColumnByIndex(0).getId();
        List<Integer> currentFilter = super.filterIndexes(firstColumnId);

        // If selector is active then ignore external filters.
        if (currentFilter.isEmpty()) {
            if (firstColumnId.equals(groupOp.getColumnGroup().getColumnId())) {
                columnSelectionMap.put(groupOp.getColumnGroup().getColumnId(), groupOp.getSelectedIntervalList());
            }
            super.onFilterEnabled(displayer, groupOp);
        }
    }
736785
public Where<T, ID> notIn(String columnName, QueryBuilder<?, ?> subQueryBuilder) throws SQLException {
		return in(false, columnName, subQueryBuilder);
	}
698817
public List executeSelectQuery(Class clazz, List<String> relationalField, CassandraDataHandler dataHandler,
        boolean isNative, String cqlQuery) {
        if (log.isDebugEnabled()) {
            log.debug("Executing cql query {}.", cqlQuery);
        }

        List entities = new ArrayList<Object>();

        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, clazz);

        MetamodelImpl metaModel =
            (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(entityMetadata.getPersistenceUnit());

        EntityType entityType = metaModel.entity(entityMetadata.getEntityClazz());

        List<AbstractManagedType> subManagedType = ((AbstractManagedType) entityType).getSubManagedType();

        if (subManagedType.isEmpty()) {
            entities.addAll(cqlClient.executeQuery(clazz, relationalField, dataHandler, true, isNative, cqlQuery));
        } else {
            for (AbstractManagedType subEntity : subManagedType) {
                EntityMetadata subEntityMetadata =
                    KunderaMetadataManager.getEntityMetadata(kunderaMetadata, subEntity.getJavaType());

                entities.addAll(cqlClient.executeQuery(subEntityMetadata.getEntityClazz(), relationalField, dataHandler,
                    true, isNative, cqlQuery));
            }
        }
        return entities;
    }
965028
@Override
  public <T> Cursor<T> selectCursor(String statement) {
    return session.selectCursor(statement);
  }
1257278
public QueryFilter withQuery(String query) {
        try {
            String encodedQuery = urlEncode(query);
            parameters.put(KEY_QUERY, encodedQuery);
            return this;
        } catch (UnsupportedEncodingException ex) {
            //"Every implementation of the Java platform is required to support the following standard charsets [...]: UTF-8"
            //cf. https://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html
            throw new IllegalStateException("UTF-8 encoding not supported by current Java platform implementation.", ex);
        }
    }