Example #1
0
 internal virtual void ProcessAllRelationships(PartBridge bridge, Interaction interaction, Visitor visitor)
 {
     foreach (BaseRelationshipBridge relationship in bridge.GetRelationshipBridges())
     {
         ProcessRelationship(interaction, relationship, visitor);
     }
 }
Example #2
0
 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);
         }
     }
 }
Example #3
0
        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);
            }
        }
Example #4
0
 public virtual void VisitAssociationEnd(PartBridge tealBean, Relationship relationship)
 {
     if (IsSomethingToRender(tealBean, relationship))
     {
         PopBuffer();
         this.propertyPathNames.Pop();
     }
 }
Example #5
0
        private void Walk(Interaction interaction, Visitor visitor)
        {
            PartBridge bridge = GetBridge();

            visitor.VisitRootStart(bridge, interaction);
            ProcessAllRelationships(bridge, interaction, visitor);
            visitor.VisitRootEnd(bridge, interaction);
        }
Example #6
0
        private NullFlavor GetNullFlavor(PartBridge tealBean)
        {
            NullFlavor nullFlavor = Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.NO_INFORMATION;

            if (tealBean.HasNullFlavor())
            {
                nullFlavor = tealBean.GetNullFlavor();
            }
            return(nullFlavor);
        }
Example #7
0
 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)));
             }
         }
     }
 }
Example #8
0
 private void ProcessPartValue(PartBridge child, Interaction interaction, AssociationBridge relationshipBridge, Visitor visitor
                               )
 {
     if (child.IsEmpty() && !ConformanceLevelUtil.IsMandatory(relationshipBridge.GetRelationship()))
     {
     }
     else
     {
         ProcessAllRelationships(child, interaction, visitor);
     }
 }
Example #9
0
        /// <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);
        }
Example #10
0
        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));
        }
Example #11
0
 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);
 }
Example #12
0
 public virtual void VisitAssociationStart(PartBridge tealBean, Relationship relationship)
 {
 }
Example #13
0
 public AssociationBridgeImpl(Relationship relationship, PartBridge bridge) : this(relationship, Arrays.AsList(bridge))
 {
 }
Example #14
0
 public IndicatorAssociationBridgeImpl(Relationship relationship, PartBridge bridge, BeanProperty beanProperty)
 {
     this.relationship = relationship;
     this.beanProperty = beanProperty;
     this.parts        = Arrays.AsList(bridge);
 }
Example #15
0
 internal static Relationship ResolveChoice(PartBridge tealBean, Relationship relationship)
 {
     return(relationship.FindChoiceOption(ChoiceSupport.ChoiceOptionTypePredicate(new string[] { tealBean.GetTypeName() })));
 }
Example #16
0
 public virtual void VisitRootEnd(PartBridge tealBean, Interaction interaction)
 {
     this.propertyPathNames.Pop();
 }
Example #17
0
 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);
                 }
             }
         }
     }
 }
Example #18
0
 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());
 }
Example #19
0
 public virtual void VisitRootStart(PartBridge tealBean, Interaction interaction)
 {
     this.rootStarted = true;
 }
Example #20
0
 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);
     }
 }
Example #21
0
 private bool IsSomethingToRender(PartBridge tealBean, Relationship relationship)
 {
     return(!tealBean.IsEmpty() || ConformanceLevelUtil.IsMandatory(relationship) || ConformanceLevelUtil.IsPopulated(relationship
                                                                                                                      ) || tealBean.HasNullFlavor());
 }
Example #22
0
 public TopLevelBeanBridgeWrapper(PartBridge bridge, string interactionId, VersionNumber version)
 {
     this.bridge        = bridge;
     this.interactionId = interactionId;
     this.version       = version;
 }