Пример #1
0
        // TODO: include whether form was sent already (or restrict always to unsent
        // forms)

        public FormInstance exportData()
        {
            FormInstance dm = RestoreUtils.createDataModel(this);

            RestoreUtils.addData(dm, "name", name);
            RestoreUtils.addData(dm, "form-id", (int)(formId));
            RestoreUtils.addData(dm, "saved-on", dateSaved,
                                 Constants.DATATYPE_DATE_TIME);
            RestoreUtils.addData(dm, "schema", schema);

            /////////////
            throw new SystemException("FormInstance.exportData(): must be updated to use new transport layer");
            //		ITransportManager tm = TransportManager._();
            //		boolean sent = (tm.getModelDeliveryStatus(id, true) == TransportMessage.STATUS_DELIVERED);
            //		RestoreUtils.addData(dm, "sent", new Boolean(sent));
            /////////////

            //		for (Enumeration e = namespaces.keys(); e.hasMoreElements(); ) {
            //			String key = (String)e.nextElement();
            //			RestoreUtils.addData(dm, "namespace/" + key, namespaces.get(key));
            //		}
            //
            //		RestoreUtils.mergeDataModel(dm, this, "data");
            //		return dm;
        }
Пример #2
0
 public void templateData(FormInstance dm, TreeReference parentRef)
 {
     RestoreUtils.applyDataType(dm, "name", parentRef, typeof(String));
     RestoreUtils.applyDataType(dm, "form-id", parentRef, typeof(int));
     RestoreUtils.applyDataType(dm, "saved-on", parentRef,
                                Constants.DATATYPE_DATE_TIME);
     RestoreUtils.applyDataType(dm, "schema", parentRef, typeof(String));
     RestoreUtils.applyDataType(dm, "sent", parentRef, typeof(Boolean));
     // don't touch data for now
 }
Пример #3
0
        public TreeElement processSaved(FormInstance template, FormDef f)
        {
            TreeElement fixedInstanceRoot = template.getRoot().deepCopy(true);
            TreeElement incomingRoot      = root.getChildAt(0);

            if (!fixedInstanceRoot.getName().Equals(incomingRoot.getName()) || incomingRoot.getMult() != 0)
            {
                throw new SystemException("Saved form instance to restore does not match form definition");
            }

            fixedInstanceRoot.populate(incomingRoot, f);
            return(fixedInstanceRoot);
        }
Пример #4
0
        public FormInstance clone()
        {
            FormInstance cloned = new FormInstance(this.getRoot().deepCopy(true));

            cloned.ID = (this.ID);
            cloned.setFormId(this.getFormId());
            cloned.setName(this.getName());
            cloned.setDateSaved(this.getDateSaved());
            cloned.schema      = this.schema;
            cloned.formVersion = this.formVersion;
            cloned.uiVersion   = this.uiVersion;
            cloned.namespaces  = new Hashtable();
            for (IEnumerator e = this.namespaces.GetEnumerator(); e.MoveNext();)
            {
                Object key = e.Current;
                cloned.namespaces.Add(key, this.namespaces[key]);
            }

            return(cloned);
        }
Пример #5
0
        public void importData(FormInstance dm)
        {
            name      = (String)RestoreUtils.getValue("name", dm);
            formId    = ((int)RestoreUtils.getValue("form-id", dm));
            dateSaved = (DateTime)RestoreUtils.getValue("saved-on", dm);
            schema    = (String)RestoreUtils.getValue("schema", dm);

            Boolean sent = RestoreUtils.getBoolean(RestoreUtils
                                                   .getValue("sent", dm));

            TreeElement names = dm.resolveReference(RestoreUtils.absRef("namespace", dm));

            if (names != null)
            {
                for (int i = 0; i < names.getNumChildren(); i++)
                {
                    TreeElement child = names.getChildAt(i);
                    String      name_ = child.getName();
                    Object      value = RestoreUtils.getValue("namespace/" + name_, dm);
                    if (value != null)
                    {
                        namespaces.Add(name_, value);
                    }
                }
            }

            /////////////
            throw new SystemException("FormInstance.importData(): must be updated to use new transport layer");
            //		if (sent) {
            //			ITransportManager tm = TransportManager._();
            //			tm.markSent(id, false);
            //		}
            /////////////

            //		IStorageUtility forms = StorageManager.getStorage(FormDef.STORAGE_KEY);
            //		FormDef f = (FormDef)forms.read(formId);
            //		setRoot(processSavedDataModel(dm.resolveReference(RestoreUtils.absRef("data", dm)), f.getDataModel(), f));
        }