public void testParseGraduationDate()
        {
            String sXML = "<StudentPersonal RefId='12345678901234567890'>"
                          + " <GradYear Type='Actual'>2005</GradYear>"
                          + "</StudentPersonal>";

            StudentPersonal sp = (StudentPersonal) parseSIF15r1XML( sXML );
            sp = (StudentPersonal) AdkObjectParseHelper.WriteParseAndReturn( sp, SifVersion.SIF11 );
            Assertion.AssertNotNull( sp );
            PartialDateType gd = sp.GraduationDate;
            Assertion.AssertNotNull( "Actual Grad Year", gd );
            Assertion.AssertEquals( "Actual Grad Year", 2005, (int) gd.Year );

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

            Element gradValue = sp.GetElementOrAttribute( "GradYear[@Type='Actual']" );
            Assertion.AssertNotNull( "Actual Grad Year", gradValue );
            PartialDateType pdt = (PartialDateType) gradValue;
            Assertion.AssertEquals( "Actual Grad Year", 2054, pdt.Year.Value );
        }
 public void testExtendedElements()
 {
     StudentPersonal sp = new StudentPersonal();
      SIF_ExtendedElements container = sp.SIFExtendedElementsContainer;
      container.SetChildren(new SIF_ExtendedElement[] { new SIF_ExtendedElement("key1", "value1") });
      container.SetChildren(new SIF_ExtendedElement[] { new SIF_ExtendedElement("key1", "value1") });
      Assert.AreEqual(1, sp.SIFExtendedElements.Length, "Result should be 1");
 }
 public static StudentPersonal makeStudentPersonal( String localId,
                                                    NameType nameType, String firstName, String lastName )
 {
     StudentPersonal s = new StudentPersonal();
     s.RefId = Adk.MakeGuid();
     s.LocalId = localId;
     Name name = new Name( nameType, lastName, firstName );
     s.Name = name;
     return s;
 }
示例#4
0
        public void TestEncodingHighAsciiChars()
        {
            StudentPersonal sp = new StudentPersonal();
             sp.RefId = Adk.MakeGuid();
             sp.StateProvinceId = "\u06DE55889";
             sp.LocalId = "987987987987987";

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

             Assert.AreEqual("\u06DE55889", copy.StateProvinceId, "LocalID, Encoded");
        }
