コード例 #1
0
        public void testStaffPersonalATCHNullPhone()
        {
            IDictionary values = new Hashtable();

            values.Add("ATCH.TCHNUM", "98");
            values.Add("ATCH.SOCSECNUM", "455128888");
            values.Add("ATCH.SCHOOLNUM", "999");
            values.Add("ATCH.SCHOOLNUM2", "999");
            values.Add("ATCH.HOMEROOM", "5");
            values.Add("ATCH.LASTNAME", "Ngo");
            values.Add("ATCH.FIRSTNAME", "Van");
            values.Add("ATCH.MIDDLENAME", null);
            values.Add("ATCH.TELEPHONE", null);
            values.Add("ATCH.TELEXTN", null);
            values.Add("ATCH.EMAILADDR", null);
            values.Add("ATCH.ETHNIC", "W");
            StringMapAdaptor sma = new StringMapAdaptor(values);
            StaffPersonal    s   = new StaffPersonal();

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

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

            Console.WriteLine(s.ToXml());

            Element e = s
                        .GetElementOrAttribute("PhoneNumber[@Format='NA' and @Type='WP']");

            Assertion.AssertNull("PhoneNumber should be null", e);
        }
コード例 #2
0
        public void testStaffPersonalATCH()
        {
            IDictionary values = new Hashtable();

            values.Add("ATCH.TCHNUM", "98");
            values.Add("ATCH.SOCSECNUM", "455128888");
            values.Add("ATCH.SCHOOLNUM", "999");
            values.Add("ATCH.SCHOOLNUM2", "999");
            values.Add("ATCH.HOMEROOM", "5");
            values.Add("ATCH.LASTNAME", "Ngo");
            values.Add("ATCH.FIRSTNAME", "Van");
            values.Add("ATCH.MIDDLENAME", null);
            values.Add("ATCH.TELEPHONE", "8011234567");
            values.Add("ATCH.TELEXTN", null);
            values.Add("ATCH.EMAILADDR", null);
            values.Add("ATCH.ETHNIC", "W");
            StringMapAdaptor sma = new StringMapAdaptor(values);
            StaffPersonal    s   = new StaffPersonal();

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

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

            Console.WriteLine(s.ToXml());
        }
コード例 #3
0
        public void testSchoolCourseInfo()
        {
            IDictionary values = new Hashtable();

            values.Add("CREDVALUE", "0");
            values.Add("MAXCREDITS", "1");

            StringMapAdaptor sma = new StringMapAdaptor(values);
            SchoolCourseInfo sc  = new SchoolCourseInfo();

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

            m.MapOutbound(sma, sc, SifVersion.SIF15r1);
            Console.WriteLine(sc.ToXml());

            Element e = sc.GetElementOrAttribute("CourseCredits[@Code='01']");

            Assertion.AssertNotNull("credits", e);
            Assertion.AssertEquals("credits", "0", e.TextValue);

            e = sc.GetElementOrAttribute("CourseCredits[@Code='02']");
            Assertion.AssertNotNull("maxcredits", e);
            Assertion.AssertEquals("maxcredits", "1", e.TextValue);
        }
コード例 #4
0
        private StringMapAdaptor createStudentContactFields()
        {
            IDictionary values = new Hashtable();

            values.Add("APRN.SOCSECNUM", "123456789");
            values.Add("APRN.SCHOOLNUM", "999");
            values.Add("APRN.SCHOOLNUM2", "999");
            values.Add("APRN.EMAILADDR", null);
            values.Add("APRN.LASTNAME", "DOE");
            values.Add("APRN.FIRSTNAME", "JOHN");
            values.Add("APRN.MIDDLENAME", null);
            values.Add("APRN.WRKADDR", null);
            values.Add("APRN.WRKCITY", null);
            values.Add("APRN.WRKSTATE", null);
            values.Add("APRN.WRKCOUNTRY", null);
            values.Add("APRN.WRKZIP", "54494");
            values.Add("APRN.ADDRESS", null);
            values.Add("APRN.CITY", null);
            values.Add("APRN.STATE", null);
            values.Add("APRN.COUNTRY", null);
            values.Add("APRN.ZIPCODE", null);
            values.Add("APRN.TELEPHONE", "8014504555");
            values.Add("APRN.ALTTEL", "8014505555");
            values.Add("APRN.WRKTEL", null);
            // Test escaping of text values in the phone number field
            values.Add("APRN.WRKEXTN", "M&W");
            values.Add("APRN.RELATION", "01");
            // values.Add( "APRN.WRKSTATE", "" );
            // values.Add( "APRN.RELATION2", "01" );

            StringMapAdaptor sma = new StringMapAdaptor(values);

            return(sma);
        }
コード例 #5
0
        public void TestConcatenateFields()
        {
            String configFileText = "<agent id=\"Repro\" sifVersion=\"2.0\">"
                                    + "    <mappings id=\"Default\">"
                                    + "        <object object=\"StudentPersonal\">"
                                    + "            <field name=\"StudentPers_guid\">@RefId</field>"
                                    + "            <field name=\"LastName\">Name[@Type='01']/LastName</field>"
                                    + "            <field name=\"FirstName\">Name[@Type='01']/FirstName</field>"
                                    + "            <field name=\"MiddleName\">Name[@Type='01']/MiddleName</field>"
                                    +
                                    "            <field name=\"FullName\">Name[@Type='01']/FullName=$(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", "Finale, Prima Mediccio", fullName.Value );
        }
コード例 #6
0
        public void testStudentSnapshot15r1()
        {
            StringMapAdaptor sma = createStudentSnapshotFields();
            StudentSnapshot  ss  = new StudentSnapshot();

            ss.StudentPersonalRefId = Adk.MakeGuid();
            ss.SnapDate             = DateTime.Now;

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

            m
            .MapOutbound(sma, ss, new DefaultValueBuilder(sma),
                         SifVersion.SIF15r1);
            Console.WriteLine(ss.ToXml());

            int?onTimeGradYear = ss.OnTimeGraduationYear;

            Assertion.Assert("onTimeGraduationYear is null", onTimeGradYear.HasValue);
            Assertion.AssertEquals("OnTimeGraduationYear", 2000, onTimeGradYear.Value);

            SchemaValidator sv = USSchemaValidator.NewInstance(SifVersion.SIF15r1);

            // 3) Validate the file
            bool validated = sv.Validate(ss, SifVersion.SIF15r1);

            // 4) If validation failed, write the object out for tracing purposes
            if (!validated)
            {
                sv.PrintProblems(Console.Out);
                Assertion.Fail("Schema Validation Failed:");
            }
        }
