Esempio n. 1
0
        /// <summary>
        /// Compare two <see cref="Object"/>s, assumed to be <see cref="ContextProperty"/>s.
        /// </summary>
        /// <param name="x">The first <see cref="Object"/> to be compared.  Assumed to be
        /// a <see cref="ContextProperty"/>.</param>
        /// <param name="y">The second <see cref="Object"/> to be compared.  Assumed to be
        /// a <see cref="ContextProperty"/>.</param>
        /// <returns><bl>
        /// <li>Less than zero if <paramref name="x"/> is less than <paramref name="y"/>.</li>
        /// <li>Zero if <paramref name="x"/> is equal to <paramref name="y"/>.</li>
        /// <li>Greater than zero if <paramref name="x"/> is greater than <paramref name="y"/>.</li>
        /// </bl></returns>
        /// <remarks>
        /// <paramref name="x"/> and <paramref name="y"/> are compared by first comparing their
        /// period start dates.  If their period start dates are equal, their period end dates
        /// are compared.  They will be equal if their period start and period end dates are equal.
        /// </remarks>
        public int Compare(object x, object y)
        {
            ContextProperty cpX = (ContextProperty)x;
            ContextProperty cpY = (ContextProperty)y;

            if (cpX.PeriodStartDate.Equals(cpY.PeriodStartDate))             //compare the end date
            {
                DateTime XEndDate = cpX.PeriodEndDate;
                DateTime YEndDate = cpY.PeriodEndDate;

                if (XEndDate == new DateTime(1, 1, 1))
                {
                    XEndDate = new DateTime(2999, 12, 31);
                }

                if (YEndDate == new DateTime(1, 1, 1))
                {
                    YEndDate = new DateTime(2999, 12, 31);
                }

                return(XEndDate.CompareTo(YEndDate));
            }
            else
            {
                return(cpX.PeriodStartDate.CompareTo(cpY.PeriodStartDate));
            }

            //return ((ContextProperty)x).TimePeriodKey.CompareTo( ((ContextProperty)y).TimePeriodKey );
        }
        public void BothHaveSegsAndScenariosCheckScenarios()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddSegment( "key1", "key1", "key1", "key1" );
            cp1.AddScenario( "key1", "key1", "key1", "key1" );
            cp1.PeriodType = Element.PeriodType.duration;
            cp1.PeriodStartDate = new DateTime( 2000,1,1);
            cp1.PeriodEndDate = new DateTime( 2000, 1, 2);

            cp2.AddSegment( "key1", "key1", "key1", "key1" );
            cp2.AddScenario( "key2", "key2", "key2", "key2" );
            cp2.PeriodType = Element.PeriodType.duration;
            cp2.PeriodStartDate = new DateTime( 2000,1,1);
            cp2.PeriodEndDate = new DateTime( 2000, 1, 2);

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper( "key1", cp1 );
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper( "key2", cp2 );

            Assert.AreEqual( 0, CompareSegments( cuw1.contextRef.Segments, cuw2.contextRef.Segments ), "segments are not equal" );
            Assert.AreEqual( 0, CompareDates( cuw1, cuw2 ), "dates are not equal" );
            Assert.AreEqual( 1, CompareScenarios( cuw2.contextRef.Scenarios, cuw1.contextRef.Scenarios ), "scenario 1 sort wrong" );

            Assert.AreEqual( 1, Compare( cuw2, cuw1 ), "1 sort wrong" );
            Assert.AreEqual( -1, Compare( cuw1, cuw2 ), "2 sort wrong" );
        }
 public MergedContextUnitsWrapper( string keyName, ContextProperty cp, UnitProperty up )
     : this(keyName, cp)
 {
     if ( up != null )
     {
         this.UPS.Add( up );
     }
 }
Esempio n. 4
0
        public bool IsEmpty(ContextProperty cp)
        {
            bool objectIsEmpty = true;

            if (cp.ContextID != string.Empty)
            {
                objectIsEmpty = false;
            }
            else if (cp.EntitySchema != string.Empty)
            {
                objectIsEmpty = false;
            }
            else if (cp.EntityValue != string.Empty)
            {
                objectIsEmpty = false;
            }
            else if (cp.PeriodDisplayName != string.Empty)
            {
                objectIsEmpty = false;
            }
            else if (cp.PeriodEndDate != DateTime.MinValue)
            {
                objectIsEmpty = false;
            }
            else if (cp.PeriodStartDate != DateTime.MinValue)
            {
                objectIsEmpty = false;
            }
            else if (cp.PeriodType != Element.PeriodType.na)
            {
                objectIsEmpty = false;
            }
            else if (cp.Scenarios != null && cp.Scenarios.Count > 0)
            {
                objectIsEmpty = false;
            }
            else if (cp.Segments != null && cp.Segments.Count > 0)
            {
                objectIsEmpty = false;
            }

            return(objectIsEmpty);
        }
        public void BothHaveSegsOneWithScenario()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddSegment( "key1", "key1", "key1", "key1" );
            cp1.PeriodType = Element.PeriodType.duration;
            cp1.PeriodStartDate = new DateTime( 2000,1,1);
            cp1.PeriodEndDate = new DateTime( 2000, 1, 2);

            cp1.AddScenario( "key1", "key1", "key1", "key1" );

            cp2.AddSegment( "key1", "key1", "key1", "key1" );
            cp2.PeriodType = Element.PeriodType.duration;
            cp2.PeriodStartDate = new DateTime( 2000,1,1);
            cp2.PeriodEndDate = new DateTime( 2000,1,2);

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper( "key1", cp1 );
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper( "key2", cp2 );

            Assert.AreEqual( -1, Compare( cuw2, cuw1 ), "1 sort wrong" );
            Assert.AreEqual( 1, Compare( cuw1, cuw2 ), "2 sort wrong" );
        }
        public void BothHaveSegsAndScenariosCheckDates()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddSegment( "key1", "key1", "key1", "key1" );
            cp1.AddScenario( "key9", "key9", "key9", "key9" );
            cp1.PeriodType = Element.PeriodType.duration;
            cp1.PeriodStartDate = new DateTime( 2000,1,1);
            cp1.PeriodEndDate = new DateTime( 2000, 1, 2);

            cp2.AddSegment( "key1", "key1", "key1", "key1" );
            cp2.AddScenario( "key2", "key2", "key2", "key2" );
            cp2.PeriodType = Element.PeriodType.duration;
            cp2.PeriodStartDate = new DateTime( 2000,1,1);
            cp2.PeriodEndDate = new DateTime( 2000, 1, 3);

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper( "key1", cp1 );
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper( "key2", cp2 );

            // and compare them - no scen should be first
            Assert.AreEqual( -1, Compare( cuw2, cuw1 ), "1 sort wrong" );
            Assert.AreEqual( 1, Compare( cuw1, cuw2 ), "2 sort wrong" );
        }
