How to get data from FormController

Greetings,

I'm attempting to integration some of the ODK/JavaRosa functionality into
an existing app. I would like to be able to ask the FormController for a
copy of the data that is going to be submitted, so I an place that data
into my own database and use my own submission strategy and stack. From
reading the code, I've learned that FormController will return a byte array
submission payload, which is itself a IDataPayload from within JavaRosa.
I'm not clear on the specifics of the IDataPayload, if it's binary or
textual xml, and if this is the only way to ask ODK for a copy of the
currently entered values programmatically. Looking for some pointers on
this - just need to ask the FormController for the currently entered
values, and my forms do not contain binary data at this time so that may
make the answer easier. If I need to customize some of the source to
achieve this, do I need to delve into JavaRosa or can I get what I need at
the FormController (ODK) level?

Thanks for your assistance.
w

Figured out something that works, snippet below. Basically FormController
will return an InputStream of the xml containing the data. You can then
parse this to your heart's content, or apply Jackson to it if you dare!

Map<String, String> values;

ByteArrayPayload payload = null;

try {

payload = mFormController.getFilledInFormXml();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

InputStream is = payload.getPayloadStream();

values = getOdkCollectFormValues(is);

Correct. The alternative is to navigate through the form using the javarosa
apis, but that can be confusing if your form is using repeat groups.

Mitch

ยทยทยท On May 14, 2013 8:46 PM, "Wyler Yerrachione" wrote:

Figured out something that works, snippet below. Basically FormController
will return an InputStream of the xml containing the data. You can then
parse this to your heart's content, or apply Jackson to it if you dare!

Map<String, String> values;

ByteArrayPayload payload = null;

try {

payload = mFormController.getFilledInFormXml();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

InputStream is = payload.getPayloadStream();

values = getOdkCollectFormValues(is);

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.