コード例 #7
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);
        }
コード例 #8
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);
        }
コード例 #9
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);
        }
コード例 #10
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);
        }
コード例 #11
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");
        }
コード例 #12
0
        public void testStudentMealMappings()
        {
            StudentMeal sm       = new StudentMeal();
            Mappings    mappings = fCfg.Mappings.GetMappings("Default");
            IDictionary map      = new Hashtable();

            map.Add("Balance", "10.55");

            StringMapAdaptor sma = new StringMapAdaptor(map);

            mappings.MapOutbound(sma, sm);

            sm = (StudentMeal)AdkObjectParseHelper.WriteParseAndReturn(sm, fVersion);

            // Assert that the object was mapped correctly
            FSAmounts amounts = sm.Amounts;

            Assertion.AssertNotNull(amounts);
            FSAmount amount = amounts.ItemAt(0);

            Assertion.Assert(amount.Value.HasValue);
            Assertion.AssertEquals(10.55, amount.Value.Value);


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

            sma = new StringMapAdaptor(restoredData);
            mappings.MapInbound(sm, sma);
            assertMapsAreEqual(map, restoredData);
        }
コード例 #13
0
        protected StringMapAdaptor createStudentContactFields()
        {
            IDictionary values = new Hashtable();

            values.Add("APRN.SOCSECNUM", "123456789");
            values.Add("APRN.SCHOOLNUM", "999");
            values.Add("APRN.SCHOOLNUM2", "999");
            values.Add("APRN.EMAILADDR", null);
            values.Add("APRN.LASTNAME", "DOE");
            values.Add("APRN.FIRSTNAME", "JOHN");
            values.Add("APRN.MIDDLENAME", null);
            values.Add("APRN.WRKADDR", null);
            values.Add("APRN.WRKCITY", null);
            values.Add("APRN.WRKSTATE", null);
            values.Add("APRN.WRKCOUNTRY", null);
            values.Add("APRN.WRKZIP", "54494");
            values.Add("APRN.ADDRESS", null);
            values.Add("APRN.CITY", null);
            values.Add("APRN.STATE", null);
            values.Add("APRN.COUNTRY", null);
            values.Add("APRN.ZIPCODE", null);
            values.Add("APRN.TELEPHONE", "8014504555");
            values.Add("APRN.ALTTEL", "8014505555");
            values.Add("APRN.WRKTEL", null);
            values.Add("APRN.WRKEXTN", null);
            values.Add("APRN.RELATION", "01");
            values.Add("APRN.PICKUPRIGHTS", "Yes");

            StringMapAdaptor sma = new StringMapAdaptor(values);

            return(sma);
        }
コード例 #14
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 );
        }
コード例 #15
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);
        }
コード例 #16
0
        public void testStudentContactSIF20()
        {
            Adk.SifVersion = SifVersion.SIF20r1;
            StringMapAdaptor sma = createStudentContactFields();
            StudentContact   sc  = new StudentContact();

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

            m.MapOutbound(sma, sc, SifVersion.SIF20r1);
            String value = sc.ToXml();

            Console.WriteLine(value);

            // Verify that the phone number is properly escaped
            int loc = value.IndexOf("<Number>M&amp;W</Number>");

            Assertion.Assert("Phone number should be escaped", loc > -1);

            // Verify that the @Type attribute is not rendered in SIF 2.0
            loc = value.IndexOf("Type=\"E4\"");
            Assertion.AssertEquals("Type Attribute should not be rendered", -1, loc);

            sc.SifVersion = SifVersion.SIF20r1;
            Element e = sc
                        .GetElementOrAttribute("//PhoneNumber[@Type='0096']/Number");

            Assertion.AssertNotNull("School PhoneNumber should be mapped", e);
            Assertion.AssertEquals("School phone", "8014504555", e.TextValue);

            e = sc.GetElementOrAttribute("//PhoneNumber[@Type='0350'][1]/Number");
            Assertion.AssertNotNull("School PhoneNumber should be mapped", e);
            // Note the " " Space at the end of the value. This should be there,
            // according to the mapping
            Assertion.AssertEquals("School phone", "8014505555 ", e.TextValue);

            e = sc.GetElementOrAttribute("//PhoneNumber[@Type='0350'][2]/Number");
            Assertion.AssertNull("School PhoneNumber should not be mapped", e);

            AddressList al = sc.AddressList;

            if (al != null)
            {
                foreach (Address addr in al)
                {
                    Assertion.AssertNull("Country should be null", addr.Country);
                    if (addr.Type.Equals("1075"))
                    {
                        Assertion.AssertNull("State should be null", addr.StateProvince);
                    }
                }
            }
        }
コード例 #17
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);
        }
コード例 #18
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 );
        }
コード例 #19
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();
        }
コード例 #20
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);
        }
コード例 #21
0
        public void testStudentContactSIF15r1()
        {
            StringMapAdaptor sma = createStudentContactFields();
            StudentContact   sc  = new StudentContact();
            Mappings         m   = fCfg.Mappings.GetMappings("Default").Select(null,
                                                                               null, null);

            m.MapOutbound(sma, sc, SifVersion.SIF15r1);
            String value = sc.ToXml();

            Console.WriteLine(value);

            //	Verify that the phone number is properly escaped
            int loc = value.IndexOf("<PhoneNumber Format=\"NA\" Type=\"EX\">M&amp;W</PhoneNumber>");

            Assertion.Assert("Phone number should be escaped", loc > -1);

            Element e = sc
                        .GetElementOrAttribute("PhoneNumber[@Format='NA' and @Type='HP']");

            Assertion.AssertNotNull("School PhoneNumber should be mapped", e);
            Assertion.AssertEquals("School phone", "8014504555", e.TextValue);

            e = sc
                .GetElementOrAttribute("PhoneNumber[@Format='NA' and @Type='AP']");
            Assertion.AssertNotNull("School PhoneNumber should be mapped", e);
            // Note the " " Space at the end of the value. This should be there,
            // according to the mapping
            Assertion.AssertEquals("School phone", "8014505555 ", e.TextValue);

            e = sc
                .GetElementOrAttribute("PhoneNumber[@Format='NA' and @Type='WP']");
            Assertion.AssertNull("School PhoneNumber should not be mapped", e);

            AddressList al = sc.AddressList;

            if (al != null)
            {
                foreach (Address addr in al)
                {
                    Assertion.AssertNull("Country should be null", addr.Country);
                    if (addr.Type.Equals("O"))
                    {
                        Assertion.AssertNull("State should be null", addr.StateProvince);
                    }
                }
            }
        }
コード例 #22
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);
        }
コード例 #23
0
        public void testStudentSnapshot15r1_Adk20r1()
        {
            Adk.SifVersion = SifVersion.SIF15r1;
            StringMapAdaptor sma = createStudentSnapshotFields();
            StudentSnapshot  ss  = new StudentSnapshot();
            Mappings         m   = fCfg.Mappings.GetMappings("Default").Select(null,
                                                                               null, null);

            m.MapOutbound(sma, ss, SifVersion.SIF20r1);
            Console.WriteLine(ss.ToXml());

            int?onTimeGradYear = ss.OnTimeGraduationYear;

            Assertion.Assert("onTimeGraduationYear is null", onTimeGradYear.HasValue);
            Assertion.AssertEquals("OnTimeGraduationYear", 2000, onTimeGradYear.Value);
        }
コード例 #24
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));
        }
コード例 #25
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);
        }
コード例 #26
0
        public void testOtherIdsNullValues()
        {
            String customMappings = "<agent id='Repro' sifVersion='2.0'>"
                                    + "   <mappings id='Default'>"
                                    + "     <object object='StudentPersonal'>"
                                    +
                                    "     <field name='PERMNUM' sifVersion='+2.0'>OtherIdList/OtherId[@Type='0593']</field>"
                                    + "     <field name='PERMNUM' sifVersion='-1.5r1'>OtherId[@Type='06']</field>"
                                    + "     <field name='PERMNUM' sifVersion='+1.5'>LocalId</field>"
                                    +
                                    "     <field name='SOCSECNUM' sifVersion='+2.0'>OtherIdList/OtherId[@Type='0004']</field>"
                                    + "     <field name='SOCSECNUM' sifVersion='-1.5r1'>OtherId[@Type='SY']</field>"
                                    +
                                    "     <field name='SCHOOLNUM' sifVersion='+2.0'>OtherIdList/OtherId[@Type='9999'+]=SCHOOL:$(SCHOOLNUM)</field>"
                                    +
                                    "     <field name='SCHOOLNUM' sifVersion='-1.5r1'>OtherId[@Type='ZZ'+]=SCHOOL:$(SCHOOLNUM)</field>"
                                    + "</object></mappings></agent>";

            Adk.SifVersion = SifVersion.SIF15r1;

            IDictionary map = new Hashtable();

            map.Add("PERMNUM", "123456");
            map.Add("SOCSECNUM", null);
            map.Add("SCHOOLNUM", "2");
            StringMapAdaptor sma = new StringMapAdaptor(map);
            StudentPersonal  obj = new StudentPersonal();

            doOutboundMapping(sma, obj, customMappings, null);

            OtherIdList list = obj.OtherIdList;

            Assertion.AssertNotNull("OtherIdList is null", list);
            OtherId oId = list["06"];

            Assertion.AssertNotNull("PERMNUM", oId);
            Assertion.AssertEquals("PERMNUM", "123456", oId.Value);

            // The SOCSECNUM was NULL, so it should not produce an element
            oId = list["SY"];
            Assertion.AssertNull("SOCSECNUM", oId);

            oId = list["ZZ"];
            Assertion.AssertNotNull("SCHOOLNUM", oId);
            Assertion.AssertEquals("SCHOOLNUM", "SCHOOL:2", oId.Value);
        }
コード例 #27
0
        public void testMap2()
        {
            StudentPersonal studentPersonal = makeStudentPersonal("34",
                                                                  NameType.BIRTH, "David", "Ortiz");
            IDictionary      student  = new Dictionary <String, String>();
            StringMapAdaptor sma      = new StringMapAdaptor(student);
            Mappings         mappings = buildMappings1();

            logger.Debug("========= Root Mappings =========");
            dumpMappings(mappings);

            if (mappings.GetMappings("Default") != null)
            {
                mappings = mappings.GetMappings("Default");
                logger.Debug("======= Default Mappings ========");
                dumpMappings(mappings);
                if (mappings.GetMappings("MA") != null)
                {
                    mappings = mappings.GetMappings("MA");
                    logger.Debug("========== MA Mappings ==========");
                    dumpMappings(mappings);
                    if (mappings.GetMappings("Boston") != null)
                    {
                        mappings = mappings.GetMappings("Boston");
                        logger.Debug("======= Boston Mappings =========");
                        dumpMappings(mappings);
                    }
                }
            }

            // This line gets a "Mappings.select can only be called..." exception
            // mappings = mappings.select("anyzone", null, Adk.SifVersion());
            logger.Debug("======= Selected (" + mappings.Id
                         + ") Mappings =========");
            dumpMappings(mappings);

            mappings.MapInbound(studentPersonal, sma);
            logger.Debug("==================================");

            foreach (DictionaryEntry de in student)
            {
                logger.Debug(String.Format("{0} = {1}", de.Key, de.Value));
            }
        }
コード例 #28
0
        public void testMap2()
        {
            StudentPersonal studentPersonal = makeStudentPersonal( "34",
                                                                   NameType.BIRTH, "David", "Ortiz" );
            IDictionary student = new Dictionary<String, String>();
            StringMapAdaptor sma = new StringMapAdaptor( student );
            Mappings mappings = buildMappings1();

            logger.Debug( "========= Root Mappings =========" );
            dumpMappings( mappings );

            if ( mappings.GetMappings( "Default" ) != null )
            {
                mappings = mappings.GetMappings( "Default" );
                logger.Debug( "======= Default Mappings ========" );
                dumpMappings( mappings );
                if ( mappings.GetMappings( "MA" ) != null )
                {
                    mappings = mappings.GetMappings( "MA" );
                    logger.Debug( "========== MA Mappings ==========" );
                    dumpMappings( mappings );
                    if ( mappings.GetMappings( "Boston" ) != null )
                    {
                        mappings = mappings.GetMappings( "Boston" );
                        logger.Debug( "======= Boston Mappings =========" );
                        dumpMappings( mappings );
                    }
                }
            }

            // This line gets a "Mappings.select can only be called..." exception
            // mappings = mappings.select("anyzone", null, Adk.SifVersion());
            logger.Debug( "======= Selected (" + mappings.Id
                          + ") Mappings =========" );
            dumpMappings( mappings );

            mappings.MapInbound( studentPersonal, sma );
            logger.Debug( "==================================" );

            foreach ( DictionaryEntry de in student )
            {
                logger.Debug( String.Format( "{0} = {1}", de.Key, de.Value ) );
            }
        }
