Adds a check for the web user condition to an SQL query.<p>

@param select the query
@param orgUnit the organizational unit
@param users the user table alias
508727
protected void addWebuserCondition(CmsSelectQuery select, CmsOrganizationalUnit orgUnit, TableAlias users) {

        String webuserConditionTemplate;
        if (orgUnit.hasFlagWebuser()) {
            webuserConditionTemplate = "( %1$s >= 32768 AND %1$s < 65536 )";
        } else {
            webuserConditionTemplate = "( %1$s < 32768 OR %1$s >= 65536 )";
        }
        String webuserCondition = String.format(webuserConditionTemplate, users.column(colFlags()));
        select.addCondition(webuserCondition);
    }
49500
public User selectUser(final long userId) throws SQLException {
      Connection conn = null;
      PreparedStatement stmt = null;
      ResultSet rs = null;
      Timer.Context ctx = metrics.selectUserTimer.time();
      try {
         conn = connectionSupplier.getConnection();
         stmt = conn.prepareStatement(selectUserByIdSQL);
         stmt.setLong(1, userId);
         rs = stmt.executeQuery();
         return rs.next() ? userFromResultSet(rs) : null;
      } finally {
         ctx.stop();
         SQLUtil.closeQuietly(conn, stmt, rs);
      }
   }
506207
@Override
  public final void addUser(final String pUserName,
    final String pPassw, final String pRole) throws Exception {
    String query = "select USERTOMCAT.ITSUSER as ITSUSER, ITSROLE"
      + " from USERTOMCAT join USERROLETOMCAT"
        + " on USERROLETOMCAT.ITSUSER = USERTOMCAT.ITSUSER;";
    IRecordSet<RS> recordSet = null;
    try {
      this.srvDatabase.setIsAutocommit(false);
      this.srvDatabase.
        setTransactionIsolation(ISrvDatabase.TRANSACTION_READ_UNCOMMITTED);
      this.srvDatabase.beginTransaction();
      recordSet = getSrvDatabase().retrieveRecords(query);
      if (recordSet.moveToFirst()) {
        throw new Exception("There are already user credentials!");
      }
      String addUserQ =
        "insert into USERTOMCAT (ITSUSER, ITSPASSWORD) values ('" + pUserName
          + "', '" + pPassw + "');";
      String addUserRoleQ =
        "insert into USERROLETOMCAT (ITSUSER, ITSROLE) values ('" + pUserName
          + "', '" + pRole + "');";
      this.srvDatabase.executeQuery(addUserQ);
      this.srvDatabase.executeQuery(addUserRoleQ);
      this.srvDatabase.commitTransaction();
      this.isThereAnyUser = true;
    } catch (Exception ex) {
      this.srvDatabase.rollBackTransaction();
      throw ex;
    } finally {
      this.srvDatabase.releaseResources();
      if (recordSet != null) {
        recordSet.close();
      }
    }
  }
761489
public static boolean hasJoinOperation(String selectQuery) {
    if (selectQuery == null || selectQuery.length() == 0) {
      return false;
    }

    SqlParser sqlParser = SqlParser.create(selectQuery);
    try {

      SqlNode all = sqlParser.parseQuery();
      SqlSelect query;
      if (all instanceof SqlSelect) {
        query = (SqlSelect) all;
      } else if (all instanceof SqlOrderBy) {
        query = (SqlSelect) ((SqlOrderBy) all).query;
      } else {
        throw new UnsupportedOperationException("The select query is type of " + all.getClass() + " which is not supported here");
      }
      return query.getFrom().getKind() == SqlKind.JOIN;
    } catch (SqlParseException e) {
      return false;
    }
  }
981239
@When("^I select '(.+?)' on the element on index '(\\d+?)'$")
    public void elementSelect(String option, Integer index) {
        Select sel = null;
        sel = new Select(commonspec.getPreviousWebElements().getPreviousWebElements().get(index));

        sel.selectByVisibleText(option);
    }
