Ejemplo n.º 1
0
        public void TestConcatenateFieldsInbound020()
        {
            String customMappings =
                "<agent id='Repro' sifVersion='2.0'>"
                + "   <mappings id='Default'>"
                + "     <object object='StudentPersonal'>"
                +
                "       <field name='CITY_STATE_ZIP'>concat( AddressList/Address/City, ', ', AddressList/Address/StateProvince, '  ', AddressList/Address/PostalCode)</field>"
                + "</object></mappings></agent>";


            StudentPersonal sp = new StudentPersonal();

            sp.SetElementOrAttribute("AddressList/Address[@Type='04']/City", "Chicago");
            sp.SetElementOrAttribute("AddressList/Address[@Type='04']/StateProvince", "IL");
            sp.SetElementOrAttribute("AddressList/Address[@Type='04']/PostalCode", "50001");
            sp.SetElementOrAttribute("Name/LastName", "Johnson");

            Console.WriteLine("StudentPersonal=" + sp.ToXml());

            IDictionary map = doInboundMapping(customMappings, sp);

            String csz = (String)map["CITY_STATE_ZIP"];

            Console.WriteLine("City State Zip=" + csz);
            Assertion.AssertEquals("CityStateZip", "Chicago, IL  50001", map["CITY_STATE_ZIP"]);
        }
Ejemplo n.º 2
0
        public void testStudentPersonalSIF15r1()
        {
            IDictionary values = new Hashtable();

            values.Add("PERMNUM", "9798");
            values.Add("SOCSECNUM", "845457898");
            values.Add("SCHOOLNUM", "999");
            values.Add("SCHOOLNUM2", "999");
            values.Add("GRADE", "09");
            values.Add("HOMEROOM", "5");
            values.Add("LASTNAME", "Doe");
            values.Add("FIRSTNAME", "Jane");
            values.Add("MIDDLENAME", null);
            values.Add("NICKNAME", null);
            values.Add("MAILADDR", "5845 Test Blvd");
            values.Add("CITY", "slc");
            values.Add("STATE", "Utah");
            values.Add("COUNTRY", "");
            values.Add("ZIPCODE", "84093");
            values.Add("RESADDR", null);
            values.Add("RESCITY", null);
            values.Add("RESSTATE", null);
            values.Add("RESCOUNTRY", null);
            values.Add("RESZIPCODE", null);
            values.Add("BIRTHDATE", "20051209");
            values.Add("GENDER", "F");
            values.Add("ETHNICCODE", "W");
            values.Add("ENGPROF", "");
            values.Add("PRIMARYLNG", "");
            values.Add("TELEPHONE", null);

            StringMapAdaptor sma = new StringMapAdaptor(values);
            StudentPersonal  sp  = new StudentPersonal();

            Mappings m = fCfg.Mappings.GetMappings("Default").Select(null,
                                                                     null, null);

            m.MapOutbound(sma, sp, SifVersion.SIF15r1);
            Console.WriteLine(sp.ToXml());
            OtherIdList oil = sp.OtherIdList;
            bool        gradeMappingFound = false;

            foreach (OtherId oid in oil)
            {
                if ("ZZ".Equals(oid.Type) &&
                    oid.Value.StartsWith("GRADE"))
                {
                    Assertion.AssertEquals("OtherId[@Type=ZZ]GRADE: mapping", "GRADE:09", oid.Value);
                    gradeMappingFound = true;
                }
            }
            Assertion.Assert("GradeMapping found", gradeMappingFound);
        }
Ejemplo n.º 3
0
        public void OnEvent(Event evnt,
                            IZone zone,
                            IMessageInfo info)
        {
            // Demonstrates basic handling of a SIF Event
            Console.WriteLine("Received a " + evnt.ActionString + " event for LearnerPersonal");
            StudentPersonal sp = (StudentPersonal)evnt.Data.ReadDataObject();

            // Simply write the XML of the event object to System.out
            Console.WriteLine(sp.ToXml());
            Console.WriteLine("End Event");
        }
