Пример #1
0
        /// <summary>
        /// Creates a CswNbtViewPropertyFilter and returns its Json
        /// </summary>
        public JObject makeViewPropFilter(CswNbtView View, JObject FilterProp, bool ClearFilters = false)
        {
            JObject Ret = new JObject();

            string FiltArbitraryId = CswConvert.ToString(FilterProp["filtarbitraryid"]);
            string PropArbitraryId = CswConvert.ToString(FilterProp["proparbitraryid"]);

            if (FiltArbitraryId == "undefined")
            {
                FiltArbitraryId = string.Empty;
            }
            if (PropArbitraryId == "undefined")
            {
                PropArbitraryId = string.Empty;
            }

            CswNbtViewPropertyFilter ViewPropFilt = null;

            if (false == string.IsNullOrEmpty(PropArbitraryId))
            {
                CswNbtViewProperty ViewProp = (CswNbtViewProperty)View.FindViewNodeByArbitraryId(PropArbitraryId);

                if (false == string.IsNullOrEmpty(FiltArbitraryId))
                {
                    ViewPropFilt = (CswNbtViewPropertyFilter)View.FindViewNodeByArbitraryId(FiltArbitraryId);
                }
                else
                {
                    ViewPropFilt = View.AddViewPropertyFilter(ViewProp, CswEnumNbtSubFieldName.Unknown, CswEnumNbtFilterMode.Unknown, string.Empty, false);
                }

                //Case 23779, 23937, 24064
                if (ClearFilters && null != ViewPropFilt)
                {
                    ViewProp.Filters.Clear();
                    ViewProp.Filters.Add(ViewPropFilt);
                }
            }

            if (ViewPropFilt != null)
            {
                CswEnumNbtFilterConjunction Conjunction = (CswEnumNbtFilterConjunction)CswConvert.ToString(FilterProp["conjunction"]);
                CswEnumNbtSubFieldName      FieldName   = (CswEnumNbtSubFieldName)CswConvert.ToString(FilterProp["subfieldname"]);
                CswEnumNbtFilterMode        FilterMode  = (CswEnumNbtFilterMode)CswConvert.ToString(FilterProp["filter"]);
                string FilterValue = CswConvert.ToString(FilterProp["filtervalue"]);

                if (FieldName != CswEnumNbtSubFieldName.Unknown &&
                    FilterMode != CswEnumNbtFilterMode.Unknown)
                {
                    ViewPropFilt.FilterMode   = FilterMode;
                    ViewPropFilt.Conjunction  = Conjunction;
                    ViewPropFilt.SubfieldName = FieldName;
                    ViewPropFilt.Value        = FilterValue;
                    _addVbPropFilter(Ret, ViewPropFilt);
                }
            }
            return(Ret);
        }
Пример #2
0
        public JObject getVbProp(CswNbtView View, string ViewPropArbitraryId)
        {
            JObject Ret = new JObject();

            if (false == string.IsNullOrEmpty(ViewPropArbitraryId))
            {
                CswNbtViewProperty ThisProp = (CswNbtViewProperty)View.FindViewNodeByArbitraryId(ViewPropArbitraryId);
                if (null != ThisProp)
                {
                    CswViewBuilderProp VbProp = new CswViewBuilderProp(ThisProp);
                    Ret = getVbProp(View, VbProp);
                }
            }
            return(Ret);
        }
        private CswNbtViewRelationship _addPropViewRelationshiop(CswNbtView View, CswNbtViewRelationship Relationship)
        {
            ICswNbtMetaDataProp prop = null;

            if (Relationship.PropType == CswEnumNbtViewPropIdType.NodeTypePropId)
            {
                prop = _CswNbtResources.MetaData.getNodeTypeProp(Relationship.PropId);
            }
            else
            {
                prop = _CswNbtResources.MetaData.getObjectClassProp(Relationship.PropId);
            }
            CswNbtViewRelationship parentRel = (CswNbtViewRelationship)View.FindViewNodeByArbitraryId(Relationship.ParentArbitraryId);
            CswNbtViewRelationship parent    = View.AddViewRelationship(parentRel, Relationship.PropOwner, prop, true);

            return(parent);
        }
