All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.labkey.remoteapi.query.GetQueryDetailsCommand Maven / Gradle / Ivy

Go to download

The client-side library for Java developers is a separate JAR from the LabKey Server code base. It can be used by any Java program, including another Java web application.

The newest version!
/*
 * Copyright (c) 2008-2018 LabKey Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.labkey.remoteapi.query;

import org.json.simple.JSONObject;
import org.labkey.remoteapi.Command;

import java.util.HashMap;
import java.util.Map;

/*
* User: Dave
* Date: Oct 21, 2008
* Time: 3:05:51 PM
*/

/**
 *  Command for obtaining the list of queries available within a given schema.
 */
public class GetQueryDetailsCommand extends Command
{
    private String _schemaName;
    private String _queryName;
    private boolean _includeSuggestedQueryColumns;

    /**
     * Constructs the command given a particular schema name.
     * @param schemaName The schema name.
     * @param queryName The name of the query (e.g., table) for the corresponding schema.
     * @param includeSuggestedQueryColumns Default true. Include the auto suggested columns in the response, e.g., user defined queries always have the container column of their root table added.
     */
    public GetQueryDetailsCommand(String schemaName, String queryName, boolean includeSuggestedQueryColumns)
    {
        super("query", "getQueryDetails");
        _schemaName = schemaName;
        _queryName = queryName;
        _includeSuggestedQueryColumns = includeSuggestedQueryColumns;
    }

    /**
     * Constructs the command given a particular schema name.
     * @param schemaName The schema name.
     * @param queryName The name of the query (e.g., table) for the corresponding schema.
     */
    public GetQueryDetailsCommand(String schemaName, String queryName)
    {
        this(schemaName, queryName, true);
    }

    public GetQueryDetailsCommand(GetQueryDetailsCommand source)
    {
        super(source);
        _schemaName = source._schemaName;
        _queryName = source._queryName;
        _includeSuggestedQueryColumns = source._includeSuggestedQueryColumns;
    }

    public String getSchemaName()
    {
        return _schemaName;
    }

    public void setSchemaName(String schemaName)
    {
        _schemaName = schemaName;
    }

    public String getQueryName()
    {
        return _queryName;
    }

    public void setQueryName(String queryName)
    {
        _queryName = queryName;
    }

    public Map getParameters()
    {
        assert null != getSchemaName() : "You must set the schema name before executing the GetQueryDetailsCommand!";
        assert null != getQueryName() : "You must set the query name before executing the GetQueryDetailsCommand!";

        Map params = new HashMap();
        params.put("schemaName", getSchemaName());
        params.put("queryName", getQueryName());
        params.put("includeSuggestedQueryColumns", _includeSuggestedQueryColumns);

        return params;
    }

    protected GetQueryDetailsResponse createResponse(String text, int status, String contentType, JSONObject json)
    {
        return new GetQueryDetailsResponse(text, status, contentType, json, this.copy());
    }

    @Override
    public GetQueryDetailsCommand copy()
    {
        return new GetQueryDetailsCommand(this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy