Search in sources :

Example 1 with DataPointerPayload

use of org.javarosa.core.services.transport.payload.DataPointerPayload in project javarosa by opendatakit.

the class XFormSerializingVisitor method createSerializedPayload.

public IDataPayload createSerializedPayload(FormInstance model, IDataReference ref) throws IOException {
    init();
    rootRef = FormInstance.unpackReference(ref);
    if (this.serializer == null) {
        this.setAnswerDataSerializer(new XFormAnswerDataSerializer());
    }
    model.accept(this);
    if (theXmlDoc != null) {
        // TODO: Did this strip necessary data?
        byte[] form = XFormSerializer.getUtfBytes(theXmlDoc);
        if (dataPointers.size() == 0) {
            return new ByteArrayPayload(form, null, IDataPayload.PAYLOAD_TYPE_XML);
        }
        MultiMessagePayload payload = new MultiMessagePayload();
        payload.addPayload(new ByteArrayPayload(form, "xml_submission_file", IDataPayload.PAYLOAD_TYPE_XML));
        for (IDataPointer pointer : dataPointers) {
            payload.addPayload(new DataPointerPayload(pointer));
        }
        return payload;
    } else {
        return null;
    }
}
Also used : XFormAnswerDataSerializer(org.javarosa.xform.util.XFormAnswerDataSerializer) DataPointerPayload(org.javarosa.core.services.transport.payload.DataPointerPayload) ByteArrayPayload(org.javarosa.core.services.transport.payload.ByteArrayPayload) MultiMessagePayload(org.javarosa.core.services.transport.payload.MultiMessagePayload) IDataPointer(org.javarosa.core.data.IDataPointer)

Aggregations

IDataPointer (org.javarosa.core.data.IDataPointer)1 ByteArrayPayload (org.javarosa.core.services.transport.payload.ByteArrayPayload)1 DataPointerPayload (org.javarosa.core.services.transport.payload.DataPointerPayload)1 MultiMessagePayload (org.javarosa.core.services.transport.payload.MultiMessagePayload)1 XFormAnswerDataSerializer (org.javarosa.xform.util.XFormAnswerDataSerializer)1