示例#5
0
        public void TestWriteXSINill()
        {
            StudentPersonal sp = new StudentPersonal();
               sp.RefId = Adk.MakeGuid();
               sp.StateProvinceId = "\u06DE55889";
               sp.LocalId = "987987987987987";
               Name name = new Name(NameType.LEGAL, "Johnson", "Steve");
               sp.Name = name;
               name.SetField( CommonDTD.NAME_TYPE, new SifString( null ) );
               name.SetField(CommonDTD.NAME_MIDDLENAME, new SifString(null));

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

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

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

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

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

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

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

               field = copy.GetField(StudentDTD.STUDENTPERSONAL_LOCALID);
               Assert.IsNotNull(field);
               Assert.IsNull(field.Value);
        }
        public void TestADKFunctionInbound()
        {
            String customMappings =
                "<agent id='Repro' sifVersion='2.0'>"
                + "   <mappings id='Default'>"
                + "     <object object='StudentPersonal'>"
                + "       <field name='FIRSTNAME'>//FirstName</field>"
                + "       <field name='LASTNAME'>//LastName</field>"
                + "       <field name='FULLNAME'>adk:toProperCase( concat( $FIRSTNAME, ' ', $LASTNAME ) )</field>"
                + "</object></mappings></agent>";

            StudentPersonal sp = new StudentPersonal();
            sp.SetElementOrAttribute( "Name/FirstName", "ahmad" );
            sp.SetElementOrAttribute( "Name/LastName", "O'TOOLE" );

            IDictionary map = doInboundMapping( customMappings, sp );

            Assertion.AssertEquals( "First Name", "ahmad", map["FIRSTNAME"] );
            Assertion.AssertEquals( "Last Name", "O'TOOLE", map["LASTNAME"] );
            Assertion.AssertEquals( "Full Name", "Ahmad O'Toole", map["FULLNAME"] );
        }
        public void CreateElementOrAttribute()
        {
            String firstName = "Rosemary";
             String middleName = null;
             String lastName = "Evans";
             StudentPersonal retval = new StudentPersonal();

             retval.SetElementOrAttribute("Name[@Type='04']/FirstName", firstName);
             retval.SetElementOrAttribute("Name[@Type='04']/MiddleName", middleName);
             retval.SetElementOrAttribute("Name[@Type='04']/LastName", lastName);

             Name name = retval.Name;
             Assert.AreEqual(firstName, name.FirstName, "First Name");
             Assert.AreEqual(lastName, name.LastName, "Last Name");
             Assert.IsNull(name.MiddleName, "Middle Name");

             // echo to the console so we can see what's going on
             SifWriter writer = new SifWriter(Console.Out);
             writer.Write(retval);
             writer.Flush();
        }
        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 ) );
        }
        public void testParseOnTimeGradYear()
        {
            String sXML = "<StudentPersonal RefId='12345678901234567890'>"
                          + " <GradYear Type='Original'>1971</GradYear>"
                          + "</StudentPersonal>";

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

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

            Element gradValue = sp.GetElementOrAttribute( "GradYear[@Type='Original']" );
            Assertion.AssertNotNull( "On Time Grad Year", gradValue );
            int gradYear = (int) gradValue.SifValue.RawValue;
            Assertion.AssertNotNull( "On Time Grad Year", gradYear );
            Assertion.AssertEquals( "On Time Grad Year", 8877, gradYear );
        }
        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 );
        }
        public void testStudentPersonalSIF15r1()
        {
            IDictionary values = new Hashtable();
            values.Add( "PERMNUM", "9798" );
            values.Add( "SOCSECNUM", "845457898" );
            values.Add( "SCHOOLNUM", "999" );
            values.Add( "SCHOOLNUM2", "999" );
            values.Add( "GRADE", "09" );
            values.Add( "HOMEROOM", "5" );
            values.Add( "LASTNAME", "Doe" );
            values.Add( "FIRSTNAME", "Jane" );
            values.Add( "MIDDLENAME", null );
            values.Add( "NICKNAME", null );
            values.Add( "MAILADDR", "5845 Test Blvd" );
            values.Add( "CITY", "slc" );
            values.Add( "STATE", "Utah" );
            values.Add( "COUNTRY", "" );
            values.Add( "ZIPCODE", "84093" );
            values.Add( "RESADDR", null );
            values.Add( "RESCITY", null );
            values.Add( "RESSTATE", null );
            values.Add( "RESCOUNTRY", null );
            values.Add( "RESZIPCODE", null );
            values.Add( "BIRTHDATE", "20051209" );
            values.Add( "GENDER", "F" );
            values.Add( "ETHNICCODE", "W" );
            values.Add( "ENGPROF", "" );
            values.Add( "PRIMARYLNG", "" );
            values.Add( "TELEPHONE", null );

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

            Mappings m = fCfg.Mappings.GetMappings( "Default" ).Select( null,
                                                                        null, null );
            m.MapOutbound( sma, sp, SifVersion.SIF15r1 );
            Console.WriteLine( sp.ToXml() );
            OtherIdList oil = sp.OtherIdList;
            bool gradeMappingFound = false;
            foreach ( OtherId oid in oil )
            {
                if ( "ZZ".Equals( oid.Type )
                     && oid.Value.StartsWith( "GRADE" ) )
                {
                    Assertion.AssertEquals( "OtherId[@Type=ZZ]GRADE: mapping", "GRADE:09", oid.Value );
                    gradeMappingFound = true;
                }
            }
            Assertion.Assert( "GradeMapping found", gradeMappingFound );
        }
        public 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 );
        }
        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 );
        }
        public void SendEvent()
        {
            /**
            * This class periodically publishes change events to the zone. This
            * method starts up the thread that publishes the change events.
            *
            * A normal SIF Agent would, instead look for changes in the application's database
            * and publish those as changes.
            */

             Console.WriteLine
             ("Event publishing enabled with an interval of " + EVENT_INTERVAL / 1000 +
               " seconds.");

             Random random = new Random();

             bool isProcessing = true;
             // Go into a loop and send events
             while (isProcessing)
             {
            try
            {
               Thread.Sleep(EVENT_INTERVAL);

               StudentPersonal changedObject = fData[random.Next(fData.Count)];
               StudentPersonal eventObject = new StudentPersonal();
               eventObject.RefId = changedObject.RefId;

               // Create a change event with a random Student ID;
               String newNum = "A" + random.Next(999999).ToString();
               eventObject.LocalId = newNum;
               fZone.ReportEvent(eventObject, EventAction.Change);

            }
            catch (Exception ex)
            {

               Console.WriteLine("Error during event processing: " + ex);
               isProcessing = false;
            }
             }
        }