Esempio n. 7
0
        private ContextProperty CreateInstantContext( string id, string schema, string val, DateTime start )
        {
            ContextProperty cp = new ContextProperty();

            cp.ContextID = id;
            cp.EntitySchema = schema;
            cp.EntityValue = val;
            cp.PeriodType = Element.PeriodType.instant;
            cp.PeriodStartDate = start;

            return cp;
        }
Esempio n. 8
0
 /// <summary>
 /// Sets the context reference and text properties of this <see cref="MarkupProperty"/>.
 /// </summary>
 /// <param name="cp">The id of this <see cref="ContextProperty"/> will be 
 /// included in context text property.</param>
 public void SetContext( ContextProperty cp )
 {
     contextRef = cp;
     contextText = ( cp == null ) ? string.Empty : "context: " + cp.ContextID;
 }
        public void TwoSegsBeforeOneSeg()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddSegment( "key1", "key1", "key1", "key1" );
            cp1.AddSegment( "key3", "key3", "key3", "key3" );

            cp2.AddSegment( "key2", "key2", "key2", "key2" );

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper( "key1", cp1 );
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper( "key2", cp2 );

            // and compare them
            Assert.AreEqual( 1, CompareSegments( cp2.Segments, cp1.Segments ), "segment sort 1 wrong" );
            Assert.AreEqual( -1, CompareSegments( cp1.Segments, cp2.Segments ), "segment sort 2 wrong" );

            Assert.AreEqual( 1, Compare( cuw2, cuw1 ), "1 sort wrong" );
            Assert.AreEqual( -1, Compare( cuw1, cuw2 ), "2 sort wrong" );
        }
Esempio n. 10
0
        public void SimpleCompareTest()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.PeriodType = Element.PeriodType.duration;
            cp2.PeriodType = Element.PeriodType.instant;

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper( "key1", cp1 );
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper( "key2", cp2 );

            Assert.AreEqual( 1, Compare( cuw2, cuw1 ), "1 sort wrong" );
            Assert.AreEqual( -1, Compare( cuw1, cuw2 ), "2 sort wrong" );
        }
Esempio n. 11
0
 public void TestMonthsBetweenSameYear()
 {
     InstanceReport report = new InstanceReport();
     InstanceReportColumn irc = new InstanceReportColumn();
     ContextProperty cp = new ContextProperty();
     cp.PeriodStartDate = new DateTime(2011, 1, 1);
     cp.PeriodEndDate = new DateTime(2014, 12, 31);
     cp.PeriodType = Element.PeriodType.duration;
     irc.MCU = new MergedContextUnitsWrapper("mcu0", cp);
     LabelLine ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()), "Calendar");
     irc.Labels.Add(ll);
     report.Columns.Add(irc);
     report.SetCalendarLabels("MMM. dd, yyyy", "{n} Months Ended");
     Assert.AreEqual("48 Months Ended", (irc.Labels[0]).Label, "wrong label");
 }
Esempio n. 12
0
        private void PopulateNonNumeric()
        {
            Element.PeriodType periodType = Element.PeriodType.duration;
            element = new Node( Element.CreateElement(Element.DataTypeCode.String, "test", false, periodType) );
            contextRef = new ContextProperty();
            contextRef.PeriodType = periodType;

            unitRef = null;

            markupData = "Test Markup Data";
        }
Esempio n. 13
0
 /// <summary>
 /// Determines if the "value" of a parameter supplied <see cref="ContextProperty"/> is equal to
 /// this <see cref="ContextProperty"/>.
 /// </summary>
 /// <param name="cp">The <see cref="ContextProperty"/> to which this <see cref="ContextProperty"/>
 /// is to be compared.</param>
 /// <returns>True if <paramref name="cp"/> is equal to this <see cref="ContextProperty"/>.</returns>
 /// <remarks>Comparison is done by calling <see cref="CompareValue"/>.  See <see cref="CompareValue"/> for
 /// details.</remarks>
 virtual public bool ValueEquals(ContextProperty cp)
 {
     return(CompareValue(cp) == 0);
 }
