Example #1
0
        public void TestCustomFunctionOutbound()
        {
            String flattenDateFunctionCall = "<agent id=\"Repro\" sifVersion=\"2.0\">"
                                             + "    <mappings id=\"Default\">"
                                             + "        <object object=\"StudentPersonal\">"
                                             + "          <field name=\"StudentPers_guid\">@RefId</field>"
                                             +
                                             "          <field name=\"DOB\">Demographics/BirthDate=@flattenDate( $(DOB) )</field>"
                                             + "        </object>"
                                             + "    </mappings>"
                                             + "</agent>";

            IDictionary map = new Dictionary <String, String>();

            map.Add("StudentPers_guid", "1234");
            map.Add("DOB", "19900904");
            StringMapAdaptor sma = new StringMapAdaptor(map);
            TestValueBuilder tvb = new TestValueBuilder(sma);

            DefaultValueBuilder.AddAlias("flattenDate", GetType().AssemblyQualifiedName);
            Adk.SifVersion = SifVersion.SIF20;
            StudentPersonal sp = mapToStudentPersonal(sma, flattenDateFunctionCall, tvb);

            Assertion.Assert("flattenDate should have been called", tvb.WasCalled);
            Assertion.AssertNotNull("Student should not be null", sp);
            Assertion.AssertNotNull("BirthDate should not be null", sp.Demographics.BirthDate);
        }
Example #2
0
        public void TestDoubleOutboundMapping()
        {
            String mapping = "<agent id=\"Repro\" sifVersion=\"2.0\">"
                             + "    <mappings id=\"Default\">"
                             + "        <object object=\"StudentPersonal\">"
                             + "           <field name='PHONE_TYPE'>PhoneNumberList/PhoneNumber/@Type</field>"
                             + "           <field name='PHONE'>PhoneNumberList/PhoneNumber[1]/Number</field>"
                             + "        </object>" + "    </mappings>" + "</agent>";

            IDictionary map = new Dictionary <String, String>();

            map.Add("PHONE_TYPE", "1234");
            map.Add("PHONE", "715-555-5555");
            StringMapAdaptor sma = new StringMapAdaptor(map);
            StudentPersonal  sp  = mapToStudentPersonal(sma, mapping, null);

            Assertion.AssertNotNull("Student should not be null", sp);
            PhoneNumberList phoneList = sp.PhoneNumberList;

            Assertion.AssertEquals("One Phone", 1, phoneList.ChildCount);

            PhoneNumber phone = (PhoneNumber)phoneList.GetChildList()[0];

            Assertion.AssertNotNull("Phone should not be null", phone);
            Assertion.AssertEquals("Phone type", "1234", phone.Type);
            Assertion.AssertEquals("PhoneNumber", "715-555-5555", phone.Number);
        }
Example #3
0
        public void TestStringConcat()
        {
            String configFileText = "<agent id=\"Repro\" sifVersion=\"2.0\">"
                                    + "    <mappings id=\"Default\">"
                                    + "        <object object=\"StudentPersonal\">"
                                    +
                                    "            <field name=\"FullName\">Name[@Type='01']/FullName=NAME:$(LastName), $(FirstName) $(MiddleName)</field>"
                                    + "        </object>" + "    </mappings>" + "</agent>";

            IDictionary map = new Dictionary <String, String>();

            map.Add("StudentPers_guid", "1234");
            map.Add("LastName", "Finale");
            map.Add("FirstName", "Prima");
            map.Add("MiddleName", "Mediccio");
            map.Add("FullName", "");

            StringMapAdaptor sma = new StringMapAdaptor(map);
            TestValueBuilder tvb = new TestValueBuilder(sma);
            StudentPersonal  sp  = mapToStudentPersonal(sma, configFileText, tvb);

            Assertion.AssertNotNull("Student should not be null", sp);

            SimpleField fullName = (SimpleField)sp
                                   .GetElementOrAttribute("Name/FullName");

            Assertion.AssertNotNull("FullName", fullName);
            Assertion.AssertEquals("FullName", "NAME:Finale, Prima Mediccio", fullName.Value);
        }
Example #4
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"]);
        }
Example #5
0
        public void testStudentMappingAdk15Mappings()
        {
            StudentPersonal sp       = new StudentPersonal();
            Mappings        mappings = fCfg.Mappings.GetMappings("Default");
            IDictionary     map      = buildIDictionaryForStudentPersonalTest();

            StringMapAdaptor adaptor = new StringMapAdaptor(map);

            mappings.MapOutbound(adaptor, sp);

            SifWriter writer = new SifWriter(Console.Out);

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

            // Assert that the StudentPersonal object was mapped correctly
            assertStudentPersonal(sp);

            // Now, map the student personal back to a hashmap and assert it
            IDictionary restoredData = new Hashtable();

            adaptor.Dictionary = restoredData;
            mappings.MapInbound(sp, adaptor);
            assertMapsAreEqual(map, restoredData, "ALT_PHONE_TYPE");
        }
        protected StudentPersonal mapToStudentPersonal(IFieldAdaptor adaptor, String cfg, IValueBuilder vb)
        {
            StudentPersonal sp = new StudentPersonal();

            doOutboundMapping(adaptor, sp, cfg, vb);
            return(sp);
        }
