コード例 #1
0
ファイル: Ontology.cs プロジェクト: jackz08/arch_ed-dotnet
        private void AddTerms(ArrayList result, C_OBJECT obj)
        {
            if (obj.GetType() == typeof(C_COMPLEX_OBJECT))
            {
                C_COMPLEX_OBJECT co = (C_COMPLEX_OBJECT)obj;

                //Add the node id
                if (!string.IsNullOrEmpty(obj.node_id) && !result.Contains(obj.node_id))
                    result.Add(obj.node_id);

                if (co.attributes != null)
                    foreach (C_ATTRIBUTE attribute in co.attributes)
                        if (attribute.children != null)
                            foreach (C_OBJECT obj_1 in attribute.children)
                                AddTerms(result, obj_1);
            }
            else if (obj.GetType() == typeof(ARCHETYPE_SLOT))
            {
                if (!string.IsNullOrEmpty(obj.node_id) && !result.Contains(obj.node_id))
                    result.Add(obj.node_id);
            }
            //check for internal codes
            else if(obj.GetType() == typeof(C_CODE_PHRASE))
            {
                C_CODE_PHRASE ct = (C_CODE_PHRASE)obj;

               //Check reference 
                if (ct.terminology_id != null)                 
                {
                    if (ct.terminology_id.value.ToString().ToLowerInvariant() == "local" && ct.code_list != null)
                    {
                        foreach (string code in ct.code_list)
                        {
                            if (!result.Contains(code))
                                result.Add(code);
                        }
                    }
                }
            }
            //Ordinals use internal codes
            else if (obj.GetType() == typeof(C_DV_ORDINAL))
            {
                C_DV_ORDINAL co = (C_DV_ORDINAL)obj;
                
                if (co.list != null && co.list.Length > 0)
                {
                    foreach (DV_ORDINAL o in co.list)
                    {
                        if (o.symbol != null && o.symbol.defining_code != null)
                        {
                            if (!result.Contains(o.symbol.defining_code.code_string))
                                result.Add(o.symbol.defining_code.code_string); 
                        }
                    }
                }
            }
            //Constraint references us acXXXX codes
            else if (obj.GetType() == typeof(CONSTRAINT_REF))
            {
                CONSTRAINT_REF cr = (CONSTRAINT_REF)obj;

                if (cr.reference != null)
                {
                    if (!result.Contains(cr.reference))
                        result.Add(cr.reference);
                }
            }
        }