protected StudentPersonal mapToStudentPersonal(IFieldAdaptor adaptor, String cfg, IValueBuilder vb)
        {
            StudentPersonal sp = new StudentPersonal();

            doOutboundMapping(adaptor, sp, cfg, vb);
            return(sp);
        }
Example #2
0
        /// <summary>Sets an element or attribute value identified by an XPath-like query string.</summary>
        /// <remarks>
        ///   NOTE: This method makes calls to SIFXPathContext. If multiple calls to
        ///  <c>setElementOrAttribute</c> are being done, it is much more efficient to create
        ///  a new <c>SifXPathContext</c> by calling <c>SifXPathContext.NewInstance(sdo)</c> and then
        /// calling <c>.SetElementorAttributeon</c> on that SifXPathContext instance
        /// </remarks>
        /// <param name="xpath">An XPath-like query string that identifies the element or
        /// attribute to set. The string must reference elements and attributes
        /// by their <i>version-independent</i> names.
        /// </param>
        /// <param name="valu">The value to assign to the element or attribute if the
        /// query string does not set a value; may be null
        /// </param>
        /// <param name="adaptor"> A data source may be used for variable
        /// substitutions within the query string
        /// </param>
        public virtual void SetElementOrAttribute(string xpath,
                                                  string valu,
                                                  IFieldAdaptor adaptor)
        {
            SifVersion = Adk.SifVersion;
            SifXPathContext spc = SifXPathContext.NewSIFContext(this);

            if (adaptor is IXPathVariableLibrary)
            {
                spc.AddVariables("", (IXPathVariableLibrary)adaptor);
            }
            spc.SetElementOrAttribute(xpath, valu);
        }
Example #3
0
        /**
         * Perform a mapping operation on the specified SIFElement. The mapping operation
         * will be either inbound or outbound, depending on whether this class was returned
         * from {@link Mappings#selectInbound(ElementDef, SIFVersion, String, String)} or
         * {@link Mappings#selectOutbound(ElementDef, SIFVersion, String, String)}
         * @param mappedElement The SIFElement to perform the mappings operation on
         * @param adaptor The FieldAdaptor to use for getting or setting data
         * @throws ADKMappingException
         */

        public void Map(SifElement mappedElement, IFieldAdaptor adaptor)
        {
            SifXPathContext context = GetXPathContext(mappedElement, adaptor);

            if (fDirection == MappingDirection.Inbound)
            {
                fMappings.MapInbound(context, adaptor, mappedElement, fFieldMappings, fSIFVersion);
            }
            else if (fDirection == MappingDirection.Outbound)
            {
                fMappings.MapOutbound(context, adaptor, mappedElement, fFieldMappings, fValueBuilder, fSIFVersion);
            }
        }
Example #4
0
        public void testStudentContactMapping010()
        {
            StudentContact sc       = new StudentContact();
            Mappings       mappings = fCfg.Mappings.GetMappings("Default");
            IFieldAdaptor  adaptor  = createStudentContactFields();

            mappings.MapOutbound(adaptor, sc);
            SifWriter writer = new SifWriter(Console.Out);

            writer.Write(sc);
            writer.Flush();

            Assertion.AssertEquals("Testing Pickup Rights", "Yes", sc.ContactFlags.PickupRights);
        }
        protected StudentPersonal doOutboundMappingSelect(IFieldAdaptor adaptor, String cfg, String zoneId,
                                                          String sourceId, SifVersion version)
        {
            AgentConfig config = createConfig(cfg);

            Mappings root        = config.Mappings;
            Mappings defMap      = root.GetMappings("Default");
            Mappings selectedMap = defMap.Select(zoneId, sourceId, version);

            StudentPersonal sp = new StudentPersonal();

            selectedMap.MapOutbound(adaptor, sp);

            Console.WriteLine(sp.ToXml());
            return(sp);
        }
        /// <summary>  Replaces all <c>$(variable)</c> tokens in the source string with
        /// the corresponding entry in the supplied Map
        /// </summary>
        /// <param name="src">The source string
        /// </param>
        /// <param name="data">The field adaptor to use
        /// </param>
        public static string ReplaceTokens(string src,
                                           IFieldAdaptor data)
        {
            if (src == null)
            {
                return(null);
            }

            StringBuilder b = new StringBuilder();

            int len  = src.Length;
            int at   = 0;
            int mark = 0;

            do
            {
                at = src.IndexOf("$(", at);
                if (at == -1)
                {
                    at = len;
                }
                b.Append(src.Substring(mark, (at - mark)));

                if (at < len)
                {
                    int i = src.IndexOf(")", at + 2);
                    if (i != -1)
                    {
                        mark = i + 1;
                        string key = src.Substring(at + 2, i - (at + 2));
                        at = mark;
                        object val = data.GetValue(key);
                        if (val != null)
                        {
                            b.Append(val);
                        }
                    }
                    else
                    {
                        b.Append(src.Substring(mark, (len - mark)));
                        at = len;
                    }
                }
            }while (at < len);

            return(b.ToString());
        }
        protected void doOutboundMapping(IFieldAdaptor adaptor, SifDataObject sdo, String cfg, IValueBuilder vb)
        {
            AgentConfig config = createConfig(cfg);

            Mappings root   = config.Mappings;
            Mappings defMap = root.GetMappings("Default");

            if (vb != null)
            {
                defMap.MapOutbound(adaptor, sdo, vb);
            }
            else
            {
                defMap.MapOutbound(adaptor, sdo);
            }

            Console.WriteLine(sdo.ToXml());
        }
