Patient Cloud AppConnect Android API References
Classes | Public Member Functions | List of all members
com.mdsol.babbage.model.internal.DataConverter

Classes

interface  DataConverterListener
 

Public Member Functions

 DataConverter (Datastore datastore)
 
void dispose ()
 
native String exportFormResponses (Form form, String deviceID) throws JSONException
 
native List< SubjectimportDemoSubjects (String json, User user) throws JSONException
 
native User importDemoUser (String json) throws JSONException
 
native List< FormimportForms (String formsJSON, String checksJSON, Subject subject) throws JSONException
 
native Study importStudy (String json, Subject subject) throws JSONException
 
native void importStudyData (String json, Study study) throws JSONException
 
native void importSubjectData (String psv, Subject subject) throws PSVException
 
native List< SubjectimportSubjects (String json, User user) throws JSONException
 
native User importUser (String json) throws JSONException
 
native void importUserData (String json, User user) throws JSONException
 
void removeListener ()
 
void setListener (DataConverterListener l)
 

Detailed Description

The data donverter is a two-way translator for JSON and model objects. It parses JSON and populates the datastore as needed. It is used by the networking client after receiving requested data, and before sending a request to submit data:

Constructor & Destructor Documentation

com.mdsol.babbage.model.internal.DataConverter.DataConverter ( Datastore  datastore)

Construct a data converter using a given datastore.

Parameters
datastorethe datastore to use

Member Function Documentation

void com.mdsol.babbage.model.internal.DataConverter.dispose ( )

Dispose of the data converter. You must call this method when you're done using the data converter.

native String com.mdsol.babbage.model.internal.DataConverter.exportFormResponses ( Form  form,
String  deviceID 
) throws JSONException

Export a form to an ODM by formatting the form and its field responses into JSON.

Parameters
formthe form to export
deviceIDthe ID of the device submitting the form
Returns
the JSON describing the exported form
Exceptions
JSONExceptionif the form or one of its fields aren't completed
native List<Subject> com.mdsol.babbage.model.internal.DataConverter.importDemoSubjects ( String  json,
User  user 
) throws JSONException

Import demo subjects by parsing the given JSON and populating the datastore. If the subjects already exist, they will be updated instead of created.

A demo subject is built into the app instead of being received from the network. It is used for demo purposes.

Parameters
jsonthe JSON describing the subjects to import
userthe user whose subjects we are importing
Returns
the subjects that were created or updated
Exceptions
JSONExceptionif any problem occurs during parsing
native User com.mdsol.babbage.model.internal.DataConverter.importDemoUser ( String  json) throws JSONException

Import a demo user by parsing the given JSON and populating the datastore. If the user already exists, it will be updated instead of created.

A demo user is built into the app instead of being received from the network. It is used for demo purposes.

Parameters
jsonthe JSON describing the user to import
Returns
the user that was created or updated
Exceptions
JSONExceptionif any problem occurs during parsing
native List<Form> com.mdsol.babbage.model.internal.DataConverter.importForms ( String  formsJSON,
String  checksJSON,
Subject  subject 
) throws JSONException

Import forms, fields and edit checks by parsing the given JSON and populating the datastore. If the forms already exist, they will be updated instead of created.

Parameters
formsJSONthe JSON describing the forms and fields to import
checksJSONthe JSON describing the edit checks to import
subjectthe subject whose forms we are importing
Returns
the forms that were created or updated
Exceptions
JSONExceptionif any problem occurs during parsing
native Study com.mdsol.babbage.model.internal.DataConverter.importStudy ( String  json,
Subject  subject 
) throws JSONException

Import a study by parsing the given JSON and populating the datastore. If the study already exists, it will be updated instead of created.

Parameters
jsonthe JSON describing the study to import
subjectthe subject whose study we are importing
Returns
the study that was created or updated
Exceptions
JSONExceptionif any problem occurs during parsing
native void com.mdsol.babbage.model.internal.DataConverter.importStudyData ( String  json,
Study  study 
) throws JSONException

Import a study's data by parsing the given JSON and populating the datastore.

Parameters
jsonthe JSON describing the study to import
studythe study whose data we are importing
Exceptions
JSONExceptionif any problem occurs during parsing
native void com.mdsol.babbage.model.internal.DataConverter.importSubjectData ( String  psv,
Subject  subject 
) throws PSVException

Import a subject's data by parsing the given PSV and populating the datastore.

Parameters
psvthe PSV describing the subject to import
subjectthe subject whose data we are importing
Exceptions
PSVExceptionif any problem occurs during parsing
native List<Subject> com.mdsol.babbage.model.internal.DataConverter.importSubjects ( String  json,
User  user 
) throws JSONException

Import subjects by parsing the given JSON and populating the datastore. If the subjects already exist, they will be updated instead of created.

Parameters
jsonthe JSON describing the subjects to import
userthe user whose subjects we are importing
Returns
the subjects that were created or updated
Exceptions
JSONExceptionif any problem occurs during parsing
native User com.mdsol.babbage.model.internal.DataConverter.importUser ( String  json) throws JSONException

Import a user by parsing the given JSON and populating the datastore. If the user already exists, it will be updated instead of created.

Parameters
jsonthe JSON describing the user to import
Returns
the user that was created or updated
Exceptions
JSONExceptionif any problem occurs during parsing
native void com.mdsol.babbage.model.internal.DataConverter.importUserData ( String  json,
User  user 
) throws JSONException

Import a user's data by parsing the given JSON and populating the datastore.

Parameters
jsonthe JSON describing the user to import
userthe user whose data we are importing
Exceptions
JSONExceptionif any problem occurs during parsing
void com.mdsol.babbage.model.internal.DataConverter.removeListener ( )
void com.mdsol.babbage.model.internal.DataConverter.setListener ( DataConverterListener  l)