Example #1
0
        public virtual DataTypes.Quantity.DateTime.DvDuration Offset()
        {
            History <T> parent = this.Parent as History <T>;

            if (parent == null)
            {
                throw new ApplicationException("parent must not be null.");
            }

            DataTypes.Quantity.DateTime.DvDuration offset;
            if (parent.Origin != null)
            {
                offset = this.Time.Diff(parent.Origin);
            }
            else
            {
                if (this.HasConstraint)
                {
                    CAttribute attribute = this.Constraint.GetAttribute("offset");
                    Check.Assert(attribute != null, "attribute must not be null");

                    CComplexObject constraint = attribute.Children[0] as CComplexObject;
                    Check.Assert(constraint != null, "constraint must not be null");
                    offset = constraint.DefaultValue as DataTypes.Quantity.DateTime.DvDuration;
                }
                else
                {
                    throw new ApplicationException("origin is null with no offset constraint");
                }
            }
            Check.Ensure(offset != null, "offset must not be null");
            return(offset);
        }
        internal static void PopulateLocatableAttributes(CComplexObject cComplexObject, OpenEhr.RM.Common.Archetyped.Impl.Locatable locatable)
        {
            Check.Require(locatable != null, "locatable must not be null.");
            Check.Require(cComplexObject != null, "cComplexObject must not be null.");

            string codeString = null;

            if (string.IsNullOrEmpty(locatable.ArchetypeNodeId))
            {
                CArchetypeRoot archetypeRoot = cComplexObject as CArchetypeRoot;

                if (archetypeRoot != null)
                {
                    locatable.ArchetypeNodeId = archetypeRoot.ArchetypeId.Value;
                    codeString = cComplexObject.NodeId;
                }
                else
                {
                    locatable.ArchetypeNodeId = cComplexObject.NodeId;
                    codeString = cComplexObject.NodeId;
                }
            }

            if (locatable.Name == null || string.IsNullOrEmpty(locatable.Name.Value))
            {
                if (string.IsNullOrEmpty(codeString))
                    codeString = cComplexObject.NodeId;
                locatable.Name = new DvText(LocalTermDefText(codeString, cComplexObject));
            }

            Check.Ensure(!string.IsNullOrEmpty(locatable.ArchetypeNodeId), "ArchetypeId must not be null or empty.");
            Check.Ensure(locatable.Name != null && !string.IsNullOrEmpty(locatable.Name.Value), "name must not be null.");
        }
 public StructureTest()
 {
     string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-entry.structure_test1.test.adl");
     se.acode.openehr.parser.ADLParser parser = new se.acode.openehr.parser.ADLParser(adl);
     //org.openehr.am.archetype.Archetype archetype = parser.parse();
     definition = parser.parse().getDefinition();
 }
        internal static string LocalTermDefText(string codeString, CAttribute cAttribute)
        {
            Check.Require(!string.IsNullOrEmpty(codeString), "codeString must not be null or empty.");
            Check.Require(cAttribute != null, "cAttribute must not be null");

            CComplexObject parent = cAttribute.parent;
            return LocalTermDefText(codeString, parent);
        }
Example #5
0
        public void setUp()
        {
            string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-car.paths.test.adl");

            se.acode.openehr.parser.ADLParser  parser    = new se.acode.openehr.parser.ADLParser(adl);
            org.openehr.am.archetype.Archetype archetype = parser.parse();
            Assert.IsNotNull(archetype);
            CComplexObject definition = archetype.getDefinition();
        }
