Creates a query in the PageContext containing all available Collections of the current
searchStorage

@throws ApplicationException
@throws PageException
@throws SearchException
552039
private void doList() throws PageException, SearchException {
	required("collection", action, "name", name);
	// if(StringUtil.isEmpty(name))throw new ApplicationException("for action list attribute name is
	// required");
	pageContext.setVariable(name, getSearchEngine().getCollectionsAsQuery());
    }
1304157
private void doGetTLDs() throws PageException {
	lucee.runtime.type.Query qry = new QueryImpl(
		new String[] { "displayname", "namespace", "namespaceseparator", "shortname", "type", "description", "uri", "elclass", "elBundleName", "elBundleVersion",
			"source" },
		new String[] { "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar", "varchar" }, 0, "tlds");

	int dialect = "lucee".equalsIgnoreCase(getString("dialect", "cfml")) ? CFMLEngine.DIALECT_LUCEE : CFMLEngine.DIALECT_CFML;

	TagLib[] libs = config.getTLDs(dialect);
	for (int i = 0; i < libs.length; i++) {
	    qry.addRow();
	    qry.setAt("displayname", i + 1, libs[i].getDisplayName());
	    qry.setAt("namespace", i + 1, libs[i].getNameSpace());
	    qry.setAt("namespaceseparator", i + 1, libs[i].getNameSpaceSeparator());
	    qry.setAt("shortname", i + 1, libs[i].getShortName());
	    qry.setAt("type", i + 1, libs[i].getType());
	    qry.setAt("description", i + 1, libs[i].getDescription());
	    qry.setAt("uri", i + 1, Caster.toString(libs[i].getUri()));
	    qry.setAt("elclass", i + 1, libs[i].getELClassDefinition().getClassName());
	    qry.setAt("elBundleName", i + 1, libs[i].getELClassDefinition().getName());
	    qry.setAt("elBundleVersion", i + 1, libs[i].getELClassDefinition().getVersionAsString());
	    qry.setAt("source", i + 1, StringUtil.emptyIfNull(libs[i].getSource()));
	}
	pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
    }
474115
private void doUpdate() throws PageException, SearchException, IOException {
	// check attributes
	required("index", action, "collection", collection);
	required("index", action, "key", key);

	if (type == -1) type = (query == null) ? SearchIndex.TYPE_FILE : SearchIndex.TYPE_CUSTOM;

	if (type == SearchIndex.TYPE_CUSTOM) {
	    required("index", action, "body", body);
	    // required("index",action,"query",query);
	}
	IndexResult result;

	result = collection.index(pageContext, key, type, urlpath, title, body, language, extensions, query, recurse, categoryTree, category, timeout, custom1, custom2, custom3,
		custom4);
	if (!StringUtil.isEmpty(status)) pageContext.setVariable(status, toStruct(result));
    }
1105400
public Map<String, Collection<String>> queries() {
    Map<String, Collection<String>> queryMap = new LinkedHashMap<>();
    this.queries.forEach((key, queryTemplate) -> {
      List<String> values = new ArrayList<>(queryTemplate.getValues());

      /* add the expanded collection, but lock it */
      queryMap.put(key, Collections.unmodifiableList(values));
    });

    return Collections.unmodifiableMap(queryMap);
  }
48705
private void doDelete() throws PageException, SearchException {
	required("index", action, "collection", collection);
	if (type != SearchIndex.TYPE_CUSTOM) required("index", action, "key", key);

	// no type defined
	if (type == -1) {
	    if (query != null) {
		type = SearchIndex.TYPE_CUSTOM;
	    }
	    else {
		Resource file = null;
		try {
		    file = ResourceUtil.toResourceExisting(pageContext, key);
		    pageContext.getConfig().getSecurityManager().checkFileLocation(file);
		}
		catch (ExpressionException e) {}

		if (file != null && file.exists() && file.isFile()) type = SearchIndex.TYPE_FILE;
		else if (file != null && file.exists() && file.isDirectory()) type = SearchIndex.TYPE_PATH;
		else {
		    try {
			new URL(key);
			type = SearchIndex.TYPE_URL;
		    }
		    catch (MalformedURLException e) {}
		}
	    }
	}

	collection.deleteIndex(pageContext, key, type, query);
    }
1225859
public void setQuery(String query) throws PageException {
	this.query = Caster.toQuery(pageContext.getVariable(query));
    }