コード例 #29
0
        public void testStudentSnapshot15r1_NullLastName()
        {
            Adk.SifVersion = SifVersion.SIF15r1;
            StringMapAdaptor sma = createStudentSnapshotFields();

            // SASI Expects that a null string will result in
            // the field not being mapped. Checking that here
            sma.Dictionary["LASTNAME"] = null;
            StudentSnapshot ss = new StudentSnapshot();

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

            m.MapOutbound(sma, ss, SifVersion.SIF15r1);
            String value = ss.ToXml();

            Console.WriteLine(value);

            Assertion.Assert("Last Name should be null", value.IndexOf("LastName") == -1);
        }
コード例 #30
0
        public void TestVariableOutbound()
        {
            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=$(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);
            StudentPersonal  sp  = mapToStudentPersonal(sma, flattenDateFunctionCall, null);

            Assertion.AssertNotNull("Student should not be null", sp);
            Assertion.AssertNotNull("BirthDate should not be null", sp.Demographics.BirthDate);
        }
コード例 #31
0
        public void testCountryCodeStudentPersonal()
        {
            Adk.SifVersion = SifVersion.SIF15r1;

            String customMappings = "<agent id='Repro' sifVersion='2.0'>"
                                    + "   <mappings id='Default'>"
                                    + "     <object object='StudentPersonal'>"
                                    +
                                    "       <field name='COUNTRY' sifVersion='+2.0'>AddressList/Address[@Type='0769']/Country=US</field>"
                                    +
                                    "       <field name='COUNTRY' sifVersion='-1.5r1'>StudentAddress[@PickupOrDropoff='NA',@DayOfWeek='NA']/Address[@Type='M']/Country[@Code='UK']</field>"
                                    +
                                    "       <field name='RESCOUNTRY' sifVersion='+2.0'>AddressList/Address[@Type='0765']/Country=US</field>"
                                    +
                                    "       <field name='RESCOUNTRY' sifVersion='-1.5r1'>StudentAddress[@PickupOrDropoff='NA',@DayOfWeek='NA']/Address[@Type='P']/Country[@Code='US']</field>"
                                    + "</object></mappings></agent>";

            Adk.SifVersion = SifVersion.SIF15r1;

            IDictionary map = new Hashtable();

            map.Add("RESCOUNTRY", "");
            map.Add("COUNTRY", "");
            StringMapAdaptor sma = new StringMapAdaptor(map);
            StudentPersonal  sp  = new StudentPersonal();

            doOutboundMapping(sma, sp, customMappings, null);

            StudentAddressList sal = sp.AddressList;

            Assertion.AssertNotNull("StudentAddressList is null", sal);
            Assertion.AssertEquals(
                "StudentAddressList does not contain two address list types",
                2, sal.ChildCount);

            assertCountry((Address)sp
                          .GetElementOrAttribute("StudentAddress/Address[@Type='P']"),
                          "US");
            assertCountry((Address)sp
                          .GetElementOrAttribute("StudentAddress/Address[@Type='M']"),
                          "UK");
        }
コード例 #32
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));
        }
コード例 #33
0
        public void testStudentSchoolEnrollmentGradeLevelMapping()
        {
            Adk.SifVersion = SifVersion.SIF15r1;
            IDictionary values = new Hashtable();

            values.Add("GRADE", "00");
            StringMapAdaptor        sma = new StringMapAdaptor(values);
            StudentSchoolEnrollment sse = new StudentSchoolEnrollment();
            Mappings m = fCfg.Mappings.GetMappings("Default").Select(null,
                                                                     null, null);

            m.MapOutbound(sma, sse, SifVersion.SIF15r1);
            sse.SetHomeroom("RoomInfo", Adk.MakeGuid());
            Console.WriteLine(sse.ToXml());

            // This specific case tests what should happen when the grade level is
            // using an undefined value.
            // The valueset entries don't have a value for "00", so "00" should be
            // returned as-is
        }
コード例 #34
0
        public void testStudentSnapshot20_BlankGradYear()
        {
            Adk.SifVersion = SifVersion.LATEST;
            StringMapAdaptor sma = createStudentSnapshotFields();

            // SASI Expects that a single space character in a grad year
            // field will not produce an error, but rather an empty element
            sma.Dictionary["ORIGYRGRAD"] = " ";
            StudentSnapshot ss = new StudentSnapshot();

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

            m.MapOutbound(sma, ss, SifVersion.LATEST);
            Console.WriteLine(ss.ToXml());

            int?onTimeGradYear = ss.OnTimeGraduationYear;

            Assertion.Assert("onTimeGraduationYear is not null", !onTimeGradYear.HasValue);
        }
コード例 #35
0
        public void testCountryCodeSchoolInfo()
        {
            String customMappings = "<agent id='Repro' sifVersion='2.0'>"
                                    + "   <mappings id='Default'>"
                                    + "     <object object='SchoolInfo'>"
                                    +
                                    "		<field name='COUNTRY' sifVersion='+2.0'>AddressList/Address[@Type='0123']/Country=US</field>"
                                    +
                                    "     <field name='COUNTRY' sifVersion='-1.5r1'>Address[@Type='SS']/Country[@Code='US']</field>"
                                    + "</object></mappings></agent>";

            Adk.SifVersion = SifVersion.SIF15r1;

            IDictionary map = new Hashtable();
            map.Add( "COUNTRY", "" );
            StringMapAdaptor sma = new StringMapAdaptor( map );
            SchoolInfo obj = new SchoolInfo();
            doOutboundMapping( sma, obj, customMappings, null );

            assertAddressWithCountry( obj.AddressList, "US" );
        }
コード例 #36
0
        public void testInBoundMapping50000()
        {
            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 );

            // Fill out the student personal using outbound mappings first
            StudentPersonal template = new StudentPersonal();
            mappings.MapOutbound( sma, template );
            Console.WriteLine( template.ToXml() );

            DateTime start = DateTime.Now;
            for ( int x = 0; x < mappingIterations; x++ )
            {
                map.Clear();
                mappings.MapInbound( 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 ) );
        }