Пример #4
0
        public override CswNbtViewEditorData GetStepData()
        {
            CswNbtViewEditorData Return = new CswNbtViewEditorData();

            Return.Step3 = new CswNbtViewEditorStep3();

            string     ViewStr  = CurrentView.ToString();
            CswNbtView TempView = _CswNbtResources.ViewSelect.restoreView(ViewStr);

            HashSet <string> seenProps = new HashSet <string>();
            Collection <CswNbtViewProperty> relatedProps = new Collection <CswNbtViewProperty>();

            if (CurrentView.ViewMode.Equals(CswEnumNbtViewRenderingMode.Grid) || CurrentView.ViewMode.Equals(CswEnumNbtViewRenderingMode.Table))
            {
                CswNbtViewRoot.forEachRelationship forEachRelationship = relationship =>
                {
                    //For property views, we ignore the top lvl relationship
                    if ((false == (relationship.Parent is CswNbtViewRoot) && CurrentView.Visibility == CswEnumNbtViewVisibility.Property) ||
                        CurrentView.Visibility != CswEnumNbtViewVisibility.Property)
                    {
                        foreach (CswNbtViewProperty ExistingViewProp in relationship.Properties)
                        {
                            if (false == seenProps.Contains(ExistingViewProp.TextLabel))
                            {
                                seenProps.Add(ExistingViewProp.TextLabel);
                                Return.Step3.Properties.Add(ExistingViewProp);
                            }
                        }

                        _populatePropsCollection(relationship, TempView, Return.Step3.Properties, seenProps);

                        //Get all props related to this relationship
                        if (CurrentView.ViewMode == CswEnumNbtViewRenderingMode.Grid)
                        {
                            Collection <CswNbtViewRelationship> rels = getViewChildRelationshipOptions(TempView, relationship.ArbitraryId);
                            foreach (CswNbtViewRelationship relatedRelationship in rels)
                            {
                                if (false == seenProps.Contains(relatedRelationship.TextLabel))
                                {
                                    relatedRelationship.Parent = relationship;
                                    Return.Step3.SecondRelationships.Add(relatedRelationship);
                                    _populatePropsCollection(relatedRelationship, TempView, relatedProps, seenProps, true, true, false);
                                    relatedRelationship.Properties = new Collection <CswNbtViewProperty>(); //otherwise this has every prop
                                    seenProps.Add(relatedRelationship.TextLabel);
                                }
                            }
                        }
                    }
                };
                TempView.Root.eachRelationship(forEachRelationship, null);

                HashSet <string> seenRelated = new HashSet <string>();
                foreach (CswNbtViewProperty vp in relatedProps)
                {
                    if (false == seenRelated.Contains(vp.TextLabel))
                    {
                        seenRelated.Add(vp.TextLabel);
                        Return.Step3.Properties.Add(vp);
                    }
                }
            }
            else if (CurrentView.ViewMode.Equals(CswEnumNbtViewRenderingMode.Tree))
            {
                CswNbtViewRoot.forEachRelationship forEachRelationship = relationship =>
                {
                    foreach (CswNbtViewRelationship related in getViewChildRelationshipOptions(CurrentView, relationship.ArbitraryId))
                    {
                        ICswNbtMetaDataProp prop;
                        if (related.PropType.Equals(CswEnumNbtViewPropIdType.ObjectClassPropId))
                        {
                            prop = _CswNbtResources.MetaData.getObjectClassProp(related.PropId);
                        }
                        else
                        {
                            prop = _CswNbtResources.MetaData.getNodeTypeProp(related.PropId);
                        }

                        CswNbtViewRelationship tempRel = (CswNbtViewRelationship)TempView.FindViewNodeByArbitraryId(relationship.ArbitraryId);
                        Return.Step3.SecondRelationships.Add(TempView.AddViewRelationship(tempRel, related.PropOwner, prop, true));
                    }
                };
                CurrentView.Root.eachRelationship(forEachRelationship, null);
            }

            base.Finalize(Return);
            return(Return);
        }