Esempio n. 14
0
        /// <summary>
        /// Compares the "value" of a parameter supplied <see cref="ContextProperty"/> to
        /// this <see cref="ContextProperty"/>.
        /// </summary>
        /// <param name="cp">The <see cref="ContextProperty"/> to which this <see cref="ContextProperty"/>
        /// is to be compared.</param>
        /// <returns>
        /// <bl>
        /// <li>Less than zero if this <see cref="ContextProperty"/> is less than <paramref name="cp"/>.</li>
        /// <li>Zero if this <see cref="ContextProperty"/> is equal to <paramref name="cp"/>.</li>
        /// <li>Greater than zero if <paramref name="cp"/> is greater than this <see cref="ContextProperty"/>.</li>
        /// </bl>
        /// </returns>
        /// <remarks>The following <see cref="ContextProperty"/> properties are compared in order:
        /// <bl>
        /// <li>Entity schema.</li>
        /// <li>Entity value.</li>
        /// <li>Period type.</li>
        /// <li>Period start date.</li>
        /// <li>Period end date, if applicable.</li>
        /// <li>Number of segments.</li>
        /// <li>Number of scenarios.</li>
        /// </bl>
        /// </remarks>
        virtual public int CompareValue(ContextProperty cp)
        {
            int ret = this.EntitySchema.CompareTo(cp.EntitySchema);

            if (ret != 0)
            {
                return(ret);
            }

            ret = this.EntityValue.CompareTo(cp.EntityValue);
            if (ret != 0)
            {
                return(ret);
            }

            ret = this.PeriodType.CompareTo(cp.PeriodType);
            if (ret != 0)
            {
                return(ret);
            }

            switch (this.PeriodType)
            {
            case Element.PeriodType.duration:
                ret = PeriodStartDate.Date.CompareTo(cp.PeriodStartDate.Date);
                if (ret != 0)
                {
                    return(ret);
                }

                ret = PeriodEndDate.Date.CompareTo(cp.PeriodEndDate.Date);
                if (ret != 0)
                {
                    return(ret);
                }
                break;

            case Element.PeriodType.instant:
                ret = PeriodStartDate.Date.CompareTo(cp.PeriodStartDate.Date);
                if (ret != 0)
                {
                    return(ret);
                }
                break;
            }
            ;

            ret = Segments.Count.CompareTo(cp.Segments.Count);
            if (ret != 0)
            {
                return(ret);
            }
            if (Segments.Count > 0)
            {
                //seq of segments might not be the same..
                //need to sort it to be the same
                if (Segments.Count > 1)
                {
                    Segments.Sort();
                    cp.Segments.Sort();
                }

                for (int i = 0; i < Segments.Count; ++i)
                {
                    ret = ((Segment)Segments[i]).CompareValue(cp.Segments[i] as Segment);
                    if (ret != 0)
                    {
                        return(ret);
                    }
                }
            }

            ret = Scenarios.Count.CompareTo(cp.Scenarios.Count);
            if (ret != 0)
            {
                return(ret);
            }
            if (Scenarios.Count > 0)
            {
                //seq of Scenarios might not be the same..
                //need to sort it to be the same
                if (Scenarios.Count > 1)
                {
                    Scenarios.Sort();
                    cp.Scenarios.Sort();
                }
                for (int i = 0; i < Scenarios.Count; ++i)
                {
                    ret = ((Scenario)Scenarios[i]).CompareValue(cp.Scenarios[i] as Scenario);
                    if (ret != 0)
                    {
                        return(ret);
                    }
                }
            }

            return(ret);
        }
Esempio n. 15
0
        public static void BuildSharedKeyParts(StringBuilder keyNameString, ContextProperty cp, bool includeEntityID)
        {
            if (includeEntityID)
            {
                keyNameString.Append(TraceUtility.FormatStringResource("DragonView.Data.EntityIDColon", cp.EntityValue));
                keyNameString.Append(Environment.NewLine);
            }

            foreach (Segment s in cp.Segments)
            {
                keyNameString.Append (InstanceUtils.BuildSegmentScenarioName( s ) ).Append(Environment.NewLine);
            }

            if ( cp.PeriodType == Element.PeriodType.duration )
            {
                keyNameString.Append( string.Format("{0} - {1}",
                    cp.PeriodStartDate.ToString("d"),
                    cp.PeriodEndDate.ToString("d")));
            }
            else if (cp.PeriodType == Element.PeriodType.instant)
            {
                // instant
                keyNameString.Append( cp.PeriodStartDate.ToString("d"));
            }
            else //forever
            {
                keyNameString.Append (TraceUtility.FormatStringResource("DragonView.Data.Forever"));
            }

            keyNameString.Append(Environment.NewLine);
        }
Esempio n. 16
0
        internal static bool TryCreateFromXml(XmlNode node, XmlNamespaceManager theManager, out ContextProperty cp, ref ArrayList errors)
        {
            if (errors == null)
            {
                errors = new ArrayList();
            }

            cp           = new ContextProperty();
            cp.ErrorList = errors;

            cp.ContextID = node.Attributes[ID_ATTR].Value;

            XmlNode entity = node.SelectSingleNode("./link2:" + ENTITY, theManager);

            if (entity == null)
            {
                if ((entity = node.SelectSingleNode(ENTITY)) == null)
                {
                    Common.WriteError("XBRLParser.Error.MissingRequiredField", errors, "Entity");
                    return(false);
                }
            }

            XmlNode identifier = entity.SelectSingleNode("./link2:" + IDENTIFIER, theManager);

            if (identifier == null)
            {
                if ((identifier = entity.SelectSingleNode("./" + IDENTIFIER)) == null)
                {
                    Common.WriteError("XBRLParser.Error.MissingRequiredField", errors, "identifier");
                    return(false);
                }
            }

            cp.EntitySchema = identifier.Attributes[SCHEME_ATTR].Value;
            cp.EntityValue  = identifier.InnerXml;

            XmlNode segments = entity.SelectSingleNode("./link2:" + SEGMENT, theManager);

            if (segments == null)
            {
                segments = entity.SelectSingleNode("./" + SEGMENT);
            }

            if (segments != null)
            {
                foreach (XmlNode segment in segments.ChildNodes)
                {
                    if (segment is XmlComment)
                    {
                        continue;
                    }

                    bool createSegment = true;
                    if (segment.LocalName.ToLower().Equals(EXPLICITMEMBER.ToLower()) &&
                        segment.NamespaceURI.Equals(DocumentBase.XBRLDI_URI))
                    {
                        //we have a dimension info
                        string dimensionId = null;
                        string valueId     = segment.InnerXml.Replace(":", "_");
                        foreach (XmlAttribute attr in segment.Attributes)
                        {
                            if (attr.Name.Equals(DIMENSION))
                            {
                                dimensionId = attr.Value.Replace(":", "_");
                                break;
                            }
                        }
                        if (dimensionId != null)
                        {
                            Segment seg             = new Segment(string.Empty, valueId, dimensionId, DocumentBase.XBRLDI_PREFIX, segment.NamespaceURI);
                            ContextDimensionInfo di = new ContextDimensionInfo();
                            di.dimensionId    = dimensionId;
                            di.Id             = valueId;
                            seg.DimensionInfo = di;

                            cp.AddSegment(seg);
                            createSegment = false;
                        }
                    }

                    if (createSegment)
                    {
                        cp.AddSegment(segment.Prefix, segment.InnerXml, segment.LocalName, segment.NamespaceURI);
                    }
                }
            }

            XmlNode scenarios = node.SelectSingleNode("./link2:" + SCENARIO, theManager);

            if (scenarios == null)
            {
                scenarios = node.SelectSingleNode("./" + SCENARIO);
            }

            if (scenarios != null)
            {
                foreach (XmlNode scenario in scenarios)
                {
                    bool createScenario = true;
                    if (scenario.LocalName.ToLower().Equals(EXPLICITMEMBER.ToLower()) &&
                        scenario.NamespaceURI.Equals(DocumentBase.XBRLDI_URI))
                    {
                        //we have a dimension info
                        string dimensionId = null;
                        string valueId     = scenario.InnerXml.Replace(":", "_");
                        foreach (XmlAttribute attr in scenario.Attributes)
                        {
                            if (attr.Name.Equals(DIMENSION))
                            {
                                dimensionId = attr.Value.Replace(":", "_");
                                break;
                            }
                        }
                        if (dimensionId != null)
                        {
                            Scenario             seg = new Scenario(string.Empty, valueId, dimensionId, DocumentBase.XBRLDI_PREFIX, scenario.NamespaceURI);
                            ContextDimensionInfo di  = new ContextDimensionInfo();
                            di.dimensionId    = dimensionId;
                            di.Id             = valueId;
                            seg.DimensionInfo = di;

                            cp.AddScenario(seg);
                            createScenario = false;
                        }
                    }

                    if (createScenario)
                    {
                        cp.AddScenario(scenario.Prefix, scenario.InnerXml, scenario.LocalName, scenario.NamespaceURI);
                    }
                }
            }

            // lastly, repopulate the time period
            XmlNode timePeriod = node.SelectSingleNode("./link2:" + PERIOD, theManager);

            if (timePeriod == null)
            {
                timePeriod = node.SelectSingleNode("./" + PERIOD);
                if (timePeriod == null)
                {
                    Common.WriteError("XBRLParser.Error.MissingRequiredField", errors, "TimePeriod");
                    return(false);
                }
                else
                {
                    if (!cp.ParsePeriods(timePeriod, theManager))
                    {
                        return(false);
                    }
                }
            }
            else
            {
                if (!cp.ParsePeriods(timePeriod, theManager))
                {
                    return(false);
                }
            }

            return(cp.IsValid());
        }