Example #6
0
        private static CObject GetCObjectByAttributeName(CComplexObject cComplexObject, string attributeName)
        {
            foreach (CAttribute attribute in cComplexObject.Attributes)
            {
                if (attribute.RmAttributeName == attributeName)
                {
                    return(attribute.Children[0]);
                }
            }

            return(null);
        }
        // TODO: this must be reinstated when ConfigurationSource is able to be specified

        #endregion



        void ReadCAttribute(XmlReader reader, CAttribute cAttribute)
        {
            Check.Require(cAttribute != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute"));

            if (reader.LocalName != "rm_attribute_name")
            {
                throw new InvalidXmlException("rm_attribute_name", reader.LocalName);
            }
            cAttribute.RmAttributeName = reader.ReadElementContentAsString("rm_attribute_name", OpenEhrNamespace);
            reader.MoveToContent();

            if (reader.LocalName != "existence")
            {
                throw new InvalidXmlException("existence", reader.LocalName);
            }
            cAttribute.Existence = new Interval <int>();
            amSerializer.ReadExistence(reader, cAttribute.Existence);

            if (reader.LocalName == "children")
            {
                cAttribute.Children = new OpenEhr.AssumedTypes.List <CObject>();
                do
                {
                    string cObjectType = reader.GetAttribute("type", RmXmlSerializer.XsiNamespace);
                    DesignByContract.Check.Assert(!string.IsNullOrEmpty(cObjectType), "cObjectType must not be null or empty.");

                    CObject cObj;
                    switch (cObjectType)
                    {
                    case "C_ARCHETYPE_ROOT":

                        CArchetypeRoot archetypeRoot = new CArchetypeRoot();
                        ReadCArchetypeRoot(reader, archetypeRoot);
                        cObj = archetypeRoot;
                        break;

                    case "C_COMPLEX_OBJECT":
                        CComplexObject complexObject = new CComplexObject();
                        ReadCComplexObject(reader, complexObject);
                        cObj = complexObject;
                        break;

                    default:
                        cObj = AmFactory.CObject(cObjectType);
                        amSerializer.ReadCObject(reader, cObj);
                        break;
                    }

                    cObj.Parent = cAttribute;
                    cAttribute.Children.Add(cObj);
                } while (reader.LocalName == "children" && reader.NodeType != XmlNodeType.EndElement);
            }
        }
Example #8
0
        internal static CObject CObject(string typeName)
        {
            DesignByContract.Check.Require(!string.IsNullOrEmpty(typeName), string.Format(CommonStrings.XMustNotBeNullOrEmpty, "typeName"));

            CObject cObject = null;

            switch (typeName)
            {
            case "C_COMPLEX_OBJECT":
                cObject = new CComplexObject();
                break;

            case "C_PRIMITIVE_OBJECT":
                cObject = new CPrimitiveObject();
                break;

            case "ARCHETYPE_INTERNAL_REF":
                cObject = new ArchetypeInternalRef();
                break;

            case "CONSTRAINT_REF":
                cObject = new ConstraintRef();
                break;

            case "ARCHETYPE_SLOT":
                cObject = new ArchetypeSlot();
                break;

            case "C_CODE_PHRASE":
                cObject = new CCodePhrase();
                break;

            case "C_DV_STATE":
                cObject = new CDvState();
                break;

            case "C_DV_ORDINAL":
                cObject = new CDvOrdinal();
                break;

            case "C_DV_QUANTITY":
                cObject = new CDvQuantity();
                break;

            default:
                throw new NotSupportedException("type not supported: " + typeName);
            }

            DesignByContract.Check.Ensure(cObject != null, "cObject must not be null.");

            return(cObject);
        }
Example #9
0
        protected void Validate(ArchetypeInternalRef archetypeInternalRef)
        {
            this.ValidateBase((CObject)archetypeInternalRef);

            Invariant(!string.IsNullOrEmpty(archetypeInternalRef.TargetPath), string.Format(
                          CommonStrings.XMustNotBeNullOrEmpty, "AarchetypeInternalRef.TargetPath"));

            // TODO: Consistency: not any_allowed
            CComplexObject rootDefinition = AmFactory.GetRootDefinition(archetypeInternalRef);

            Invariant(rootDefinition.HasPath(archetypeInternalRef.TargetPath),
                      AmValidationStrings.ArchetypeInternalRefTargetPathMissing);
        }
Example #10
0
        public Archetype(ArchetypeId archetypeId, string concept, CComplexObject definition,
                         ArchetypeOntology ontology, CodePhrase originalLanguage, RevisionHistory revisionHistory,
                         bool isControlled)
            : base(originalLanguage, revisionHistory, isControlled)
        {
            Check.Require(archetypeId != null, string.Format(CommonStrings.XMustNotBeNull, "archetypeId"));
            Check.Require(!string.IsNullOrEmpty(concept) != null, string.Format(CommonStrings.XMustNotBeNullOrEmpty, "concept"));
            Check.Require(definition != null, string.Format(CommonStrings.XMustNotBeNull, "definition"));
            Check.Require(ontology != null, string.Format(CommonStrings.XMustNotBeNull, "ontology"));

            this.archetypeId = archetypeId;
            this.definition  = definition;
            this.ontology    = ontology;
        }
Example #11
0
        protected void Validate(CComplexObject cComplexObject)
        {
            this.Validate((CDefinedObject)cComplexObject);

            if (cComplexObject.Attributes != null)
            {
                foreach (CAttribute attri in cComplexObject.Attributes)
                {
                    this.Validate(attri);
                }
            }

            Invariant(cComplexObject.AnyAllowed() || (cComplexObject.Attributes != null && !cComplexObject.Attributes.IsEmpty()),
                      AmValidationStrings.CComplexObjectAllowAnyXor);
        }
Example #12
0
        /// <summary>
        /// returns true if all Nodeids valid for a CComplex object
        /// </summary>
        /// <param name="cComplexObj"></param>
        /// <returns></returns>
        private bool NodeIdsValid(CComplexObject cComplexObj)
        {
            if (cComplexObj.Attributes != null)
            {
                foreach (CAttribute attribute in cComplexObj.Attributes)
                {
                    if (!NodeIdsValid(attribute))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Example #13
0
        public static CComplexObject Map(this C_COMPLEX_OBJECT model)
        {
            var complexObject = new CComplexObject();

            foreach (C_ATTRIBUTE attribute in model.attributes)
            {
                complexObject.Attributes.Add(attribute.Map());
            }
            complexObject.NodeId = model.node_id;
            complexObject.ReferenceModelTypeName = model.rm_type_name;
            complexObject.Occurences             = model.occurrences.Map();
            complexObject.AnyAllowed             = model.any_allowed;

            return(complexObject);
        }
Example #14
0
        public void testPath()
        {
            string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-car.paths.test.adl");

            se.acode.openehr.parser.ADLParser  parser    = new se.acode.openehr.parser.ADLParser(adl);
            org.openehr.am.archetype.Archetype archetype = parser.parse();
            Assert.IsNotNull(archetype);
            CComplexObject definition = archetype.getDefinition();

            // root path CAR
            Assert.AreEqual("/", definition.path());

            // wheels attribute
            CAttribute wheels = (CAttribute)definition.getAttributes().get(0);

            Assert.AreEqual("/wheels", wheels.path());

            // first WHEEL node
            CObject firstWheel = (CObject)wheels.getChildren().get(0);

            Assert.AreEqual("/wheels[at0001]", firstWheel.path());

            // description and parts of first WHEEL
            CComplexObject firstWheelObj = (CComplexObject)firstWheel;
            CAttribute     description   = (CAttribute)firstWheelObj.getAttributes().get(0);

            Assert.AreEqual("/wheels[at0001]/description", description.path());
            CAttribute parts = (CAttribute)firstWheelObj.getAttributes().get(1);

            Assert.AreEqual("/wheels[at0001]/parts", parts.path());

            // WHEEL_PART node
            CObject wheelParts = (CObject)parts.getChildren().get(0);

            Assert.AreEqual("/wheels[at0001]/parts[at0002]",
                            wheelParts.path());

            // something and something_else of WHEEL_PART node
            //CComplexObject wheelPartsObj = (CComplexObject)wheelParts;
            //Assert.AreEqual("something of WHEEL_PART",
            //        "/wheels[at0001]/parts[at0002]/something",
            //        wheelPartsObj.getAttributes().get(0).path());

            //Assert.AreEqual("something_else of WHEEL_PART",
            //        "/wheels[at0001]/parts[at0002]/something_else",
            //        wheelPartsObj.getAttributes().get(1).path());
        }
Example #15
0
        internal static string GetNameConstraint(CComplexObject cComplexObject)
        {
            var name = string.Empty;

            if (cComplexObject.Attributes == null) return name;
            foreach (CAttribute attribute in cComplexObject.Attributes)
            {
                if (attribute.RmAttributeName != "name" || attribute.Children.Count <= 0) continue;
                var primativeObject = attribute.Children[0] as CPrimitiveObject;
                if (primativeObject == null) continue;
                var cString = primativeObject.Item as CString;
                if (cString == null || cString.List.Count <= 0) continue;
                name = cString.List[0];
                break;
            }
            return name;
        }
Example #16
0
        /// <summary>
        /// an internal static method returning the targetPath corresponding CObject.
        /// Returns null if the targetPath doesn't have any associated CObject
        /// </summary>
        /// <param name="archetypeDefinition"></param>
        /// <param name="targetPath"></param>
        /// <returns></returns>
        internal static CObject GetCObjectAtTargetPath(CComplexObject archetypeDefinition, string targetPath)
        {
            CComplexObject cObj      = archetypeDefinition;
            CAttribute     attribute = null;

            Path pathProcessor = new Path(targetPath);

            do
            {
                foreach (CAttribute cAttri in cObj.Attributes)
                {
                    if (cAttri.RmAttributeName == pathProcessor.CurrentAttribute)
                    {
                        attribute = cAttri;
                        break;
                    }
                }

                Check.Assert(attribute != null, string.Format(CommonStrings.XMustNotBeNull, "attribute"));

                if (attribute.RmAttributeName != pathProcessor.CurrentAttribute)
                {
                    return(null);
                }

                foreach (CObject obj in attribute.Children)
                {
                    if (obj.NodeId == pathProcessor.CurrentNodeId)
                    {
                        cObj = obj as CComplexObject;
                        break;
                    }
                }

                Check.Assert(cObj != null, string.Format(CommonStrings.XMustNotBeNull, "cObj"));

                if (cObj.NodeId != pathProcessor.CurrentNodeId)
                {
                    return(null);
                }
            } while (pathProcessor.NextStep());

            Check.Ensure(cObj.Path == targetPath, "cObj.Path must be the same as this.TargetPath");

            return(cObj);
        }
Example #17
0
        public void testExistenceCardinalityAndOccurrences()
        {
            // second attribute of root object
            CAttribute  attr = (CAttribute)definition.getAttributes().get(1);
            Cardinality card = new Cardinality(true, false, interval(0, 8));

            assertCAttribute(attr, "members", CAttribute.Existence.OPTIONAL, card, 2);

            // 1st PERSON
            CComplexObject obj = (CComplexObject)attr.getChildren().get(0);

            assertCComplexObject(obj, "PERSON", null, interval(1, 1), 1);

            // 2nd PERSON
            obj = (CComplexObject)attr.getChildren().get(1);
            assertCComplexObject(obj, "PERSON", null,
                                 new Interval(new java.lang.Integer(0), null, java.lang.Boolean.TRUE, java.lang.Boolean.FALSE), 1);
        }
Example #18
0
        internal static CComplexObject GetRootDefinition(ArchetypeInternalRef archeytpeInternalRef)
        {
            DesignByContract.Check.Require(archeytpeInternalRef != null, string.Format(CommonStrings.XMustNotBeNull, "archeytpeInternalRef"));
            DesignByContract.Check.Require(archeytpeInternalRef.Parent != null, string.Format(CommonStrings.XMustNotBeNull, "archeytpeInternalRef.Parent"));

            CComplexObject root = null;

            CAttribute parent = archeytpeInternalRef.Parent;

            while (parent != null)
            {
                root   = parent.parent;
                parent = root.Parent;
            }

            DesignByContract.Check.Ensure(root != null, "Root definition must not be null.");

            return(root);
        }
Example #19
0
        /// <summary>
        /// Get the origin value based on the history.Events time or IntervalStartTime
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="history"></param>
        /// <returns></returns>
        static public DvDateTime CalculateOrigin(History <T> history)
        {
            Check.Require(history != null, "history must not be null");

            DvDateTime originValue = null;

            if (history.Events != null && history.Events.Count > 0)
            {
                foreach (Event <T> anEvent in history.Events)
                {
                    DvDateTime        eventTime;
                    IntervalEvent <T> intervalEvent = anEvent as IntervalEvent <T>;
                    if (intervalEvent != null)
                    {
                        eventTime = intervalEvent.IntervalStartTime();
                    }
                    else
                    {
                        eventTime = anEvent.Time;
                    }

                    CComplexObject constraint = ((IRmType)anEvent).Constraint as CComplexObject;
                    if (constraint != null)
                    {
                        CAttribute offsetConstraint = constraint.GetAttribute("offset");
                        if (offsetConstraint != null && offsetConstraint.Children != null && offsetConstraint.Children.Count == 1)
                        {
                            CComplexObject offsetDuration = offsetConstraint.Children[0] as CComplexObject;
                            eventTime = eventTime.Subtract((DvDuration)offsetDuration.DefaultValue);
                        }
                    }

                    if (originValue == null || originValue > eventTime)
                    {
                        originValue = new DvDateTime(eventTime.Value);
                    }
                }
            }
            Check.Ensure(originValue != null, "originValue must not be null");
            return(originValue);
        }
Example #20
0
        private static string GetName(CComplexObject cComplexObject)
        {
            CComplexObject nameAttribute = GetCObjectByAttributeName(cComplexObject, "name") as CComplexObject;

            if (nameAttribute != null)
            {
                CPrimitiveObject cPrimativeObject = GetCObjectByAttributeName(nameAttribute, "value") as CPrimitiveObject;

                Check.Assert(cPrimativeObject != null);

                CString cString = cPrimativeObject.Item as CString;

                Check.Assert(cString != null);

                foreach (string name in cString.List)
                {
                    return(name);
                }
            }

            return(string.Empty);
        }
Example #21
0
        public void testStructure()
        {
            // root object
            CComplexObject obj = definition;

            java.lang.Integer temp1       = new java.lang.Integer(1);
            Interval          occurrences = new Interval(temp1, temp1);

            assertCComplexObject(obj, "ENTRY", "at0000", occurrences, 2);

            // first attribute of root object
            CAttribute attr = (CAttribute)obj.getAttributes().get(0);

            assertCAttribute(attr, "subject_relationship", 1);

            // 2nd level object
            obj = (CComplexObject)attr.getChildren().get(0);
            assertCComplexObject(obj, "RELATED_PARTY", null, occurrences, 1);

            // attribute of 2nd level object
            attr = (CAttribute)obj.getAttributes().get(0);
            assertCAttribute(attr, "relationship", 1);

            // leaf object
            obj = (CComplexObject)attr.getChildren().get(0);
            assertCComplexObject(obj, "TEXT", null, occurrences, 1);

            // attribute of leaf object
            attr = (CAttribute)obj.getAttributes().get(0);
            assertCAttribute(attr, "value", 1);

            // primitive constraint of leaf object
            CString str = (CString)((CPrimitiveObject)attr.getChildren().get(0)).getItem();

            Assert.AreEqual(null, str.getPattern(), "pattern");
            Assert.AreEqual(1, str.getList().size(), "set.size");
            Assert.IsTrue(str.getList().contains("self"), "set has");
        }
Example #22
0
        /// <summary>
        /// returns true if all NodeIds valid for an CAttribute object
        /// </summary>
        /// <param name="attri"></param>
        /// <returns></returns>
        private bool NodeIdsValid(CAttribute attri)
        {
            if (attri.Children != null)
            {
                foreach (CObject child in attri.Children)
                {
                    if (!string.IsNullOrEmpty(child.NodeId) && !this.Ontology.HasTermCode(child.NodeId))
                    {
                        return(false);
                    }
                    CComplexObject cComplexObj = child as CComplexObject;
                    if (cComplexObj != null)
                    {
                        if (!NodeIdsValid(cComplexObj))
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Example #23
0
        private bool InternalReferencesValid(CAttribute cAttribute)
        {
            Check.Require(cAttribute != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute"));

            if (cAttribute.Children != null)
            {
                foreach (CObject cObj in cAttribute.Children)
                {
                    ArchetypeInternalRef archetypeInternalRef = cObj as ArchetypeInternalRef;
                    if (archetypeInternalRef != null)
                    {
                        CObject legitimateNode = GetCObjectAtTargetPath(this.Definition, archetypeInternalRef.TargetPath);
                        if (legitimateNode == null)
                        {
                            return(false);
                        }
                    }

                    else
                    {
                        CComplexObject cComplexObj = cObj as CComplexObject;
                        if (cComplexObj != null && cComplexObj.Attributes != null)
                        {
                            foreach (CAttribute attri in cComplexObj.Attributes)
                            {
                                if (!InternalReferencesValid(attri))
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }
Example #24
0
        private bool ConstraintReferencesValid(CAttribute cAttribute)
        {
            Check.Require(cAttribute != null, string.Format(CommonStrings.XMustNotBeNull, "cAttribute"));

            if (cAttribute.Children != null)
            {
                foreach (CObject cObj in cAttribute.Children)
                {
                    ConstraintRef constraintRef = cObj as ConstraintRef;
                    if (constraintRef != null)
                    {
                        string reference = constraintRef.Reference;
                        if (this.Ontology.ConstraintCodes == null || !this.Ontology.ConstraintCodes.Has(reference))
                        {
                            return(false);
                        }
                    }

                    else
                    {
                        CComplexObject cComplexObj = cObj as CComplexObject;
                        if (cComplexObj != null && cComplexObj.Attributes != null)
                        {
                            foreach (CAttribute attri in cComplexObj.Attributes)
                            {
                                if (!ConstraintReferencesValid(attri))
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }
Example #25
0
        void WriteCComplexObject(XmlWriter writer, CComplexObject cComplexObject)
        {
            amSerializer.WriteCObject(writer, cComplexObject);

            string openEhrPrefix = UseOpenEhrPrefix(writer);

            if (cComplexObject.Attributes != null && cComplexObject.Attributes.Count > 0)
            {
                foreach (CAttribute attribute in cComplexObject.Attributes)
                {
                    string typeAttribute = AmType.GetName(attribute);

                    if (!string.IsNullOrEmpty(openEhrPrefix))
                    {
                        typeAttribute = string.Format("{0}:{1}",
                                                      openEhrPrefix, typeAttribute);
                    }

                    writer.WriteStartElement(openEhrPrefix, "attributes", OpenEhrNamespace);

                    writer.WriteAttributeString(
                        UseXsiPrefix(writer), "type", XsiNamespace, typeAttribute);

                    if (AmType.GetName(attribute) == "C_MULTIPLE_ATTRIBUTE")
                    {
                        WriteCMulitpleAttribute(writer, attribute);
                    }
                    else
                    {
                        WriteCSingleAttribute(writer, attribute);
                    }

                    writer.WriteEndElement();
                }
            }
        }
Example #26
0
 public void IsSubsetOfThrowsException()
 {
     var instance = new CComplexObject();
     var result = instance.IsSubsetOf(null);
 }
Example #27
0
        public void testNodeAtPath()
        {
            string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-car.paths.test.adl");

            se.acode.openehr.parser.ADLParser  parser    = new se.acode.openehr.parser.ADLParser(adl);
            org.openehr.am.archetype.Archetype archetype = parser.parse();
            Assert.IsNotNull(archetype);
            CComplexObject definition = archetype.getDefinition();

            String[] paths =
            {
                "/",
                "/wheels[at0001]",
                "/wheels[at0001]/description",
                "/wheels[at0001]/parts[at0002]",
                "/wheels[at0001]/parts[at0002]/something",
                "/wheels[at0001]/parts[at0002]/something_else",
                "/wheels[at0003]",
                "/wheels[at0003]/description",
                "/wheels[at0004]",
                "/wheels[at0004]/description",
                "/wheels[at0005]",
                "/wheels[at0005]/description"
            };

            CAttribute       wheels = (CAttribute)definition.getAttributes().get(0);
            CComplexObject   wheel1 = ((CComplexObject)wheels.getChildren().get(0));
            CComplexObject   wheel2 = ((CComplexObject)wheels.getChildren().get(1));
            CComplexObject   wheel3 = ((CComplexObject)wheels.getChildren().get(2));
            CComplexObject   wheel4 = ((CComplexObject)wheels.getChildren().get(3));
            CAttribute       w      = (CAttribute)wheel1.getAttributes().get(1);
            CComplexObject   parts  = (CComplexObject)w.getChildren().get(0);
            CAttribute       pt     = (CAttribute)parts.getAttributes().get(0);
            CPrimitiveObject pts    = (CPrimitiveObject)pt.getChildren().get(0);
            CAttribute       pt2    = (CAttribute)parts.getAttributes().get(1);
            CPrimitiveObject pts2   = (CPrimitiveObject)pt2.getChildren().get(0);

            CAttribute       h1 = (CAttribute)wheel1.getAttributes().get(0);
            CPrimitiveObject p1 = (CPrimitiveObject)h1.getChildren().get(0);
            CAttribute       h2 = (CAttribute)wheel2.getAttributes().get(0);
            CPrimitiveObject p2 = (CPrimitiveObject)h2.getChildren().get(0);
            CAttribute       h3 = (CAttribute)wheel3.getAttributes().get(0);
            CPrimitiveObject p3 = (CPrimitiveObject)h3.getChildren().get(0);
            CAttribute       h4 = (CAttribute)wheel4.getAttributes().get(0);
            CPrimitiveObject p4 = (CPrimitiveObject)h4.getChildren().get(0);

            CObject[] nodes =
            {
                definition,
                wheel1,
                p1,
                parts,
                pts,
                pts2,
                wheel2,
                p2,
                wheel3,
                p3,
                wheel4,
                p4,
            };

            for (int i = 0; i < paths.Length; i++)
            {
                Assert.AreEqual(nodes[i], archetype.node(paths[i]));
            }
        }
Example #28
0
 public void IsValidValueThrowsException()
 {
     var instance = new CComplexObject();
     var result   = instance.IsValidValue(null);
 }
Example #29
0
 public void DefaultValueThrowsException()
 {
     var instance = new CComplexObject();
     var result   = instance.DefaultValue();
 }
Example #30
0
 public void IsSubsetOfThrowsException()
 {
     var instance = new CComplexObject();
     var result   = instance.IsSubsetOf(null);
 }
Example #31
0
        public void ListsAreNotNull()
        {
            var instance = new CComplexObject();

            Assert.IsNotNull(instance.Attributes);
        }
Example #32
0
        protected void BuildPath(Path path)
        {
            Check.Require(path != null, "path must not be null");
            Check.Require(path.Current != null, "current path step must not be null");

            string attributeName = path.Current.Attribute;

            object value = GetAttributeValue(attributeName);

            if (value == null)
            {
                CComplexObject complexObjectConstraint = this.Constraint as CComplexObject;
                if (complexObjectConstraint == null)
                {
                    throw new NotImplementedException();
                }

                CAttribute attributeConstraint = complexObjectConstraint.GetAttribute(attributeName);
                if (attributeConstraint == null)
                {
                    throw new ApplicationException("constraint for attribute not found");
                }

                CMultipleAttribute multipleAttributeConstraint = attributeConstraint as CMultipleAttribute;

                if (multipleAttributeConstraint == null)
                {
                    if (attributeConstraint.Children.Count != 1)
                    {
                        throw new ApplicationException("Single attribute constraint must have exactly one children");
                    }

                    CObject        objectConstraint        = attributeConstraint.Children[0];
                    CDefinedObject definedObjectConstraint = objectConstraint as CDefinedObject;
                    if (definedObjectConstraint == null)
                    {
                        throw new NotImplementedException();
                    }

                    value = definedObjectConstraint.DefaultValue;
                    SetAttributeValue(attributeName, value);
                }
                else
                {
                    Type itemType = null;
                    value = multipleAttributeConstraint.CreateAggregate(itemType);
                    SetAttributeValue(attributeName, value);
                }
            }

            if (path.NextStep())
            {
                IRmType rmType = value as IRmType;
                if (rmType == null)
                {
                    AssumedTypes.IAggregate container = value as AssumedTypes.IAggregate;
                    if (container != null)
                    {
                        container.BuildPath(path);
                    }
                    else
                    {
                        throw new ApplicationException("expected IRmType");
                    }
                }
                else
                {
                    rmType.BuildPath(path);
                }
            }
        }
Example #33
0
 public void ListsAreNotNull()
 {
     var instance = new CComplexObject();
     Assert.IsNotNull(instance.Attributes);
 }
Example #34
0
 public void IsValidValueThrowsException()
 {
     var instance = new CComplexObject();
     var result = instance.IsValidValue(null);
 }
Example #35
0
 public void DefaultValueThrowsException()
 {
     var instance = new CComplexObject();
     var result = instance.DefaultValue();
 }