internal virtual void ProcessAllRelationships(PartBridge bridge, Interaction interaction, Visitor visitor) { foreach (BaseRelationshipBridge relationship in bridge.GetRelationshipBridges()) { ProcessRelationship(interaction, relationship, visitor); } }
private void RenderRealmCodes(PartBridge tealBean) { if (tealBean.GetRealmCode() != null) { string type = "CS"; PropertyFormatter formatter = this.formatterRegistry.Get(type); Relationship placeholderRelationship = new Relationship("realmCode", type, Cardinality.Create("0-*")); placeholderRelationship.DomainType = "Realm"; FormatContext context = Ca.Infoway.Messagebuilder.Marshalling.FormatContextImpl.Create(this.result, null, placeholderRelationship , version, null, null, null, this.isCda); foreach (Realm realm in tealBean.GetRealmCode()) { BareANY any = (BareANY)DataTypeFactory.CreateDataType(type, this.isCda && this.isR2); if (this.isR2) { ((BareANYImpl)any).BareValue = new CodedTypeR2 <Realm>(realm); } else { ((BareANYImpl)any).BareValue = realm; } string xmlFragment = formatter.Format(context, any, GetIndent()); CurrentBuffer().GetChildBuilder().Append(xmlFragment); } } }
private void AddChoiceAnnotation(PartBridge part, Relationship relationship) { NamedAndTyped choiceOptionRelationship = null; string choiceType = relationship.Type; if (relationship.Choice) { choiceOptionRelationship = BeanBridgeChoiceRelationshipResolver.ResolveChoice(part, relationship); } else { if (relationship.TemplateRelationship) { Argument argument = this.interaction.GetArgumentByTemplateParameterName(relationship.TemplateParameterName); if (argument != null && argument.Choice) { Ca.Infoway.Messagebuilder.Xml.Predicate <Relationship> predicate = ChoiceSupport.ChoiceOptionTypePredicate(new string[] { part.GetTypeName() }); choiceOptionRelationship = argument.FindChoiceOption(predicate); choiceType = argument.Name; } } } if (choiceOptionRelationship != null) { CurrentBuffer().AddInfo("Selected option " + choiceOptionRelationship.Type + " (" + choiceOptionRelationship.Name + ") from choice " + choiceType); } }
public virtual void VisitAssociationEnd(PartBridge tealBean, Relationship relationship) { if (IsSomethingToRender(tealBean, relationship)) { PopBuffer(); this.propertyPathNames.Pop(); } }
private void Walk(Interaction interaction, Visitor visitor) { PartBridge bridge = GetBridge(); visitor.VisitRootStart(bridge, interaction); ProcessAllRelationships(bridge, interaction, visitor); visitor.VisitRootEnd(bridge, interaction); }
private NullFlavor GetNullFlavor(PartBridge tealBean) { NullFlavor nullFlavor = Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.NO_INFORMATION; if (tealBean.HasNullFlavor()) { nullFlavor = tealBean.GetNullFlavor(); } return(nullFlavor); }
private AssociationBridge CreateAssociationBridge(Relationship relationship, RelationshipSorter sorter, Interaction interaction , MessagePartHolder currentMessagePart, BridgeContext context) { if (sorter.IsCollapsedRelationship(relationship)) { if (relationship.Cardinality.Multiple) { return(CreateCollectionRelationshipBridge(relationship, sorter, interaction)); } else { RelationshipSorter collapsedSorter = sorter.GetAsRelationshipSorter(relationship); PartBridge bridge = CreatePartBridge(collapsedSorter, interaction, GetMessagePart(interaction, relationship, collapsedSorter .GetBean()), new BridgeContext(true, context.GetOriginalIndex()), false); return(new AssociationBridgeImpl(relationship, bridge)); } } else { object o = sorter.Get(relationship); BeanProperty property = (BeanProperty)o; object value = property.Get(); if (relationship.Cardinality.Multiple && value is IEnumerable) { this.log.Debug("Association " + Describer.Describe(currentMessagePart, relationship) + " maps to collection property " + Describer.Describe(sorter.GetBeanType(), property)); return(CreateCollectionOfCompositeBeanBridges(property.Name, relationship, (IEnumerable)value, interaction)); } else { if (context.IsIndexed() && property.Collection) { this.log.Debug("Association " + Describer.Describe(currentMessagePart, relationship) + " maps to index " + context.GetIndex () + " of collection property " + Describer.Describe(sorter.GetBeanType(), property)); object elementValue = ListElementUtil.GetElement(value, context.GetIndex()); // use the indexed object's part instead MessagePartHolder part = GetMessagePart(interaction, relationship, elementValue); return(new AssociationBridgeImpl(relationship, CreatePartBridgeFromBean(property.Name + "[" + context.GetIndex() + "]", elementValue , interaction, part))); } else { this.log.Debug("Association " + Describer.Describe(currentMessagePart, relationship) + " maps to property " + Describer.Describe (sorter.GetBeanType(), property)); // Bug 13050 - should handle a single cardinality relationship if mapped to a collection if (ListElementUtil.IsCollection(value)) { value = ListElementUtil.IsEmpty(value) ? null : ListElementUtil.GetElement(value, 0); } MessagePartHolder part = GetMessagePart(interaction, relationship, value); return(new AssociationBridgeImpl(relationship, CreatePartBridgeFromBean(property.Name, value, interaction, part))); } } } }
private void ProcessPartValue(PartBridge child, Interaction interaction, AssociationBridge relationshipBridge, Visitor visitor ) { if (child.IsEmpty() && !ConformanceLevelUtil.IsMandatory(relationshipBridge.GetRelationship())) { } else { ProcessAllRelationships(child, interaction, visitor); } }
/// <summary>Very rarely, there's a mandatory association that has no data.</summary> /// <remarks>Very rarely, there's a mandatory association that has no data.</remarks> /// <param name="part"></param> /// <returns></returns> private bool IsTrivial(PartBridge part) { bool trivial = true; foreach (BaseRelationshipBridge relationship in part.GetRelationshipBridges()) { Relationship r = relationship.GetRelationship(); if (relationship.GetRelationship().Association || !r.HasFixedValue()) { trivial = false; break; } } return(trivial); }
private IndicatorAssociationBridgeImpl CreateIndicatorAssociationBridge(Relationship relationship, RelationshipSorter sorter , Interaction interaction, BridgeContext context, BeanProperty beanProperty) { PartBridge partBridge = null; if (beanProperty == null || beanProperty.Get() == null) { partBridge = CreateNullPartBridge(relationship, interaction); } else { partBridge = CreatePartBridge(sorter, interaction, GetMessagePart(interaction, relationship, null), new BridgeContext(), false); } return(new IndicatorAssociationBridgeImpl(relationship, partBridge, beanProperty)); }
public virtual void VisitRootStart(PartBridge tealBean, Interaction interaction) { this.propertyPathNames.Push(DeterminePropertyName(tealBean.GetPropertyName(), interaction)); this.interaction = interaction; this.buffers.Clear(); this.buffers.Push(new XmlRenderingVisitor.Buffer(this, this.isCda ? "ClinicalDocument" : interaction.Name, 0)); CurrentBuffer().GetStructuralBuilder().Append(" xmlns=\"urn:hl7-org:v3\" "); CurrentBuffer().GetStructuralBuilder().Append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "); if (this.isCda) { CurrentBuffer().GetStructuralBuilder().Append("xmlns:sdtc=\"urn:hl7-org:sdtc\" xmlns:cda=\"urn:hl7-org:v3\""); } else { CurrentBuffer().GetStructuralBuilder().Append("ITSVersion=\"XML_1.0\""); } RenderRealmCodes(tealBean); }
public virtual void VisitAssociationStart(PartBridge tealBean, Relationship relationship) { }
public AssociationBridgeImpl(Relationship relationship, PartBridge bridge) : this(relationship, Arrays.AsList(bridge)) { }
public IndicatorAssociationBridgeImpl(Relationship relationship, PartBridge bridge, BeanProperty beanProperty) { this.relationship = relationship; this.beanProperty = beanProperty; this.parts = Arrays.AsList(bridge); }
internal static Relationship ResolveChoice(PartBridge tealBean, Relationship relationship) { return(relationship.FindChoiceOption(ChoiceSupport.ChoiceOptionTypePredicate(new string[] { tealBean.GetTypeName() }))); }
public virtual void VisitRootEnd(PartBridge tealBean, Interaction interaction) { this.propertyPathNames.Pop(); }
private string DetermineXmlName(PartBridge tealBean, Relationship relationship) { if (!relationship.Choice && !relationship.TemplateRelationship) { return(relationship.Name); } else { if (relationship.TemplateRelationship) { Argument argument = this.interaction.GetArgumentByTemplateParameterName(relationship.TemplateParameterName); if (argument == null) { throw new RenderingException("Cannot determine the template/choice parameter type : " + relationship.Name); } else { if (argument.Choice) { Ca.Infoway.Messagebuilder.Xml.Predicate <Relationship> predicate = ChoiceSupport.ChoiceOptionTypePredicate(new string[] { tealBean.GetTypeName() }); Relationship option = argument.FindChoiceOption(predicate); if (option == null) { throw new RenderingException("Cannot determine the choice type of template argument : " + argument.Name); } else { return(option.Name); } } else { return(argument.TraversalName); } } } else { if (tealBean.IsEmpty()) { return(relationship.Choices[0].Name); } else { if (relationship.Cardinality.Multiple) { return(relationship.Name); } Relationship option = BeanBridgeChoiceRelationshipResolver.ResolveChoice(tealBean, relationship); if (option == null) { // log an error instead? throw new RenderingException("Cannot determine the choice type of relationship : " + relationship.Name); } else { return(option.Name); } } } } }
private void ProcessAssociation(Interaction interaction, AssociationBridge relationshipBridge, Visitor visitor, PartBridge child) { visitor.VisitAssociationStart(child, relationshipBridge.GetRelationship()); ProcessPartValue(child, interaction, relationshipBridge, visitor); visitor.VisitAssociationEnd(child, relationshipBridge.GetRelationship()); }
public virtual void VisitRootStart(PartBridge tealBean, Interaction interaction) { this.rootStarted = true; }
public virtual void VisitAssociationStart(PartBridge part, Relationship relationship) { if (IsSomethingToRender(part, relationship)) { bool validationWarning = false; string warningMessage = null; PushPropertyPathName(DeterminePropertyName(part.GetPropertyName(), relationship), part.IsCollapsed()); string propertyPath = BuildPropertyPath(); string xmlElementName = DetermineXmlName(part, relationship); if (StringUtils.IsNotBlank(relationship.Namespaze)) { xmlElementName = relationship.Namespaze + ":" + xmlElementName; } this.buffers.Push(new XmlRenderingVisitor.Buffer(this, xmlElementName, this.buffers.Count)); AddChoiceAnnotation(part, relationship); if (part.IsEmpty() && (ConformanceLevelUtil.IsPopulated(relationship) || part.HasNullFlavor())) { // MBR-319 - some clients want xsi:nil suppressed string nf = Ca.Infoway.Messagebuilder.BooleanUtils.ValueOf(Runtime.GetProperty(NullFlavorHelper.MB_SUPPRESS_XSI_NIL_ON_NULLFLAVOR )) ? NULL_FLAVOR_FORMAT_FOR_ASSOCIATIONS_NO_XSI_NIL : NULL_FLAVOR_FORMAT_FOR_ASSOCIATIONS; CurrentBuffer().GetStructuralBuilder().Append(System.String.Format(nf, GetNullFlavor(part).CodeValue)); } else { if (part.IsEmpty() && ConformanceLevelUtil.IsMandatory(relationship) && !IsTrivial(part)) { // some errors are due to "null" parts MB has inserted to create structural XML; don't log errors on these validationWarning = !part.IsNullPart() && !part.IsCollapsed(); warningMessage = "Mandatory association has no data."; if (!validationWarning) { CurrentBuffer().AddWarning(warningMessage + " (" + propertyPath + ")"); } } else { if (ConformanceLevelUtil.IsIgnored(relationship)) { validationWarning = true; warningMessage = System.String.Format(ConformanceLevelUtil.IsIgnoredNotAllowed() ? ConformanceLevelUtil.ASSOCIATION_IS_IGNORED_AND_CANNOT_BE_USED : ConformanceLevelUtil.ASSOCIATION_IS_IGNORED_AND_WILL_NOT_BE_USED, relationship.Name); } else { if (ConformanceLevelUtil.IsNotAllowed(relationship)) { validationWarning = true; warningMessage = System.String.Format(ConformanceLevelUtil.ASSOCIATION_IS_NOT_ALLOWED, relationship.Name); } } } } if (validationWarning) { // store error within error collection this.result.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, warningMessage, propertyPath)); } AddNewErrorsToList(CurrentBuffer().GetWarnings()); RenderRealmCodes(part); } }
private bool IsSomethingToRender(PartBridge tealBean, Relationship relationship) { return(!tealBean.IsEmpty() || ConformanceLevelUtil.IsMandatory(relationship) || ConformanceLevelUtil.IsPopulated(relationship ) || tealBean.HasNullFlavor()); }
public TopLevelBeanBridgeWrapper(PartBridge bridge, string interactionId, VersionNumber version) { this.bridge = bridge; this.interactionId = interactionId; this.version = version; }