Esempio n. 17
0
        public void CreateFromXml()
        {
            string startXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
            <!--Blah Blah Blah-->
            <!--Based on XBRL 2.1-->
            <!--Blah Blah Blah-->
            <xbrl xmlns=""http://www.xbrl.org/2003/instance"" xmlns:link=""http://www.xbrl.org/2003/linkbase"" xmlns:xlink=""http://www.w3.org/1999/xlink"" xmlns:usfr_pt=""http://www.xbrl.org/2003/usfr"" xmlns:iso4217=""http://www.xbrl.org/2003/iso4217"">
              <link:schemaRef xlink:type=""simple"" xlink:href=""test.xsd"" />
              <!--Context Section-->
              <context id=""current_AsOf"">
            <entity>
              <identifier scheme=""http://www.rivetsoftware.com"">Rivet</identifier>
            </entity>
            <period>
              <instant>2003-12-31</instant>
            </period>
              </context>
              <!--Unit Section-->
              <unit id=""u1"">
            <!--Scale: 0-->
            <measure>iso4217:USD</measure>
              </unit>
              <unit id=""u2"">
            <!--Scale: 3-->
            <measure>iso4217:USD</measure>
              </unit>
              <!--Tuple Section-->
              <usfr_pt:tupleParent1>
            <!--Tuple Set Name: set1-->
            <!--Document address: Excel - Sheet1!$A$2-->
            <usfr_pt:element2 contextRef=""current_AsOf"" unitRef=""u2"" decimals=""10"">98765000</usfr_pt:element2>
            <!--Tuple Set Name: set1-->
            <!--Document address: Excel - Sheet1!$A$1-->
            <usfr_pt:element1 contextRef=""current_AsOf"" unitRef=""u1"" decimals=""10"">12345</usfr_pt:element1>
              </usfr_pt:tupleParent1>
            </xbrl>";

            XmlDocument xDoc = new XmlDocument();
            xDoc.LoadXml( startXml );

            XmlNamespaceManager theManager = new XmlNamespaceManager( xDoc.NameTable );
            theManager.AddNamespace( "link2", "http://www.xbrl.org/2003/instance" );
            theManager.AddNamespace( "usfr_pt", "http://www.xbrl.org/2003/usfr" );

            ContextProperty cp = new ContextProperty( "current_AsOf" );
            cp.EntityValue = "Rivet";
            cp.EntitySchema = "http://www.rivetsoftware.com";
            cp.PeriodType = Element.PeriodType.instant;
            cp.PeriodStartDate = new DateTime( 2003, 12, 31 );

            ArrayList contexts = new ArrayList( );
            contexts.Add( cp );

            UnitProperty up = new UnitProperty( "u1", UnitProperty.UnitTypeCode.Standard );
            up.StandardMeasure.MeasureNamespace = "iso4217";
            up.StandardMeasure.MeasureSchema = "http://www.xbrl.org/2003/iso4217";
            up.StandardMeasure.MeasureValue = "USD";

            ArrayList units = new ArrayList();
            units.Add( up );

            UnitProperty up2 = new UnitProperty( "u2", UnitProperty.UnitTypeCode.Standard );
            up2.StandardMeasure.MeasureNamespace = "iso4217";
            up2.StandardMeasure.MeasureSchema = "http://www.xbrl.org/2003/iso4217";
            up2.StandardMeasure.MeasureValue = "USD";

            units.Add( up2 );

            XmlNodeList elemList = xDoc.SelectNodes( "//usfr_pt:tupleParent1", theManager );
            Assert.IsNotNull( elemList, "elem not found" );
            Assert.AreEqual( 1, elemList.Count, "elem count is wrong" );

            TupleSet ts = null;
            ArrayList tupleMarkups;
            ArrayList errors = new ArrayList();
            TupleSet.TryCreateFromXml(elemList[0], contexts, units, out ts, out tupleMarkups, ref errors);

            Assert.AreEqual(2, tupleMarkups.Count, "wrong number of elements returned");
            Assert.AreEqual(2, ts.Children.Count , "wrong number of elements returned");
        }
