private Mappings buildMappings1() { // root Mappings root = new Mappings(); // root.Default Mappings defaults = new Mappings(root, "Default", null, null, null); root.AddChild(defaults); // root.Default.StudentPersonal ObjectMapping studentMappings = new ObjectMapping("StudentPersonal"); defaults.AddRules(studentMappings); studentMappings.AddRule(new FieldMapping("REFID", "@RefId")); // root.Default.MA Mappings massachusetts = new Mappings(defaults, "MA", null, null, null); defaults.AddChild(massachusetts); // root.Default.MA.StudentPersonal studentMappings = new ObjectMapping("StudentPersonal"); massachusetts.AddRules(studentMappings); studentMappings.AddRule(new FieldMapping("LOCALID", "LocalId")); studentMappings.AddRule(new FieldMapping("FIRSTNAME", "Name[@Type='01']/FirstName")); studentMappings.AddRule(new FieldMapping("LASTNAME", "Name[@Type='01']/LastName")); // root.Default.MA.Boston Mappings boston = new Mappings(massachusetts, "Boston", null, "Boston", null); massachusetts.AddChild(boston); // root.Default.MA.Boston.StudentPersonal studentMappings = new ObjectMapping("StudentPersonal"); boston.AddRules(studentMappings); studentMappings.AddRule(new FieldMapping("BIRTHDAY", "Demographics/BirthDate")); return(root); }
public void testCreateMappings() { // Create the root instance Mappings root = new Mappings(); // Create the default set of universal mappings Mappings defaults = new Mappings(root, "Default"); root.AddChild(defaults); // Create an ObjectMapping for StudentPersonal ObjectMapping studentMappings = new ObjectMapping("StudentPersonal"); defaults.AddRules(studentMappings); // Add field rules studentMappings.AddRule(new FieldMapping("FIRSTNAME", "Name[@Type='04']/FirstName")); studentMappings.AddRule(new FieldMapping("LASTNAME", "Name[@Type='04']/LastName")); // Create a set of mappings for the state of Wisconsin Mappings wisconsin = new Mappings(defaults, "Wisconsin"); defaults.AddChild(wisconsin); // Create a set of mappings for the Neillsville School District Mappings neillsville = new Mappings(wisconsin, "Neillsville"); wisconsin.AddChild(neillsville); XmlDocument doc = new XmlDocument( ); doc.LoadXml("<agent/>"); XmlElement n = root.ToDom(doc); debug(doc); }
/** * Creates a set of mappings that operations can be applied to, such as * saving to a DOM or Agent.cfg. The results can be asserted by calling * {@see #assertMappings(Mappings)}. * * NOTE: This method returns an AgentConfig instance instead of a mappings * instance because there is no way set the Mappings instance on * AgentConfig. This might change in the future * * @return */ private AgentConfig createMappings() { Mappings root = fCfg.Mappings; // Remove the mappings being used root.RemoveChild(root.GetMappings("Default")); root.RemoveChild(root.GetMappings("TestID")); Mappings newMappings = root.CreateChild("Test"); // Add an object mapping ObjectMapping objMap = new ObjectMapping("StudentPersonal"); // Currently, the Adk code requires that an Object Mapping be added // to it's parent before fields are added. // We should re-examine this and perhaps fix it, if possible newMappings.AddRules(objMap); objMap.AddRule(new FieldMapping("FIELD1", "Name/FirstName")); // Field 2 FieldMapping field2 = new FieldMapping("FIELD2", "Name/LastName"); field2.ValueSetID = "VS1"; field2.Alias = "ALIAS1"; field2.DefaultValue = "DEFAULT1"; MappingsFilter mf = new MappingsFilter(); mf.Direction = MappingDirection.Inbound; mf.SifVersion = SifVersion.SIF11.ToString(); field2.Filter = mf; objMap.AddRule(field2); // Field 3 test setting the XML values after it's been added to the // parent object (the code paths are different) FieldMapping field3 = new FieldMapping("FIELD3", "Name/MiddleName"); objMap.AddRule(field3); field3.ValueSetID = "VS2"; field3.Alias = "ALIAS2"; field3.DefaultValue = "DEFAULT2"; MappingsFilter mf2 = new MappingsFilter(); mf2.Direction = MappingDirection.Outbound; mf2.SifVersion = SifVersion.SIF15r1.ToString(); field3.Filter = mf2; field3.NullBehavior = MappingBehavior.IfNullDefault; OtherIdMapping oim = new OtherIdMapping("ZZ", "BUSROUTE"); FieldMapping field4 = new FieldMapping("FIELD4", oim); objMap.AddRule(field4); field4.DefaultValue = "Default"; field4.ValueSetID = "vs"; field4.Alias = "alias"; field4.DefaultValue = null; field4.ValueSetID = null; field4.Alias = null; field4.NullBehavior = MappingBehavior.IfNullSuppress; // Field4 tests the new datatype attribute FieldMapping field5 = new FieldMapping("FIELD5", "Demographics/BirthDate"); objMap.AddRule(field5); field5.DataType = SifDataType.Date; // Add a valueset translation ValueSet vs = new ValueSet("VS1"); newMappings.AddValueSet(vs); // Add a few definitions for (int a = 0; a < 10; a++) { vs.Define("Value" + a, "SifValue" + a, "Title" + a); } vs.Define("AppDefault", "0000", "Default App Value"); vs.SetAppDefault("AppDefault", true); vs.Define("0000", "SifDefault", "Default Sif Value"); vs.SetSifDefault("SifDefault", false); // Add a valueset translation vs = new ValueSet("VS2"); newMappings.AddValueSet(vs); // Add a few definitions for (int a = 0; a < 3; a++) { vs.Define("q" + a, "w" + a, "t" + a); } vs.Define("AppDefault", "0000", "Default Value"); vs.SetAppDefault("AppDefault", true); vs.SetSifDefault("0000", true); return(fCfg); }