Example #7
0
        public void SDOParse()
        {
            // Create a StudentPersonal
            StudentPersonal sp = ObjectCreator.CreateStudentPersonal();

            // Test changing the name
            sp.Name = new Name(NameType.BIRTH, "STUDENT", "JOE");

            sp = AdkObjectParseHelper.runParsingTest(sp, SifVersion.SIF15r1);

            // Test to ensure that Email is not a child of StudentPersonal
            Assertion.AssertEquals("No StudentPersonal/Email", 0, sp.GetChildList(CommonDTD.EMAIL).Count);
            Assertion.AssertNotNull("StudentPersonal/EmailList", sp.EmailList);
            Assertion.Assert("StudentPersonal/EmailList/Email", sp.EmailList.ChildCount > 0);

            sp = AdkObjectParseHelper.runParsingTest(sp, SifVersion.SIF20);

            // Test to ensure that Email is not a child of StudentPersonal
            Assertion.AssertEquals("No StudentPersonal/Email", 0, sp.GetChildList(CommonDTD.EMAIL).Count);
            Assertion.AssertNotNull("StudentPersonal/EmailList", sp.EmailList);
            Assertion.Assert("StudentPersonal/EmailList/Email", sp.EmailList.ChildCount > 0);
            sp = AdkObjectParseHelper.runParsingTest(sp, SifVersion.SIF11);

            // Test to ensure that Email is not a child of StudentPersonal
            Assertion.AssertEquals("No StudentPersonal/Email", 0, sp.GetChildList(CommonDTD.EMAIL).Count);
            Assertion.AssertNotNull("StudentPersonal/EmailList", sp.EmailList);
            Assertion.Assert("StudentPersonal/EmailList/Email", sp.EmailList.ChildCount > 0);

            sp = AdkObjectParseHelper.runParsingTest(sp, SifVersion.SIF22);

            // Test to ensure that Email is not a child of StudentPersonal
            Assertion.AssertEquals("No StudentPersonal/Email", 0, sp.GetChildList(CommonDTD.EMAIL).Count);
            Assertion.AssertNotNull("StudentPersonal/EmailList", sp.EmailList);
            Assertion.Assert("StudentPersonal/EmailList/Email", sp.EmailList.ChildCount > 0);
        }
Example #8
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());
     }
 }
Example #9
0
        public void WriteSpeedTest()
        {
            Adk.Debug = AdkDebugFlags.None;

            StudentPersonal sp   = ObjectCreator.CreateStudentPersonal();
            Address         addr = sp.AddressLists[0][0];

            // Add in a few cases where escaping needs to be done
            addr.Street.Line1 = "ATTN: \"Miss Thompson\"";
            addr.Street.Line2 = "321 Dunn & Bradstreeet Lane";
            addr.Street.Line3 = "Weyer's Way, MO 32254";

            // Dump the object once to the console
            SifWriter writer = new SifWriter(Console.Out);

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

            MemoryStream stream = new MemoryStream();

            writer = new SifWriter(stream);

            for (int a = 0; a < 50000; a++)
            {
                writer.Write(sp);
                writer.Flush();
                stream.Seek(0, SeekOrigin.Begin);
            }

            Console.WriteLine("Test Complete. Please See timings for details");
        }
        public void testParseProjectedGradYear()
        {
            String sXML = "<StudentPersonal RefId='12345678901234567890'>"
                          + " <GradYear Type='Projected'>2012</GradYear>"
                          + "</StudentPersonal>";

            StudentPersonal sp = (StudentPersonal)parseSIF15r1XML(sXML);

            sp = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.SIF11);
            Assertion.AssertNotNull(sp);
            Assertion.AssertNotNull("Projected Grad Year", sp.ProjectedGraduationYear);
            Assertion.AssertEquals("Projected Grad Year", 2012, (int)sp
                                   .ProjectedGraduationYear);

            Adk.SifVersion = SifVersion.SIF15r1;
            sp             = new StudentPersonal();
            sp.SetElementOrAttribute("GradYear[@Type='Projected']", "2089");
            Assertion.AssertNotNull("Projected Grad Year", sp.ProjectedGraduationYear);
            Assertion.AssertEquals("Projected Grad Year", 2089, (int)sp
                                   .ProjectedGraduationYear);

            Element gradValue = sp.GetElementOrAttribute("GradYear[@Type='Projected']");

            Assertion.AssertNotNull("Projected Grad Year", gradValue);
            int gradYear = (int)gradValue.SifValue.RawValue;

            Assertion.AssertNotNull("Projected Grad Year", gradYear);
            Assertion.AssertEquals("Projected Grad Year", 2089, gradYear);
        }
        public void testParseGraduationDate()
        {
            String sXML = "<StudentPersonal RefId='12345678901234567890'>"
                          + " <GradYear Type='Actual'>2005</GradYear>"
                          + "</StudentPersonal>";

            StudentPersonal sp = (StudentPersonal)parseSIF15r1XML(sXML);

            sp = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.SIF11);
            Assertion.AssertNotNull(sp);
            PartialDateType gd = sp.GraduationDate;

            Assertion.AssertNotNull("Actual Grad Year", gd);
            Assertion.AssertEquals("Actual Grad Year", 2005, (int)gd.Year);

            Adk.SifVersion = SifVersion.SIF15r1;
            sp             = new StudentPersonal();
            sp.SetElementOrAttribute("GradYear[@Type='Actual']", "2054");
            gd = sp.GraduationDate;
            Assertion.AssertNotNull("Actual Grad Year", gd);
            Assertion.AssertNotNull("GraduationDate/getYear()", gd.Year);
            Assertion.AssertEquals("Actual Grad Year", 2054, gd.Year.Value);

            Element gradValue = sp.GetElementOrAttribute("GradYear[@Type='Actual']");

            Assertion.AssertNotNull("Actual Grad Year", gradValue);
            PartialDateType pdt = (PartialDateType)gradValue;

            Assertion.AssertEquals("Actual Grad Year", 2054, pdt.Year.Value);
        }
