Package org.labkey.remoteapi.query
Class ImportDataCommand
java.lang.Object
org.labkey.remoteapi.Command<ResponseType,org.apache.hc.client5.http.classic.methods.HttpPost>
- All Implemented Interfaces:
HasRequiredVersion
Import data in bulk from a text, local file, or a file
contained within a module on the LabKey Server.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumNested classes/interfaces inherited from class org.labkey.remoteapi.Command
Command.CommonParameters, Command.Response -
Field Summary
FieldsFields inherited from class org.labkey.remoteapi.Command
CONTENT_TYPE_JSON -
Constructor Summary
ConstructorsConstructorDescriptionImportDataCommand(String schemaName, String queryName) Constructs an ImportDataCommand for the given schemaName and queryName. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.hc.client5.http.classic.methods.HttpPostcreateRequest(URI uri) Creates theHttpPostinstance used for the request.protected ImportDataResponsecreateResponse(String text, int status, String contentType, org.json.JSONObject json) Creates an instance of the response class, initialized with the response text, the HTTP status code, and parsed JSONObject.org.json.JSONObjectReturns the JSON object to post or null for no JSON.Returns the query nameReturns the schema name.booleanbooleanvoidUploads a file for import.voidvoidsetImportIdentity(Boolean importIdentity) voidsetImportLookupByAlternateKey(Boolean importLookupByAlternateKey) voidsetInsertOption(ImportDataCommand.InsertOption insertOption) voidsetModuleResource(String module, String moduleResource) Import data from a resource file embedded in a module.voidImport data from a file relative from the server's webdav root.voidsetSaveToPipeline(boolean saveToPipeline) Save the uploaded file to the pipeline root under the "QueryImportFiles" directory.voidSubmits tsv or csv data as text to the server for import.voidsetUseAsync(boolean useAsync) Import the data in a pipeline job.Methods inherited from class org.labkey.remoteapi.Command
_execute, createParameterMap, execute, getActionName, getControllerName, getHttpRequest, getParameters, getParamValueAsString, getRequiredVersion, getTimeout, setRequiredVersion, setTimeout
-
Field Details
-
_importIdentity
-
_importLookupByAlternateKey
-
-
Constructor Details
-
ImportDataCommand
Constructs an ImportDataCommand for the given schemaName and queryName.- Parameters:
schemaName- The schemaNamequeryName- The queryName.
-
-
Method Details
-
getSchemaName
Returns the schema name.- Returns:
- The schema name.
-
getQueryName
Returns the query name- Returns:
- the query name.
-
setText
Submits tsv or csv data as text to the server for import.- See Also:
-
setPath
Import data from a file relative from the server's webdav root. -
setModuleResource
Import data from a resource file embedded in a module.- Parameters:
module- module namemoduleResource- path to the file from the exploded module's directory
-
setFile
Uploads a file for import. -
isImportIdentity
-
setImportIdentity
-
isImportLookupByAlternateKey
-
setImportLookupByAlternateKey
-
getFormat
-
setFormat
-
getInsertOption
-
setInsertOption
-
isUseAsync
public boolean isUseAsync() -
setUseAsync
public void setUseAsync(boolean useAsync) Import the data in a pipeline job. Currently only supported when submitting data as a file.- See Also:
-
isSaveToPipeline
public boolean isSaveToPipeline() -
setSaveToPipeline
public void setSaveToPipeline(boolean saveToPipeline) Save the uploaded file to the pipeline root under the "QueryImportFiles" directory. Currently only supported when submitting data as a file.- See Also:
-
getJsonObject
public org.json.JSONObject getJsonObject()Description copied from class:PostCommandReturns the JSON object to post or null for no JSON. Override this method to provide parameters as JSON.- Overrides:
getJsonObjectin classPostCommand<ImportDataResponse>- Returns:
- The JSON object to post.
-
createRequest
Description copied from class:PostCommandCreates theHttpPostinstance used for the request. Override to modify the HttpPost object before use or to send something other than JSON in the post body. In your override, create the HttpPost and set the request entity appropriately.- Overrides:
createRequestin classPostCommand<ImportDataResponse>- Parameters:
uri- the uri to convert- Returns:
- The PostMethod object.
-
createResponse
protected ImportDataResponse createResponse(String text, int status, String contentType, org.json.JSONObject json) Description copied from class:CommandCreates an instance of the response class, initialized with the response text, the HTTP status code, and parsed JSONObject.Override this method to create an instance of a different class that extends CommandResponse
- Overrides:
createResponsein classCommand<ImportDataResponse,org.apache.hc.client5.http.classic.methods.HttpPost> - Parameters:
text- The response text from the server.status- The HTTP status code.contentType- The Content-Type header value.json- The parsed JSONObject (or null if no JSON was returned).- Returns:
- An instance of the response object.
-