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); }
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); }
public void RemoveConstraintBinding(string a_query, string a_terminology_id) { ConstraintBindingSet ts = GetBindings(a_terminology_id, _archetype.ontology.constraint_bindings); ArrayList bindingsArray = new ArrayList(ts.items); foreach (CONSTRAINT_BINDING_ITEM b in ts.items) { if (b.code == a_query) { bindingsArray.Remove(b); break; } } ts.items = bindingsArray.ToArray() as CONSTRAINT_BINDING_ITEM[]; }
public void AddOrReplaceConstraintBinding(string query, string acCode, string terminology) { ConstraintBindingSet ts = ConstraintBindingSetForTerminology(terminology); if (ts != null) { AddTerminology(terminology); CONSTRAINT_BINDING_ITEM binding = null; CONSTRAINT_BINDING_ITEM[] bindings = ts.items; if (bindings != null) { foreach (CONSTRAINT_BINDING_ITEM b in bindings) { if (b.code == acCode) { binding = b; } } } if (binding == null) { int i = 0; if (bindings == null) { bindings = new CONSTRAINT_BINDING_ITEM[1]; } else { i = bindings.Length; Array.Resize(ref bindings, i + 1); } ts.items = bindings; bindings[i] = binding = new CONSTRAINT_BINDING_ITEM(); binding.code = acCode.ToLowerInvariant(); } binding.value = query; } }
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); }