Example #12
0
        public void SharedChildren()
        {
            Adk.SifVersion = SifVersion.LATEST;
            StudentPersonal sp = new StudentPersonal(Adk.MakeGuid(), new Name(NameType.LEGAL, "hello", "world"));
            // Replace the existing demographics so there is no confusion
            Demographics d = new Demographics();

            sp.Demographics = d;
            d.SetCountryOfBirth(CountryCode.US);
            CountriesOfCitizenship countries = new CountriesOfCitizenship();

            d.CountriesOfCitizenship = countries;
            CountriesOfResidency residencies = new CountriesOfResidency();

            d.CountriesOfResidency = residencies;

            countries.AddCountryOfCitizenship(CountryCode.Wrap("UK"));
            residencies.AddCountryOfResidency(CountryCode.Wrap("AU"));

            // overwrite the country codes again, just to try to repro the issue
            d.SetCountryOfBirth(CountryCode.Wrap("AA")); // Should overwrite the existing one

            //Remove the existing CountryOfCitizenship, add three more, and remove the middle one
            Assert.IsTrue(countries.Remove(CountryCode.Wrap("UK")));
            countries.AddCountryOfCitizenship(CountryCode.Wrap("BB1"));
            countries.AddCountryOfCitizenship(CountryCode.Wrap("BB2"));
            countries.AddCountryOfCitizenship(CountryCode.Wrap("BB3"));
            Assert.IsTrue(countries.Remove(CountryCode.Wrap("BB2")));

            // Remove the existing CountryOfResidency, add three more, and remove the first one
            Assert.IsTrue(residencies.Remove(CountryCode.Wrap("AU")));
            residencies.AddCountryOfResidency(CountryCode.Wrap("CC1"));
            residencies.AddCountryOfResidency(CountryCode.Wrap("CC2"));
            residencies.AddCountryOfResidency(CountryCode.Wrap("CC3"));
            Assert.IsTrue(residencies.Remove(CountryCode.Wrap("CC1")));

            StudentPersonal sp2 = AdkObjectParseHelper.runParsingTest(sp, SifVersion.LATEST);

            // The runParsingTest() method will compare the objects after writing them and reading them
            // back in, but to be completely sure, let's assert the country codes again

            // NOTE: Due to the .Net Array.Sort algorithm, repeatable elements come out in reverse order.
            // This doesn't appear to be a problem yet, but may be fixed in a future release.
            // For now, these tests look for the elements in reverse order

            Demographics d2 = sp2.Demographics;

            Assert.AreEqual("AA", d2.CountryOfBirth.ToString(), "Country of Birth");
            Country[] citizenships = d2.CountriesOfCitizenship.ToArray();

            Assert.AreEqual(2, citizenships.Length, "Should be two CountryOfCitizenships");
            Assert.AreEqual("BB1", citizenships[0].TextValue, "First CountryOfCitizenship");
            Assert.AreEqual("BB3", citizenships[1].TextValue, "Second CountryOfCitizenship");

            // assert
            Country[] resid = d2.CountriesOfResidency.ToArray();
            Assert.AreEqual(2, resid.Length, "Should be two CountryOfResidencys");
            Assert.AreEqual("CC2", resid[0].TextValue, "First CountryOfResidencys");
            Assert.AreEqual("CC3", resid[1].TextValue, "Second CountryOfResidencys");
        }
        public void testParseOnTimeGradYear()
        {
            String sXML = "<StudentPersonal RefId='12345678901234567890'>"
                          + " <GradYear Type='Original'>1971</GradYear>"
                          + "</StudentPersonal>";

            StudentPersonal sp = (StudentPersonal)parseSIF15r1XML(sXML);

            sp = (StudentPersonal)AdkObjectParseHelper.WriteParseAndReturn(sp, SifVersion.SIF11);
            Assertion.AssertNotNull(sp);
            Assertion.AssertNotNull("On Time Grad Year", sp.OnTimeGraduationYear);
            Assertion.AssertEquals("On Time Grad Year", 1971, (int)sp
                                   .OnTimeGraduationYear);

            Adk.SifVersion = SifVersion.SIF15r1;
            sp             = new StudentPersonal();
            sp.SetElementOrAttribute("GradYear[@Type='Original']", "8877");
            Assertion.AssertNotNull("On Time Grad Year", sp.OnTimeGraduationYear);
            Assertion.AssertEquals("On Time Grad Year", 8877, (int)sp
                                   .OnTimeGraduationYear);

            Element gradValue = sp.GetElementOrAttribute("GradYear[@Type='Original']");

            Assertion.AssertNotNull("On Time Grad Year", gradValue);
            int gradYear = (int)gradValue.SifValue.RawValue;

            Assertion.AssertNotNull("On Time Grad Year", gradYear);
            Assertion.AssertEquals("On Time Grad Year", 8877, gradYear);
        }
Example #14
0
        public void testSetChildren()
        {
            StudentPersonal sp     = ObjectCreator.CreateStudentPersonal();
            Email           email1 = new Email(EmailType.PRIMARY, "*****@*****.**");
            Email           email2 = new Email(EmailType.ALT1, "*****@*****.**");

            sp.EmailList = new EmailList();
            sp.EmailList.SetChildren(CommonDTD.EMAIL, new Email[] { email1, email2 });

            EmailList studentEmails = sp.EmailList;

            Assert.AreEqual(2, studentEmails.ChildCount, "Should be two emails");

            studentEmails.SetChildren(CommonDTD.EMAIL, new Email[0]);
            studentEmails = sp.EmailList;
            Assert.AreEqual(0, studentEmails.ChildCount, "Should be zero emails after setting empty array");

            studentEmails.SetChildren(CommonDTD.EMAIL, new Email[] { email1, email2 });
            studentEmails = sp.EmailList;
            Assert.AreEqual(2, studentEmails.ChildCount, "Should be two emails");

            studentEmails.SetChildren(CommonDTD.EMAIL, null);
            studentEmails = sp.EmailList;
            Assert.AreEqual(0, studentEmails.ChildCount, "Should be zero emails after setting null");
        }
