コード例 #1
0
        /// <summary> serialize a compact instance</summary>
        //UPGRADE_TODO: Class 'java.io.DataOutputStream' was converted to 'System.IO.BinaryWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataOutputStream'"
        public virtual void  writeExternal(System.IO.BinaryWriter out_Renamed)
        {
            if (instance == null)
            {
                throw new System.SystemException("instance has not yet been set via setData()");
            }

            ExtUtil.writeNumeric(out_Renamed, instance.FormId);
            ExtUtil.writeNumeric(out_Renamed, instance.ID);
            ExtUtil.write(out_Renamed, new ExtWrapNullable(instance.DateSaved));

            writeTreeElement(out_Renamed, instance.getRoot());
        }
コード例 #2
0
        /// <summary> deserialize a compact instance. note the retrieval of the template data instance</summary>
        //UPGRADE_TODO: Class 'java.io.DataInputStream' was converted to 'System.IO.BinaryReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioDataInputStream'"
        public virtual void  readExternal(System.IO.BinaryReader in_Renamed, PrototypeFactory pf)
        {
            int formID = ExtUtil.readInt(in_Renamed);

            instance = getTemplateInstance(formID).Clone();

            instance.ID        = ExtUtil.readInt(in_Renamed);
            instance.DateSaved = (System.DateTime)ExtUtil.read(in_Renamed, new ExtWrapNullable(typeof(System.DateTime)));
            //formID, name, schema, versions, and namespaces are all invariants of the template instance

            TreeElement root = instance.getRoot();

            readTreeElement(root, in_Renamed, pf);
        }
コード例 #3
0
        public static void mergeDataModel(FormInstance parent, FormInstance child, TreeReference parentRef)
        {
            TreeElement parentNode = parent.resolveReference(parentRef);

            //ugly
            if (parentNode == null)
            {
                parentRef  = parent.addNode(parentRef);
                parentNode = parent.resolveReference(parentRef);
            }
            TreeElement childNode = child.getRoot();

            int mult = parentNode.getChildMultiplicity(childNode.getName());

            childNode.setMult(mult);

            parentNode.addChild(childNode);
        }
コード例 #4
0
        /*
         * (non-Javadoc)
         * @see org.javarosa.core.model.utils.ITreeVisitor#visit(org.javarosa.core.model.DataModelTree)
         */
        public virtual void  visit(FormInstance tree)
        {
            theXmlDoc = new Document();
            //TreeElement root = tree.getRoot();

            TreeElement root = tree.resolveReference(rootRef);

            //For some reason resolveReference won't ever return the root, so we'll
            //catch that case and just start at the root.
            if (root == null)
            {
                root = tree.getRoot();
            }

            for (int i = 0; i < root.NumChildren; i++)
            {
                TreeElement childAt = root.getChildAt(i);
            }

            if (root != null)
            {
                theXmlDoc.addChild(Node.ELEMENT, serializeNode(root));
            }

            Element top = theXmlDoc.getElement(0);

            System.String[] prefixes = tree.NamespacePrefixes;
            for (int i = 0; i < prefixes.Length; ++i)
            {
                top.setPrefix(prefixes[i], tree.getNamespaceURI(prefixes[i]));
            }
            if (tree.schema != null)
            {
                top.setNamespace(tree.schema);
                top.setPrefix("", tree.schema);
            }
        }
コード例 #5
0
ファイル: XPathPathExpr.cs プロジェクト: amasasi/DotNetRosa
        public override XPathNodeset eval(FormInstance m, EvaluationContext ec)
        {
            TreeReference genericRef = getReference();

            TreeReference ref_Renamed;

            if (genericRef.Context == TreeReference.CONTEXT_ORIGINAL)
            {
                ref_Renamed = genericRef.contextualize(ec.OriginalContext);
            }
            else
            {
                ref_Renamed = genericRef.contextualize(ec.ContextRef);
            }

            //We don't necessarily know the model we want to be working with until we've contextualized the
            //node

            //check if this nodeset refers to a non-main instance
            if (ref_Renamed.InstanceName != null && ref_Renamed.Absolute)
            {
                FormInstance nonMain = ec.getInstance(ref_Renamed.InstanceName);
                if (nonMain != null)
                {
                    m = nonMain;
                }
                else
                {
                    throw new XPathMissingInstanceException(ref_Renamed.InstanceName, "Instance referenced by " + ref_Renamed.toString(true) + " does not exist");
                }
            }
            else
            {
                //TODO: We should really stop passing 'm' around and start just getting the right instance from ec
                //at a more central level
                m = ec.MainInstance;

                if (m == null)
                {
                    System.String refStr = ref_Renamed == null?"":ref_Renamed.toString(true);
                    throw new XPathException("Cannot evaluate the reference [" + refStr + "] in the current evaluation context. No default instance has been declared!");
                }
            }

            // regardless of the above, we want to ensure there is a definition
            if (m.getRoot() == null)
            {
                //This instance is _declared_, but doesn't actually have any data in it.
                throw new XPathMissingInstanceException(ref_Renamed.InstanceName, "Instance referenced by " + ref_Renamed.toString(true) + " has not been loaded");
            }

            // this makes no sense...
            //		if (ref.isAbsolute() && m.getTemplatePath(ref) == null) {
            //			Vector<TreeReference> nodesetRefs = new Vector<TreeReference>();
            //			return new XPathNodeset(nodesetRefs, m, ec);
            //		}



            //to fix conditions based on non-relevant data, filter the nodeset by relevancy
            for (int i = 0; i < nodesetRefs.size(); i++)
            {
                if (!m.resolveReference((TreeReference)nodesetRefs.elementAt(i)).isRelevant())
                {
                    nodesetRefs.removeElementAt(i);
                    i--;
                }
            }

            return(new XPathNodeset(nodesetRefs, m, ec));
        }
コード例 #6
0
 public static TreeReference topRef(FormInstance dm)
 {
     return(ref_Renamed("/" + dm.getRoot().getName()));
 }