private void memoize() { if (payload == null) { IStorageUtility instances = StorageManager.getStorage(FormInstance.STORAGE_KEY); try { FormInstance tree = (FormInstance)instances.read(recordId); payload = serializer.createSerializedPayload(tree); } catch (System.IO.IOException e) { //Assertion, do not catch! if (e is org.javarosa.core.io.StreamsUtil.DirectionalIOException) { ((org.javarosa.core.io.StreamsUtil.DirectionalIOException)e).printStackTrace(); } else { SupportClass.WriteStackTrace(e, Console.Error); } //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" throw new System.SystemException("ModelReferencePayload failed to retrieve its model from rms [" + e.Message + "]"); } } }
/// <summary> load a template instance fresh from the original FormDef, retrieved from RMS</summary> /// <param name="formID"> /// </param> /// <returns> /// </returns> public static FormInstance loadTemplateInstance(int formID) { IStorageUtility forms = StorageManager.getStorage(FormDef.STORAGE_KEY); FormDef f = (FormDef)forms.read(formID); return(f != null?f.MainInstance:null); }
public static void importRMS(FormInstance dm, IStorageUtility storage, System.Type type, System.String path) { if (!typeof(Externalizable).IsAssignableFrom(type) || !typeof(Restorable).IsAssignableFrom(type)) { return; } bool idMatters = typeof(Persistable).IsAssignableFrom(type); System.String childName = ((Restorable)PrototypeFactory.getInstance(type)).RestorableType; TreeElement e = dm.resolveReference(absRef(path, dm)); System.Collections.ArrayList children = e.getChildrenWithName(childName); for (int i = 0; i < children.Count; i++) { FormInstance child = subDataModel((TreeElement)children[i]); Restorable inst = (Restorable)PrototypeFactory.getInstance(type); //restore record id first so 'importData' has access to it int recID = -1; if (idMatters) { recID = ((System.Int32)getValue(RECORD_ID_TAG, child)); ((Persistable)inst).ID = recID; } inst.importData(child); try { if (idMatters) { storage.write((Persistable)inst); } else { storage.add((Externalizable)inst); } } catch (System.Exception ex) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" throw new System.SystemException("Error importing RMS during restore! [" + type.FullName + ":" + recID + "]; " + ex.Message); } } }
public static FormInstance exportRMS(IStorageUtility storage, System.Type type, System.String parentTag, IRecordFilter filter) { if (!typeof(Externalizable).IsAssignableFrom(type) || !typeof(Restorable).IsAssignableFrom(type)) { return(null); } FormInstance dm = newDataModel(parentTag); IStorageIterator ri = storage.iterate(); while (ri.hasMore()) { System.Object obj = ri.nextRecord(); if (filter == null || filter.filter(obj)) { FormInstance objModel = ((Restorable)obj).exportData(); mergeDataModel(dm, objModel, topRef(dm)); } } return(dm); }
public static void exportRMS(FormInstance parent, System.Type type, System.String grouperName, IStorageUtility storage, IRecordFilter filter) { FormInstance entities = RestoreUtils.exportRMS(storage, type, grouperName, filter); RestoreUtils.mergeDataModel(parent, entities, "."); }