Example #15
0
        public void TestOtherIdMappings()
        {
            String otherIdMapping = "<agent id=\"Repro\" sifVersion=\"2.0\">"
                                    + "    <mappings id=\"Default\">"
                                    + "        <object object='StudentPersonal'>"
                                    +
                                    "            <field direction='inbound' name='FIELD1'><otherid type='ZZ' prefix='FIELD1:'/></field>"
                                    +
                                    "            <field direction='outbound' name='FIELD1'>OtherIdList/OtherId[@Type='ZZ'+]=FIELD1:$(FIELD1)</field>"
                                    +
                                    "            <field direction='inbound' name='FIELD2'><otherid type='ZZ' prefix='FIELD2:'/></field>"
                                    +
                                    "            <field direction='outbound' name='FIELD2'>OtherIdList/OtherId[@Type='ZZ'+]=FIELD2:$(FIELD2)</field>"
                                    + "        </object>" + "    </mappings>" + "</agent>";

            Dictionary <String, String> sourceMap = new Dictionary <String, String>();

            sourceMap.Add("FIELD1", "1234");
            sourceMap.Add("FIELD2", "5678");
            StringMapAdaptor sma = new StringMapAdaptor(sourceMap);
            StudentPersonal  sp  = mapToStudentPersonal(sma, otherIdMapping, null);

            Assertion.AssertNotNull("Student should not be null", sp);

            IDictionary destinationMap = doInboundMapping(otherIdMapping, sp);

            assertMapsAreEqual(sourceMap, destinationMap);
        }
Example #16
0
        public void testIDProperty()
        {
            SifElement element = new StudentPersonal();

            element.XmlId = "Foo";

            Assert.AreEqual("Foo", element.XmlId);
        }
        private static StudentPersonal CreateStudent()
        {
            NameOfRecordType name = new NameOfRecordType { Type = NameOfRecordTypeType.LGL, FamilyName = RandomNameGenerator.FamilyName, GivenName = RandomNameGenerator.GivenName };
            PersonInfoType personInfo = new PersonInfoType { Name = name };
            StudentPersonal studentPersonal = new StudentPersonal { LocalId = random.Next(10000, 99999).ToString(), PersonInfo = personInfo };

            return studentPersonal;
        }
        private static StudentPersonal CreateStudent(
            String id,
            String lastName,
            String firstName,
            String street,
            String city,
            String state,
            CountryCode country,
            String post,
            String phone,
            Sex gender,
            YearLevelCode grade,
            String birthDateyyyyMMdd)
        {
            StudentPersonal student = new StudentPersonal();

            ;
            student.RefId   = Adk.MakeGuid();
            student.LocalId = id;

            PersonInfo stupersonal = new PersonInfo();

            student.PersonInfo = stupersonal;

            // Set the Name
            Name name = new Name(NameType.LEGAL);

            name.FamilyName  = lastName;
            name.GivenName   = firstName;
            stupersonal.Name = name;

            Address addr = new Address();

            addr.SetType(AddressType.C0765_PHYSICAL_LOCATION);
            addr.SetStreet(street);
            addr.City          = city;
            addr.StateProvince = state;
            addr.PostalCode    = post;
            addr.Country       = country.ToString();

            stupersonal.AddressList = new AddressList(addr);

            stupersonal.PhoneNumberList =
                new PhoneNumberList(new PhoneNumber(PhoneNumberType.PRIMARY, phone));


            Demographics dem = new Demographics();

            dem.SetSex(gender);
            dem.BirthDate =
                DateTime.ParseExact
                    (birthDateyyyyMMdd, "yyyyMMdd", CultureInfo.InvariantCulture.DateTimeFormat);

            stupersonal.Demographics = dem;

            return(student);
        }
        public void testExtendedElements()
        {
            StudentPersonal      sp        = new StudentPersonal();
            SIF_ExtendedElements container = sp.SIFExtendedElementsContainer;

            container.SetChildren(new SIF_ExtendedElement[] { new SIF_ExtendedElement("key1", "value1") });
            container.SetChildren(new SIF_ExtendedElement[] { new SIF_ExtendedElement("key1", "value1") });
            Assert.AreEqual(1, sp.SIFExtendedElements.Length, "Result should be 1");
        }
Example #20
0
        public void testConditionWithNullValue()
        {
            StudentPersonal sp = new StudentPersonal(Adk.MakeGuid(), new Name(NameType.BIRTH, "E", "Sally"));

            Query q = new Query(StudentDTD.STUDENTPERSONAL);

            q.AddCondition(CommonDTD.NAME_LASTNAME, ComparisonOperators.GT, null);
            Assert.IsFalse(q.Evaluate(sp));
        }
Example #21
0
        public void TestWriteXSINillMultiple()
        {
            SIF_Data data = new SIF_Data();

            for (int a = 0; a < 3; a++)
            {
                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));
                data.AddChild(sp);
            }



            SIF_Data data2 = (SIF_Data)AdkObjectParseHelper.WriteParseAndReturn(data, SifVersion.LATEST, null, true);

            foreach (SifElement child in data2.GetChildList())
            {
                StudentPersonal copy = (StudentPersonal)child;
                Name            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);

                SIF_ExtendedElement 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);
            }
        }
