示例#1
0
        private PartBridge CreatePartBridge(RelationshipSorter sorter, Interaction interaction, MessagePartHolder currentMessagePart
                                            , BridgeContext context, bool nullPart)
        {
            IList <BaseRelationshipBridge> relationships = new List <BaseRelationshipBridge>();

            foreach (Relationship relationship in currentMessagePart.GetRelationships())
            {
                object o = sorter.Get(relationship);
                if (relationship.Attribute && relationship.HasFixedValue())
                {
                    relationships.Add(new FixedValueAttributeBeanBridge(relationship, (BareANY)null));
                }
                else
                {
                    if (relationship.Attribute)
                    {
                        if (o == null)
                        {
                            CreateWarningIfPropertyIsNotMapped(sorter, currentMessagePart, relationship);
                            relationships.Add(new AttributeBridgeImpl(relationship, null));
                        }
                        else
                        {
                            if (context.IsIndexed())
                            {
                                CreateWarningIfConformanceLevelIsNotAllowed(relationship);
                                object field = sorter.GetField(relationship);
                                if (ListElementUtil.IsCollection(field))
                                {
                                    relationships.Add(new CollapsedAttributeBridge(((BeanProperty)o).Name, relationship, ListElementUtil.GetElement(field, context
                                                                                                                                                    .GetIndex())));
                                }
                                else
                                {
                                    throw new MarshallingException("Expected relationship " + relationship.Name + " on " + sorter + " to resolve to a List because we think it's a collapsed "
                                                                   + " attribute");
                                }
                            }
                            else
                            {
                                CreateWarningIfConformanceLevelIsNotAllowed(relationship);
                                relationships.Add(CreateAttributeBridge(relationship, (BeanProperty)o, sorter, currentMessagePart));
                            }
                        }
                    }
                    else
                    {
                        if (IsIndicator(relationship))
                        {
                            CreateWarningIfConformanceLevelIsNotAllowed(relationship);
                            relationships.Add(CreateIndicatorAssociationBridge(relationship, sorter, interaction, context, (BeanProperty)o));
                        }
                        else
                        {
                            if (o == null)
                            {
                                CreateWarningIfPropertyIsNotMapped(sorter, currentMessagePart, relationship);
                                if (ConformanceLevelUtil.IsMandatory(relationship) || ConformanceLevelUtil.IsPopulated(relationship))
                                {
                                    relationships.Add(new AssociationBridgeImpl(relationship, CreateNullPartBridge(relationship, interaction)));
                                }
                            }
                            else
                            {
                                CreateWarningIfConformanceLevelIsNotAllowed(relationship);
                                relationships.Add(CreateAssociationBridge(relationship, sorter, interaction, currentMessagePart, context));
                            }
                        }
                    }
                }
            }
            //		if (sorter.getPropertyName() == null || sorter.getPropertyName().equals("null")) {
            //			System.out.println("not correct");
            //		}
            return(new PartBridgeImpl(sorter.GetPropertyName(), sorter.GetBean(), currentMessagePart.GetName(), relationships, context
                                      .IsCollapsed(), nullPart));
        }