public class Soda2Producer extends Soda2Consumer
HASH_RETURN_TYPE
SODA_BASE_PATH, SODA_QUERY
Constructor and Description |
---|
Soda2Producer(HttpLowLevel httpLowLevel)
Constructor
|
Modifier and Type | Method and Description |
---|---|
<T> Meta |
addObject(String resourceId,
T object)
Add an object using SODA2, the object will be added to the dataset with the specified resource ID.
|
<T> T |
addObject(String resourceId,
T object,
Class<T> retType)
Add an object using SODA2, the object will be added to the dataset with the specified resource ID.
|
void |
delete(String resourceId,
String id)
Deletes a row from a dataset.
|
static Soda2Producer |
newProducer(String url,
String userName,
String password,
String token)
Create a new Soda2Producer object, using the supplied credentials for authentication.
|
UpsertResult |
replace(String resourceId,
List objects)
Replaces a dataset with a list of objects.
|
UpsertResult |
replaceCsv(String resourceId,
File csvFile)
Replaces a dataset with the rows defined in the provided CSV.
|
UpsertResult |
replaceStream(String resourceId,
javax.ws.rs.core.MediaType mediaType,
InputStream stream)
Replaces a dataset with a the objects serialized in an input stream.
|
void |
truncate(String resourceId)
Truncates a dataset by deleting all rows in the dataset.
|
<T> Meta |
update(String resourceId,
Object id,
T object)
Updates an object in a dataset.
|
UpsertResult |
upsert(String resourceId,
List objects)
"Upserts" a list of objects.
|
UpsertResult |
upsertCsv(String resourceId,
File csvFile)
"Upserts" a list of objects.
|
UpsertResult |
upsertStream(String resourceId,
javax.ws.rs.core.MediaType mediaType,
InputStream stream)
"Upserts" a list of objects.
|
getById, newConsumer, newConsumer, query, query
doAdd, doAddObjects, doAddStream, doDelete, doReplaceObjects, doReplaceStream, doTruncate, doUpdate, getById, getHttpLowLevel, query, query
public Soda2Producer(HttpLowLevel httpLowLevel)
httpLowLevel
- HttpLowLevel object to use for connecting to the SODA2 service.public static final Soda2Producer newProducer(String url, String userName, String password, String token)
url
- the base URL for the SODA2 domain to access.userName
- user name to log in aspassword
- password to log in withtoken
- the App Token to use for authorization and usage tracking. If this is null
, no value will be sent.public void truncate(String resourceId) throws SodaError, InterruptedException
resourceId
- id of the dataset to truncateSodaError
- thrown if there is an error. Investigate the structure for more information.InterruptedException
- throws is the thread is interrupted.public void delete(String resourceId, String id) throws SodaError, InterruptedException
resourceId
- resourceId id of the dataset to delete a record fromid
- id of the record to delete. This should be the unique id of the record, which could be
either the id the system sets, or the Row Identifier.SodaError
- thrown if there is an error. Investigate the structure for more information.InterruptedException
- throws is the thread is interrupted.public <T> Meta addObject(String resourceId, T object) throws SodaError, InterruptedException
resourceId
- unique id or resource name of the datasetobject
- object to addSodaError
- thrown if there is an error. Investigate the structure for more information.InterruptedException
- throws is the thread is interrupted.public <T> T addObject(String resourceId, T object, Class<T> retType) throws SodaError, InterruptedException
resourceId
- unique id or resource name of the datasetobject
- object to addretType
- the type of object to returnSodaError
- thrown if there is an error. Investigate the structure for more information.InterruptedException
- throws is the thread is interrupted.public UpsertResult upsert(String resourceId, List objects) throws SodaError, InterruptedException
resourceId
- unique id or resource name of the datasetobjects
- list of objects to upsertSodaError
- thrown if there is an error. Investigate the structure for more information.InterruptedException
- throws is the thread is interrupted.public UpsertResult replace(String resourceId, List objects) throws SodaError, InterruptedException
resourceId
- unique id or resource name of the datasetobjects
- list of objects to replace the contents of the dataset withSodaError
InterruptedException
public UpsertResult upsertStream(String resourceId, javax.ws.rs.core.MediaType mediaType, InputStream stream) throws SodaError, InterruptedException
resourceId
- unique id or resource name of the datasetmediaType
- what the format of the stream is. Normally, HttpLowLevel.JSON_TYPE or HttpLowLevel.CSV_TYPEstream
- JSON stream of objects to updateSodaError
- thrown if there is an error. Investigate the structure for more information.InterruptedException
- throws is the thread is interrupted.public UpsertResult replaceStream(String resourceId, javax.ws.rs.core.MediaType mediaType, InputStream stream) throws SodaError, InterruptedException
resourceId
- unique id or resource name of the datasetmediaType
- what the format of the stream is. Normally, HttpLowLevel.JSON_TYPE or HttpLowLevel.CSV_TYPEstream
- JSON stream of objects to replace the existing dataset with.SodaError
InterruptedException
public UpsertResult upsertCsv(String resourceId, File csvFile) throws SodaError, InterruptedException
resourceId
- unique id or resource name of the datasetcsvFile
- File that contains a CSV to uploadSodaError
- thrown if there is an error. Investigate the structure for more information.InterruptedException
- throws is the thread is interrupted.public UpsertResult replaceCsv(String resourceId, File csvFile) throws SodaError, InterruptedException
resourceId
- unique id or resource name of the datasetcsvFile
- File that contains a CSV to replace the dataset withSodaError
InterruptedException
public <T> Meta update(String resourceId, Object id, T object) throws SodaError, InterruptedException
resourceId
- unique id or resource name of the datasetid
- Id based on a dataset specific unique column, or the system ID created for each row.object
- object to update the result withSodaError
- thrown if there is an error. Investigate the structure for more information.InterruptedException
- throws is the thread is interrupted.Copyright © 2013. All Rights Reserved.