Esempio n. 18
0
        public void CreateFromXml()
        {
            string startXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
            <?xml-stylesheet type=""text/xsl"" href=""Test.xsl""?>
            <!--XBRLParser message-->
            <!--Based on XBRL 2.1-->
            <!--Created on SomeDate-->
            <xbrl xmlns=""http://www.xbrl.org/2003/instance"" xmlns:link=""http://www.xbrl.org/2003/linkbase"" xmlns:xlink=""http://www.w3.org/1999/xlink"" xmlns:usfr_pt=""http://www.xbrl.org/2003/usfr"" xmlns:iso4217=""http://www.xbrl.org/2003/iso4217"">
              <link:schemaRef xlink:type=""simple"" xlink:href=""test.xsd"" />
              <!--Context Section-->
              <context id=""current_AsOf"">
            <entity>
              <identifier scheme=""http://www.rivetsoftware.com"">Rivet</identifier>
            </entity>
            <period>
              <instant>2003-12-31</instant>
            </period>
              </context>
              <!--Unit Section-->
              <unit id=""u1"">
            <!--Scale: 2-->
            <measure>iso4217:USD</measure>
              </unit>
              <!--Element Section-->
              <!--Document address: Excel - Sheet1!$A$1-->
              <usfr_pt:element1 contextRef=""current_AsOf"" unitRef=""u1"" decimals=""10"">1234500</usfr_pt:element1>
            </xbrl>";

            XmlDocument xDoc = new XmlDocument();
            xDoc.LoadXml( startXml );

            XmlNamespaceManager theManager = new XmlNamespaceManager( xDoc.NameTable );
            theManager.AddNamespace( "link2", "http://www.xbrl.org/2003/instance" );
            theManager.AddNamespace( "usfr_pt", "http://www.xbrl.org/2003/usfr" );

            ContextProperty cp = new ContextProperty( "current_AsOf" );
            cp.EntityValue = "Rivet";
            cp.EntitySchema = "http://www.rivetsoftware.com";
            cp.PeriodType = Element.PeriodType.instant;
            cp.PeriodStartDate = new DateTime( 2003, 12, 31 );

            ArrayList contexts = new ArrayList( );
            contexts.Add( cp );

            UnitProperty up = new UnitProperty( "u1", UnitProperty.UnitTypeCode.Standard );
            up.StandardMeasure.MeasureNamespace = "iso4217";
            up.StandardMeasure.MeasureSchema = "http://www.xbrl.org/2003/iso4217";
            up.StandardMeasure.MeasureValue = "USD";

            MarkupProperty realMP = new MarkupProperty();
            realMP.contextRef = cp;
            realMP.unitRef = up;
            realMP.elementId = "usfr_pt_element1";
            realMP.element = new Node( new Element( "element1" ) );
            realMP.markupData = "1234500";
            realMP.precisionDef = new Precision( Precision.PrecisionTypeCode.Decimals, 10 );

            ArrayList units = new ArrayList();
            units.Add( up );

            XmlNodeList elemList = xDoc.SelectNodes( "//usfr_pt:element1", theManager );
            Assert.AreEqual( 1, elemList.Count, "elem not found" );

            MarkupProperty mp = null;

            ArrayList errors = new ArrayList();

            Assert.IsTrue( MarkupProperty.TryCreateFromXml( 0, elemList, contexts, units, out mp, ref errors ), "markup property not created" );

            Assert.IsTrue( mp.Equals( realMP ), "elem different from the real deal" );
            Assert.AreEqual( "http://www.xbrl.org/2003/usfr", mp.elementNamespace, "namespace wrong" );
        }
Esempio n. 19
0
        private void PopulateNumeric()
        {
            Element.PeriodType periodType = Element.PeriodType.duration;
            element = new Node( Element.CreateMonetaryElement("test", false, Element.BalanceType.credit, periodType) );
            contextRef = new ContextProperty();
            contextRef.PeriodType = periodType;

            unitRef = new UnitProperty();

            markupData = "-123.12";
        }
Esempio n. 20
0
 /// <summary>
 /// Sets the context reference and text properties of this <see cref="MarkupProperty"/>.
 /// </summary>
 /// <param name="cp">The id of this <see cref="ContextProperty"/> will be
 /// included in context text property.</param>
 public void SetContext(ContextProperty cp)
 {
     contextRef  = cp;
     contextText = (cp == null) ? string.Empty : "context: " + cp.ContextID;
 }