Ejemplo n.º 4
0
        public void TestWriteXSINill()
        {
            StudentPersonal sp = new StudentPersonal();

            sp.RefId           = Adk.MakeGuid();
            sp.StateProvinceId = "\u06DE55889";
            sp.LocalId         = "987987987987987";
            Name name = new Name(NameType.LEGAL, "Johnson", "Steve");

            sp.Name = name;
            name.SetField(CommonDTD.NAME_TYPE, new SifString(null));
            name.SetField(CommonDTD.NAME_MIDDLENAME, new SifString(null));

            SIF_ExtendedElement see = new SIF_ExtendedElement("FOO", null);

            see.SetField(GlobalDTD.SIF_EXTENDEDELEMENT, new SifString(null));
            see.XsiType = "Integer";
            sp.SIFExtendedElementsContainer.Add(see);

            sp.SetField(StudentDTD.STUDENTPERSONAL_LOCALID, new SifString(null));


            Console.WriteLine(sp.ToXml());
            StudentPersonal copy = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.LATEST, null, true);

            Console.WriteLine(copy.ToXml());

            name = copy.Name;
            Assert.IsNull(name.Type);
            Assert.IsNull(name.MiddleName);
            Assert.IsNotNull(name.FirstName);
            Assert.IsNotNull(name.LastName);

            // Attributes cannot be represented using xs nil
            SimpleField field = name.GetField(CommonDTD.NAME_TYPE);

            Assert.IsNull(field);


            field = name.GetField(CommonDTD.NAME_MIDDLENAME);
            Assert.IsNotNull(field);
            Assert.IsNull(field.Value);

            see   = copy.GetSIFExtendedElement("FOO");
            field = see.GetField(GlobalDTD.SIF_EXTENDEDELEMENT);
            Assert.IsNotNull(field);
            Assert.IsNull(field.Value);

            field = copy.GetField(StudentDTD.STUDENTPERSONAL_LOCALID);
            Assert.IsNotNull(field);
            Assert.IsNull(field.Value);
        }
Ejemplo n.º 5
0
        public void testFieldMapping010()
        {
            StudentPersonal sp       = new StudentPersonal();
            Mappings        mappings = fCfg.Mappings.GetMappings("Default");
            IDictionary     map      = buildIDictionaryForStudentPersonalTest();

            // Add a "default" to the middle name rule and assert that it gets
            // created
            ObjectMapping om             = mappings.GetObjectMapping("StudentPersonal", false);
            FieldMapping  middleNameRule = om.GetRule(3);

            middleNameRule.DefaultValue = "Jerry";
            map.Remove("MIDDLE_NAME");

            StringMapAdaptor adaptor = new StringMapAdaptor(map);

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

            writer.Write(sp);
            writer.Flush();

            // For the purposes of this test, all we care about is the Ethnicity
            // mapping.
            // It should have the default outbound value we specified, which is "7"
            Assertion.AssertEquals("Middle Name should be Jerry", "Jerry", sp
                                   .Name.MiddleName);

            // Now, remap the student back into application fields
            IDictionary restoredData = new Hashtable();

            adaptor.Dictionary = restoredData;
            mappings.MapInbound(sp, adaptor);

            Assertion.AssertEquals("Middle Name should be Jerry", "Jerry",
                                   restoredData["MIDDLE_NAME"]);

            sp.Name.LastName = null;
            // Now, remap the student back into application fields
            restoredData       = new Hashtable();
            adaptor.Dictionary = restoredData;
            mappings.MapInbound(sp, adaptor);

            Object lastName = restoredData["LAST_NAME"];

            Console.WriteLine(sp.ToXml());
            Assertion.AssertNull("Last Name should be null", lastName);
        }