コード例 #37
0
        public void testSchoolCourseInfo()
        {
            IDictionary values = new Hashtable();
            values.Add( "CREDVALUE", "0" );
            values.Add( "MAXCREDITS", "1" );

            StringMapAdaptor sma = new StringMapAdaptor( values );
            SchoolCourseInfo sc = new SchoolCourseInfo();
            sc.SchoolYear = 1999;
            Mappings m = fCfg.Mappings.GetMappings( "Default" ).Select( null,
                                                                        null, null );
            m.MapOutbound( sma, sc, SifVersion.SIF15r1 );
            Console.WriteLine( sc.ToXml() );

            Element e = sc.GetElementOrAttribute( "CourseCredits[@Code='01']" );
            Assertion.AssertNotNull( "credits", e );
            Assertion.AssertEquals( "credits", "0", e.TextValue );

            e = sc.GetElementOrAttribute( "CourseCredits[@Code='02']" );
            Assertion.AssertNotNull( "maxcredits", e );
            Assertion.AssertEquals( "maxcredits", "1", e.TextValue );
        }
コード例 #38
0
        public void testStaffPersonalASTF()
        {
            IDictionary values = new Hashtable();
            values.Add( "ASTF.STAFFNUM", "9847" );
            values.Add( "ASTF.SOCSECNUM", "123456789" );
            values.Add( "ASTF.SCHOOLNUM", "999" );
            values.Add( "ASTF.SCHOOLNUM2", "999" );
            values.Add( "ASTF.HOMEROOM", "8" );
            values.Add( "ASTF.EMAILADDR", null );
            values.Add( "ASTF.LASTNAME", "Ngo" );
            values.Add( "ASTF.FIRSTNAME", "Tom" );
            values.Add( "ASTF.MIDDLENAME", "C" );
            values.Add( "ASTF.ADDRESS", "1232 Bateman Point Drive" );
            values.Add( "ASTF.CITY", "West Jordan" );
            values.Add( "ASTF.STATE", "Utah" );
            values.Add( "ASTF.COUNTRY", "" );
            values.Add( "ASTF.ZIPCODE", "84084" );
            values.Add( "ASTF.SCHOOLTEL", "1234567890" );
            values.Add( "ASTF.TELEXTN", null );
            values.Add( "ASTF.HOMETEL", null );
            values.Add( "ASTF.ETHNICCODE", "W" );
            StringMapAdaptor sma = new StringMapAdaptor( values );
            StaffPersonal s = new StaffPersonal();

            Mappings m = fCfg.Mappings.GetMappings( "Default" ).Select( null,
                                                                        null, null );
            m.MapOutbound( sma, s, SifVersion.SIF15r1 );

            Console.WriteLine( s.ToXml() );

            Element e = s
                .GetElementOrAttribute( "PhoneNumber[@Format='NA' and @Type='HP']" );
            Assertion.AssertNull( "Home PhoneNumber should not be mapped", e );
            e = s.GetElementOrAttribute( "PhoneNumber[@Format='NA' and @Type='WP']" );
            Assertion.AssertNotNull( "School PhoneNumber should be mapped", e );
            Assertion.AssertEquals( "School phone", "1234567890", e.TextValue );
        }
コード例 #39
0
        public void testCountryCodeLEAInfo()
        {
            Adk.SifVersion = SifVersion.SIF15r1;

            String customMappings = "<agent id='Repro' sifVersion='2.0'>"
                                    + "   <mappings id='Default'>"
                                    + "     <object object='LEAInfo'>"
                                    +
                                    "		<field name='DISTRICT_COUNTRY' sifVersion='+2.0'>AddressList/Address[@Type='0123']/Country=US</field>"
                                    +
                                    "		<field name='DISTRICT_COUNTRY' sifVersion='-1.5r1'>Address[@Type='07']/Country[@Code='US']</field>"
                                    +
                                    "		<field name='CONTACT_PHONE' sifVersion='+2.0'>LEAContactList/LEAContact/ContactInfo/PhonenumberList/PhoneNumber[@Type='0096']/Number</field>"
                                    +
                                    "     <field name='CONTACT_PHONE' sifVersion='-1.5r1'>LEAContact/ContactInfo/PhoneNumber[@Format='NA',@Type='TE']</field>"
                                    + "</object></mappings></agent>";

            Adk.SifVersion = SifVersion.SIF15r1;

            IDictionary map = new Hashtable();
            map.Add( "DISTRICT_COUNTRY", null );
            map.Add( "CONTACT_PHONE", "801.550.2796" );
            StringMapAdaptor sma = new StringMapAdaptor( map );
            LEAInfo obj = new LEAInfo();
            doOutboundMapping( sma, obj, customMappings, null );

            Assertion.AssertNull( "Address should be null", obj.AddressList );

            ContactInfo ci = (ContactInfo) obj
                                               .GetElementOrAttribute( "LEAContact/ContactInfo" );
            PhoneNumber phone = ci.PhoneNumberList.ItemAt( 0 );
            Assertion.AssertNotNull( "Phone was not set", phone );
            Assertion.AssertEquals( "Format", "NA", phone.Format );
            Assertion.AssertEquals( "Type", "TE", phone.Type );
            Assertion.AssertEquals( "Format", "801.550.2796", phone.Number );
        }
