Exemple #1
0
 /// <summary>  Constructs a query condition</summary>
 /// <param name="field">A static constant defined by the <c>Adk</c>
 /// to identify the field (i.e. element or attribute) to evaluate
 /// </param>
 /// <param name="ops">The comparison operator</param>
 /// <param name="val">The value to evaluate
 /// </param>
 public Condition(IElementDef field,
                  ComparisonOperators ops,
                  string val)
 {
     fField = field;
     fOps   = ops;
     fValue = val;
     fXPath = field.GetSQPPath(Adk.SifVersion);
 }
Exemple #2
0
        /// <summary>
        /// Add a condition to this query.
        /// </summary>
        /// <remarks>
        /// This method of adding conditions is convenient for adding conditions involving
        /// root attributes or elements to a query. If you need to add conditions on deeply
        /// nested elements, use <see cref="AddCondition(string,ComparisonOperators,string)"/>
        /// </remarks>
        /// <param name="field">A constant from the package DTD class that identifies an element
        /// or attribute of the data object (e.g. <c>StudentDTD.STUDENTPERSONAL_REFID</c>)</param>
        /// <param name="ops">The comparison operator. Comparison operator constants are
        /// defined by the ComparisionOperators enum</param>
        /// <param name="value">The data that is used to compare to the element or attribute</param>
        /// <exception cref="ArgumentException">if the ElementDef does not represent an immediate
        /// child of the object being queried.</exception>
        public void AddCondition(IElementDef field, ComparisonOperators ops, String value)
        {
            // Do some validation to try to prevent invalid query paths from being created
            String      relativePath = field.GetSQPPath(Adk.SifVersion);
            IElementDef lookedUp     = Adk.Dtd.LookupElementDefBySQP(fObjType, relativePath);

            if (lookedUp == null)
            {
                throw new ArgumentException("Invalid path: " + fObjType.Name + "/" + relativePath +
                                            " is unable to be resolved");
            }

            AddCondition(new Condition(fObjType, relativePath, ops, value));
        }
        /**
         * Creates a SIF_Query element from the specified Adk query object using
         * the specified version of SIF
         * @param query The Query to convert to a SIF_Query
         * @param version The version of SIF to render the SIF_Query xml in
         * @param allowFieldRestrictions True if the field restrictions in the query should be rendered
         * @return a SIF_Query object
         */
        public static SIF_Query CreateSIF_Query(Query query, SifVersion version, bool allowFieldRestrictions)
        {
            SIF_QueryObject sqo  = new SIF_QueryObject(query.ObjectType.Tag(version));
            SIF_Query       sifQ = new SIF_Query(sqo);

            if (query.HasConditions)
            {
                sifQ.SIF_ConditionGroup = createConditionGroup(query, version);
            }

            if (allowFieldRestrictions && query.HasFieldRestrictions)
            {
                foreach (ElementRef elementRef in query.FieldRestrictionRefs)
                {
                    String      path  = null;
                    IElementDef field = elementRef.Field;
                    if (field != null)
                    {
                        if (!field.IsSupported(version))
                        {
                            continue;
                        }
                        path = field.GetSQPPath(version);
                    }
                    if (path == null)
                    {
                        path = elementRef.XPath;
                    }
                    if (path != null)
                    {
                        path = Adk.Dtd.TranslateSQP(query.ObjectType, path, version);
                        sqo.AddSIF_Element(new SIF_Element(path));
                    }
                }
            }

            return(sifQ);
        }
Exemple #4
0
 /// <summary>
 /// Creates an ElementRef instance using the specified IElementDef as the reference path
 /// </summary>
 /// <param name="root"></param>
 /// <param name="referencedField"></param>
 /// <param name="version"></param>
 public ElementRef(IElementDef root, IElementDef referencedField, SifVersion version)
 {
     fField = referencedField;
     fXPath = referencedField.GetSQPPath(version);
 }
 /// <summary>
 /// Creates an ElementRef instance using the specified IElementDef as the reference path
 /// </summary>
 /// <param name="root"></param>
 /// <param name="referencedField"></param>
 /// <param name="version"></param>
 public ElementRef(IElementDef root, IElementDef referencedField, SifVersion version)
 {
     fField = referencedField;
     fXPath = referencedField.GetSQPPath(version);
 }
Exemple #6
0
        /// <summary>
        /// Add a condition to this query.
        /// </summary>
        /// <remarks>
        /// This method of adding conditions is convenient for adding conditions involving 
        /// root attributes or elements to a query. If you need to add conditions on deeply
        /// nested elements, use <see cref="AddCondition(string,ComparisonOperators,string)"/>
        /// </remarks>
        /// <param name="field">A constant from the package DTD class that identifies an element
        /// or attribute of the data object (e.g. <c>StudentDTD.STUDENTPERSONAL_REFID</c>)</param>
        /// <param name="ops">The comparison operator. Comparison operator constants are
        /// defined by the ComparisionOperators enum</param>
        /// <param name="value">The data that is used to compare to the element or attribute</param>
        /// <exception cref="ArgumentException">if the ElementDef does not represent an immediate
        /// child of the object being queried.</exception>
        public void AddCondition(IElementDef field, ComparisonOperators ops, String value)
        {
            // Do some validation to try to prevent invalid query paths from being created
            String relativePath = field.GetSQPPath(Adk.SifVersion);
            IElementDef lookedUp = Adk.Dtd.LookupElementDefBySQP(fObjType, relativePath);
            if (lookedUp == null)
            {
                throw new ArgumentException("Invalid path: " + fObjType.Name + "/" + relativePath +
                             " is unable to be resolved");
            }

            AddCondition(new Condition(fObjType, relativePath, ops, value));
        }