Пример #5
0
        public Collection <CswNbtViewRelationship> getViewChildRelationshipOptions(CswNbtView View, string ArbitraryId)
        {
            Collection <CswNbtViewRelationship> ret = new Collection <CswNbtViewRelationship>();

            if (View.ViewId != null)
            {
                CswNbtViewNode SelectedViewNode = View.FindViewNodeByArbitraryId(ArbitraryId);
                if (View.ViewMode != CswEnumNbtViewRenderingMode.Unknown || View.Root.ChildRelationships.Count == 0)
                {
                    if (SelectedViewNode is CswNbtViewRelationship)
                    {
                        CswNbtViewRelationship CurrentRelationship = (CswNbtViewRelationship)SelectedViewNode;
                        Int32          CurrentLevel = 0;
                        CswNbtViewNode Parent       = CurrentRelationship;
                        while (!(Parent is CswNbtViewRoot))
                        {
                            CurrentLevel++;
                            Parent = Parent.Parent;
                        }

                        // Child options are all relations to this nodetype
                        Int32 CurrentId = CurrentRelationship.SecondId;

                        Collection <CswNbtViewRelationship> Relationships = null;
                        if (CurrentRelationship.SecondType == CswEnumNbtViewRelatedIdType.PropertySetId)
                        {
                            Relationships = getPropertySetRelated(CurrentId, View, CurrentLevel);
                        }
                        else if (CurrentRelationship.SecondType == CswEnumNbtViewRelatedIdType.ObjectClassId)
                        {
                            Relationships = getObjectClassRelated(CurrentId, View, CurrentLevel);
                        }
                        else if (CurrentRelationship.SecondType == CswEnumNbtViewRelatedIdType.NodeTypeId)
                        {
                            Relationships = getNodeTypeRelated(CurrentId, View, CurrentLevel);
                        }

                        foreach (CswNbtViewRelationship R in from CswNbtViewRelationship _R in Relationships orderby _R.SecondName select _R)
                        {
                            R.Parent = CurrentRelationship;

                            string Label = String.Empty;
                            if (R.PropOwner == CswEnumNbtViewPropOwnerType.First)
                            {
                                Label = R.SecondName + " (by " + R.PropName + ")";
                            }
                            else if (R.PropOwner == CswEnumNbtViewPropOwnerType.Second)
                            {
                                Label = R.SecondName + " (by " + R.SecondName + "'s " + R.PropName + ")";
                            }
                            R.TextLabel = Label;

                            bool contains = ret.Any(existingRel => existingRel.TextLabel == R.TextLabel);    //no dupes
                            if (false == contains)
                            {
                                ret.Add(R);
                            }
                        } // foreach( CswNbtViewRelationship R in Relationships )
                    }
                }
            }
            return(ret);
        } // getViewChildOptions()
Пример #6
0
        protected void _getFilterProps(CswNbtViewEditorData Return)
        {
            string     viewStr  = CurrentView.ToString();
            CswNbtView TempView = new CswNbtView(_CswNbtResources);

            TempView.LoadXml(viewStr);
            HashSet <string> seenProps = new HashSet <string>();

            CswNbtViewRelationship Relationship = (CswNbtViewRelationship)TempView.FindViewNodeByArbitraryId(Request.Relationship.ArbitraryId);

            if (null != Relationship)
            {
                foreach (CswNbtViewProperty viewProp in Relationship.Properties.Where(p => CswEnumNbtFieldType.Button != p.FieldType))
                {
                    seenProps.Add(viewProp.TextLabel);
                    Return.Step4.Properties.Add(viewProp);
                }

                if (Relationship.SecondType.Equals(CswEnumNbtViewRelatedIdType.PropertySetId))
                {
                    CswNbtMetaDataPropertySet PropSet = _CswNbtResources.MetaData.getPropertySet(Relationship.SecondId);
                    if (null != PropSet)
                    {
                        foreach (CswNbtMetaDataObjectClass ObjClass in PropSet.getObjectClasses())
                        {
                            IEnumerable <CswNbtViewProperty> props = _getProps(ObjClass, TempView, seenProps, Relationship).Where(p => CswEnumNbtFieldType.Button != p.FieldType);;
                            foreach (CswNbtViewProperty vp in props)
                            {
                                Return.Step4.Properties.Add(vp);
                            }
                        }
                    }
                }
                else if (Relationship.SecondType.Equals(CswEnumNbtViewRelatedIdType.ObjectClassId))
                {
                    CswNbtMetaDataObjectClass ObjClass = _CswNbtResources.MetaData.getObjectClass(Relationship.SecondId);
                    if (null != ObjClass)
                    {
                        IEnumerable <CswNbtViewProperty> props = _getProps(ObjClass, TempView, seenProps, Relationship).Where(p => CswEnumNbtFieldType.Button != p.FieldType);;
                        foreach (CswNbtViewProperty vp in props)
                        {
                            Return.Step4.Properties.Add(vp);
                        }
                    }
                }
                else if (Relationship.SecondType.Equals(CswEnumNbtViewRelatedIdType.NodeTypeId))
                {
                    CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(Relationship.SecondId);
                    if (null != NodeType)
                    {
                        IEnumerable <CswNbtViewProperty> props = _getProps(NodeType, TempView, seenProps, Relationship).Where(p => CswEnumNbtFieldType.Button != p.FieldType);
                        foreach (CswNbtViewProperty vp in props)
                        {
                            Return.Step4.Properties.Add(vp);
                        }
                    }
                }
            }

            Collection <CswNbtViewProperty> sortedProps = new Collection <CswNbtViewProperty>();

            foreach (CswNbtViewProperty prop in Return.Step4.Properties.OrderBy(vp => vp.TextLabel))
            {
                sortedProps.Add(prop);
            }
            Return.Step4.Properties = sortedProps;
            Return.Step4.ViewJson   = TempView.ToJson().ToString();
        }