Esempio n. 21
0
        private void InitializeTestInstanceReport()
        {
            this.Columns.Clear();
            this.Rows.Clear();

            //Add reporting periods to columns for testing MergeInstanceAndDuration
            InstanceReportColumn irc = new InstanceReportColumn();
            ContextProperty cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 10, 1);
            cp.PeriodEndDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu0", cp);
            LabelLine ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()), "Calendar");
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 10, 1);
            cp.PeriodEndDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu1", cp);
            ll = new LabelLine( 0, string.Format( "{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString() ), "Calendar" );
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            irc.MCU = new MergedContextUnitsWrapper("mcu2", cp);
            ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString(), "Calendar");
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            irc.MCU = new MergedContextUnitsWrapper("mcu3", cp);
            ll = new LabelLine( 0, cp.PeriodStartDate.ToShortDateString(), "Calendar" );
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2008, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            irc.MCU = new MergedContextUnitsWrapper("mcu4", cp);
            ll = new LabelLine( 0, cp.PeriodStartDate.ToShortDateString(), "Calendar" );
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2008, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            cp.Segments.Add(new Segment("Segment1", "Segment One", "Value1"));
            irc.MCU = new MergedContextUnitsWrapper("mcu5", cp);
            ll = new LabelLine( 0, cp.PeriodStartDate.ToShortDateString(), "Calendar" );
            irc.Labels.Add(ll);
            irc.Labels.Add(new LabelLine(1, "Segment One"));
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2008, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            cp.Segments.Add(new Segment("Segment2", "Segment Two", "Value2"));
            irc.MCU = new MergedContextUnitsWrapper("mcu6", cp);
            ll = new LabelLine( 0, cp.PeriodStartDate.ToShortDateString(), "Calendar" );
            irc.Labels.Add(ll);
            irc.Labels.Add(new LabelLine(2, "Segment Two"));
            this.Columns.Add(irc);

            InstanceReportRow irr = new InstanceReportRow("Test Elem", 0);
            irr.ElementName = "Test Elem";
            for (int i = 0; i < 7; i++)
            {
                Cell cell = new Cell();

                if( i < 2 || 4 < i )
                {
                    cell.IsNumeric = true;
                    cell.NumericAmount = (decimal)( ( i + 1 ) * 10.0 );
                }

                irr.Cells.Add(cell);
            }
            this.Rows.Add( irr );

            irr = new InstanceReportRow( "Test Elem2", 0 );
            irr.ElementName = "Test Elem2";
            for( int i = 0; i < 7; i++ )
            {
                Cell cell = new Cell();

                if( 1 < i && i < 5 )
                {
                    cell.IsNumeric = true;
                    cell.NumericAmount = (decimal)( ( i + 1 ) * 10.0 );
                }

                irr.Cells.Add( cell );
            }

            this.Rows.Add(irr);
        }
Esempio n. 22
0
 /// <summary>
 /// Creates a new ContextUnitWrapper.
 /// </summary>
 public ContextUnitWrapper(string keyName, ContextProperty cp, UnitProperty up)
 {
     this.KeyName = keyName;
     this.CP = cp;
     this.UP = up;
 }
Esempio n. 23
0
        public void DateTest()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.PeriodType = Element.PeriodType.duration;
            cp1.PeriodStartDate = new DateTime( 2006, 1, 1 );
            cp1.PeriodEndDate = new DateTime( 2006, 3, 31 );

            cp2.PeriodType = Element.PeriodType.duration;
            cp2.PeriodStartDate = new DateTime( 2006, 4, 1 );
            cp2.PeriodEndDate = new DateTime( 2006, 6, 30 );

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper( "key1", cp1 );
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper( "key2", cp2 );

            /// x == y -> 0
            /// x > y -> 1
            /// x < y -> -1

            ArrayList arrg = new ArrayList();
            arrg.Add( cuw2 );
            arrg.Add( cuw1 );
            arrg.Sort( new SortByDurationFirst() );

            Assert.AreEqual( cp2.PeriodEndDate, ((MergedContextUnitsWrapper)arrg[0]).contextRef.PeriodEndDate, "index 0 wrong" );
            Assert.AreEqual( cp1.PeriodEndDate, ((MergedContextUnitsWrapper)arrg[1]).contextRef.PeriodEndDate, "index 1 wrong" );
        }
Esempio n. 24
0
        private void InitializeTestEquityReport()
        {
            this.Columns.Clear();
            this.Rows.Clear();

            //Add reporting periods to columns for testing MergeInstanceAndDuration
            InstanceReportColumn irc = new InstanceReportColumn();
            irc.Id = 0;
            ContextProperty cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 10, 1);
            cp.PeriodEndDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu0", cp);
            cp.Segments.Add(new Segment("Segment 1", "Shared One", "Segment One Value"));
            LabelLine ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            irc.Id = 1;
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 10, 1);
            cp.PeriodEndDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu1", cp);
            cp.Segments.Add(new Segment("Segment 1", "Shared One", "Segment One Value"));
            ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            irc.Id = 2;
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 10, 1);
            cp.PeriodEndDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu0", cp);
            cp.Segments.Add(new Segment("Segment 2", "Shared Two", "Segment Two Value"));
            ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            irc.Id = 3;
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 10, 1);
            cp.PeriodEndDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu1", cp);
            cp.Segments.Add(new Segment("Segment 2", "Shared Two", "Segment Two Value"));
            ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            irc.Id = 4;
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 10, 1);
            cp.PeriodEndDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu0", cp);
            cp.Segments.Add(new Segment("Segment 3", "Shared Three", "Segment Three Value"));
            ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            irc.Id = 5;
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 10, 1);
            cp.PeriodEndDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu1", cp);
            cp.Segments.Add(new Segment("Segment 3", "Shared Three", "Segment Three Value"));
            ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            for (int i = 0; i < 4; i++)
            {
                InstanceReportRow irr = new InstanceReportRow("Test Elem", 6);
                irr.ElementName = "Test Elem";
                irr.IsBeginningBalance = (i == 0);

                for (int j = 0; j < 6; j++)
                {
                    Cell cell = new Cell();
                    cell.Id = j;
                    cell.NumericAmount = (decimal)((j + 1) * 10.0);
                    irr.Cells.Add(cell);
                }
                this.Rows.Add(irr);
            }
        }
Esempio n. 25
0
 /// <summary>
 /// Not sure how to call a constructor from the NxBRE rules engine so instead we will call this helper method to build
 /// a new ColumnMap
 /// </summary>
 /// <param name="instanceColIndex"></param>
 /// <param name="durationColIndex"></param>
 /// <param name="durationContext"></param>
 /// <returns></returns>
 public static ColumnInstantDurationMap NewColumnMap(int instanceColIndex, int durationColIndex, ContextProperty durationContext)
 {
     return new ColumnInstantDurationMap(instanceColIndex, durationColIndex, durationContext.PeriodEndDate - durationContext.PeriodStartDate);
 }
