示例#1
0
        internal virtual PartBridge CreatePartBridgeFromBean(string propertyPath, object tealBean, Interaction interaction, MessagePartHolder
                                                             currentMessagePart)
        {
            RelationshipSorter sorter = RelationshipSorter.Create(propertyPath, tealBean);

            return(CreatePartBridge(sorter, interaction, currentMessagePart, new BridgeContext(), false));
        }
示例#2
0
 internal BeanWrapper(object bean)
 {
     this.map           = BeanProperty.GetProperties(bean);
     this.sorter        = RelationshipSorter.Create(string.Empty, bean);
     this.contextName   = null;
     this.parentWrapper = null;
 }
示例#3
0
        public virtual void ShouldHandleInlinedPropertiesWithMapByPartTypeAndWithout()
        {
            RelationshipSorter sorter = RelationshipSorter.Create(string.Empty, new MockMultiplyCompoundNestedMappedMessagePartBean()
                                                                  );
            Relationship organizationInMapByPartTypeRelationship = new Relationship("representedOrganization", "COCT_MT090102CA.Organization"
                                                                                    , Cardinality.Create("1"));
            Relationship organizationNotInMapByPartTypeRelationship = new Relationship("representedOrganization", "MOCK_MT090102CA.Organization"
                                                                                       , Cardinality.Create("1"));
            Relationship assignedOrganizationInMapByPartTypeRelationship = new Relationship("assignedOrganization", "COCT_MT260030CA.Organization"
                                                                                            , Cardinality.Create("1"));
            Relationship nameRelationship    = new Relationship("name", "ST", Cardinality.Create("1"));
            Relationship idRelationship      = new Relationship("id", "II", Cardinality.Create("1"));
            Relationship otherIdRelationship = new Relationship("otherId", "II", Cardinality.Create("1"));
            // >>>>>>>>>>>>>>>>>>
            object @object = sorter.Get(organizationInMapByPartTypeRelationship);

            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is RelationshipSorter, "type");
            RelationshipSorter innerSorter = (RelationshipSorter)@object;

            @object = innerSorter.Get(nameRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is BeanProperty, "type");
            AssertPropertyNamesEqual("property name", "assignedOrganizationName", @object);
            @object = innerSorter.Get(idRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is BeanProperty, "type");
            AssertPropertyNamesEqual("property id", "organizationIdentifier", @object);
            @object = innerSorter.Get(otherIdRelationship);
            Assert.IsNull(@object, "type does not exists");
            // >>>>>>>>>>>>>>>>>>
            @object = sorter.Get(organizationNotInMapByPartTypeRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is RelationshipSorter, "type");
            innerSorter = (RelationshipSorter)@object;
            @object     = innerSorter.Get(nameRelationship);
            Assert.IsNull(@object, "type does not exist");
            @object = innerSorter.Get(idRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is BeanProperty, "type");
            AssertPropertyNamesEqual("property id", "organizationIdentifier", @object);
            @object = innerSorter.Get(otherIdRelationship);
            Assert.IsNull(@object, "type does not exist");
            // >>>>>>>>>>>>>>>>>>
            @object = sorter.Get(assignedOrganizationInMapByPartTypeRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is RelationshipSorter, "type");
            innerSorter = (RelationshipSorter)@object;
            @object     = innerSorter.Get(nameRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is BeanProperty, "type");
            AssertPropertyNamesEqual("property name", "assignedOrganizationName", @object);
            @object = innerSorter.Get(idRelationship);
            Assert.IsNull(@object, "type should not exist");
            @object = innerSorter.Get(otherIdRelationship);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is BeanProperty, "type");
            AssertPropertyNamesEqual("other property id", "otherOrganizationIdentifier", @object);
        }
示例#4
0
        private PartBridge CreateNullPartBridge(Relationship relationship, Interaction interaction)
        {
            RelationshipSorter sorter             = RelationshipSorter.Create(relationship.Name, null);
            MessagePartHolder  currentMessagePart = GetMessagePart(interaction, relationship, null);

            if (currentMessagePart != null)
            {
                return(CreatePartBridge(sorter, interaction, currentMessagePart, new BridgeContext(), true));
            }
            else
            {
                return(new PartBridgeImpl(relationship.Name, null, relationship.Type, CollUtils.EmptyList <BaseRelationshipBridge>(), false
                                          , true));
            }
        }
示例#5
0
        public virtual void ShouldHandlePropertiesWithMapByPartType()
        {
            RelationshipSorter sorter       = RelationshipSorter.Create(string.Empty, new MockMultiplyMappedMessagePartBean());
            Relationship       relationship = new Relationship("theType", "MOCK_MT898989CA.SubType", Cardinality.Create("1"));
            object             @object      = sorter.Get(relationship);

            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is BeanProperty, "type");
            AssertPropertyNamesEqual("property name", "type2", @object);
            Relationship otherRelationship = new Relationship("theType", "MOCK_MT123456CA.SubType", Cardinality.Create("1"));
            object       otherObject       = sorter.Get(otherRelationship);

            Assert.IsNotNull(otherObject, "other type exists");
            Assert.IsTrue(otherObject is BeanProperty, "other type");
            AssertPropertyNamesEqual("other property name", "type", otherObject);
        }