Example #8
0
        private SifXPathContext GetXPathContext(
            SifElement mappedElement, IFieldAdaptor adaptor)

        {
            lock (this)
            {
                if (!mappedElement.ElementDef.Name.Equals(fElementDef.Name))
                {
                    throw new AdkMappingException(
                              "Unable to use object for mapping. MappingsContext expected an object of type '" +
                              fElementDef.Name + "' but was '" + mappedElement.ElementDef.Name + "'.", null);
                }

                if (fRootContext == null)
                {
                    fRootContext = SifXPathContext.NewSIFContext(mappedElement, fSIFVersion);
                    if (adaptor is IXPathVariableLibrary)
                    {
                        fRootContext.AddVariables("", (IXPathVariableLibrary)adaptor);
                    }
                }
                return(SifXPathContext.NewSIFContext(fRootContext, mappedElement));
            }
        }
 /**
  * Perform a mapping operation on the specified SIFElement. The mapping operation
  * will be either inbound or outbound, depending on whether this class was returned
  * from {@link Mappings#selectInbound(ElementDef, SIFVersion, String, String)} or
  * {@link Mappings#selectOutbound(ElementDef, SIFVersion, String, String)}
  * @param mappedElement The SIFElement to perform the mappings operation on
  * @param adaptor The FieldAdaptor to use for getting or setting data
  * @throws ADKMappingException
  */
 public void Map(SifElement mappedElement, IFieldAdaptor adaptor)
 {
     SifXPathContext context = GetXPathContext(mappedElement, adaptor);
     if (fDirection == MappingDirection.Inbound)
     {
         fMappings.MapInbound(context, adaptor, mappedElement, fFieldMappings, fSIFVersion);
     }
     else if (fDirection == MappingDirection.Outbound)
     {
         fMappings.MapOutbound(context, adaptor, mappedElement, fFieldMappings, fValueBuilder, fSIFVersion);
     }
 }
 /// <summary>  Constructor</summary>
 public DefaultValueBuilder(IFieldAdaptor data) : this(data, Adk.TextFormatter)
 {
 }
Example #11
0
 /// <summary>
 /// Constructor called by the ADK. Set the <seealso cref="Edustructures.SifWorks.DefaultValueBuilder.DefaultClass">DefaultClass</seealso> property here so the ADK can find your macro method to call.
 /// </summary>
 /// <param name="data"></param>
 public DataUtilMacro(IFieldAdaptor data)
     : base(data)
 {
     DefaultClass = typeof(DataUtilMacro).AssemblyQualifiedName;
 }