Esempio n. 26
0
        private void InitializeTestInstanceReportCommonSegment()
        {
            this.Columns.Clear();
            this.Rows.Clear();

            Segment sharedSegment = new Segment("SharedSeg", "Shared Segment", "Shared Segment Value");
            sharedSegment.DimensionInfo = new ContextDimensionInfo();
            sharedSegment.DimensionInfo.Id = "SharedSegmentAxis";
            sharedSegment.DimensionInfo.dimensionId = "SharedSegmentMember";

            //Add reporting periods to columns for testing MergeInstanceAndDuration
            InstanceReportColumn irc = new InstanceReportColumn();
            ContextProperty cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 10, 1);
            cp.PeriodEndDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu0", cp);
            cp.Segments.Add(sharedSegment);
            LabelLine ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 10, 1);
            cp.PeriodEndDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.duration;
            irc.MCU = new MergedContextUnitsWrapper("mcu1", cp);
            cp.Segments.Add(sharedSegment);
            ll = new LabelLine(0, string.Format("{0} - {1}", cp.PeriodStartDate.ToShortDateString(), cp.PeriodEndDate.ToShortDateString()));
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2007, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            irc.MCU = new MergedContextUnitsWrapper("mcu2", cp);
            cp.Segments.Add(sharedSegment);
            ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString());
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2006, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            irc.MCU = new MergedContextUnitsWrapper("mcu3", cp);
            cp.Segments.Add(sharedSegment);
            ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString());
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2008, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            cp.Segments.Add(sharedSegment);
            irc.MCU = new MergedContextUnitsWrapper("mcu4", cp);
            ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString());
            irc.Labels.Add(ll);
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2008, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            cp.Segments.Add(sharedSegment);
            irc.MCU = new MergedContextUnitsWrapper("mcu5", cp);
            ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString());
            irc.Labels.Add(ll);
            cp.Segments.Add(sharedSegment);
            irc.Labels.Add(new LabelLine(1, "Segment One"));
            this.Columns.Add(irc);

            irc = new InstanceReportColumn();
            cp = new ContextProperty();
            cp.PeriodStartDate = new DateTime(2008, 12, 31);
            cp.PeriodType = Element.PeriodType.instant;
            cp.Segments.Add(sharedSegment);
            irc.MCU = new MergedContextUnitsWrapper("mcu6", cp);
            ll = new LabelLine(0, cp.PeriodStartDate.ToShortDateString());
            irc.Labels.Add(ll);
            cp.Segments.Add(sharedSegment);
            irc.Labels.Add(new LabelLine(2, "Segment Two"));
            this.Columns.Add(irc);

            InstanceReportRow irr = new InstanceReportRow("Test Elem", 7);
            irr.ElementName = "Test Elem";
            for (int i = 0; i < 7; i++)
            {
                Cell cell = new Cell();
                cell.NumericAmount = (decimal)((i + 1) * 10.0);
                irr.Cells.Add(cell);
            }
            this.Rows.Add(irr);
        }
 public MergedContextUnitsWrapper(string keyName, ContextProperty cp)
     : this()
 {
     this.KeyName = keyName;
     this.contextRef = cp;
 }
Esempio n. 28
0
        public void OneSegBeforeTwoScenarios()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddScenario( "key11", "key11", "key11", "key11" );
            cp1.AddScenario( "key3", "key3", "key3", "key3" );

            cp2.AddSegment( "key1", "key1", "key1", "key1" );

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper( "key1", cp1 );
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper( "key2", cp2 );

            // and compare them
            Assert.AreEqual( -1, Compare( cuw2, cuw1 ), "1 sort wrong" );
            Assert.AreEqual( 1, Compare( cuw1, cuw2 ), "2 sort wrong" );
        }
 public MergedContextUnitsWrapper(string keyName, ContextProperty cp, List<UnitProperty> ups)
     : this(keyName, cp)
 {
     this.UPS = ups;
 }
Esempio n. 30
0
        public void SimpleCompareTestWithSegment()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.PeriodType = Element.PeriodType.duration;
            cp1.AddSegment( "key1", "key1", "key1", "key1" );

            cp2.PeriodType = Element.PeriodType.instant;

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper( "key1", cp1 );
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper( "key2", cp2 );

            Assert.AreEqual( -1, Compare( cuw2, cuw1 ), "1 sort wrong" );
            Assert.AreEqual( 1, Compare( cuw1, cuw2 ), "2 sort wrong" );

            ArrayList test = new ArrayList();
            test.Add( cuw1 );
            test.Add( cuw2 );

            test.Sort( new SortByDurationFirst() );

            Assert.AreEqual( cuw2.KeyName, ((MergedContextUnitsWrapper)test[0]).KeyName );
        }
Esempio n. 31
0
 private ContextProperty CreateDurationContextWithScenario( string id, string schema, string val, DateTime start, DateTime end )
 {
     ContextProperty cp = new ContextProperty();
     cp.ContextID = id;
     cp.EntitySchema = schema;
     cp.EntityValue = val;
     cp.PeriodType = Element.PeriodType.duration;
     cp.PeriodStartDate = start;
     cp.PeriodEndDate = end;
     cp.AddScenario("og", "Audited","rel","http://www.StandardAdvantage.com/em/og/2004-12-28");
     return cp;
 }
Esempio n. 32
0
        public void SimpleSegmentTest()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddSegment( "key1", "key1", "key1", "key1" );
            cp2.AddSegment( "key2", "key2", "key2", "key2" );

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper( "key1", cp1 );
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper( "key2", cp2 );

            // and compare them
            Assert.AreEqual( 1, Compare( cuw2, cuw1 ), "1 sort wrong" );
            Assert.AreEqual( -1, Compare( cuw1, cuw2 ), "2 sort wrong" );
            Assert.AreEqual( 0, Compare( cuw1, cuw1 ), "3 sort wrong" );
        }