436366
public function checkExists($whereValue = '', $whereField = 'id', $select = '*')
    {
        if (is_array($whereValue) && count($whereValue) > 0) {
            foreach ($whereValue as $column => $column_value) {
                if (is_array($column_value)) {
                    $this->db->where($column, $column_value, self::OPERATOR_IS_IN);
                } else {
                    $this->db->where($column, $column_value, self::OPERATOR_EQUAL_TO);
                }
            }
        } else {
            $this->db->where($whereField, $whereValue, self::OPERATOR_EQUAL_TO);
        }
        $this->db->get($this->table, NULL, $select);

        return (int) $this->db->count;
    }
880302
@Override
	public void check() throws JMSException
    {
        Iterator<User> users = userMap.values().iterator();
        while (users.hasNext())
        {
            User user = users.next();
            user.check();
        }
    }
1034596
private function mapMemberCondition(MemberCondition $condition, Select $select, array $memberMappings) : Expr
    {
        $mapping = $memberMappings[$condition->getNestedMember()->asString()];

        return $mapping->getMapping()
            ->getWhereConditionExpr($select, $mapping->getLastTableAlias(), $condition->getOperator(), $condition->getValue());
    }
73873
protected void addGroupCondition(CmsSelectQuery select, TableAlias users, CmsUserSearchParameters searchParams) {

        CmsGroup group = searchParams.getGroup();
        if (group != null) {
            CmsUUID groupId = group.getId();
            TableAlias groupUsers = select.addTable(tabGroupUsers(), "groupusrs");
            select.addCondition(
                new CmsSimpleQueryFragment(groupUsers.column(colGroupUserGroupId()) + " = ? ", groupId.toString()));
            select.addCondition(
                new CmsSimpleQueryFragment(groupUsers.column(colGroupUserUserId()) + " = " + users.column(colId())));
            if (searchParams.isFilterByGroupOu()) {
                select.addCondition(new CmsSimpleQueryFragment(users.column(colOu()) + " = ? ", group.getOuFqn()));
            }
        }
        CmsGroup notGroup = searchParams.getNotGroup();
        if (notGroup != null) {
            CmsSimpleQueryFragment notGroupCondition = new CmsSimpleQueryFragment(
                "NOT EXISTS (SELECT "
                    + getGroupUserSubqueryColumns()
                    + " FROM "
                    + tabGroupUsers()
                    + " GU WHERE GU."
                    + colGroupUserUserId()
                    + " = "
                    + users.column(colId())
                    + " AND GU."
                    + colGroupUserGroupId()
                    + " = ?)",
                notGroup.getId().toString());
            select.addCondition(notGroupCondition);
        }

        Collection<CmsGroup> anyGroups = searchParams.getAnyGroups();
        if ((anyGroups != null) && !anyGroups.isEmpty()) {
            CmsCompositeQueryFragment groupClause = new CmsCompositeQueryFragment();
            groupClause.setSeparator(" OR ");
            for (CmsGroup grp : anyGroups) {
                groupClause.add(
                    new CmsSimpleQueryFragment("GU." + colGroupUserGroupId() + " = ?", grp.getId().toString()));
            }
            CmsCompositeQueryFragment existsClause = new CmsCompositeQueryFragment();
            existsClause.add(
                new CmsSimpleQueryFragment(
                    "EXISTS (SELECT "
                        + getGroupUserSubqueryColumns()
                        + " FROM "
                        + tabGroupUsers()
                        + " GU WHERE GU."
                        + colGroupUserUserId()
                        + " = "
                        + users.column(colId())
                        + " AND "));
            existsClause.add(groupClause);
            existsClause.add(new CmsSimpleQueryFragment(" ) "));
            select.addCondition(existsClause);
        }
        Collection<CmsGroup> notAnyGroups = searchParams.getNotAnyGroups();
        if ((notAnyGroups != null) && (!notAnyGroups.isEmpty())) {
            CmsCompositeQueryFragment groupClause = new CmsCompositeQueryFragment();
            groupClause.setPrefix("(");
            groupClause.setSuffix(")");
            groupClause.setSeparator(" OR ");
            for (CmsGroup grp : notAnyGroups) {
                groupClause.add(
                    new CmsSimpleQueryFragment("GU." + colGroupUserGroupId() + " = ?", grp.getId().toString()));
            }
            CmsCompositeQueryFragment notExistsClause = new CmsCompositeQueryFragment();
            notExistsClause.add(
                new CmsSimpleQueryFragment(
                    "NOT EXISTS (SELECT "
                        + getGroupUserSubqueryColumns()
                        + " FROM "
                        + tabGroupUsers()
                        + " GU WHERE GU."
                        + colGroupUserUserId()
                        + " = "
                        + users.column(colId())
                        + " AND "));
            notExistsClause.add(groupClause);
            notExistsClause.add(new CmsSimpleQueryFragment(" ) "));
            select.addCondition(notExistsClause);
        }
    }