339602
public void addQueryToCollection(String queryName, String query, boolean isNativeQuery, Class clazz)
    {
        if (namedNativeQueries == null)
        {
            namedNativeQueries = new ConcurrentHashMap<String, QueryWrapper>();
        }
        if (!namedNativeQueries.containsKey(queryName))
        {
            namedNativeQueries.put(queryName, new QueryWrapper(queryName, query, isNativeQuery, clazz));
        }
        // No null check made as it will never hold null value
        else if (queryName != null && !getQuery(queryName).equals(query))
        {
            logger.error("Duplicate named/native query with name:" + queryName
                    + "found! Already there is a query with same name:" + namedNativeQueries.get(queryName));
            throw new ApplicationLoaderException("Duplicate named/native query with name:" + queryName
                    + "found! Already there is a query with same name:" + namedNativeQueries.get(queryName));
        }
    }
990493
@Override
	public Page<T> findAll(final Pageable pageable) {
		if (pageable == null) {
			LOGGER.debug("Pageable in findAll(Pageable) is null");
		}

		final ArangoCursor<T> result = findAllInternal(pageable, null, new HashMap<>());
		final List<T> content = result.asListRemaining();
		return new PageImpl<>(content, pageable, result.getStats().getFullCount());
	}
1008221
@Override
    public IterableResult<Extension> search(ExtensionQuery query) throws SearchException
    {
        return RepositoryUtils.search(query, this.repositories);
    }
866901
public static String call(PageContext pc, Object var, boolean serializeQueryByColumns) throws PageException {
	return _call(pc, var, serializeQueryByColumns, pc.getWebCharset());
    }
660535
private void doGetDatasources() throws PageException {

	Map ds = config.getDataSourcesAsMap();
	Iterator it = ds.keySet().iterator();
	lucee.runtime.type.Query qry = new QueryImpl(new String[] { "name", "host", "classname", "bundleName", "bundleVersion", "dsn", "DsnTranslated", "database", "port",
		"timezone", "username", "password", "passwordEncrypted", "readonly", "grant", "drop", "create", "revoke", "alter", "select", "delete", "update", "insert",
		"connectionLimit", "openConnections", "connectionTimeout", "clob", "blob", "validate", "storage", "customSettings", "metaCacheTimeout" }, ds.size(), "query");

	int row = 0;

	while (it.hasNext()) {
	    Object key = it.next();
	    DataSource d = (DataSource) ds.get(key);
	    row++;

	    qry.setAt(KeyConstants._name, row, key);
	    qry.setAt(KeyConstants._host, row, d.getHost());
	    qry.setAt("classname", row, d.getClassDefinition().getClassName());
	    qry.setAt("bundleName", row, d.getClassDefinition().getName());
	    qry.setAt("bundleVersion", row, d.getClassDefinition().getVersionAsString());
	    qry.setAt("dsn", row, d.getDsnOriginal());
	    qry.setAt("database", row, d.getDatabase());
	    qry.setAt(KeyConstants._port, row, d.getPort() < 1 ? "" : Caster.toString(d.getPort()));
	    qry.setAt("dsnTranslated", row, d.getDsnTranslated());
	    qry.setAt("timezone", row, toStringTimeZone(d.getTimeZone()));
	    qry.setAt(KeyConstants._password, row, d.getPassword());

	    qry.setAt("passwordEncrypted", row, ConfigWebUtil.encrypt(d.getPassword()));
	    qry.setAt(KeyConstants._username, row, d.getUsername());
	    qry.setAt(KeyConstants._readonly, row, Caster.toBoolean(d.isReadOnly()));
	    qry.setAt(KeyConstants._select, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_SELECT)));
	    qry.setAt(KeyConstants._delete, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DELETE)));
	    qry.setAt(KeyConstants._update, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_UPDATE)));
	    qry.setAt(KeyConstants._create, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_CREATE)));
	    qry.setAt(KeyConstants._insert, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_INSERT)));
	    qry.setAt(KeyConstants._drop, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_DROP)));
	    qry.setAt(KeyConstants._grant, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_GRANT)));
	    qry.setAt(KeyConstants._revoke, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_REVOKE)));
	    qry.setAt(KeyConstants._alter, row, Boolean.valueOf(d.hasAllow(DataSource.ALLOW_ALTER)));
	    int oc = config.getDatasourceConnectionPool().openConnections(key.toString());
	    qry.setAt("openConnections", row, oc < 0 ? 0 : oc);
	    qry.setAt("connectionLimit", row, d.getConnectionLimit() < 1 ? "" : Caster.toString(d.getConnectionLimit()));
	    qry.setAt("connectionTimeout", row, d.getConnectionTimeout() < 1 ? "" : Caster.toString(d.getConnectionTimeout()));
	    qry.setAt("customSettings", row, d.getCustoms());
	    qry.setAt("blob", row, Boolean.valueOf(d.isBlob()));
	    qry.setAt("clob", row, Boolean.valueOf(d.isClob()));
	    qry.setAt("validate", row, Boolean.valueOf(d.validate()));
	    qry.setAt("storage", row, Boolean.valueOf(d.isStorage()));
	    qry.setAt("metaCacheTimeout", row, Caster.toDouble(d.getMetaCacheTimeout()));

	}
	pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
    }
