[This is preliminary documentation and is subject to change.]
| C# | Visual Basic | Visual C++ |
public class Mappings
Public Class Mappings
public ref class Mappings
| All Members | Constructors | Methods | Properties | Fields | |
| Icon | Member | Description |
|---|---|---|
| MappingsMappingsNew()() | Constructs the root-level Mappings container | |
| MappingsMappingsNew(Mappings, String) | Constructs a child Mappings object with no filters.
| |
| MappingsMappingsNew(Mappings, String, String, String, String) | Constructs a child Mappings object with optional filters.
| |
| AddChild(Mappings) | Adds a Mappings child | |
| AddRules(ObjectMapping) | Add an ObjectMapping definition to this Mappings instance | |
| AddValueSet(ValueSet) | Add a ValueSet to this Mappings instance | |
| AllowsSourceId(String) | Determines if this nested Mappings instance allows the specified SourceId.
This method is only called on nested children of a Mappings object, never
on a top-level Mappings object because top-level parents always allow all
ZoneIds, SourceIds, and SIF Versions.
| |
| AllowsVersion(SifVersion) | Determines if this nested Mappings instance allows the specified version of SIF
This method is only called on nested children of a Mappings object, never
on a top-level Mappings object because top-level parents always allow all
ZoneIds, SourceIds, and SIF Versions.
| |
| AllowsZoneId(String) | Determines if this nested Mappings instance allows the specified ZoneId.
This method is only called on nested children of a Mappings object, never
on a top-level Mappings object because top-level parents always allow all
ZoneIds, SourceIds, and SIF Versions.
| |
| ChildCount | Count the number of Mappings children | |
| Children | Return an array of all Mappings children | |
| Copy(Mappings) | Creates a copy of this Mappings object and adds the copy as a child of
the specified parent. Note the root Mappings container cannot be copied.
If this method is called on the root an exception is raised.
This method performs a "deep copy", such that a copy is made of each
child Mappings, ObjectMapping, FieldMapping, ValueSet, and Property
instance.
| |
| CreateChild(String) | Create a Mappings child | |
| GetMappings(String) | Gets the Mappings object with the specified ID.
Unlike the select methods, getMappings should
be called when the agent knows the specific Mappings object it is going
to use to perform a mapping operation. Conversely, the select
methods select the most appropriate Mappings object based on the ZoneId,
SourceId, and SifVersion values passed to those methods.
| |
| GetObjectMapping(String, Boolean) | ||
| GetObjectMappings()() | Gets all ObjectMappings defined for this Mappings instance, including
those inherited by its parents.
| |
| GetObjectMappings(Boolean) | Gets all ObjectMappings defined for this Mappings instance, optionally
including those inherited by its parents.
| |
| GetProperty(String, String) | Gets a user-defined property.
| |
| GetRoot()() | Gets the root Mappings container. | |
| GetRules(SifDataObject, Boolean) | Return an array of all ObjectMapping definitions for a given object type. | |
| GetRules(String, Boolean) | Returns the ObjectMapping for a given object type. | |
| GetSIFVersionFilter()() | Returns the SifVersion filters in effect for this Mappings instance.
A Mappings instances always inherits the filters of its ancestry.
| |
| GetSourceIdFilter()() | Returns the SourceId filters in effect for this Mappings instance.
A Mappings instances always inherits the filters of its ancestry.
| |
| GetValueSet(String, Boolean) | Gets a ValueSet by ID. | |
| GetValueSets(Boolean) | Gets all ValueSets for this Mappings instance. | |
| GetZoneIdFilter()() | Returns the ZoneId filters in effect for this Mappings instance.
A Mappings instances always inherits the filters of its ancestry.
| |
| HasProperty(String) | Determines if a user-defined property is currently set on this Mappings instance.
| |
| Id | Gets the unique ID of this Mappings instance | |
| IsRoot()() | Determines if this is the root Mappings container. Applications may call
the select and map methods on the root
container only.
| |
| Main(array<String>[]()) | Displays the Mappings defined by a configuration file
Usage: Mappings config.xml [[/zone=zoneId /sifVersion=version /sourceId=sourceId] /v]
When the /zone, /sifVersion, or /sourceId parameters are specified, the
Mappings.select method is called to select the Mappings object that most
closely matches the Zone(s), SIF Version, and SourceId value(s).
All three options must be specified. When these options are not present,
all Mappings are written to System.out
When the /v option is specified, the configuration file is parsed with a
validating parser.
| |
| Map(SifDataObject, IDictionary) | Produce a table of field values from a SIF Data Object.
This map 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 consumed by the agent when processing SIF
Events or SIF Responses. In contrast, the other form of the map
method is intended to populate a new SifDataObject instance when an
agent is publishing objects to a zone.
To use this method,
| |
| Map(SifDataObject, IDictionary, MappingDirection, SifVersion) | Produce a table of field values from a SIF Data Object.
This form of the map 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 ValueSet attribute.
| |
| Map(IDictionary, SifDataObject) | Populate a SifDataObject from values in the supplied IDictionary by evaluating
all field rules for the associated SIF Data Object type. For each key in
the IDictionary, the corresponding field rule is evaluated to assign the
IDictionary value to the appropriate element or attribute in the SifDataObject.
If a field is not represented in the IDictionary, its associated rule will
not be evaluated.
This method is intended to populate a new SifDataObject instance when an
agent is publishing objects to a zone. The other form of the
map method is intended to obtain element and attribute values
from a SifDataObject consumed by the agent when processing SIF
Events or SIF Responses.
To use this method,
| |
| Map(IDictionary, SifDataObject, IValueBuilder) | Populate a SifDataObject from values in the supplied IDictionary.
This form of the map method that accepts a custom
ValueBuilder implementation to evaluate value expressions
in XPath-like query strings. The map method uses the
DefaultValueBuilder class as its built-in implementation, but you can
supply your own by calling this method instead.
| |
| Map(IDictionary, SifDataObject, MappingDirection) | Populate a SifDataObject from values in the supplied IDictionary.
This form of the map 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 ValueSet attribute.
| |
| Map(IDictionary, SifDataObject, MappingDirection, SifVersion) |
Populate a SifDataObject from values in the supplied IDictionary.
| |
| Map(IDictionary, SifDataObject, IValueBuilder, MappingDirection, SifVersion) | Populate a SifDataObject from values in the supplied IDictionary.
This form of the map 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 ValueSet attribute.
| |
| Parent | Gets the parent Mappings instance | |
| Populate(XmlDocument, XmlElement) | Populate the Mappings hierarchy from an XML Document.
This method can only be called on the root Mappings object or an exception
is raised. It reads all <mapping> elements from the Document to build
the Mappings hierarchy.
| |
| PropertyNames | Gets the names of all user-defined properties currently set on this Mappings instance.
| |
| RemoveChild(Mappings) | Removes a Mappings child | |
| RemoveRules(ObjectMapping) | Remove an ObjectMapping definition from this Mappings instance | |
| RemoveValueSet(ValueSet) | Remove a ValueSet from this Mappings instance.
If the ValueSet has a DOM XmlElement attached to it, it is removed from its
parent XmlElement and dereferenced.
| |
| RemoveValueSet(String) | Remove a ValueSet from this Mappings instance.
If a ValueSet with the specified ID is found, it is removed from this
Mappings and returned; otherwise no action is taken. If the ValueSet has
a DOM XmlElement attached to it, it is removed from its parent XmlElement and
dereferenced.
| |
| Select(String, String, SifVersion) | Selects the appropriate Mappings object to use for map
operations. Call this method on the root Mappings object to obtain a
Mappings instance, then call its map method to perform a
mapping operation.
The selection process is as follows:
| |
| SetProperty(String, String) | Set a user-defined property.
| |
| SetSIFVersionFilter(String) | Sets a SifVersion filter on this Mappings object.
| |
| SetSourceIdFilter(String) | Sets a SourceId filter on this Mappings object.
| |
| SetZoneIdFilter(String) | Sets a ZoneId filter on this Mappings object.
| |
| SIFVersionFilterString | Returns the SIF Version filters in effect for this Mappings instance as a
comma-delimited string.
| |
| SourceIdFilterString | Returns the SourceId filters in effect for this Mappings instance as a
comma-delimited string.
| |
| ToDom(XmlDocument) | Produces a DOM XmlElement graph of this Mappings object
| |
| ToXml()() | Returns the Mappings as a string in XML form | |
| ToXml(Boolean) | Returns the Mappings as a string in XML form.
| |
| XML_FIELD | ||
| XML_MAPPINGS | ||
| XML_OBJECT | ||
| XmlElement | Gets or Sets the optional DOM XmlElement associated with this Mappings instance. The
DOM XmlElement is set when a Mappings object is populated from a DOM Document.
| |
| ZoneIdFilterString | Returns the Zone ID filters in effect for this Mappings instance as a
comma-delimited string.
|
The Mappings class is a powerful facility for programmatically transforming sets of field/value pairs into SifDataObject instances based on XPath-like mapping rules. These rules can be read from any DOM Document or configuration file read and written by the AgentConfig class, which makes them easily customizable by the end-user.
Mappings are arranged into a selection hierarchy so that different sets of rules can be created for individual zones, agent SourceIds, and versions of SIF. Rules at lower levels in the hierarchy are inherited from higher levels. Thus, you could create a default set of rules describing how to produce StudentPersonal objects for all zones, and extend or override these rules in a set of child rules that are specific to an individual zone. When selecting the Mappings object for the SIF Message being processed, the select method would choose the zone-specific set of rules over the default rules, but would inherit any default field mappings not explicitly overridden. This technique is very useful when the mapping rules of a SIF Agent differ from zone-to-zone or from one version of SIF to the next.
OverviewEach Mappings object is comprised of one or more of the following:
ObjectMappings that defines how to map fields of the application to a SIF Data Object's elements and attributes. Create one ObjectMapping per SIF Data Object type (e.g. for "StudentPersonal", "BusInfo", etc.) An ObjectMapping instance is in turn comprised of one or more FieldMapping objects, each of which is comprised of a Rule. Two Rule implementations are currently defined: XPathRule, which uses an XPath-like query string to describe how to interpret or build a SIF element or attribute; and OtherIdRule, which describes how to interpret or build <OtherId> values.
ValueSets that define a simple mapping from codes and constants used in the application to equivalent codes and constants used by SIF. A ValueSet could be used, for example, to define a mapping table for Grade Levels, Ethnicity Codes, English Proficiency Codes, etc.
User-defined properties comprised of a name and value pair.
Mappings HierarchyMappings objects form a hierarchy comprised of a root Mappings object -- which is always present and does not have an ID -- and one or more child Mappings of the root. The root serves as a container for all other Mappings objects. Each child of the root container must be assigned a unique ID. Mappings may also be assigned an optional ZoneId filter, SourceId filter, an SIF Version filter.
The unique ID is used to select a Mappings object at runtime when multiple groups of Mappings are present. If you only have one Mappings object, it is recommended that it be given an ID of "default". However, agents that both provide and consume objects will usually define two groups of Mappings objects: one used in the translation of incoming messages and another used in the production of outgoing messages. In this case it is recommended that two Mappings objects be defined, one with an ID of "incoming" or similar and the other with an ID of "outgoing" or similar.
When Mappings are nested, child Mappings inherit the filters, ObjectMappings, ValueSets, and properties of the parent.
SourceId FilterWhen a SourceId filter is assigned to a Mappings object, the select method will exclude any Mappings object that does not include the SourceId passed to that method. If you have tested your agent with several Student Information Systems, for example, you may wish to define the unique mapping rules for each SIS in a separate Mappings object where the SourceId filter includes the SourceId of the SIS agent.
ZoneId FilterWhen a ZoneId filter is assigned to a Mappings object, the select method will exclude any Mappings instance that does not include the ZoneId passed to that method. The ZoneId filter can be used to customize mappings on a zone-by-zone basis.
SifVersion FilterWhen a SifVersion filter is assigned to a Mappings object, the select method will exclude any Mappings instance that does not include the SIF Version passed to that method. Such a filter can be used to customize mappings for a specific version of SIF. This is often necessary if the tag names of elements or attributes have changed from one version of SIF to the next. In this case, the XPath-like rules that you include in a Mappings object must reflect the element and attribute names of each version of SIF.
Mappings RulesMapping rules are comprised of one or more ObjectMapping and FieldMapping objects that define how to map a field of the local application's database to a SIF Data Object element or attribute. When multiple mappings are defined for a field, the first one that evaluates true is selected. The map method that accepts a SifElement object evaluates the rules of a Mappings object against a SIF Data Object instance to produce a IDictionary of values. Each entry in the table is a key/value pair where the key is the name of the local application field and the value is the value from the SIF Data Object that mapped to that field. Thus, an agent can call the map method to obtain a table of values for each SIF Data Object it is processing. The Mappings class can also be used to produce a SIF Data Object instance from a IDictionary prepared by the agent. Call the map method that accepts a IDictionary instance to return a SifElement object.
Mappings are comprised of a hierarchy of ObjectMapping and FieldMapping object. The ObjectMapping class encapsulates a SIF Data Object type such as StudentPersonal and BusInfo. Each ObjectMapping contains one or more FieldMapping objects to define a field-level mapping. Mapping rules are specified in an XPath-like format relative to the SIF Data Object type named in the ObjectMapping.
XML ConfigurationThe populate method constructs a Mappings hierarchy from a parsed DOM Document. The populate method can only be called on the root Mappings container. Consult the Mappings.dtd file in the Adk's Extras directory for the expected schema.
Author: Eric Petersen
Version: Adk 1.0
Create a Mappings instance and populate it with Mappings children. The easiest way to accomplish this is to call the read method to read an XML configuration file or the populate method to populate a Mappings instance from a DOM Document. Refer to the Adk Developer Guide for more information.
When your agent needs to map local application field values to SIF Data Object elements and attributes, call the select method to select the appropriate Mappings instance based on ZoneId, SourceId, and SIF Version. The select method returns a Mappings instance.
Call the map method to produce a SifDataObject from a IDictionary of field values prepared by your application (i.e. when preparing outbound messages), or to populate a IDictionary from a SifDataObject (i.e. when processing inbound messages).| Object | |
| Mappings | |