コード例 #40
0
        public void testOtherIdsWithValues()
        {
            String customMappings = "<agent id='Repro' sifVersion='2.0'>"
                                    + "   <mappings id='Default'>"
                                    + "     <object object='StudentPersonal'>"
                                    + "     <field name='PERMNUM' sifVersion='+2.0'>OtherIdList/OtherId[@Type='0593']</field>"
                                    + "     <field name='PERMNUM' sifVersion='-1.5r1'>OtherId[@Type='06']</field>"
                                    + "     <field name='PERMNUM' sifVersion='+1.5'>LocalId</field>"
                                    + "     <field name='SOCSECNUM' sifVersion='+2.0'>OtherIdList/OtherId[@Type='0004']</field>"
                                    + "     <field name='SOCSECNUM' sifVersion='-1.5r1'>OtherId[@Type='SY']</field>"
                                    + "     <field name='SCHOOLNUM' sifVersion='+2.0'>OtherIdList/OtherId[@Type='9999'+]=SCHOOL:$(SCHOOLNUM)</field>"
                                    + "     <field name='SCHOOLNUM' sifVersion='-1.5r1'>OtherId[@Type='ZZ'+]=SCHOOL:$(SCHOOLNUM)</field>"
                                    + "</object></mappings></agent>";

            Adk.SifVersion = SifVersion.SIF15r1;

            IDictionary map = new Hashtable();
            map.Add( "PERMNUM", "123456" );
            map.Add( "SOCSECNUM", "111-555-9987" );
            map.Add( "SCHOOLNUM", "2" );
            StringMapAdaptor sma = new StringMapAdaptor( map );
            StudentPersonal obj = new StudentPersonal();
            doOutboundMapping( sma, obj, customMappings, null );

            OtherIdList list = obj.OtherIdList;
            Assertion.AssertNotNull( "OtherIdList is null", list );
            OtherId oId = list[ "06" ];
            Assertion.AssertNotNull( "PERMNUM", oId );
            Assertion.AssertEquals( "PERMNUM", "123456", oId.Value );

            oId = list[ "SY"];
            Assertion.AssertNotNull( "SOCSECNUM", oId );
            Assertion.AssertEquals( "SOCSECNUM", "111-555-9987", oId.Value );

            oId = list[ "ZZ" ];
            Assertion.AssertNotNull( "SCHOOLNUM", oId );
            Assertion.AssertEquals( "SCHOOLNUM", "SCHOOL:2", oId.Value );
        }
コード例 #41
0
        public void testCountryCodeStudentPersonal()
        {
            Adk.SifVersion = SifVersion.SIF15r1;

            String customMappings = "<agent id='Repro' sifVersion='2.0'>"
                                    + "   <mappings id='Default'>"
                                    + "     <object object='StudentPersonal'>"
                                    +
                                    "       <field name='COUNTRY' sifVersion='+2.0'>AddressList/Address[@Type='0769']/Country=US</field>"
                                    +
                                    "       <field name='COUNTRY' sifVersion='-1.5r1'>StudentAddress[@PickupOrDropoff='NA',@DayOfWeek='NA']/Address[@Type='M']/Country[@Code='UK']</field>"
                                    +
                                    "       <field name='RESCOUNTRY' sifVersion='+2.0'>AddressList/Address[@Type='0765']/Country=US</field>"
                                    +
                                    "       <field name='RESCOUNTRY' sifVersion='-1.5r1'>StudentAddress[@PickupOrDropoff='NA',@DayOfWeek='NA']/Address[@Type='P']/Country[@Code='US']</field>"
                                    + "</object></mappings></agent>";

            Adk.SifVersion = SifVersion.SIF15r1;

            IDictionary map = new Hashtable();
            map.Add( "RESCOUNTRY", "" );
            map.Add( "COUNTRY", "" );
            StringMapAdaptor sma = new StringMapAdaptor( map );
            StudentPersonal sp = new StudentPersonal();
            doOutboundMapping( sma, sp, customMappings, null );

            StudentAddressList sal = sp.AddressList;
            Assertion.AssertNotNull( "StudentAddressList is null", sal );
            Assertion.AssertEquals(
                "StudentAddressList does not contain two address list types",
                2, sal.ChildCount );

            assertCountry( (Address) sp
                                         .GetElementOrAttribute( "StudentAddress/Address[@Type='P']" ),
                           "US" );
            assertCountry( (Address) sp
                                         .GetElementOrAttribute( "StudentAddress/Address[@Type='M']" ),
                           "UK" );
        }
コード例 #42
0
        public void testSchoolInfo010()
        {
            String schoolInfoResp = "	<SIF_Message  xmlns=\"http://www.sifinfo.org/infrastructure/1.x\" Version=\"1.5r1\">"
                                    + "	  <SIF_Response>"
                                    + "		<SIF_Header>"
                                    + "		  <SIF_MsgId>B329CA6E5BC342339F135880CEE0578E</SIF_MsgId>"
                                    + "		  <SIF_Date>20070813</SIF_Date>"
                                    + "		  <SIF_Time Zone=\"UTC-06:00\">13:55:57</SIF_Time>"
                                    + "		  <SIF_Security>"
                                    + "			<SIF_SecureChannel>"
                                    + "			  <SIF_AuthenticationLevel>0</SIF_AuthenticationLevel>"
                                    + "			  <SIF_EncryptionLevel>0</SIF_EncryptionLevel>"
                                    + "			</SIF_SecureChannel>"
                                    + "		  </SIF_Security>"
                                    + "		  <SIF_SourceId>SASIxp</SIF_SourceId>"
                                    + "		  <SIF_DestinationId>Destiny</SIF_DestinationId>"
                                    + "		</SIF_Header>"
                                    + "		<SIF_RequestMsgId>88BE30BA0B8746809598854A1F58C8CC</SIF_RequestMsgId>"
                                    + "		<SIF_PacketNumber>1</SIF_PacketNumber>"
                                    + "		<SIF_MorePackets>No</SIF_MorePackets>"
                                    + "		<SIF_ObjectData>"
                                    + "		 <SchoolInfo RefId=\"B3E73AC5E8C7392044015E25A454AC6F\">"
                                    + "			<LocalId>997</LocalId>"
                                    + "			<SchoolName>Junior High Demo</SchoolName>"
                                    + "			<PrincipalInfo>"
                                    + "			  <ContactName>Mrs. Pleasant</ContactName>"
                                    + "			</PrincipalInfo>\r\n"
                                    +
                                    /* " <PhoneNumber Format=\"NA\" Type=\"TE\">(949) 888-7655</PhoneNumber>" + */
                                    "			<PhoneNumber Format=\"NA\" Type=\"FE\">888-9877</PhoneNumber>\r\n"
                                    + "			<Address Type=\"SS\">"
                                    + "			  <Street>"
                                    + "				<Line1>Grand Avenue</Line1>"
                                    + "			  </Street>"
                                    + "			  <City>Plesantville</City>"
                                    + "			  <StatePr Code=\"CA\" />"
                                    + "			  <Country Code=\"US\" />"
                                    + "			  <PostalCode>12345</PostalCode>"
                                    + "			</Address>"
                                    + "			<IdentificationInfo Code=\"76\">997</IdentificationInfo>"
                                    + "		  </SchoolInfo>"
                                    + "		</SIF_ObjectData>"
                                    + "	  </SIF_Response>" + "	</SIF_Message>";

            SifParser parser = SifParser.NewInstance();
            SifMessagePayload smi = (SifMessagePayload) parser.Parse(
                                                            schoolInfoResp, null );

            // Verify that it is parsing the correct version
            Assertion.AssertEquals( "Version", SifVersion.SIF15r1, smi.SifVersion );
            Assertion.AssertEquals( "Version attribute", "1.5r1", smi.VersionAttribute );

            SifDataObject sdo = (SifDataObject) ((SIF_Response) smi)
                                                    .SIF_ObjectData.GetChildList()[0];

            // Now attempt an inbound mapping
            IDictionary fields = new ListDictionary();
            StringMapAdaptor sma = new StringMapAdaptor( fields );
            Mappings m = fCfg.Mappings.GetMappings( "Default" ).Select( "asdf","SASIxp", smi.SifVersion );

            m.MapInbound( sdo, sma, smi.SifVersion );
            Assertion.Assert( "Elements Mapped", fields.Count > 0 );
            Assertion.AssertEquals( "Phone Number", "888-9877", fields["FAX"] );
        }