1244537
private static Object toQuery(Object obj) throws PageException {
	if (obj instanceof Struct) {
	    Struct sct = (Struct) obj;
	    Key[] keys = CollectionUtil.keys(sct);

	    // Columns
	    Key[] columns = null;
	    if (contains(keys, KeyConstants._COLUMNS)) columns = toColumns(sct.get(KeyConstants._COLUMNS, null));
	    else if (contains(keys, KeyConstants._COLUMNLIST)) columns = toColumnlist(sct.get(KeyConstants._COLUMNLIST, null));

	    // rowcount
	    int rowcount = -1;
	    if (contains(keys, ROWCOUNT)) rowcount = toRowCount(sct.get(ROWCOUNT, null));
	    else if (contains(keys, KeyConstants._RECORDCOUNT)) rowcount = toRowCount(sct.get(KeyConstants._RECORDCOUNT, null));

	    if (columns != null) {
		if (keys.length == 2 && contains(keys, KeyConstants._DATA)) {

		    Array[] data = toData(sct.get(KeyConstants._DATA, null), columns);
		    if (data != null) {
			return new QueryImpl(columns, data, "query");
		    }
		}

		else if (keys.length == 3 && rowcount != -1 && contains(keys, KeyConstants._DATA)) {
		    Array[] data = toData(sct.get(KeyConstants._DATA, null), columns, rowcount);
		    if (data != null) {
			return new QueryImpl(columns, data, "query");
		    }
		}
	    }
	    return toQuery(sct, keys);
	}
	/*
	 * else if(obj instanceof Query) { return toQuery((Query) obj); }
	 */
	else if (obj instanceof Collection) {
	    Collection coll = (Collection) obj;
	    return toQuery(coll, CollectionUtil.keys(coll));
	}

	return obj;

    }
932831
public void setCollection(String collection) throws PageException {
	try {
	    this.collection = pageContext.getConfig().getSearchEngine(pageContext).getCollectionByName(collection.toLowerCase().trim());
	}
	catch (SearchException e) {
	    throw Caster.toPageException(e);
	}

    }
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);
   }
1240482
@Override
    public Object get(PageContext pc, Collection.Key key) throws PageException {
	return COMUtil.toObject(this, Dispatch.call(dispatch, key.getString()), key.getString());
    }
158562
public function index()
    {
        $this->request->allowMethod('get');

        $query = $this->SavedSearches->find('all')
            ->where(['name IS NOT' => null])
            ->where(['name !=' => ''])
            ->where($this->request->getQueryParams());

        $entities = $this->paginate($query);

        $this->set('success', true);
        $this->set('data', $entities);
        $this->set('_serialize', ['success', 'data']);
    }
931687
@Override
    public Collection<String> createResources(Request request)
            throws InvalidQueryException, ResourceNotFoundException, ResourceAlreadyExistsException {

        Collection<String> relativeUrls = new ArrayList<>();
        AtlasQuery atlasQuery = queryFactory.createEntityQuery(request);
        Collection<String> guids = new ArrayList<>();
        for (Map<String, Object> entityMap: atlasQuery.execute()) {
            guids.add(String.valueOf(entityMap.get("id")));
        }

        Collection<Map<String, String>> tagMaps = request.getProperty("tags");
        for (Map<String, String> tagMap : tagMaps) {
            Result termResult = getTermQueryResult(tagMap.get("name"));
            relativeUrls.addAll(tagEntities(guids, termResult.getPropertyMaps().iterator().next()));
        }
        return relativeUrls;
    }