Example #22
0
        public void testInheritRules()
        {
            String configFileText1_ = "<agent id=\"mcmTest.MappingsTest\" sifVersion=\"2.0\">\n"
                                      + " <mappings id=\"Default\">\n"
                                      + " <object object=\"StudentPersonal\">\n"
                                      + " <field name=\"StudentPers_guid\">@RefId</field>\n"
                                      + " <field name=\"LastName\">Name[@Type='01']/LastName</field>\n"
                                      + " <field name=\"FirstName\">Name[@Type='01']/FirstName</field>\n"
                                      + " <field name=\"MiddleName\">Name[@Type='01']/MiddleName</field>\n"
                                      +
                                      " <field name=\"Street\">StudentAddress[@PickupOrDropoff='NA',@DayOfWeek='NA']/Address[@Type='01']/Street/Line1</field>\n"
                                      +
                                      " <field name=\"City\">StudentAddress[@PickupOrDropoff='NA',@DayOfWeek='NA']/Address[@Type='01']/City</field>\n"
                                      +
                                      " <field name=\"State\">StudentAddress[@PickupOrDropoff='NA',@DayOfWeek='NA']/Address[@Type='01']/StateProvince</field>\n"
                                      +
                                      " <field name=\"Zip\">StudentAddress[@PickupOrDropoff='NA',@DayOfWeek='NA']/Address[@Type='01']/PostalCode</field>\n"
                                      + " </object>\n"
                                      + "  <mappings id=\"Zone A\" zoneId=\"Zone A\">\n"
                                      + "   <object object=\"StudentPersonal\">\n"
                                      + "     <field name=\"LastName\">Name[@Type='06']/LastName</field>\n"
                                      + "     <field name=\"FirstName\">Name[@Type='06']/FirstName</field>\n"
                                      + "     <field name=\"MiddleName\">Name[@Type='06']/MiddleName</field>\n"
                                      + "   </object>\n"
                                      + "  </mappings>\n"
                                      + " </mappings>\n"
                                      + "</agent>";

            IDictionary psValueMap = new Dictionary <String, String>();

            psValueMap["StudentPers_guid"] = "14050614103526133C3FD2324C5BC8FF";
            psValueMap["LastName"]         = "Finale";
            psValueMap["FirstName"]        = "Prima";
            psValueMap["MiddleName"]       = "Mediccio";
            psValueMap["Street"]           = "667 Gate Way";
            psValueMap["City"]             = "Sacramento";
            psValueMap["State"]            = "CA";
            psValueMap["Zip"] = "91020";

            StringMapAdaptor sma = new StringMapAdaptor(psValueMap);
            StudentPersonal  sp  = doOutboundMappingSelect(sma, configFileText1_,
                                                           "Zone A", null, null);

            Assertion.AssertNotNull("Student should not be null", sp);

            SifElement address = (SifElement)sp
                                 .GetElementOrAttribute(
                "StudentAddress[@PickupOrDropoff='NA',@DayOfWeek='NA']/Address[@Type='01']");

            Assertion.AssertNotNull("Student Address should have mapped", address);

            SifElement name = (SifElement)sp
                              .GetElementOrAttribute("Name[@Type='06']");

            Assertion.AssertNotNull("Name should have mapped to '06'", name);
        }
Example #23
0
        private void assertStudentPersonal(StudentPersonal sp)
        {
            DateTime birthDate = new DateTime(1990, 1, 1);

            Assertion.AssertEquals("First Name", "Betty", sp.Name.FirstName);
            Assertion.AssertEquals("Middle Name", "George", sp.Name.MiddleName);
            Assertion.AssertEquals("Last Name", "Johnson", sp.Name.LastName);
            Assertion.AssertEquals("Student Number", "998", sp.OtherIdList.ItemAt(0).TextValue);
            Assertion.AssertEquals("Birthdate", birthDate, sp.Demographics.BirthDate.Value);
            Assertion.AssertEquals("Ethnicity", "H", sp.Demographics.RaceList.ItemAt(0).Code);

            PhoneNumberList pnl = sp.PhoneNumberList;

            Assertion.AssertNotNull("PhoneNumberList", pnl);

            PhoneNumber homePhone = pnl[PhoneNumberType.SIF1x_HOME_PHONE];

            Assertion.AssertNotNull("Home Phone is null", homePhone);
            Assertion.AssertEquals("Home Phone", "202-358-6687", homePhone
                                   .Number);

            PhoneNumber cellPhone = pnl
                                    [PhoneNumberType.SIF1x_PERSONAL_CELL];

            Assertion.AssertNotNull("cellPhone Phone is null", cellPhone);
            Assertion.AssertEquals("Cell Phone", "202-502-4856", cellPhone.Number);

            SifXPathContext xpathContext = SifXPathContext.NewSIFContext(sp, SifVersion.SIF20r1);

            assertByXPath(xpathContext, "AddressList/Address/Street/Line1",
                          "321 Oak St");
            assertByXPath(xpathContext, "AddressList/Address/Street/Line1",
                          "321 Oak St");
            assertByXPath(xpathContext, "AddressList/Address/Street/Line2",
                          "APT 11");
            assertByXPath(xpathContext, "AddressList/Address/City", "Metropolis");
            assertByXPath(xpathContext, "AddressList/Address/StateProvince", "IL");
            assertByXPath(xpathContext, "AddressList/Address/Country", "US");
            assertByXPath(xpathContext, "AddressList/Address/PostalCode", "321546");

            /*
             * These assertions are currently commented out because the Adk does not
             * currently support Repeatable elements that have wildcard attributes
             *
             * PhoneNumber number = sp.PhoneNumber( PhoneNumberType.PHONE );
             * Assertion.AssertNotNull( "Alternate Phone Element is null", number );
             * Assertion.AssertEquals( "Alternate Phone", "201-668-1245",
             * number.ToString() );
             */

            Assertion.AssertEquals("OriginalGradYear", 2005, sp.OnTimeGraduationYear.Value);
            Assertion.AssertEquals("Projected", 2007, sp.ProjectedGraduationYear.Value);
            Assertion.AssertNotNull("Actual Grad Year", sp.GraduationDate.Value);
            Assertion.AssertEquals("OriginalGradYear", 2007, sp.GraduationDate.Year);
        }
Example #24
0
        public void TestEncodingHighAsciiChars()
        {
            StudentPersonal sp = new StudentPersonal();

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

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

            Assert.AreEqual("\u06DE55889", copy.StateProvinceId, "LocalID, Encoded");
        }
Example #25
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");
        }
        private static List <StudentPersonal> CreateStudents(int count)
        {
            var students = new List <StudentPersonal>();

            for (var i = 0; i < count; i++)
            {
                StudentPersonal studentPersonal = CreateStudent();
                students.Add(studentPersonal);
            }

            return(students);
        }
