Search in sources :

Example 1 with IStorageUtility

use of org.javarosa.core.services.storage.IStorageUtility in project javarosa by opendatakit.

the class CompactInstanceWrapper method loadTemplateInstance.

/**
 * load a template instance fresh from the original FormDef, retrieved from RMS
 * @param formID
 * @return
 */
public static FormInstance loadTemplateInstance(int formID) {
    IStorageUtility forms = StorageManager.getStorage(FormDef.STORAGE_KEY);
    FormDef f = (FormDef) forms.read(formID);
    return (f != null ? f.getMainInstance() : null);
}
Also used : IStorageUtility(org.javarosa.core.services.storage.IStorageUtility) FormDef(org.javarosa.core.model.FormDef)

Example 2 with IStorageUtility

use of org.javarosa.core.services.storage.IStorageUtility in project javarosa by opendatakit.

the class ModelReferencePayload method memoize.

private void memoize() {
    if (payload == null) {
        IStorageUtility<FormInstance> instances = (IStorageUtility<FormInstance>) StorageManager.getStorage(FormInstance.STORAGE_KEY);
        try {
            FormInstance tree = instances.read(recordId);
            payload = serializer.createSerializedPayload(tree);
        } catch (IOException e) {
            // Assertion, do not catch!
            Std.printStack(e);
            throw new RuntimeException("ModelReferencePayload failed to retrieve its model from rms [" + e.getMessage() + "]");
        }
    }
}
Also used : IStorageUtility(org.javarosa.core.services.storage.IStorageUtility) IOException(java.io.IOException) FormInstance(org.javarosa.core.model.instance.FormInstance)

Aggregations

IStorageUtility (org.javarosa.core.services.storage.IStorageUtility)2 IOException (java.io.IOException)1 FormDef (org.javarosa.core.model.FormDef)1 FormInstance (org.javarosa.core.model.instance.FormInstance)1