示例#6
0
        public virtual void ShouldHandleCollapsedProperties()
        {
            RelationshipSorter sorter       = RelationshipSorter.Create(string.Empty, new MockMessageBean());
            Relationship       relationship = new Relationship("theType", "MOCK_MT898989CA.SubType", Cardinality.Create("1"));

            Assert.IsNotNull(sorter.Get(relationship), "type exists");
            Assert.IsTrue(sorter.Get(relationship) is BeanProperty, "type");
            sorter       = RelationshipSorter.Create(string.Empty, new MockSubType());
            relationship = new Relationship("component", "MOCK_MT123456CA.Component", Cardinality.Create("1"));
            Assert.IsNotNull(sorter.Get(relationship), "component exists");
            Assert.IsTrue(sorter.Get(relationship) is RelationshipSorter, "component");
            RelationshipSorter deviceSorter = (RelationshipSorter)sorter.Get(relationship);

            Assert.IsNotNull(deviceSorter.Get(new Relationship("subject3", "MOCK_MT123456CA.Subject6", Cardinality.Create("1"))), "id exists"
                             );
        }
示例#7
0
        public virtual void ShouldHandleCompoundPropertiesWithMapByPartType()
        {
            RelationshipSorter sorter        = RelationshipSorter.Create(string.Empty, new MockMultiplyCompoundMappedMessagePartBean());
            Relationship       relationship1 = new Relationship("theType", "MOCK_MT123458CA.SubTypeA", Cardinality.Create("1"));
            Relationship       relationship2 = new Relationship("theSubType", "MOCK_MT123457CA.SubTypeB", Cardinality.Create("1"));
            Relationship       relationship3 = new Relationship("theSubSubType", "MOCK_MT898989CA.SubType", Cardinality.Create("1"));
            // first level
            object @object = sorter.Get(relationship1);

            Assert.IsNotNull(@object, "exists");
            Assert.IsTrue(@object is RelationshipSorter, "type");
            RelationshipSorter tempSorter = (RelationshipSorter)@object;

            // second level
            @object = tempSorter.Get(relationship2);
            Assert.IsNotNull(@object, "exists");
            Assert.IsTrue(@object is RelationshipSorter, "type");
            tempSorter = (RelationshipSorter)@object;
            // third level
            @object = tempSorter.Get(relationship3);
            Assert.IsNotNull(@object, "type exists");
            Assert.IsTrue(@object is BeanProperty, "type");
            AssertPropertyNamesEqual("property name", "type2", @object);
            Relationship otherRelationship1 = new Relationship("theType", "MOCK_MT123458CA.SubTypeA", Cardinality.Create("1"));
            Relationship otherRelationship2 = new Relationship("theSubType", "MOCK_MT123457CA.SubTypeB", Cardinality.Create("1"));
            Relationship otherRelationship3 = new Relationship("theSubSubType", "MOCK_MT123456CA.SubType", Cardinality.Create("1"));

            // first level
            @object = sorter.Get(otherRelationship1);
            Assert.IsNotNull(@object, "other exists");
            Assert.IsTrue(@object is RelationshipSorter, "other type");
            tempSorter = (RelationshipSorter)@object;
            // second level
            @object = tempSorter.Get(otherRelationship2);
            Assert.IsNotNull(@object, "other exists");
            Assert.IsTrue(@object is RelationshipSorter, "other type");
            tempSorter = (RelationshipSorter)@object;
            // third level
            @object = tempSorter.Get(otherRelationship3);
            Assert.IsNotNull(@object, "other type exists");
            Assert.IsTrue(@object is BeanProperty, "other type");
            AssertPropertyNamesEqual("other property name", "type", @object);
        }
示例#8
0
        private static void DescribeBeanPath(object bean, string xpath, StringBuilder result)
        {
            IList <string> pathParts = ObtainParts(xpath);

            RemovePartType(bean, pathParts);
            result.Append(bean.GetType().Name).Append('.');
            RelationshipSorter sorter = RelationshipSorter.Create(string.Empty, bean);

            foreach (string part in pathParts)
            {
                object sorterObj = sorter.Get(part);
                if (sorterObj is RelationshipSorter)
                {
                    sorter = (RelationshipSorter)sorterObj;
                }
                else
                {
                    if (sorterObj is BeanProperty)
                    {
                        BeanProperty beanProperty = (BeanProperty)sorterObj;
                        //				result.append(beanProperty.getPropertyType().getSimpleName()).append('.');  // BEAN PATH
                        result.Append(beanProperty.Name).Append('.');
                        // ACCESSOR PATH
                        sorter = RelationshipSorter.Create(string.Empty, beanProperty.Get());
                    }
                    else
                    {
                        // if can't find a mapping match then stop here
                        // just append letfover parts? i.e. a.b.c (.leftover1.leftover2)
                        break;
                    }
                }
            }
            if (result[result.Length - 1] == '.')
            {
                result.DeleteCharAt(result.Length - 1);
            }
        }