示例#15
0
        public void testElementWithNullValue()
        {
            StudentPersonal sp = new StudentPersonal( Adk.MakeGuid(), new Name( NameType.BIRTH, null, "Sally" ) );

            Query q = new Query( StudentDTD.STUDENTPERSONAL );
            q.AddCondition( CommonDTD.NAME_LASTNAME, ComparisonOperators.GT, "E" );
            Assert.IsFalse( q.Evaluate( sp ) );

            q = new Query( StudentDTD.STUDENTPERSONAL );
            q.AddCondition( CommonDTD.NAME_LASTNAME, ComparisonOperators.EQ, "E" );
            Assert.IsFalse( q.Evaluate( sp ) );

            q = new Query( StudentDTD.STUDENTPERSONAL );
            q.AddCondition( CommonDTD.NAME_LASTNAME, ComparisonOperators.NE, "E" );
            Assert.IsTrue( q.Evaluate( sp ) );
        }
        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" );
        }
        public void TestConcatenateFieldsInbound020()
        {
            String customMappings =
                "<agent id='Repro' sifVersion='2.0'>"
                + "   <mappings id='Default'>"
                + "     <object object='StudentPersonal'>"
                +
                "       <field name='CITY_STATE_ZIP'>concat( AddressList/Address/City, ', ', AddressList/Address/StateProvince, '  ', AddressList/Address/PostalCode)</field>"
                + "</object></mappings></agent>";

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

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

            IDictionary map = doInboundMapping( customMappings, sp );

            String csz = (String) map["CITY_STATE_ZIP"];
            Console.WriteLine( "City State Zip=" + csz );
            Assertion.AssertEquals( "CityStateZip", "Chicago, IL  50001", map["CITY_STATE_ZIP"] );
        }
        public void testParseProjectedGradYear()
        {
            String sXML = "<StudentPersonal RefId='12345678901234567890'>"
                          + " <GradYear Type='Projected'>2012</GradYear>"
                          + "</StudentPersonal>";

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

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

            Element gradValue = sp.GetElementOrAttribute( "GradYear[@Type='Projected']" );
            Assertion.AssertNotNull( "Projected Grad Year", gradValue );
            int gradYear = (int) gradValue.SifValue.RawValue;
            Assertion.AssertNotNull( "Projected Grad Year", gradYear );
            Assertion.AssertEquals( "Projected Grad Year", 2089, gradYear );
        }
        public void 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 ) );
        }