Example #27
0
        /**
         * @param sp
         * @param mappings
         * @param map
         * @throws AdkMappingException
         */

        private void MapOutbound(StudentPersonal sp, Mappings mappings, IDictionary map)
        {
            StringMapAdaptor adaptor = new StringMapAdaptor(map);

            mappings.MapOutbound(adaptor, sp);

            SifWriter writer = new SifWriter(Console.Out);

            writer.Write(sp);
            writer.Flush();
            writer.Close();
        }
Example #28
0
        public void testSettingStatePrAndCountry()
        {
            StudentPersonal sp = ObjectCreator.CreateStudentPersonal();
            Demographics    d  = sp.Demographics;

            d.SetCountryOfBirth(CountryCode.US);
            d.SetStateOfBirth(StatePrCode.AR);


            Assert.AreEqual(CountryCode.US.Value, d.CountryOfBirth);
            Assert.AreEqual(StatePrCode.AR.Value, d.StateOfBirth);
        }
Example #29
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);
        }
        public static StudentPersonal makeStudentPersonal(String localId,
                                                          NameType nameType, String firstName, String lastName)
        {
            StudentPersonal s = new StudentPersonal();

            s.RefId   = Adk.MakeGuid();
            s.LocalId = localId;
            Name name = new Name(nameType, lastName, firstName);

            s.Name = name;
            return(s);
        }
Example #31
0
        public void testAddChildTwice()
        {
            StudentPersonal sp1    = new StudentPersonal();
            Email           email1 = new Email(EmailType.PRIMARY, "*****@*****.**");

            EmailList eList = new EmailList();

            sp1.EmailList = eList;

            eList.AddChild(CommonDTD.EMAIL, email1);
            // We should be able to add the same child twice without getting an exception
            eList.AddChild(CommonDTD.EMAIL, email1);

            // Add it again, using the overload
            eList.AddChild(email1);

            Email[] studentEmails = sp1.EmailList.ToArray();
            Assert.AreEqual(1, studentEmails.Length, "Should be one email");

            StudentPersonal sp2    = ObjectCreator.CreateStudentPersonal();
            Email           email2 = new Email(EmailType.ALT1, "*****@*****.**");
            EmailList       elist2 = new EmailList();

            elist2.Add(email2);
            sp2.EmailList = elist2;

            bool exceptionThrown = false;

            try
            {
                eList.AddChild(email2); // should throw here
            }
            catch (InvalidOperationException)
            {
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown, "IllegalStateException should have been thrown in addChild(SIFElement)");

            exceptionThrown = false;
            try
            {
                eList.AddChild(CommonDTD.EMAILLIST, email2); // should throw here
            }
            catch (InvalidOperationException)
            {
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown,
                          "IllegalStateException should have been thrown in addChild( ElementDef, SIFElement)");
        }
