コード例 #1
0
        /// <summary>
        /// Get table from a universal search.
        /// </summary>
        /// <param name="View"></param>
        /// <returns></returns>
        public JObject getTable( CswNbtView View )
        {
            _View = View;
            JObject ret = new JObject();

            if( _View != null )
            {
                // Find current max order set in view
                Int32 maxOrder = ( from ViewRel in _View.Root.ChildRelationships
                                   from ViewProp in ViewRel.Properties
                                   select ViewProp.Order ).Concat( new[] { 0 } ).Max();  // thanks Resharper!

                // Set default order for properties in the view without one
                foreach( CswNbtViewProperty ViewProp in from ViewRel in _View.Root.ChildRelationships
                                                        from ViewProp in ViewRel.Properties
                                                        where Int32.MinValue == ViewProp.Order
                                                        select ViewProp )
                {
                    ViewProp.Order = maxOrder + 1;
                    maxOrder++;
                }

                // Add 'default' Table layout elements for the nodetype to the view for efficiency
                // Set the order to be after properties in the view
                foreach( CswNbtViewRelationship ViewRel in _View.Root.ChildRelationships )
                {
                    if( ViewRel.SecondType == CswEnumNbtViewRelatedIdType.NodeTypeId )
                    {
                        IEnumerable<CswNbtMetaDataNodeTypeProp> Props = _CswNbtResources.MetaData.NodeTypeLayout.getPropsInLayout( ViewRel.SecondId, Int32.MinValue, CswEnumNbtLayoutType.Table );
                        foreach( CswNbtMetaDataNodeTypeProp NTProp in Props )
                        {
                            bool AlreadyExists = false;
                            foreach( CswNbtViewProperty ViewProp in ViewRel.Properties )
                            {
                                if( ViewProp.NodeTypePropId == NTProp.PropId )
                                {
                                    AlreadyExists = true;
                                }
                            }

                            if( false == AlreadyExists )
                            {
                                CswNbtViewProperty NewViewProp = _View.AddViewProperty( ViewRel, NTProp );
                                CswNbtMetaDataNodeTypeLayoutMgr.NodeTypeLayout propTableLayout = NTProp.getTableLayout();
                                NewViewProp.Order = maxOrder + propTableLayout.DisplayRow;
                            }
                        } // foreach( CswNbtMetaDataNodeTypeProp NTProp in Props )
                    } // if( ViewRel.SecondType == RelatedIdType.NodeTypeId )
                } // foreach( CswNbtViewRelationship ViewRel in View.Root.ChildRelationships )

                ICswNbtTree Tree = _CswNbtResources.Trees.getTreeFromView( _View, true, false, false );
                ret = makeTableFromTree( Tree, null );
            } // if( _View != null )
            return ret;
        } // getTable()
コード例 #2
0
        } // getPropOrder()

        /// <summary>
        /// Returns the order in which properties should appear in the table
        /// </summary>
        public SortedSet <SearchOrder> getPropOrderDict(CswNbtNodeKey NodeKey, CswNbtView View = null)
        {
            SortedSet <SearchOrder> ret      = null;
            CswNbtMetaDataNodeType  NodeType = _CswNbtResources.MetaData.getNodeType(NodeKey.NodeTypeId);

            if (null != NodeType)
            {
                if (false == _PropOrderDict.ContainsKey(NodeType))
                {
                    ret = new SortedSet <SearchOrder>();

                    // View order goes first
                    if (View != null)
                    {
                        CswNbtViewRelationship ViewRel = (CswNbtViewRelationship)View.FindViewNodeByUniqueId(NodeKey.ViewNodeUniqueId);
                        if (ViewRel != null)
                        {
                            foreach (CswNbtViewProperty ViewProp in ViewRel.Properties)
                            {
                                SearchOrder ThisOrder = new SearchOrder
                                {
                                    NodeTypePropId    = ViewProp.NodeTypePropId,
                                    ObjectClassPropId = ViewProp.ObjectClassPropId,
                                    Source            = CswEnumNbtSearchPropOrderSourceType.View,
                                    Order             = 0
                                };


                                foreach (CswNbtViewProperty OtherViewProp in ViewRel.Properties)
                                {
                                    if ((OtherViewProp.Order != Int32.MinValue && OtherViewProp.Order < ViewProp.Order) ||
                                        ViewProp.Order == Int32.MinValue)
                                    {
                                        ThisOrder.Order += 1;
                                    }
                                }
                                ret.Add(ThisOrder);
                            } // foreach( CswNbtViewProperty ViewProp in ViewRel.Properties )
                        }     // if( ViewRel != null )
                    }         // if( _View != null )


                    // Table layout goes second
                    Int32 maxOrder = (ret.Count > 0) ? ret.Max().Order : 0;
                    if (false == _TableLayoutDict.Keys.Contains(NodeType))
                    {
                        _TableLayoutDict[NodeType] = _CswNbtResources.MetaData.NodeTypeLayout.getPropsInLayout(NodeType.NodeTypeId, Int32.MinValue, CswEnumNbtLayoutType.Table);
                    }
                    foreach (CswNbtMetaDataNodeTypeProp Prop in _TableLayoutDict[NodeType])
                    {
                        SearchOrder ThisOrder = new SearchOrder
                        {
                            NodeTypePropId    = Prop.PropId,
                            ObjectClassPropId = Prop.ObjectClassPropId,
                            Source            = CswEnumNbtSearchPropOrderSourceType.Table,
                        };
                        if (false == ret.Contains(ThisOrder))
                        {
                            CswNbtMetaDataNodeTypeLayoutMgr.NodeTypeLayout propTableLayout = Prop.getTableLayout();
                            if (propTableLayout.DisplayRow > 0)
                            {
                                ThisOrder.Order = maxOrder + propTableLayout.DisplayRow;
                                ret.Add(ThisOrder);
                            }
                        }
                    } // foreach( CswNbtMetaDataNodeTypeProp Prop in _TableLayoutDict[thisNode.NodeType] )


                    // Everything else in alphabetical order
                    maxOrder = (ret.Count > 0) ? ret.Max().Order : 0;
                    foreach (CswNbtMetaDataNodeTypeProp Prop in NodeType.getNodeTypeProps()
                             .OrderBy(Prop => Prop.PropName))
                    {
                        SearchOrder ThisOrder = new SearchOrder
                        {
                            NodeTypePropId    = Prop.PropId,
                            ObjectClassPropId = Prop.ObjectClassPropId,
                            Source            = CswEnumNbtSearchPropOrderSourceType.Results,
                        };
                        if (false == ret.Contains(ThisOrder))
                        {
                            maxOrder++;
                            ThisOrder.Order = maxOrder;
                            ret.Add(ThisOrder);
                        }
                    }
                    _PropOrderDict.Add(NodeType, ret);
                } // if( false == _PropOrderDict.ContainsKey( thisNode.NodeType ) )

                ret = _PropOrderDict[NodeType];
            } // if(null != NodeType)
            return(ret);
        }     //getPropOrderDict()