Ejemplo n.º 1
0
        ConstraintBindingSet[] VisitConstraintBindings(ConstraintBindingSet[] constraintBindings)
        {
            ConstraintBindingSet[] result = null;

            if (constraintBindings != null)
            {
                SortedDictionary<string, ConstraintBindingSet> sortedItems = new SortedDictionary<string, ConstraintBindingSet>();

                foreach (ConstraintBindingSet constraintBindingsItem in constraintBindings)
                {
                    ConstraintBindingSet canonicalItem = new ConstraintBindingSet();
                    canonicalItem.terminology = constraintBindingsItem.terminology;

                    // sort constraint bindings items hash list
                    canonicalItem.items = VisitConstraintBindingItems(constraintBindingsItem.items);
                    sortedItems.Add(constraintBindingsItem.terminology, canonicalItem);
                }

                result = new ConstraintBindingSet[sortedItems.Count];
                sortedItems.Values.CopyTo(result, 0);
            }

            return result;
        }
        protected virtual ConstraintBindingSet[] CloneConstraintBindingSet(EiffelStructures.table.HASH_TABLE_REFERENCE_REFERENCE o)
        {
            ConstraintBindingSet[] result = null;

            if (o != null && o.count() > 0)
            {
                result = new ConstraintBindingSet[o.count()];
                o.start();

                for (int i = 1; i <= result.Length; i++)
                {
                    ConstraintBindingSet constraintBindingSet = new ConstraintBindingSet();
                    constraintBindingSet.terminology = o.key_for_iteration().ToString();
                    EiffelStructures.table.Impl.HASH_TABLE_REFERENCE_REFERENCE adlTerms = o.item_for_iteration() as EiffelStructures.table.Impl.HASH_TABLE_REFERENCE_REFERENCE;
                    CONSTRAINT_BINDING_ITEM[] localTerms = new CONSTRAINT_BINDING_ITEM[adlTerms.count()];
                    adlTerms.start();

                    for (int j = 1; j <= adlTerms.count(); j++)
                    {
                        openehr.common_libs.basic.Impl.URI term = adlTerms.item_for_iteration() as openehr.common_libs.basic.Impl.URI;
                        CONSTRAINT_BINDING_ITEM localTerm = new CONSTRAINT_BINDING_ITEM();
                        localTerm.code = adlTerms.key_for_iteration().ToString();
                        localTerm.value = adlTerms.item_for_iteration().ToString();
                        localTerms[j - 1] = localTerm;
                        adlTerms.forth();
                    }

                    constraintBindingSet.items = localTerms;
                    result[i - 1] = constraintBindingSet;
                    o.forth();
                }
            }

            return result;
        }
Ejemplo n.º 3
0
        public ConstraintBindingSet GetBindings(string a_terminology_id, ConstraintBindingSet[] terminology_sets)
        {
            foreach (ConstraintBindingSet ts in terminology_sets)
            {
                if (ts.terminology == a_terminology_id)
                {
                    return ts;
                }
            }

            return null;
        }
Ejemplo n.º 4
0
        private ConstraintBindingSet[] PackTerminologySets(ConstraintBindingSet[] terminologySets)
        {
            ConstraintBindingSet t;
            bool removeBinding = true;
            ArrayList tempTerminologySets = new ArrayList(terminologySets);
            bool resetBindings = false;

            for (int i = 0; i < terminologySets.Length; i++)
            {
                t = terminologySets[i];

                if (t.items == null || t.items.Length == 0)
                {
                    tempTerminologySets.Remove(t);
                    resetBindings = true;
                }
                else
                {
                    removeBinding = false;
                }
            }

            if (removeBinding)
            {
                //No bindings with terms etc so remove term bindings completely
                return null;
            }
            else
            {
                //If there has been a term binding removed as it is empty
                if (resetBindings)
                {
                    return tempTerminologySets.ToArray(typeof(ConstraintBindingSet)) as ConstraintBindingSet[];
                }
                else
                    return terminologySets;
            }
        }
Ejemplo n.º 5
0
        private ConstraintBindingSet ConstraintBindingSetForTerminology(string terminology)
        {
            ConstraintBindingSet result = null;

            if (!string.IsNullOrEmpty(terminology))
            {
                int i = 0;
                ConstraintBindingSet[] bindings = _archetype.ontology.constraint_bindings;

                if (bindings != null)
                {
                    foreach (ConstraintBindingSet ts in bindings)
                    {
                        if (ts.terminology == terminology)
                            result = ts;
                    }

                    i = bindings.Length;
                }

                if (result == null)
                {
                    Array.Resize(ref bindings, i + 1);
                    bindings[i] = result = new ConstraintBindingSet();
                    result.terminology = terminology;
                    _archetype.ontology.constraint_bindings = bindings;
                }
            }

            return result;
        }