示例#20
0
        public void testSimpleLTFilter()
        {
            StudentPersonal sp = new StudentPersonal( Adk.MakeGuid(), new Name( NameType.BIRTH, "E", "Sally" ) );

            Query q = new Query( StudentDTD.STUDENTPERSONAL );
            q.AddCondition( CommonDTD.NAME_LASTNAME, ComparisonOperators.LT, "G" );
            Assert.IsTrue( q.Evaluate( sp ) );

            q = new Query( StudentDTD.STUDENTPERSONAL );
            q.AddCondition( CommonDTD.NAME_LASTNAME, ComparisonOperators.LT, "E" );
            Assert.IsFalse( q.Evaluate( sp ) );
        }
        public void TestVariableMapping()
        {
            String customMappings =
                "<agent id='Repro' sifVersion='2.0'>"
                + "   <mappings id='Default'>"
                + "     <object object='StudentPersonal'>"
                + "       <field name='STUDENT_NUM'>OtherIdList/OtherId[@Type='06']</field>"
                + "       <field name='HOMEROOM'>$STUDENT_NUM</field>"
                + "</object></mappings></agent>";

            StudentPersonal sp = new StudentPersonal();
            sp.SetElementOrAttribute( "OtherIdList/OtherId[@Type='06']", "998" );

            IDictionary map = doInboundMapping( customMappings, sp );

            Assertion.AssertEquals( "STUDENT_NUM", "998", map["STUDENT_NUM"] );
            Assertion.AssertEquals( "HOMEROOM", "998", map["HOMEROOM"] );

            Console.WriteLine( "HomeRoom = " + map["HOMEROOM"] );
        }
        private static StudentPersonal CreateStudent(
          String id,
          String lastName,
            String firstName,
            String street,
            String city,
            StatePrCode state,
            CountryCode country,
            String post,
            String phone,
            Gender gender,
            GradeLevelCode grade,
            RaceType race,
            String birthDateyyyyMMdd)
        {
            StudentPersonal student = new StudentPersonal();
             ;
             student.RefId = Adk.MakeGuid();
             student.LocalId = id;

             // Set the Name
             Name name = new Name(NameType.LEGAL, firstName, lastName);
             student.Name = name;

             Address addr = new Address();
             addr.SetType(AddressType.C0369_PERMANENT);
             addr.SetStreet(street);
             addr.City = city;
             addr.SetStateProvince(state);
             addr.PostalCode = post;
             addr.SetCountry(country);

             student.AddressList = new StudentAddressList(PickupOrDropoff.NA, "NA", addr);
             student.PhoneNumberList =
             new PhoneNumberList(new PhoneNumber(PhoneNumberType.PRIMARY, phone));

             Demographics dem = new Demographics();
             dem.RaceList = new RaceList(new Race("", race));
             dem.SetGender(gender);
             dem.BirthDate =
             DateTime.ParseExact
                 (birthDateyyyyMMdd, "yyyyMMdd", CultureInfo.InvariantCulture.DateTimeFormat);

             student.Demographics = dem;

             return student;
        }
        public void TestConcatenateFieldsInbound()
        {
            String customMappings =
                "<agent id='Repro' sifVersion='2.0'>"
                + "   <mappings id='Default'>"
                + "     <object object='StudentPersonal'>"
                + "       <field name='FIRSTNAME'>//FirstName</field>"
                + "       <field name='LASTNAME'>//LastName</field>"
                + "       <field name='FULLNAME'>concat( //FirstName, ' ' , //LastName )</field>"
                + "</object></mappings></agent>";

            StudentPersonal sp = new StudentPersonal();
            sp.SetElementOrAttribute( "Name/FirstName", "Jimmy" );
            sp.SetElementOrAttribute( "Name/LastName", "Johnson" );

            IDictionary map = doInboundMapping( customMappings, sp );

            Assertion.AssertEquals( "First Name", "Jimmy", map["FIRSTNAME"] );
            Assertion.AssertEquals( "Last Name", "Johnson", map["LASTNAME"] );
            Assertion.AssertEquals( "Full Name", "Jimmy Johnson", map["FULLNAME"] );
        }
示例#24
0
        public void TestWriteXSIType()
        {
            StudentPersonal sp = new StudentPersonal();
               sp.RefId = Adk.MakeGuid();
               sp.StateProvinceId = "\u06DE55889";
               sp.LocalId = "987987987987987";

               SIF_ExtendedElement see = new SIF_ExtendedElement( "FOO", "BAR" );
               see.XsiType = "Integer";
               sp.SIFExtendedElementsContainer.Add( see );

               Console.WriteLine( sp.ToXml() );

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

               see = copy.SIFExtendedElements[0];

               Assert.IsNotNull( see );
               Assert.AreEqual( "Integer", see.XsiType );
        }