Ejemplo n.º 1
0
        protected void Validate(ArchetypeSlot archetypeSlot)
        {
            this.ValidateBase((CObject)archetypeSlot);

            Invariant(archetypeSlot.Includes == null || !archetypeSlot.Includes.IsEmpty(),
                      string.Format(CommonStrings.IfXIsNotNullMustBeEmpty, "ArchetypeSlot.Includes"));

            Invariant(archetypeSlot.Excludes == null || !archetypeSlot.Excludes.IsEmpty(),
                      string.Format(CommonStrings.IfXIsNotNullMustBeEmpty, "ArchetypeSlot.Excludes"));

            // TODO: validity: any_allowed xor (includes /= Void or excludes /= Void)

            if (archetypeSlot.Includes != null)
            {
                foreach (Assertion assertion in archetypeSlot.Includes)
                {
                    this.Validate(assertion);
                }
            }

            if (archetypeSlot.Excludes != null)
            {
                foreach (Assertion assertion in archetypeSlot.Excludes)
                {
                    this.Validate(assertion);
                }
            }
        }
Ejemplo n.º 2
0
        public void ListsAreNotNull()
        {
            var archetypeSlot = new ArchetypeSlot();

            Assert.IsNotNull(archetypeSlot.Includes);
            Assert.IsNotNull(archetypeSlot.Excludes);
        }
Ejemplo n.º 3
0
        private static ArchetypeSlot Map(this ARCHETYPE_SLOT model)
        {
            var archetypeSlot = new ArchetypeSlot
            {
                Occurences             = model.occurrences.Map(),
                NodeId                 = model.node_id,
                ReferenceModelTypeName = model.rm_type_name
            };

            if (model.includes != null)
            {
                foreach (ASSERTION assertion in model.includes)
                {
                    archetypeSlot.Includes.Add(assertion.Map());
                }
            }
            if (model.excludes != null)
            {
                foreach (ASSERTION assertion in model.excludes)
                {
                    archetypeSlot.Excludes.Add(assertion.Map());
                }
            }
            return(archetypeSlot);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public void testParseSingleInclude()
        {
            string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-entry.archetype_slot.test2.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);
            ArchetypeConstraint node = archetype.node("/content[at0001]");

            ArchetypeSlot slot = (ArchetypeSlot)node;

            Assert.AreEqual("at0001", slot.getNodeId(), "nodeId wrong");
            Assert.AreEqual("SECTION", slot.getRmTypeName(), "rmTypeName wrong");

            //  Assert.AreEqual("occurrences wrong", new Interval<Integer>(0, 1),slot.getOccurrences());

            Assert.AreEqual("/content[at0001]", slot.path(), "path wrong");

            Assert.AreEqual(1, slot.getIncludes().size(), "includes total wrong");

            Assertion      assertion = (Assertion)slot.getIncludes().iterator().next();
            ExpressionItem item      = assertion.getExpression();
            //assertTrue("expressionItem type wrong",
            //      item instanceof ExpressionBinaryOperator);
            ExpressionBinaryOperator bo      = (ExpressionBinaryOperator)item;
            ExpressionItem           leftOp  = bo.getLeftOperand();
            ExpressionItem           rightOp = bo.getRightOperand();

            //assertTrue("left operator type wrong",
            //        leftOp instanceof ExpressionLeaf);
            ExpressionLeaf left = (ExpressionLeaf)leftOp;

            Assert.AreEqual("archetype_id/value", left.getItem(), "left value wrong");

            //assertTrue("right operator type wrong",
            //        rightOp instanceof ExpressionLeaf);
            ExpressionLeaf right = (ExpressionLeaf)rightOp;
            //assertTrue("right item type wrong", right.getItem() instanceof CString);
            string cstring = Convert.ToString(right.getItem());

            //Assert.AreEqual("right value wrong", "openEHR-EHR-CLUSTER\\.device\\.v1",
            //        cstring.getPattern());

            Assert.IsNotNull("stringExpression missing", assertion.getStringExpression());
            String expectedStringExpression =
                "archetype_id/value matches {/openEHR-EHR-CLUSTER\\.device\\.v1/}";

            Assert.AreEqual(expectedStringExpression, assertion.getStringExpression(), "stringExpression wrong, got: " + assertion.getStringExpression());
        }
Ejemplo n.º 6
0
        public void testParseIncludesExcludes()
        {
            string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-entry.archetype_slot.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);
            ArchetypeConstraint node = archetype.node("/content[at0001]");
            // Type e = typeof(node);
            ArchetypeSlot slot = (ArchetypeSlot)node;

            Assert.AreEqual("at0001", slot.getNodeId(), "nodeId wrong");
            Assert.AreEqual("SECTION", slot.getRmTypeName(), "rmTypeName wrong");
            Interval a = new Interval(0, 1);

            // Assert.AreEqual(  a, slot.getOccurrences());//错误???

            Assert.AreEqual("/content[at0001]", slot.path(), "path wrong");

            Assert.AreEqual(1, slot.getIncludes().size(), "includes total wrong");
            Assert.AreEqual(2, slot.getExcludes().size(), "Excludes total wrong");

            object         b         = slot.getIncludes().iterator().next();
            Assertion      assertion = (Assertion)b;
            ExpressionItem item      = assertion.getExpression();

            Assert.IsInstanceOfType(item, typeof(ExpressionBinaryOperator));
            //assertTrue("expressionItem type wrong",
            //	item instanceof ExpressionBinaryOperator);
            ExpressionBinaryOperator bo      = (ExpressionBinaryOperator)item;
            ExpressionItem           leftOp  = bo.getLeftOperand();
            ExpressionItem           rightOp = bo.getRightOperand();

            Assert.IsInstanceOfType(leftOp, typeof(ExpressionLeaf));
            //assertTrue("left operator type wrong",
            //    leftOp instanceof ExpressionLeaf);
            ExpressionLeaf left = (ExpressionLeaf)leftOp;

            Assert.AreEqual("domain_concept", left.getItem(), "left value wrong");
            Assert.IsInstanceOfType(rightOp, typeof(ExpressionLeaf));
            //  assertTrue("right operator type wrong", rightOp instanceof ExpressionLeaf);
            ExpressionLeaf right = (ExpressionLeaf)rightOp;

            Assert.IsInstanceOfType(right.getItem(), typeof(CString));
            // assertTrue("right item type wrong", right.getItem() instanceof CString);
            CString cstring = (CString)right.getItem();

            Assert.AreEqual("blood_pressure.v1", cstring.getPattern(), "right value wrong");
        }
Ejemplo n.º 7
0
 public void IsValidThrowsException()
 {
     var archetypeSlot = new ArchetypeSlot();
     var result        = archetypeSlot.IsValid();
 }
Ejemplo n.º 8
0
 public void IsSubsetOfThrowsException()
 {
     var archetypeSlot = new ArchetypeSlot();
     var result        = archetypeSlot.IsSubsetOf(null);
 }