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 enum
static enum
Nested 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.HttpPost
createRequest
(URI uri) Creates theHttpPost
instance used for the request.protected ImportDataResponse
createResponse
(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.JSONObject
Returns the JSON object to post or null for no JSON.Returns the query nameReturns the schema name.boolean
boolean
void
Uploads a file for import.void
void
setImportIdentity
(Boolean importIdentity) void
setImportLookupByAlternateKey
(Boolean importLookupByAlternateKey) void
setInsertOption
(ImportDataCommand.InsertOption insertOption) void
setModuleResource
(String module, String moduleResource) Import data from a resource file embedded in a module.void
Import data from a file relative from the server's webdav root.void
setSaveToPipeline
(boolean saveToPipeline) Save the uploaded file to the pipeline root under the "QueryImportFiles" directory.void
Submits tsv or csv data as text to the server for import.void
setUseAsync
(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:PostCommand
Returns the JSON object to post or null for no JSON. Override this method to provide parameters as JSON.- Overrides:
getJsonObject
in classPostCommand<ImportDataResponse>
- Returns:
- The JSON object to post.
-
createRequest
Description copied from class:PostCommand
Creates theHttpPost
instance 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:
createRequest
in 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:Command
Creates 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:
createResponse
in 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.
-