575551
public final void mSELECT() throws RecognitionException {
		try {
			int _type = SELECT;
			int _channel = DEFAULT_TOKEN_CHANNEL;
			// hql.g:58:8: ( 'select' )
			// hql.g:58:10: 'select'
			{
			match("select"); if (state.failed) return;

			}

			state.type = _type;
			state.channel = _channel;
		}
		finally {
			// do for sure before leaving
		}
	}
614388
boolean canSelect(Table table, boolean[] columnCheckList) {

        if (isFull || isFullSelect) {
            return true;
        }

        return containsAllColumns(selectColumnSet, table, columnCheckList);
    }
1216437
private void validateGroupByItem(SqlSelect select, SqlNode groupByItem) {
		final SqlValidatorScope groupByScope = getGroupScope(select);
		groupByScope.validateExpr(groupByItem);
	}
706845
protected void addSorting(CmsSelectQuery select, TableAlias users, CmsUserSearchParameters searchParams) {

        boolean ascending = searchParams.isAscending();
        String ordering = getSortExpression(users, searchParams);
        if (ascending) {
            ordering += " ASC";
        } else {
            ordering += " DESC";
        }

        select.setOrdering(ordering);
    }
1281962
@SuppressWarnings("unchecked")
    @Override
    public Boolean execute() {
        validateCommand();
        List<User> users = new ArrayList<>();
        for(String username : usernames) {
            User sfsUser = CommandUtil.getSfsUser(username, api);
            if(sfsUser != null) users.add(sfsUser);
        }
        ISFSObject params = createResponseParams();
        extension.send(command, params, users, useUDP);
        logResponse(params);
        return Boolean.TRUE;
    }
1033087
protected I_CmsQueryFragment createFlagCondition(TableAlias users, int flags) {

        return new CmsSimpleQueryFragment(
            users.column(colFlags()) + " & ? = ? ",
            new Integer(flags),
            new Integer(flags));
    }
591601
private String setSelectQuery(List<String> columns) {
        if (columns != null && !columns.isEmpty()) {
            return CQLTranslator.SELECT_QUERY;
        }
        if (kunderaQuery.isAggregated()) {
            Expression selectExpression =
                ((SelectClause) kunderaQuery.getSelectStatement().getSelectClause()).getSelectExpression();
            // create query depending on function
            if (selectExpression instanceof CountFunction) {
                return CQLTranslator.SELECT_COUNT_QUERY;
            }
        }
        return CQLTranslator.SELECTALL_QUERY;
    }
1372289
protected boolean isAlreadyAvailable(String userName) {

        List<CmsUser> availableUsers;
        try {
            availableUsers = OpenCms.getOrgUnitManager().getUsers(getCms(), m_ou, false);
        } catch (CmsException e) {
            availableUsers = new ArrayList<CmsUser>();
        }
        Iterator<CmsUser> itAvailableUsers = availableUsers.iterator();
        while (itAvailableUsers.hasNext()) {
            if (userName.equals(itAvailableUsers.next().getSimpleName())) {
                return true;
            }
        }
        return false;
    }