Example #32
0
        /// <summary>  Respond to SIF RequestsGetTopicMap
        /// </summary>
        public virtual void OnRequest(IDataObjectOutputStream outStream,
                                       Query query,
                                       IZone zone,
                                       IMessageInfo inf)
        {
            SifMessageInfo info = (SifMessageInfo)inf;
            SifWriter debug = new SifWriter(Console.Out);

            Console.WriteLine
                ("Received a request for " + query.ObjectTag + " from agent \"" + info.SourceId +
                  "\" in zone " + zone.ZoneId);

            //  Read all students from the database to populate a HashMap of
            //  field/value pairs. The field names can be whatever we choose as long
            //  as they match the field names used in the <mappings> section of the
            //  agent.cfg configuration file. Each time a record is read, convert it
            //  to a StudentPersonal object using the Mappings class and stream it to
            //  the supplied output stream.
            //
            IDbCommand command = null;

            // Set a basic filter on the outgoing data stream
            // What will happen is that any object written to the output stream will
            // be evaluated based on the query conditions. If the object doesn't meet the
            // query conditions, it will be excluded
            outStream.Filter = query;

            //  Get the root Mappings object from the configuration file
            Edustructures.SifWorks.Tools.Mapping.Mappings m = fCfg.Mappings.GetMappings("Default");

            //  Ask the root Mappings instance to select a Mappings from its
            //  hierarchy. For example, you might have customized the agent.cfg
            //  file with mappings specific to zones, versions of SIF, or
            //  requesting agents. The Mappings.select() method will select
            //  the most appropriate instance from the hierarchy given the
            //  three parameters passed to it.
            //
            //IDictionary<string, string> dataMap = new System.Collections.Generic.Dictionary<string, string>();
            // IFieldAdaptor adaptor = new StringMapAdaptor(dataMap);
            //m.MapOutbound();
            MappingsContext mc = m.SelectOutbound(StudentDTD.STUDENTPERSONAL, info);

            try {
                int count = 0;

                //  Query the database for all students
                command = fConn.CreateCommand();
                fConn.Open();
                command.CommandText = "SELECT * FROM Students";
                using (IDataReader rs = command.ExecuteReader(CommandBehavior.CloseConnection)) {

                    DataReaderAdaptor dra = new DataReaderAdaptor(rs);

                    while (rs.Read()) {

                        //  Finally, create a new StudentPersonal object and ask the
                        //  Mappings to populate it with SIF elements from the HashMap
                        //  of field/value pairs. As long as there is an <object>/<field>
                        //  definition for each entry in the HashMap, the ADK will take
                        //  care of producing the appropriate SIF element/attribute in
                        //  the StudentPersonal object.
                        //
                        StudentPersonal sp = new StudentPersonal();
                        sp.RefId = Adk.MakeGuid();
                        // TODO: When using custom macros for outboud mapping operations, set the ValueBuilder.
                        // You will need to call SetValueBuilder() giving the MappingsContext a derived version
                        // of DefaultValueBuilder that has the macro methods available in it.
                        mc.SetValueBuilder(new DataUtilMacro(dra));
                        mc.Map(sp, dra);

                        //  Now write out the StudentPersonal to the output stream and
                        //  we're done publishing this student.
                        //
                        Console.WriteLine("\nThe agent has read these values from the database:");

                        DumpFieldsToConsole(rs);
                        Console.WriteLine("To produce this StudentPersonal object:");
                        debug.Write(sp);
                        debug.Flush();

                        outStream.Write(sp);
                    }

                    rs.Close();
                }
                Console.WriteLine
                    ("- Returned " + count + " records from the Student database in response");
            } catch (Exception ex) {
                Console.WriteLine("- Returning a SIF_Error response: " + ex);
                throw new SifException
                    (SifErrorCategoryCode.RequestResponse, SifErrorCodes.REQRSP_GENERIC_ERROR_1,
                      "An error occurred while querying the database for students", ex.ToString(), zone);
            } finally {
                if (command != null) {
                    try {
                        fConn.Close();
                    } catch (Exception ignored) {
                        Log.Warn(ignored.Message, ignored);
                    }
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        void RunStudentPersonalConsumer()
        {
            IStudentPersonalConsumer studentPersonalConsumer = new StudentPersonalConsumer("Sif3DemoApp");
            studentPersonalConsumer.Register();
            if (log.IsInfoEnabled) log.Info("Registered the Consumer.");

            try
            {
                // Retrieve Bart Simpson.
                Name name = new Name { FamilyName = "Simpson", GivenName = "Bart" };
                PersonInfo personInfo = new PersonInfo { Name = name };
                StudentPersonal studentPersonal = new StudentPersonal { PersonInfo = personInfo };
                ICollection<StudentPersonal> filteredStudents = studentPersonalConsumer.Retrieve(studentPersonal);

                foreach (StudentPersonal student in filteredStudents)
                {
                    if (log.IsInfoEnabled) log.Info("Filtered student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                }

                // Create and then retrieve a new student.
                Name newStudentName = new Name() { FamilyName = "Wayne", GivenName = "Bruce", Type = NameType.LGL };
                PersonInfo newStudentInfo = new PersonInfo() { Name = newStudentName };
                StudentPersonal newStudent = new StudentPersonal() { LocalId = "555", PersonInfo = newStudentInfo };
                Guid newStudentId = studentPersonalConsumer.Create(newStudent);
                if (log.IsInfoEnabled) log.Info("Created new student " + newStudent.PersonInfo.Name.GivenName + " " + newStudent.PersonInfo.Name.FamilyName);
                StudentPersonal retrievedNewStudent = studentPersonalConsumer.Retrieve(newStudentId);
                if (log.IsInfoEnabled) log.Info("Retrieved new student " + retrievedNewStudent.PersonInfo.Name.GivenName + " " + retrievedNewStudent.PersonInfo.Name.FamilyName);

                // Retrieve all students.
                ICollection<StudentPersonal> students = studentPersonalConsumer.Retrieve();

                foreach (StudentPersonal student in students)
                {
                    if (log.IsInfoEnabled) log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                }

                // Retrieve a single student.
                Guid studentId = students.ElementAt(1).Id;
                StudentPersonal secondStudent = studentPersonalConsumer.Retrieve(studentId);
                if (log.IsInfoEnabled) log.Info("Name of second student is " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName);

                // Update that student and confirm.
                secondStudent.PersonInfo.Name.GivenName = "Homer";
                secondStudent.PersonInfo.Name.FamilyName = "Simpson";
                studentPersonalConsumer.Update(secondStudent);
                secondStudent = studentPersonalConsumer.Retrieve(studentId);
                if (log.IsInfoEnabled) log.Info("Name of second student has been changed to " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName);

                // Delete that student and confirm.
                studentPersonalConsumer.Delete(studentId);
                students = studentPersonalConsumer.Retrieve();
                bool studentDeleted = true;

                foreach (StudentPersonal student in students)
                {

                    if (studentId == student.Id)
                    {
                        studentDeleted = false;
                        break;
                    }

                }

                if (studentDeleted)
                {
                    if (log.IsInfoEnabled) log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was successfully deleted.");
                }
                else
                {
                    if (log.IsInfoEnabled) log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was NOT deleted.");
                }

            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                studentPersonalConsumer.Unregister();
                if (log.IsInfoEnabled) log.Info("Unregistered the Consumer.");
            }
        }
        void RunStudentPersonalConsumer()
        {
            StudentPersonalConsumer studentPersonalConsumer = new StudentPersonalConsumer("Sif3DemoApp");
            studentPersonalConsumer.Register();
            if (log.IsInfoEnabled) log.Info("Registered the Consumer.");

            try
            {
                // Retrieve Bart Simpson using QBE.
                if (log.IsInfoEnabled) log.Info("*** Retrieve Bart Simpson using QBE.");
                NameOfRecordType name = new NameOfRecordType { FamilyName = "Simpson", GivenName = "Bart" };
                PersonInfoType personInfo = new PersonInfoType { Name = name };
                StudentPersonal studentPersonal = new StudentPersonal { PersonInfo = personInfo };
                IEnumerable<StudentPersonal> filteredStudents = studentPersonalConsumer.QueryByExample(studentPersonal);

                foreach (StudentPersonal student in filteredStudents)
                {
                    if (log.IsInfoEnabled) log.Info("Filtered student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                }

                // Create a new student.
                if (log.IsInfoEnabled) log.Info("*** Create a new student.");
                string[] text = new string[]
                {
                    @"
                        <MedicalCondition>
                            <ConditionID>Unique Medical Condition ID</ConditionID>
                            <Condition>Condition</Condition>
                            <Severity>Condition Severity</Severity>
                            <Details>Condition Details</Details>
                        </MedicalCondition>
                    "
                };
                SIF_ExtendedElementsTypeSIF_ExtendedElement extendedElement = new SIF_ExtendedElementsTypeSIF_ExtendedElement { Name = "MedicalConditions", Text = text };
                SIF_ExtendedElementsTypeSIF_ExtendedElement[] extendedElements = new SIF_ExtendedElementsTypeSIF_ExtendedElement[] { extendedElement };
                NameOfRecordType newStudentName = new NameOfRecordType { FamilyName = "Wayne", GivenName = "Bruce", Type = NameOfRecordTypeType.LGL };
                PersonInfoType newStudentInfo = new PersonInfoType { Name = newStudentName };
                StudentPersonal newStudent = new StudentPersonal { LocalId = "555", PersonInfo = newStudentInfo, SIF_ExtendedElements = extendedElements };
                StudentPersonal retrievedNewStudent = studentPersonalConsumer.Create(newStudent);
                if (log.IsInfoEnabled) log.Info("Created new student " + newStudent.PersonInfo.Name.GivenName + " " + newStudent.PersonInfo.Name.FamilyName);

                // Create multiple new students.
                if (log.IsInfoEnabled) log.Info("*** Create multiple new students.");
                List<StudentPersonal> newStudents = CreateStudents(5);
                MultipleCreateResponse multipleCreateResponse = studentPersonalConsumer.Create(newStudents);
                int count = 0;

                foreach (CreateStatus status in multipleCreateResponse.StatusRecords)
                {
                    if (log.IsInfoEnabled) log.Info("Create status code is " + status.StatusCode);
                    newStudents[count++].RefId = status.Id;
                }

                // Update multiple students.
                if (log.IsInfoEnabled) log.Info("*** Update multiple students.");
                foreach (StudentPersonal student in newStudents)
                {
                    student.PersonInfo.Name.GivenName += "o";
                }

                MultipleUpdateResponse multipleUpdateResponse = studentPersonalConsumer.Update(newStudents);

                foreach (UpdateStatus status in multipleUpdateResponse.StatusRecords)
                {
                    if (log.IsInfoEnabled) log.Info("Update status code is " + status.StatusCode);
                }

                // Delete multiple students.
                if (log.IsInfoEnabled) log.Info("*** Delete multiple students.");
                ICollection<string> refIds = new List<string>();

                foreach (CreateStatus status in multipleCreateResponse.StatusRecords)
                {
                    refIds.Add(status.Id);
                }

                MultipleDeleteResponse multipleDeleteResponse = studentPersonalConsumer.Delete(refIds);

                foreach (DeleteStatus status in multipleDeleteResponse.StatusRecords)
                {
                    if (log.IsInfoEnabled) log.Info("Delete status code is " + status.StatusCode);
                }

                // Retrieve all students from zone "Gov" and context "Curr".
                if (log.IsInfoEnabled) log.Info("*** Retrieve all students from zone \"Gov\" and context \"Curr\".");
                IEnumerable<StudentPersonal> students = studentPersonalConsumer.Query(zone: "Gov", context: "Curr");

                foreach (StudentPersonal student in students)
                {
                    if (log.IsInfoEnabled) log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);
                }

                if (students.Count() > 1)
                {

                    // Retrieve a single student.
                    if (log.IsInfoEnabled) log.Info("*** Retrieve a single student.");
                    string studentId = students.ElementAt(1).RefId;
                    StudentPersonal secondStudent = studentPersonalConsumer.Query(studentId);
                    if (log.IsInfoEnabled) log.Info("Name of second student is " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName);

                    // Update that student and confirm.
                    if (log.IsInfoEnabled) log.Info("*** Update that student and confirm.");
                    secondStudent.PersonInfo.Name.GivenName = "Homer";
                    secondStudent.PersonInfo.Name.FamilyName = "Simpson";
                    studentPersonalConsumer.Update(secondStudent);
                    secondStudent = studentPersonalConsumer.Query(studentId);
                    if (log.IsInfoEnabled) log.Info("Name of second student has been changed to " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName);

                    // Delete that student and confirm.
                    if (log.IsInfoEnabled) log.Info("*** Delete that student and confirm.");
                    studentPersonalConsumer.Delete(studentId);
                    StudentPersonal deletedStudent = studentPersonalConsumer.Query(studentId);
                    bool studentDeleted = (deletedStudent == null ? true : false);

                    if (studentDeleted)
                    {
                        if (log.IsInfoEnabled) log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was successfully deleted.");
                    }
                    else
                    {
                        if (log.IsInfoEnabled) log.Info("Student " + secondStudent.PersonInfo.Name.GivenName + " " + secondStudent.PersonInfo.Name.FamilyName + " was NOT deleted.");
                    }

                }

                // Retrieve students based on Teaching Group using Service Paths.
                if (log.IsInfoEnabled) log.Info("*** Retrieve students based on Teaching Group using Service Paths.");
                EqualCondition condition = new EqualCondition() { Left = "TeachingGroups", Right = "597ad3fe-47e7-4b2c-b919-a93c564d19d0" };
                IList<EqualCondition> conditions = new List<EqualCondition>();
                conditions.Add(condition);
                IEnumerable<StudentPersonal> teachingGroupStudents = studentPersonalConsumer.QueryByServicePath(conditions);

                foreach (StudentPersonal student in teachingGroupStudents)
                {
                    if (log.IsInfoEnabled) log.Info("Student name is " + student.PersonInfo.Name.GivenName + " " + student.PersonInfo.Name.FamilyName);

                    if (student.SIF_ExtendedElements != null && student.SIF_ExtendedElements.Length > 0)
                    {

                        foreach (SIF_ExtendedElementsTypeSIF_ExtendedElement element in student.SIF_ExtendedElements)
                        {

                            foreach (string content in element.Text)
                            {
                                if (log.IsInfoEnabled) log.Info("Extended element text is ...\n" + content);
                            }

                        }

                    }

                }

            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                studentPersonalConsumer.Unregister();
                if (log.IsInfoEnabled) log.Info("Unregistered the Consumer.");
            }
        }