コード例 #43
0
        public void testOutBoundMappingContext50000()
        {
            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();

            MappingsContext mc = mappings.SelectOutbound( template.ElementDef,
                                                          SifVersion.SIF20, null, null );
            mc.Map( template, sma );
            Console.WriteLine( template.ToXml() );

            DateTime start = DateTime.Now;
            for ( int x = 0; x < mappingIterations; x++ )
            {
                template = new StudentPersonal();
                mc.Map( template, sma );
                if ( x%500 == 0 )
                {
                    Console.WriteLine( "Iteration " + x + " of "
                                       + mappingIterations );
                }
            }
            Console.WriteLine( template.ToXml() );
            DateTime end = DateTime.Now;
            Console.WriteLine( "Mapping "
                               + mappingIterations
                               + " Students inbound took " + end.Subtract( start ) );
        }
コード例 #44
0
        public void TestVariableOutbound()
        {
            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=$(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 );
            StudentPersonal sp = mapToStudentPersonal( sma, flattenDateFunctionCall, null );
            Assertion.AssertNotNull( "Student should not be null", sp );
            Assertion.AssertNotNull( "BirthDate should not be null", sp.Demographics.BirthDate );
        }
コード例 #45
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 );
        }
コード例 #46
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 );
        }
コード例 #47
0
        public void testStaffPersonalATCH()
        {
            IDictionary values = new Hashtable();
            values.Add( "ATCH.TCHNUM", "98" );
            values.Add( "ATCH.SOCSECNUM", "455128888" );
            values.Add( "ATCH.SCHOOLNUM", "999" );
            values.Add( "ATCH.SCHOOLNUM2", "999" );
            values.Add( "ATCH.HOMEROOM", "5" );
            values.Add( "ATCH.LASTNAME", "Ngo" );
            values.Add( "ATCH.FIRSTNAME", "Van" );
            values.Add( "ATCH.MIDDLENAME", null );
            values.Add( "ATCH.TELEPHONE", "8011234567" );
            values.Add( "ATCH.TELEXTN", null );
            values.Add( "ATCH.EMAILADDR", null );
            values.Add( "ATCH.ETHNIC", "W" );
            StringMapAdaptor sma = new StringMapAdaptor( values );
            StaffPersonal s = new StaffPersonal();

            Mappings m = fCfg.Mappings.GetMappings( "Default" ).Select( null,
                                                                        null, null );
            m.MapOutbound( sma, s, SifVersion.SIF15r1 );

            Console.WriteLine( s.ToXml() );
        }
コード例 #48
0
    /// <summary>  Handles SIF_Responses
    /// </summary>
    public virtual void OnQueryResults( IDataObjectInputStream inStream,
                                        SIF_Error error,
                                        IZone zone,
                                        IMessageInfo inf )
    {
        SifMessageInfo info = (SifMessageInfo) inf;

        Console.WriteLine
            ( "\nReceived a query response from agent \"" + info.SourceId + "\" in zone " +
              zone.ZoneId );
        IRequestInfo reqInfo = info.SIFRequestInfo;
        if ( reqInfo != null )
        {
            Console.WriteLine
                ( "\nResponse was received in {0}. Object State is '{1}'",
                  DateTime.Now.Subtract( reqInfo.RequestTime ), reqInfo.UserData );
        }

        //
        //  Use the Mappings class to translate the LearnerPersonal objects received
        //  from the zone into a HashMap of field/value pairs, then dump the table
        //  to System.out
        //

        //  Always check for an error response
        if ( error != null )
        {
            Console.WriteLine
                ( "The request for LearnerPersonal failed with an error from the provider:" );
            Console.WriteLine
                ( "  [Category=" + error.SIF_Category + "; Code=" + error.SIF_Code + "]: " +
                  error.SIF_Desc +
                  ". " + error.SIF_ExtendedDesc );
            return;
        }

        //  Get the root Mappings object from the configuration file
        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.
        MappingsContext mappings = m.SelectInbound( StudentDTD.STUDENTPERSONAL, info );
        Hashtable data = new Hashtable();
        StringMapAdaptor sma = new StringMapAdaptor( data, Adk.Dtd.GetFormatter( SifVersion.LATEST ) );

        int count = 0;
        while ( inStream.Available )
        {
            Console.WriteLine( "Object Number {0}", count++ );
            StudentPersonal sp = (StudentPersonal) inStream.ReadDataObject();
            //  Ask the Mappings object to populate the dictionary with field/value pairs
            //  by using the mapping rules in the configuration file to decompose
            //  the LearnerPersonal object into field values.
            mappings.Map( sp, sma );
            //  Now dump the field/value pairs to System.out
            DumpDictionaryToConsole( data );
            Console.WriteLine();
            data.Clear();
        }
    }
コード例 #49
0
        public void testStaffPersonalATCHNullPhone()
        {
            IDictionary values = new Hashtable();
            values.Add( "ATCH.TCHNUM", "98" );
            values.Add( "ATCH.SOCSECNUM", "455128888" );
            values.Add( "ATCH.SCHOOLNUM", "999" );
            values.Add( "ATCH.SCHOOLNUM2", "999" );
            values.Add( "ATCH.HOMEROOM", "5" );
            values.Add( "ATCH.LASTNAME", "Ngo" );
            values.Add( "ATCH.FIRSTNAME", "Van" );
            values.Add( "ATCH.MIDDLENAME", null );
            values.Add( "ATCH.TELEPHONE", null );
            values.Add( "ATCH.TELEXTN", null );
            values.Add( "ATCH.EMAILADDR", null );
            values.Add( "ATCH.ETHNIC", "W" );
            StringMapAdaptor sma = new StringMapAdaptor( values );
            StaffPersonal s = new StaffPersonal();

            Mappings m = fCfg.Mappings.GetMappings( "Default" ).Select( null,
                                                                        null, null );
            m.MapOutbound( sma, s, SifVersion.SIF15r1 );

            Console.WriteLine( s.ToXml() );

            Element e = s
                .GetElementOrAttribute( "PhoneNumber[@Format='NA' and @Type='WP']" );
            Assertion.AssertNull( "PhoneNumber should be null", e );
        }