Ejemplo n.º 6
0
        public void testStudentPersonal2Addresses20r1()
        {
            IDictionary values = new Hashtable();

            values.Add("PERMNUM", "9798");
            values.Add("LASTNAME", "Doe");
            values.Add("FIRSTNAME", "Jane");
            values.Add("MIDDLENAME", null);
            values.Add("MAILADDR", "PO Box 80077");
            values.Add("CITY", "Salt Lake City");
            values.Add("STATE", "Utah");
            values.Add("COUNTRY", "US");
            values.Add("ZIPCODE", "84093");
            values.Add("RESADDR", "528 Big CottonWood Rd");
            values.Add("RESCITY", "Sandy");
            values.Add("RESSTATE", "UT");
            values.Add("RESCOUNTRY", "US");
            values.Add("RESZIPCODE", "84095");

            StringMapAdaptor sma = new StringMapAdaptor(values);
            StudentPersonal  sp  = new StudentPersonal();

            Mappings m = fCfg.Mappings.GetMappings("Default").Select(null,
                                                                     null, null);

            m.MapOutbound(sma, sp, SifVersion.SIF20r1);

            Console.WriteLine(sp.ToXml());

            Element e = sp
                        .GetElementOrAttribute("AddressList/Address[@Type='0123']/Street/Line1");

            Assertion.AssertNotNull("Mailing Address was not mapped ", e);
            Assertion.AssertEquals("Mailing Address", "PO Box 80077", e.TextValue);

            e = sp
                .GetElementOrAttribute("AddressList/Address[@Type='0765']/Street/Line1");
            Assertion.AssertNotNull("Residential Address was not mapped ", e);
            Assertion.AssertEquals("Mailing Address", "528 Big CottonWood Rd", e
                                   .TextValue);

            StudentAddressList[] list     = sp.AddressLists;
            SifElementList       children = sp.GetChildList(CommonDTD.ADDRESSLIST);

            Assertion.AssertEquals("Should have one StudentAddress elements", 1,
                                   children.Count);
            Assertion.AssertEquals("Should have two address elements", 2, children[0].ChildCount);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        public void testInBoundMappingContext50000()
        {
            fCfg = new AgentConfig();
            fCfg
            .Read(
                "..\\..\\Library\\Tools\\Mapping\\MultiVersion.agent.cfg",
                false);

            int mappingIterations = 0;
            //
            // UNCOMMENT THIS LINE TO RUN THE SPEED TEST
            //
            // mappingIterations = 50000;

            Mappings mappings = fCfg.Mappings.GetMappings("Default");

            // Fill out the student personal using outbound mappings first
            StudentPersonal template = new StudentPersonal();

            IDictionary      map = buildIDictionaryForStudentPersonalTest();
            StringMapAdaptor sma = new StringMapAdaptor(map);

            mappings.MapOutbound(sma, template);
            Console.WriteLine(template.ToXml());

            MappingsContext mc = mappings.SelectInbound(template.ElementDef,
                                                        SifVersion.SIF20, null, null);

            DateTime start = DateTime.Now;

            for (int x = 0; x < mappingIterations; x++)
            {
                map.Clear();
                mc.Map(template, sma);
                if (x % 500 == 0)
                {
                    Console.WriteLine("Iteration " + x + " of "
                                      + mappingIterations);
                }
            }

            DateTime end = DateTime.Now;

            Console.WriteLine("Mapping "
                              + mappingIterations
                              + " Students inbound took " + end.Subtract(start));
        }
Ejemplo n.º 9
0
        public void testStudentPersonalNullHomeroom()
        {
            IDictionary values = new Hashtable();

            values.Add("PERMNUM", "9798");
            values.Add("SOCSECNUM", "845457898");
            values.Add("SCHOOLNUM", "999");
            values.Add("SCHOOLNUM2", "999");
            values.Add("GRADE", "09");
            values.Add("HOMEROOM", null);
            values.Add("LASTNAME", "Doe");
            values.Add("FIRSTNAME", "Jane");
            values.Add("MIDDLENAME", null);
            values.Add("NICKNAME", null);
            values.Add("MAILADDR", "5845 Test Blvd");
            values.Add("CITY", "slc");
            values.Add("STATE", "Utah");
            values.Add("COUNTRY", "");
            values.Add("ZIPCODE", "84093");
            values.Add("RESADDR", null);
            values.Add("RESCITY", null);
            values.Add("RESSTATE", null);
            values.Add("RESCOUNTRY", null);
            values.Add("RESZIPCODE", null);
            values.Add("BIRTHDATE", "20051209");
            values.Add("GENDER", "F");
            values.Add("ETHNICCODE", "W");
            values.Add("ENGPROF", "");
            values.Add("PRIMARYLNG", "");
            values.Add("TELEPHONE", null);

            StringMapAdaptor sma = new StringMapAdaptor(values);
            StudentPersonal  sp  = new StudentPersonal();

            Mappings m = fCfg.Mappings.GetMappings("Default").Select(null,
                                                                     null, null);

            m.MapOutbound(sma, sp, SifVersion.SIF15r1);

            Console.WriteLine(sp.ToXml());

            Element e = sp
                        .GetElementOrAttribute("OtherId[@Type='ZZ' and starts-with(., 'HOMEROOM') ]");

            Assertion.AssertNull("HOMEROOM should not have been mapped", e);
        }
Ejemplo n.º 10
0
        public void testOutBoundMapping50000()
        {
            fCfg = new AgentConfig();
            fCfg
            .Read(
                "..\\..\\Library\\Tools\\Mapping\\MultiVersion.agent.cfg",
                false);

            int mappingIterations = 0;
            //
            // UNCOMMENT THIS LINE TO RUN THE SPEED TEST
            //
            //mappingIterations = 50000;

            Mappings         mappings = fCfg.Mappings.GetMappings("Default");
            IDictionary      map      = buildIDictionaryForStudentPersonalTest();
            StringMapAdaptor sma      = new StringMapAdaptor(map);

            StudentPersonal template = new StudentPersonal();

            mappings.MapOutbound(sma, template);
            Console.WriteLine(template.ToXml());

            DateTime start = DateTime.Now;

            for (int x = 0; x < mappingIterations; x++)
            {
                template = new StudentPersonal();
                mappings.MapOutbound(sma, template);
                if (x % 500 == 0)
                {
                    Console.WriteLine("Iteration " + x + " of "
                                      + mappingIterations);
                }
            }

            DateTime end = DateTime.Now;

            Console.WriteLine("Mapping "
                              + mappingIterations
                              + " Students inbound took " + end.Subtract(start));
        }
Ejemplo n.º 11
0
        public void TestWriteXSIType()
        {
            StudentPersonal sp = new StudentPersonal();

            sp.RefId           = Adk.MakeGuid();
            sp.StateProvinceId = "\u06DE55889";
            sp.LocalId         = "987987987987987";


            SIF_ExtendedElement see = new SIF_ExtendedElement("FOO", "BAR");

            see.XsiType = "Integer";
            sp.SIFExtendedElementsContainer.Add(see);

            Console.WriteLine(sp.ToXml());

            StudentPersonal copy =
                (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.LATEST, null, true);

            see = copy.SIFExtendedElements[0];

            Assert.IsNotNull(see);
            Assert.AreEqual("Integer", see.XsiType);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Process a response (of a request) for an StudentPersonal SIF Object.
 /// </summary>
 /// <param name="sifDataObject">StudentPersonal response received.</param>
 /// <param name="zone">Zone used.</param>
 protected override void ProcessResponse(StudentPersonal sifDataObject, IZone zone)
 {
     if (log.IsDebugEnabled)
     {
         log.Debug("Received a request response for StudentPersonal in Zone " + zone.ZoneId + ":\n" + sifDataObject.ToXml());
     }
 }