Example #12
0
 /// <summary>  Produce a table of field values from a SIF Data Object.
 /// 
 /// This <c>map</c> method populates the supplied IDictionary with element
 /// or attribute values from the SifDataObject by evaluating all field rules
 /// defined by this Mappings object for the associated SIF Data Object type.
 /// Field rules are only evaluated if no entry currently exists in the
 /// IDictionary. Consequently, the caller may pre-load the IDictionary with known
 /// field values if possible and they will not be overridden by the mapping
 /// process.
 /// 
 /// 
 /// This method is intended to obtain element and attribute values from a
 /// SifDataObject <i>consumed</i> by the agent when processing SIF
 /// Events or SIF Responses. In contrast, the other form of the <c>map</c>
 /// method is intended to populate a new SifDataObject instance when an
 /// agent is <i>publishing</i> objects to a zone.
 /// 
 /// 
 /// To use this method,
 /// 
 /// <ol>
 /// <item><term>
 /// Create a IDictionary and optionally populate it with known field
 /// values that will not be subject to the mapping process. If pre-loading
 /// the IDictionary, the key of each entry should be the local
 /// application-defined field name and the value should be the string
 /// value of that field. Any field added to the IDictionary before calling
 /// this method will not be subject to mapping rules.
 /// </term></item>
 /// <item><term>
 /// Call this <c>map</c> method, passing the SifDataObject
 /// instance to retrieve field values from for insertion into the
 /// IDictionary. The method first looks up the ObjectMapping instance
 /// corresponding to the SIF Data Object type. If no ObjectMapping
 /// has been defined for the object type, no action is taken and the
 /// method returns successfully without exception. Otherwise, all
 /// field rules defined by the ObjectMapping are evaluated in order.
 /// If a rule evaluates successfully, the corresponding element or
 /// attribute value will be inserted into the IDictionary. A rule will
 /// not be evaluated if the associated field already exists in the
 /// IDictionary.
 /// </term></item>
 /// </ol>
 /// 
 /// </summary>
 /// <param name="dataObject">The SifDataObject from which to retrieve element and
 /// attribute values from when performing the mapping operation.
 /// 
 /// </param>
 /// <param name="results">A IDictionary to receive the results of the mapping, where
 /// each entry in the map is keyed by the local application-defined name
 /// of a field and the value is the text value of the corresponding
 /// element or attribute in the SifDataObject.
 /// 
 /// </param>
 /// <exception cref="AdkMappingException">  thrown if an error occurs while evaluating
 /// a field rule
 /// </exception>
 public void MapInbound(SifDataObject dataObject,
                        IFieldAdaptor results)
 {
     MapInbound(dataObject, results, Adk.SifVersion);
 }
Example #13
0
 /// <summary>Sets an element or attribute value identified by an XPath-like query string.</summary>
 /// <remarks>
 ///   NOTE: This method makes calls to SIFXPathContext. If multiple calls to
 ///  <c>setElementOrAttribute</c> are being done, it is much more efficient to create
 ///  a new <c>SifXPathContext</c> by calling <c>SifXPathContext.NewInstance(sdo)</c> and then
 /// calling <c>.SetElementorAttributeon</c> on that SifXPathContext instance
 /// </remarks>
 /// <param name="xpath">An XPath-like query string that identifies the element or
 /// attribute to set. The string must reference elements and attributes
 /// by their <i>version-independent</i> names.
 /// </param>
 /// <param name="valu">The value to assign to the element or attribute if the
 /// query string does not set a value; may be null
 /// </param>
 /// <param name="adaptor"> A data source may be used for variable
 /// substitutions within the query string
 /// </param>
 public virtual void SetElementOrAttribute( string xpath,
                                            string valu,
                                            IFieldAdaptor adaptor )
 {
     SifVersion = Adk.SifVersion;
     SifXPathContext spc = SifXPathContext.NewSIFContext( this );
     if ( adaptor is IXPathVariableLibrary )
     {
         spc.AddVariables( "", (IXPathVariableLibrary) adaptor );
     }
     spc.SetElementOrAttribute( xpath, valu );
 }
 public TestValueBuilder( IFieldAdaptor data )
     : base(data)
 {
 }
        private SifXPathContext GetXPathContext(
            SifElement mappedElement, IFieldAdaptor adaptor)
        {
            lock (this)
            {
                if (!mappedElement.ElementDef.Name.Equals(fElementDef.Name))
                {
                    throw new AdkMappingException(
                        "Unable to use object for mapping. MappingsContext expected an object of type '" +
                        fElementDef.Name + "' but was '" + mappedElement.ElementDef.Name + "'.", null);
                }

                if (fRootContext == null)
                {
                    fRootContext = SifXPathContext.NewSIFContext(mappedElement, fSIFVersion);
                    if (adaptor is IXPathVariableLibrary)
                    {
                        fRootContext.AddVariables( "", (IXPathVariableLibrary)adaptor);
                    }
                }
                return SifXPathContext.NewSIFContext(fRootContext, mappedElement);
            }
        }
