private static ArchetypeInternalRef Map(this ARCHETYPE_INTERNAL_REF model) { var archetypeInternalRef = new ArchetypeInternalRef { Occurences = model.occurrences.Map(), NodeId = model.node_id, ReferenceModelTypeName = model.rm_type_name, TargetPath = model.target_path }; return(archetypeInternalRef); }
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); }
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); }
public void testParseInternalRefWithGenerics() { string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-SOME_TYPE.generic_type_use_node.draft.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("/interval_attr2"); //assertTrue("ArchetypeInternalRef expected, actual: " + node.getClass(), // node instanceof ArchetypeInternalRef); Assert.IsInstanceOfType(node, typeof(ArchetypeInternalRef)); ArchetypeInternalRef refe = (ArchetypeInternalRef)node; Assert.AreEqual("INTERVAL<QUANTITY>", refe.getRmTypeName()); Assert.AreEqual("/interval_attr[at0001]", refe.getTargetPath()); }
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); }
public void testParseInternalRefWithOverwrittingOccurrences() { string adl = System.IO.File.ReadAllText(@"..\..\..\..\java-libs\adl-parser\src\test\resources\adl-test-entry.archetype_internal_ref.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("/attribute2"); Assert.IsInstanceOfType(node, typeof(ArchetypeInternalRef)); ArchetypeInternalRef refff = (ArchetypeInternalRef)node; Assert.AreEqual("SECTION", refff.getRmTypeName(), "rmType wrong"); Assert.AreEqual("/attribute1", refff.getTargetPath(), "path wrong"); Interval occurrences = new Interval(1, 2); //Assert.AreEqual( occurrences, refff.getOccurrences());//错误??? }
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); }
public void IsValidThrowsException() { var archetypeInternalRef = new ArchetypeInternalRef(); var result = archetypeInternalRef.IsValid(); }
public void IsSubsetOfThrowsException() { var archetypeInternalRef = new ArchetypeInternalRef(); var result = archetypeInternalRef.IsSubsetOf(null); }