Esempio n. 33
0
        private bool IsValidMarkup(ContextProperty cp,
			Dimension.MeasureHyperCubeInfo mhci,
			ref ArrayList errors)
        {
            BuildValidMembersByDimension();
            ListDictionary instanceDimensionInfos = new ListDictionary();
            if (mhci.IsScenario)
            {
                foreach (Scenario sc in cp.Scenarios)
                {
                    if (sc.DimensionInfo != null)
                    {
                        instanceDimensionInfos[sc.DimensionInfo.dimensionId] = sc.DimensionInfo;
                    }
                }
            }
            else
            {
                //TODO: same thing for segments..
            }

            ListDictionary validationByDimension = new ListDictionary();

            int baseValidationData = 0;
            if (mhci.IsAllRelationShip)
            {
                baseValidationData += ValidationDataEnum.ALLRelationShip.GetHashCode();
            }
            else
            {
                baseValidationData += ValidationDataEnum.NotAllRelationShip.GetHashCode();

            }

            if (mhci.IsClosed)
            {
                baseValidationData += ValidationDataEnum.IsClosed.GetHashCode();

            }
            else
            {
                baseValidationData += ValidationDataEnum.IsNotClosed.GetHashCode();

            }

            foreach (DictionaryEntry de in validMembersByDimension)
            {
                int validationData = baseValidationData;
                bool found = false;
                bool hasDefault = false;

                ContextDimensionInfo cdi = instanceDimensionInfos[de.Key] as ContextDimensionInfo;
                instanceDimensionInfos.Remove(de.Key);
                if (cdi == null)
                {
                    validationData += ValidationDataEnum.DimensionNotInInstance.GetHashCode();
                }
                else
                {
                    HybridDictionary validMembers = de.Value as HybridDictionary;
                    if (validMembers != null)
                    {
                        found = validMembers[cdi.Id] != null;
                    }
                }

                if (found)
                {
                    validationData += ValidationDataEnum.Found.GetHashCode();

                }
                else
                {
                    validationData += ValidationDataEnum.NotFound.GetHashCode();

                }

                if (hasDefault)
                {
                    validationData += ValidationDataEnum.DimensionHasDefault.GetHashCode();

                    //TODO: determine if the default value is being used
                    //which is not a good thing and is an error condition.
                }

                ValidateResult(validationData, errors);

            }

            if (instanceDimensionInfos.Keys.Count != 0)
            {
                if (mhci.IsClosed)
                {
                    //this is an error condition as we have dimensions that are not part of
                    //the cube in the instance but the cube is a closed cube and does not
                    //allow other dimension infos
                    //TODO: enhance the error message...
                    string error = "Found invalid dimension for an element that is using a closed hypercube";

                    errors.Add(error);
                }
            }

            return errors.Count == 0;
        }
Esempio n. 34
0
        public bool ReportingPeriodEquals( ContextProperty cp )
        {
            if( this.MyContextProperty == null )
            {
                if( cp != null )
                    return false;

                if( cp == null )
                    return true;
            }

            if( this.MyContextProperty == cp ) return true;
            if( this.MyContextProperty.PeriodType != cp.PeriodType ) return false;
            if( this.MyContextProperty.PeriodStartDate != cp.PeriodStartDate ) return false;
            if( this.MyContextProperty.PeriodEndDate != cp.PeriodEndDate ) return false;
            return true;
        }
Esempio n. 35
0
 public static void AppendScenarios(StringBuilder keyNameString, ContextProperty cp)
 {
     foreach (Scenario s in cp.Scenarios)
     {
         keyNameString.Append(InstanceUtils.BuildSegmentScenarioName(s)).Append(Environment.NewLine);
     }
 }
Esempio n. 36
0
        private bool IsValidMarkup(ContextProperty cp,
                                   Dimension.MeasureHyperCubeInfo mhci,
                                   ref ArrayList errors)
        {
            BuildValidMembersByDimension();
            ListDictionary instanceDimensionInfos = new ListDictionary();

            if (mhci.IsScenario)
            {
                foreach (Scenario sc in cp.Scenarios)
                {
                    if (sc.DimensionInfo != null)
                    {
                        instanceDimensionInfos[sc.DimensionInfo.dimensionId] = sc.DimensionInfo;
                    }
                }
            }
            else
            {
                //TODO: same thing for segments..
            }

            ListDictionary validationByDimension = new ListDictionary();

            int baseValidationData = 0;

            if (mhci.IsAllRelationShip)
            {
                baseValidationData += ValidationDataEnum.ALLRelationShip.GetHashCode();
            }
            else
            {
                baseValidationData += ValidationDataEnum.NotAllRelationShip.GetHashCode();
            }

            if (mhci.IsClosed)
            {
                baseValidationData += ValidationDataEnum.IsClosed.GetHashCode();
            }
            else
            {
                baseValidationData += ValidationDataEnum.IsNotClosed.GetHashCode();
            }

            foreach (DictionaryEntry de in validMembersByDimension)
            {
                int  validationData = baseValidationData;
                bool found          = false;
                bool hasDefault     = false;

                ContextDimensionInfo cdi = instanceDimensionInfos[de.Key] as ContextDimensionInfo;
                instanceDimensionInfos.Remove(de.Key);
                if (cdi == null)
                {
                    validationData += ValidationDataEnum.DimensionNotInInstance.GetHashCode();
                }
                else
                {
                    HybridDictionary validMembers = de.Value as HybridDictionary;
                    if (validMembers != null)
                    {
                        found = validMembers[cdi.Id] != null;
                    }
                }

                if (found)
                {
                    validationData += ValidationDataEnum.Found.GetHashCode();
                }
                else
                {
                    validationData += ValidationDataEnum.NotFound.GetHashCode();
                }

                if (hasDefault)
                {
                    validationData += ValidationDataEnum.DimensionHasDefault.GetHashCode();

                    //TODO: determine if the default value is being used
                    //which is not a good thing and is an error condition.
                }

                ValidateResult(validationData, errors);
            }

            if (instanceDimensionInfos.Keys.Count != 0)
            {
                if (mhci.IsClosed)
                {
                    //this is an error condition as we have dimensions that are not part of
                    //the cube in the instance but the cube is a closed cube and does not
                    //allow other dimension infos
                    //TODO: enhance the error message...
                    string error = "Found invalid dimension for an element that is using a closed hypercube";

                    errors.Add(error);
                }
            }

            return(errors.Count == 0);
        }
Esempio n. 37
0
 private ContextProperty CreateDurationContext( string id, string schema, string val, DateTime start, DateTime end )
 {
     ContextProperty cp = new ContextProperty();
     cp.ContextID = id;
     cp.EntitySchema = schema;
     cp.EntityValue = val;
     cp.PeriodType = Element.PeriodType.duration;
     cp.PeriodStartDate = start;
     cp.PeriodEndDate = end;
     return cp;
 }