コード例 #50
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 );
        }
コード例 #51
0
        private StringMapAdaptor createStudentSnapshotFields()
        {
            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 );
            values.Add( "ORIGYRGRAD", "2000" );

            StringMapAdaptor sma = new StringMapAdaptor( values );
            return sma;
        }
コード例 #52
0
        public void testLEAInfoPhones()
        {
            String customMappings = "<agent id='Repro' sifVersion='2.0'>"
                                    + "   <mappings id='Default'>"
                                    + "     <object object='LEAInfo'>"
                                    +
                                    "		<field name='DISTRICT_PHONE' sifVersion='-1.5r1'>PhoneNumber[@Format='NA',@Type='TE']</field>"
                                    +
                                    "		<field name='CONTACT_PHONE' sifVersion='-1.5r1'>LEAContact/ContactInfo/PhoneNumber[@Format='NA',@Type='TE']</field>"
                                    + "</object></mappings></agent>";

            Adk.SifVersion = SifVersion.SIF15r1;

            IDictionary map = new Hashtable();
            map.Add( "DISTRICT_PHONE", "912-555-6658" );
            map.Add( "CONTACT_PHONE", "912-888-6658" );
            StringMapAdaptor sma = new StringMapAdaptor( map );
            LEAInfo obj = new LEAInfo();
            doOutboundMapping( sma, obj, customMappings, null );

            PhoneNumberList pnl = obj.PhoneNumberList;
            Assertion.AssertNotNull( "LeaInfo/PhoneNumberList is Null", pnl );
            PhoneNumber phone = obj.PhoneNumberList.ItemAt( 0 );
            Assertion.AssertEquals( "Format", "NA", phone.Format );
            Assertion.AssertEquals( "Type", "TE", phone.Type );
            Assertion.AssertEquals( "Number", "912-555-6658", phone.Number );

            LEAContact contact = obj.LEAContactList.ItemAt( 0 );
            phone = contact.ContactInfo.PhoneNumberList.ItemAt( 0 );
            Assertion.AssertEquals( "Contact Format", "NA", phone.Format );
            Assertion.AssertEquals( "Contact Type", "TE", phone.Type );
            Assertion.AssertEquals( "Contact Number", "912-888-6658", phone.Number );
        }
コード例 #53
0
        public void testStudentSchoolEnrollmentGradeLevelMapping()
        {
            Adk.SifVersion = SifVersion.SIF15r1;
            IDictionary values = new Hashtable();
            values.Add( "GRADE", "00" );
            StringMapAdaptor sma = new StringMapAdaptor( values );
            StudentSchoolEnrollment sse = new StudentSchoolEnrollment();
            Mappings m = fCfg.Mappings.GetMappings( "Default" ).Select( null,
                                                                        null, null );
            m.MapOutbound( sma, sse, SifVersion.SIF15r1 );
            sse.SetHomeroom( "RoomInfo", Adk.MakeGuid() );
            Console.WriteLine( sse.ToXml() );

            // This specific case tests what should happen when the grade level is
            // using an undefined value.
            // The valueset entries don't have a value for "00", so "00" should be
            // returned as-is
        }
コード例 #54
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 );
        }
コード例 #55
0
        private StringMapAdaptor createStudentContactFields()
        {
            IDictionary values = new Hashtable();
            values.Add( "APRN.SOCSECNUM", "123456789" );
            values.Add( "APRN.SCHOOLNUM", "999" );
            values.Add( "APRN.SCHOOLNUM2", "999" );
            values.Add( "APRN.EMAILADDR", null );
            values.Add( "APRN.LASTNAME", "DOE" );
            values.Add( "APRN.FIRSTNAME", "JOHN" );
            values.Add( "APRN.MIDDLENAME", null );
            values.Add( "APRN.WRKADDR", null );
            values.Add( "APRN.WRKCITY", null );
            values.Add( "APRN.WRKSTATE", null );
            values.Add( "APRN.WRKCOUNTRY", null );
            values.Add( "APRN.WRKZIP", "54494" );
            values.Add( "APRN.ADDRESS", null );
            values.Add( "APRN.CITY", null );
            values.Add( "APRN.STATE", null );
            values.Add( "APRN.COUNTRY", null );
            values.Add( "APRN.ZIPCODE", null );
            values.Add( "APRN.TELEPHONE", "8014504555" );
            values.Add( "APRN.ALTTEL", "8014505555" );
            values.Add( "APRN.WRKTEL", null );
            // Test escaping of text values in the phone number field
            values.Add( "APRN.WRKEXTN", "M&W" );
            values.Add( "APRN.RELATION", "01" );
            // values.Add( "APRN.WRKSTATE", "" );
            // values.Add( "APRN.RELATION2", "01" );

            StringMapAdaptor sma = new StringMapAdaptor( values );
            return sma;
        }
コード例 #56
0
        public void testCountryCodeStudentContact()
        {
            String customMappings = "<agent id='Repro' sifVersion='2.0'>"
                                    + "   <mappings id='Default'>"
                                    + "     <object object='StudentContact'>"
                                    +
                                    "		<field name='APRN.COUNTRY' sifVersion='+2.0'>AddressList/Address[@Type='0123']/Country=US</field>"
                                    +
                                    "		<field name='APRN.COUNTRY' sifVersion='-1.5r1'>Address[@Type='M']/Country[@Code='US']</field>"
                                    + "</object></mappings></agent>";

            Adk.SifVersion = SifVersion.SIF15r1;

            IDictionary map = new Hashtable();
            map.Add( "APRN.COUNTRY", null );
            StringMapAdaptor sma = new StringMapAdaptor( map );
            StudentContact obj = new StudentContact();
            doOutboundMapping( sma, obj, customMappings, null );

            Assertion.AssertNull( "AddressList should be null", obj.AddressList );
        }
コード例 #57
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 );
        }