Example #16
0
 /// <summary>  Populate a SifDataObject from values in the supplied IDictionary.
 /// 
 /// This form of the <c>map</c> method that accepts a custom 
 /// <c>ValueBuilder</c> implementation to evaluate value expressions 
 /// in XPath-like query strings. The <c>map</c> method uses the 
 /// DefaultValueBuilder class as its built-in implementation, but you can 
 /// supply your own by calling this method instead.
 /// 
 /// </summary>
 /// <param name="adaptor">An IFieldAdaptor that contains field values to assign to the
 /// supplied SifDataObject, where each entry in the map is keyed by the
 /// local application-defined name of a field and the value is the text
 /// value to assign to the corresponding element or attribute of the
 /// SifDataObject.
 /// 
 /// </param>
 /// <param name="adaptor">An IFieldAdaptor containing field values</param>
 /// <param name="data">The SifDataObject to assign field values to
 /// 
 /// </param>
 /// <param name="valueBuilder">A custom ValueBuilder implementation to evaluate
 /// value expressions in XPath-like query strings
 /// 
 /// </param>
 /// <exception cref="AdkMappingException">  thrown if an error occurs while
 /// evaluating a field rule
 /// </exception>
 public void MapOutbound(IFieldAdaptor adaptor,
                         SifDataObject data,
                         IValueBuilder valueBuilder)
 {
     MapOutbound(adaptor, data, valueBuilder, Adk.SifVersion);
 }
Example #17
0
 /// <summary>
 /// Populate a SifDataObject from values in the supplied IDictionary.
 /// </summary>
 /// <param name="adaptor">An IFieldAdaptor that contains field values to assign to the
 /// supplied SifDataObject, where each entry in the map is keyed by the
 /// local application-defined name of a field and the value is the text
 /// value to assign to the corresponding element or attribute of the
 /// SifDataObject.</param>
 /// <param name="dataObject">The SifDataObject to assign field values to</param>
 /// <param name="version">The SifVersion associated with the mapping operation. 
 /// For inbound SIF_Event and SIF_Response messages, this value should 
 /// be obtained by calling <c>getSIFVersion</c> on the 
 /// <i>SifMessageInfo</i> parameter passed to the message handler. For 
 /// inbound SIF_Request messages, it should be obtained by calling the
 /// <c>SifMessageInfo.getSIFRequestVersion</c> method. For 
 /// outbound messages, this value should be obtained by calling
 /// <c>Adk.getSIFVersion</c> to get the version of SIF the class
 /// framework was initialized with. Note when this parameter is 
 /// <c>null</c>, no SIF Version filtering will be applied to 
 /// field mapping rules.</param>
 public void MapOutbound(IFieldAdaptor adaptor,
                         SifDataObject dataObject,
                         SifVersion version)
 {
     MapOutbound(adaptor, dataObject, new DefaultValueBuilder(adaptor), version);
 }
 public TestValueBuilder(IFieldAdaptor data) : base(data)
 {
 }
Example #19
0
        internal void MapOutbound(
            SifXPathContext context,
            IFieldAdaptor adaptor,
            SifElement dataObject,
            ICollection<FieldMapping> fields,
            IValueBuilder valueBuilder,
            SifVersion version)
        {
            #if PROFILED
            if( BuildOptions.PROFILED ){
            ProfilerUtils.profileStart( String.valueOf( com.OpenADK.sifprofiler.api.OIDs.ADK_OUTBOUND_TRANSFORMATIONS ), dataObject.getElementDef(), null );
            }
            #endif

            SifFormatter textFormatter = Adk.TextFormatter;
            FieldMapping lastRule = null;
            try
            {
                foreach (FieldMapping fm in fields)
                {
                    lastRule = fm;
                    String fieldName = fm.Alias;
                    if (fieldName == null)
                    {
                        fieldName = fm.FieldName;
                    }

                    if (fieldName == null || fieldName.Length == 0)
                    {
                        throw new AdkMappingException(
                            "Mapping rule for " + dataObject.ElementDef.Name + "[" + fm.FieldName +
                            "] must specify a field name", null);
                    }

                    if (adaptor.HasField(fieldName) || fm.HasDefaultValue)
                    {
                        //
                        //  For outbound mapping operations, only process
                        //	XPathRules. All other rule types, like OtherIdRule,
                        //  are only intended to be used for inbound mappings.
                        //
                        if (fm.fRule is XPathRule)
                        {
                            XPathRule rule = (XPathRule) fm.fRule;
                            //  Lookup or create the element/attribute referenced by the rule
                            String ruledef = rule.XPath;
                            if (ruledef == null || ruledef.Trim().Length == 0)
                            {
                                throw new AdkMappingException(
                                    "Mapping rule for " + dataObject.ElementDef.Name + "[\"" + fieldName +
                                    "\"] must specify a path to an element or attribute", null);
                            }

                            // TT 199 If the FieldMapping has an "ifnull" value of "suppress",
                            // don't render a result

                            // Determine if this element should be created before attempting to create it
                            // If the value resolves to null and the IFNULL_SUPPRESS flag is set, the element
                            // should not be created. That's why we have to look up the ElementDef first
                            TypeConverter typeConverter = null;
                            IElementDef def = rule.LookupTargetDef(dataObject.ElementDef);
                            if (def != null)
                            {
                                typeConverter = def.TypeConverter;
                            }
                            if (typeConverter == null)
                            {
                                typeConverter = SifTypeConverters.STRING;
                                // TODO: Perhaps the following exception should be thrown when
                                // in STRICT mode
                                //	throw new ADKMappingException( "Element {" + def.name() +
                                //				"} from rule \"" + ruledef + "\" does not have a data type definition.", null );
                            }

                            SifSimpleType mappedValue;
                            mappedValue = adaptor.GetSifValue(fieldName, typeConverter, fm);

                            // Perform a valueset translation, if applicable
                            if (mappedValue != null &&
                                mappedValue is SifString &&
                                fm.ValueSetID != null)
                            {
                                String textValue = mappedValue.ToString();
                                //	Perform automatic ValueSet translation
                                ValueSet vs = GetValueSet(fm.ValueSetID, true);
                                if (vs != null)
                                {
                                    // TT 199. Perform a more detailed valueset translation.
                                    // If there is a default value for this field, use it if there is
                                    // no match found in the value set
                                    textValue = vs.Translate(textValue, fm.DefaultValue);
                                }
                                mappedValue = new SifString(textValue);
                            }

                            bool usedDefault = false;
                            if (mappedValue == null || mappedValue.RawValue == null)
                            {
                                // If the FieldMapping has a Default value, use that, unless
                                // it is explicitly suppressed
                                if (fm.NullBehavior != MappingBehavior.IfNullSuppress && fm.HasDefaultValue)
                                {
                                    mappedValue = fm.GetDefaultValue(typeConverter, textFormatter);
                                    usedDefault = true;
                                }
                                else
                                {
                                    continue;
                                }
                            }

                            if (!usedDefault)
                            {
                                String valueExpression = rule.ValueExpression;
                                if (valueExpression != null)
                                {
                                    // This XPath rule has a value assignment expression at the end of it
                                    String value = valueBuilder.Evaluate(valueExpression);
                                    mappedValue = typeConverter.Parse(textFormatter, value);
                                }
                            }

                            // If we have a null value to assign at this point, move on to the next rule
                            if (mappedValue == null || mappedValue.RawValue == null)
                            {
                                continue;
                            }

                            // At this point, mappedValue should not be null. We are committeed
                            // to building out the path and setting the value.
                            INodePointer pointer = rule.CreatePath(context, version);
                            //  If the element/attribute does not have a value, assign one.
                            //	If it does have a value, it was already assigned by the XPath
                            //	rule in the lookupByXPath method above and should not be
                            //	changed.
                            //
                            if (pointer != null)
                            {
                                Element pointedElement = (Element) pointer.Value;
                                SifSimpleType elementValue = pointedElement.SifValue;
                                if (elementValue == null || elementValue.RawValue == null)
                                {
                                    if (mappedValue is SifString)
                                    {
                                        // Now that we have the actual element, we may need to create convert the
                                        // data if we were unable to resolve the TypeConverter above. This only happens
                                        // in cases involving surrogates where the rule.lookupTargetDef( dataObject.getElementDef() );
                                        // fails to find the target ElementDef
                                        TypeConverter converter = pointedElement.ElementDef.TypeConverter;
                                        if (converter != null && converter.DataType != mappedValue.DataType)
                                        {
                                            mappedValue = converter.Parse(textFormatter, mappedValue.ToString());
                                        }
                                    }

                                    // This check for null should really not be necessary,
                                    // however keepingit in for now
                                    if (mappedValue != null)
                                    {
                                        pointedElement.SifValue = mappedValue;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (lastRule != null)
                {
                    throw new AdkMappingException(
                        "Unable to evaluate field rule: " + lastRule.fRule + " : " + e.Message, null, e);
                }
                throw new AdkMappingException(e.ToString(), null, e);
            }
            #if PROFILED
            finally
            {

            if( BuildOptions.PROFILED )
                ProfilerUtils.profileStop();
            }
            #endif
        }
Example #20
0
        internal void MapInbound(
            SifXPathContext xpathContext,
            IFieldAdaptor results,
            SifElement inboundObject,
            ICollection<FieldMapping> fields,
            SifVersion version)
        {
            #if PROFILED
            if( BuildOptions.PROFILED ){
            ProfilerUtils.profileStart( String.valueOf( com.OpenADK.sifprofiler.api.OIDs.ADK_INBOUND_TRANSFORMATIONS ), inboundObject.getElementDef(), null );
            }
            #endif

            FieldMapping lastRule = null;
            try
            {
                foreach (FieldMapping rule in fields)
                {
                    lastRule = rule;
                    if (!results.HasField(rule.FieldName))
                    {
                        SifSimpleType val = rule.Evaluate(xpathContext, version, true);
                        if (val != null)
                        {
                            if (rule.ValueSetID != null &&
                                val is SifString)
                            {
                                String currentValue = val.ToString();
                                //	Perform automatic ValueSet translation
                                // TT 199. Perform a more detailed valueset translation.
                                // If there is a default value set, use it if there is
                                // no match found in the value set
                                ValueSet vs = GetValueSet(rule.ValueSetID, true);
                                if (vs != null)
                                {
                                    currentValue = vs.TranslateReverse(currentValue, rule.DefaultValue);
                                }
                                val = new SifString(currentValue);
                            }
                            results.SetSifValue(rule.FieldName, val, rule);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (lastRule != null)
                {
                    throw new AdkMappingException(
                        "Unable to evaluate field rule: " + lastRule.fRule + " : " + e.Message, null, e);
                }
                throw new AdkMappingException(e.ToString(), null, e);
            }
        }
Example #21
0
        /// <summary>  Populate a SifDataObject from values in the supplied IDictionary.
        /// 
        /// This form of the <c>map</c> method allows the caller to specify 
        /// whether it is performing an inbound or outbound mapping operation,
        /// as well as the version of SIF associated with the SIF Data Object
        /// that's being mapped. These values are used to filter field mapping rules. 
        /// The direction flag is also used to invoke automatic ValueSet 
        /// translations on fields that have a <i>ValueSet</i> attribute.
        /// 
        /// </summary>
        /// <param name="adaptor">An IFieldAdaptor that contains field values to assign to the
        /// supplied SifDataObject, where each entry in the map is keyed by the
        /// local application-defined name of a field and the value is the text
        /// value to assign to the corresponding element or attribute of the
        /// SifDataObject.
        /// 
        /// </param>
        /// <param name="dataObject">The SifDataObject to assign field values to
        /// 
        /// </param>
        /// <param name="valueBuilder">A custom ValueBuilder implementation to evaluate
        /// value expressions in XPath-like query strings
        /// 
        /// </param>
        /// <param name="version">The SifVersion associated with the mapping operation. 
        /// For inbound SIF_Event and SIF_Response messages, this value should 
        /// be obtained by calling <c>getSIFVersion</c> on the 
        /// <i>SifMessageInfo</i> parameter passed to the message handler. For 
        /// inbound SIF_Request messages, it should be obtained by calling the
        /// <c>SifMessageInfo.getSIFRequestVersion</c> method. For 
        /// outbound messages, this value should be obtained by calling
        /// <c>Adk.getSIFVersion</c> to get the version of SIF the class
        /// framework was initialized with. Note when this parameter is 
        /// <c>null</c>, no SIF Version filtering will be applied to 
        /// field mapping rules.
        /// 
        /// </param>
        /// <exception cref="AdkMappingException">  thrown if an error occurs while
        /// evaluating a field rule</exception>
        public void MapOutbound(IFieldAdaptor adaptor,
                                SifDataObject dataObject,
                                IValueBuilder valueBuilder,
                                SifVersion version)
        {
            ObjectMapping om = GetRules(dataObject.ElementDef.Tag(version), true);
            if (om != null)
            {
                SifXPathContext xpathContext = SifXPathContext.NewSIFContext(dataObject, version);
                if (adaptor is IXPathVariableLibrary)
                {
                    xpathContext.AddVariables("", (IXPathVariableLibrary) adaptor);
                }

                IList<FieldMapping> list = GetRulesList(om, version, MappingDirection.Outbound);
                MapOutbound(xpathContext, adaptor, dataObject, list, valueBuilder, version);
            }
        }
 /// <summary>
 /// Creates an instance of DefaultValueBuilder that builds values based
 /// on the SIFDataMap, using the specified <c>SIFFormatter</c> instance
 /// </summary>
 /// <param name="data"></param>
 /// <param name="formatter"></param>
 public DefaultValueBuilder(IFieldAdaptor data, SifFormatter formatter)
 {
     fVars      = data;
     fFormatter = formatter;
 }
Example #23
0
 /// <summary>  Produce a table of field values from a SIF Data Object.
 /// 
 /// This form of the <c>map</c> method allows the client to specify 
 /// whether it is performing an inbound or outbound mapping operation.
 /// Currently, the direction flag is used to invoke automatic ValueSet
 /// translations on fields that have a <i>ValueSet</i> attribute.
 /// 
 /// </summary>
 /// <param name="data">The SifDataObject from which to retrieve element and
 /// attribute values from when performing the mapping operation.
 /// 
 /// </param>
 /// <param name="results">A IDictionary to receive the results of the mapping, where
 /// each entry in the map is keyed by the local application-defined name
 /// of a field and the value is the text value of the corresponding
 /// element or attribute in the SifDataObject.</param>
 /// <param name="version">The SifVersion associated with the mapping operation. 
 /// For inbound SIF_Event and SIF_Response messages, this value should 
 /// be obtained by calling <c>getSIFVersion</c> on the 
 /// <i>SifMessageInfo</i> parameter passed to the message handler. For 
 /// inbound SIF_Request messages, it should be obtained by calling the
 /// <c>SifMessageInfo.getSIFRequestVersion</c> method. For 
 /// outbound messages, this value should be obtained by calling
 /// <c>Adk.getSIFVersion</c> to get the version of SIF the class
 /// framework was initialized with. Note when this parameter is 
 /// <c>null</c>, no SIF Version filtering will be applied to 
 /// field mapping rules.
 /// 
 /// </param>
 /// <exception cref="AdkMappingException">  thrown if an error occurs while evaluating
 /// a field rule
 /// 
 /// @since Adk 1.5
 /// </exception>
 public void MapInbound(SifDataObject data,
                        IFieldAdaptor results,
                        SifVersion version)
 {
     ObjectMapping om = GetRules(data.ElementDef.Tag(data.SifVersion), true);
     if (om != null)
     {
         SifXPathContext xpathContext = SifXPathContext.NewSIFContext(data, version);
         if (results is IXPathVariableLibrary)
         {
             xpathContext.AddVariables("", (IXPathVariableLibrary) results);
         }
         IList<FieldMapping> list = GetRulesList(om, version, MappingDirection.Inbound);
         MapInbound(xpathContext, results, data, list, version);
     }
 }