public override CswNbtViewEditorData GetStepData()
        {
            CswNbtViewEditorData Return = new CswNbtViewEditorData();

            _getFilters(Return, CurrentView);

            HashSet <string> seenRels = new HashSet <string>();

            CswNbtViewRoot.forEachRelationship eachRelationship = relationship =>
            {
                string label = _getRelationshipOwnerName(relationship);

                if (false == seenRels.Contains(label))
                {
                    seenRels.Add(label);
                    Return.Step4.Relationships.Add(relationship);
                }
            };
            CurrentView.Root.eachRelationship(eachRelationship, null);

            Return.Step4.ViewJson = CswConvert.ToString(CurrentView.ToJson());

            base.Finalize(Return);
            return(Return);
        }
        private void _getPropertyViewProps(CswNbtView TempView, CswNbtViewEditorData Return)
        {
            TempView.Visibility = CswEnumNbtViewVisibility.Property;
            CswNbtViewRelationship propRoot = null; //this is OK if it's null

            TempView = _CswNbtResources.ViewSelect.restoreView(CurrentView.ToString());
            propRoot = TempView.Root.ChildRelationships[0]; //grab the root level for property views
            propRoot.ChildRelationships.Clear();

            foreach (CswNbtViewRelationship related in getViewChildRelationshipOptions(CurrentView, propRoot.ArbitraryId))
            {
                if (related.SecondType.Equals(CswEnumNbtViewRelatedIdType.NodeTypeId))
                {
                    CswNbtMetaDataNodeType nt = _CswNbtResources.MetaData.getNodeType(related.SecondId);
                    if (null != nt)
                    {
                        _addNameTemplateProps(CurrentView, related, nt);
                    }
                }
                else
                {
                    CswNbtMetaDataObjectClass oc = _CswNbtResources.MetaData.getObjectClass(related.SecondId);
                    if (null != oc)
                    {
                        foreach (CswNbtMetaDataNodeType nt in oc.getNodeTypes())
                        {
                            _addNameTemplateProps(CurrentView, related, nt);
                        }
                    }
                }

                Return.Step2.Relationships.Add(related);
            }
        }
Ejemplo n.º 3
0
        public override CswNbtViewEditorData HandleAction()
        {
            ICswNbtMetaDataProp prop = null;

            if (Request.Property.Type.Equals(CswEnumNbtViewPropType.NodeTypePropId))
            {
                prop = _CswNbtResources.MetaData.getNodeTypeProp(Request.Property.NodeTypePropId);
            }
            else if (Request.Property.Type.Equals(CswEnumNbtViewPropType.ObjectClassPropId))
            {
                prop = _CswNbtResources.MetaData.getObjectClassProp(Request.Property.ObjectClassPropId);
            }

            if (Request.Action == "AddProp")
            {
                _addProp(prop);
            }
            else
            {
                _removeProp(prop);
            }

            CswNbtViewEditorData Return = new CswNbtViewEditorData();

            base.Finalize(Return);
            return(Return);
        }
        private void _addFilter(CswNbtViewEditorData Return)
        {
            CswNbtViewRelationship parent = (CswNbtViewRelationship)CurrentView.FindViewNodeByArbitraryId(Request.Property.ParentArbitraryId);

            CswNbtViewRoot.forEachRelationship eachRel = relationship =>
            {
                if (parent.SecondId == relationship.SecondId)
                {
                    CswNbtViewProperty viewProp = relationship.Properties.FirstOrDefault(vp => vp.Name == Request.Property.Name);
                    if (null != viewProp)
                    {
                        if (false == _hasFilter(viewProp))
                        {
                            CurrentView.AddViewPropertyFilter(viewProp,
                                                              Conjunction: (CswEnumNbtFilterConjunction)Request.FilterConjunction,
                                                              SubFieldName: (CswEnumNbtSubFieldName)Request.FilterSubfield,
                                                              FilterMode: (CswEnumNbtFilterMode)Request.FilterMode,
                                                              Value: Request.FilterValue);
                        }
                    }
                    else
                    {
                        ICswNbtMetaDataProp Prop = null;
                        if (Request.Property.Type.Equals(CswEnumNbtViewPropType.NodeTypePropId))
                        {
                            Prop = _CswNbtResources.MetaData.getNodeTypeProp(Request.Property.NodeTypePropId);
                        }
                        else if (Request.Property.Type.Equals(CswEnumNbtViewPropType.ObjectClassPropId))
                        {
                            Prop = _CswNbtResources.MetaData.getObjectClassProp(Request.Property.ObjectClassPropId);
                        }

                        CurrentView.AddViewPropertyAndFilter(relationship, Prop,
                                                             Value: Request.FilterValue,
                                                             Conjunction: Request.FilterConjunction,
                                                             SubFieldName: (CswEnumNbtSubFieldName)Request.FilterSubfield,
                                                             FilterMode: (CswEnumNbtFilterMode)Request.FilterMode,
                                                             ShowInGrid: false       // the user is filtering on a prop not in the grid, don't show it in the grid
                                                             );
                    }
                }
            };
            CurrentView.Root.eachRelationship(eachRel, null);

            _getFilters(Return, CurrentView);
            HashSet <string> seenRels = new HashSet <string>();

            CswNbtViewRoot.forEachRelationship eachRelationship = relationship =>
            {
                if (false == seenRels.Contains(relationship.TextLabel))
                {
                    seenRels.Add(relationship.TextLabel);
                    Return.Step4.Relationships.Add(relationship);
                }
            };
            CurrentView.Root.eachRelationship(eachRelationship, null);

            Return.Step4.ViewJson = CswConvert.ToString(CurrentView.ToJson());
        }
        public override CswNbtViewEditorData HandleAction()
        {
            _addRelationship();
            CswNbtViewEditorData Return = Request;

            base.Finalize(Return);
            return(Return);
        }
        public override CswNbtViewEditorData GetStepData()
        {
            CswNbtViewEditorData Return = new CswNbtViewEditorData();

            Return.Step4.ViewJson = CswConvert.ToString(CurrentView.ToJson());
            base.Finalize(Return);
            return(Return);
        }
Ejemplo n.º 7
0
        public override CswNbtViewEditorData GetStepData()
        {
            //This step just allows the user to edit View properties such as View Name, Category, Width, ect.
            //The client already has this information in the current view, if we get a request to get this step data, just return the view
            CswNbtViewEditorData Return = new CswNbtViewEditorData();

            base.Finalize(Return);
            return(Return);
        }
Ejemplo n.º 8
0
        protected CswNbtViewEditorRule(CswNbtResources CswNbtResources, CswNbtViewEditorData IncomingRequest)
        {
            _CswNbtResources = CswNbtResources;
            Request          = IncomingRequest;

            //Whenever we get a view from a Wcf service, all View Nodes are missing the View and Parent properties
            //  because those props can't be serialized without an infinite loop - this restores them
            if (null != Request.CurrentView)
            {
                Request.CurrentView.Root.SetViewRootView(Request.CurrentView);
                Request.CurrentView.SetResources(_CswNbtResources);
                _addViewNodeViews(Request.CurrentView);
                CurrentView = Request.CurrentView;
            }
        }
Ejemplo n.º 9
0
        public override CswNbtViewEditorData HandleAction()
        {
            CswNbtViewEditorData Return = new CswNbtViewEditorData();

            CurrentView.ViewName         = Request.NewViewName;
            CurrentView.Visibility       = (CswEnumNbtViewVisibility)Request.NewViewVisibility;
            CurrentView.VisibilityRoleId = CswConvert.ToPrimaryKey(Request.NewVisibilityRoleId);
            CurrentView.VisibilityUserId = CswConvert.ToPrimaryKey(Request.NewVisbilityUserId);
            CurrentView.Category         = Request.NewViewCategory;
            if (Int32.MinValue != Request.NewViewWidth)
            {
                CurrentView.Width = Request.NewViewWidth;
            }

            base.Finalize(Return);
            return(Return);
        }
        private void _getFilters(CswNbtViewEditorData Return, CswNbtView View)
        {
            HashSet <string> seenFilters = new HashSet <string>();

            CswNbtViewRoot.forEachProperty eachProp = property =>
            {
                foreach (CswNbtViewPropertyFilter filter in property.Filters)
                {
                    string parentName = _getRelationshipOwnerName((CswNbtViewRelationship)property.Parent);
                    string fullLabel  = parentName + " " + property.TextLabel + " " + filter.TextLabel;
                    if (false == seenFilters.Contains(fullLabel))
                    {
                        Return.Step4.Filters.Add(filter);
                        seenFilters.Add(fullLabel);
                    }
                }
            };
            View.Root.eachRelationship(null, eachProp);
        }
        private void _getViewProps(CswNbtView TempView, CswNbtViewEditorData Return)
        {
            foreach (CswNbtMetaDataNodeType NodeType in _CswNbtResources.MetaData.getNodeTypes()
                     .Where(nt => _CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.View, nt)))
            {
                CswNbtViewRelationship Relationship = TempView.AddViewRelationship(NodeType, true);
                //CswNbtViewNode foundNode = CurrentView.FindViewNodeByArbitraryId( Relationship.ArbitraryId );
                Return.Step2.Relationships.Add(Relationship);
                _addNameTemplateProps(TempView, Relationship, NodeType);
            }

            foreach (CswNbtMetaDataObjectClass ObjClass in _CswNbtResources.MetaData.getObjectClasses()
                     .Where(oc => false == oc.IsDesign() || _CswNbtResources.Permit.can(CswEnumNbtActionName.Design))                                                                      // case 31533
                     .OrderBy(ObjClass => ObjClass.ObjectClass.Value))
            {
                CswNbtViewRelationship Relationship = TempView.AddViewRelationship(ObjClass, true);
                //CswNbtViewNode foundNode = CurrentView.FindViewNodeByArbitraryId( Relationship.ArbitraryId );
                Return.Step2.Relationships.Add(Relationship);
                foreach (CswNbtMetaDataNodeType NodeType in ObjClass.getNodeTypes()
                         .Where(nt => _CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.View, nt)))
                {
                    _addNameTemplateProps(TempView, Relationship, NodeType);
                }
            }

            foreach (CswNbtMetaDataPropertySet PropSet in _CswNbtResources.MetaData.getPropertySets()
                     .OrderBy(PropSet => PropSet.Name))
            {
                CswNbtViewRelationship Relationship = TempView.AddViewRelationship(PropSet, true);
                //CswNbtViewNode foundNode = CurrentView.FindViewNodeByArbitraryId( Relationship.ArbitraryId );
                Return.Step2.Relationships.Add(Relationship);
                foreach (CswNbtMetaDataObjectClass ObjClass in PropSet.getObjectClasses()
                         .Where(oc => false == oc.IsDesign() || _CswNbtResources.Permit.can(CswEnumNbtActionName.Design)))                                                     // case 31533
                {
                    foreach (CswNbtMetaDataNodeType NodeType in ObjClass.getNodeTypes()
                             .Where(nt => _CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.View, nt)))
                    {
                        _addNameTemplateProps(TempView, Relationship, NodeType);
                    }
                }
            }
        }
        public override CswNbtViewEditorData HandleAction()
        {
            CswNbtViewEditorData Return = new CswNbtViewEditorData();

            if (Request.Action == "GetFilterProps")
            {
                _getFilterProps(Return);
            }
            else if (Request.Action == "AddFilter")
            {
                _addFilter(Return);
            }
            else
            {
                _removeFilter(Return);
            }

            base.Finalize(Return);
            return(Return);
        }
        public override CswNbtViewEditorData GetStepData()
        {
            CswNbtViewEditorData Return = new CswNbtViewEditorData();

            if (null == CurrentView)
            {
                CswNbtViewId selectedViewId = new CswNbtViewId();
                if (CswNbtSessionDataId.isSessionDataIdString(Request.ViewId))
                {
                    CswNbtSessionDataId sessionDataId = new CswNbtSessionDataId(Request.ViewId);
                    if (sessionDataId.isSet())
                    {
                        selectedViewId = _CswNbtResources.ViewSelect.getSessionView(sessionDataId).ViewId;
                    }
                }

                if (false == selectedViewId.isSet())
                {
                    selectedViewId = new CswNbtViewId(Request.ViewId);
                }

                CurrentView = _CswNbtResources.ViewSelect.restoreView(selectedViewId);
            }

            if (null != CurrentView)
            {
                CswNbtView TempView = new CswNbtView(_CswNbtResources);
                if (CurrentView.Visibility.Equals(CswEnumNbtViewVisibility.Property))
                {
                    _getPropertyViewProps(TempView, Return);
                }
                else
                {
                    _getViewProps(TempView, Return);
                }
            }

            base.Finalize(Return);
            return(Return);
        }
 public CswNbtViewEditorRuleFineTuning(CswNbtResources CswNbtResources, CswNbtViewEditorData IncomingRequest)
     : base(CswNbtResources, IncomingRequest)
 {
     RuleName = CswEnumNbtViewEditorRuleName.FineTuning;
 }
        public override CswNbtViewEditorData HandleAction()
        {
            CswNbtViewEditorData Return = new CswNbtViewEditorData();

            if (Request.Action == "Click")
            {
                CswNbtViewNode foundNode = Request.CurrentView.FindViewNodeByArbitraryId(Request.ArbitraryId);
                if (null != foundNode)
                {
                    CswNbtView TempView = _CswNbtResources.ViewSelect.restoreView(CurrentView.ToString());
                    if (foundNode is CswNbtViewPropertyFilter)
                    {
                        Return.Step6.FilterNode = (CswNbtViewPropertyFilter)foundNode;
                    }
                    else if (foundNode is CswNbtViewRelationship)
                    {
                        CswNbtViewRelationship asRelationship = (CswNbtViewRelationship)foundNode;

                        if (asRelationship.SecondType == CswEnumNbtViewRelatedIdType.NodeTypeId)
                        {
                            CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(asRelationship.SecondId);
                            foreach (CswNbtViewProperty prop in _getProps(NodeType, TempView, new HashSet <string>(), asRelationship))
                            {
                                if (((CswEnumNbtViewRenderingMode.Tree == Request.CurrentView.ViewMode || CswEnumNbtViewRenderingMode.List == Request.CurrentView.ViewMode) && CswEnumNbtFieldType.Button != prop.FieldType) ||
                                    CswEnumNbtViewRenderingMode.Grid == Request.CurrentView.ViewMode || CswEnumNbtViewRenderingMode.Table == Request.CurrentView.ViewMode)
                                {
                                    Return.Step6.Properties.Add(prop);
                                }
                            }
                        }
                        else if (asRelationship.SecondType == CswEnumNbtViewRelatedIdType.ObjectClassId)
                        {
                            CswNbtMetaDataObjectClass ObjClass = _CswNbtResources.MetaData.getObjectClass(asRelationship.SecondId);
                            foreach (CswNbtViewProperty prop in _getProps(ObjClass, TempView, new HashSet <string>(), asRelationship))
                            {
                                if (((CswEnumNbtViewRenderingMode.Tree == Request.CurrentView.ViewMode || CswEnumNbtViewRenderingMode.List == Request.CurrentView.ViewMode) && CswEnumNbtFieldType.Button != prop.FieldType) ||
                                    CswEnumNbtViewRenderingMode.Grid == Request.CurrentView.ViewMode || CswEnumNbtViewRenderingMode.Table == Request.CurrentView.ViewMode)
                                {
                                    Return.Step6.Properties.Add(prop);
                                }
                            }
                        }
                        else
                        {
                            CswNbtMetaDataPropertySet PropSet   = _CswNbtResources.MetaData.getPropertySet(asRelationship.SecondId);
                            HashSet <string>          seenProps = new HashSet <string>();
                            foreach (CswNbtMetaDataObjectClass ObjClass in PropSet.getObjectClasses())
                            {
                                foreach (CswNbtViewProperty prop in _getProps(ObjClass, TempView, seenProps, asRelationship).OrderBy(prop => prop.TextLabel))
                                {
                                    if (((CswEnumNbtViewRenderingMode.Tree == Request.CurrentView.ViewMode || CswEnumNbtViewRenderingMode.List == Request.CurrentView.ViewMode) && CswEnumNbtFieldType.Button != prop.FieldType) ||
                                        CswEnumNbtViewRenderingMode.Grid == Request.CurrentView.ViewMode || CswEnumNbtViewRenderingMode.Table == Request.CurrentView.ViewMode)
                                    {
                                        Return.Step6.Properties.Add(prop);
                                    }
                                }
                            }
                        }

                        Return.Step6.Relationships = getViewChildRelationshipOptions(CurrentView, asRelationship.ArbitraryId);

                        Return.Step6.RelationshipNode = asRelationship;
                    }
                    else if (foundNode is CswNbtViewRoot && CurrentView.Visibility != CswEnumNbtViewVisibility.Property)  //can't add to view root on Prop view
                    {
                        TempView.Root.ChildRelationships.Clear();
                        foreach (CswNbtMetaDataNodeType NodeType in _CswNbtResources.MetaData.getNodeTypes().OrderBy(NT => NT.NodeTypeName))
                        {
                            Return.Step6.Relationships.Add(TempView.AddViewRelationship(NodeType, false));
                        }
                        foreach (CswNbtMetaDataObjectClass ObjClass in _CswNbtResources.MetaData.getObjectClasses().OrderBy(OC => OC.ObjectClass.Value))
                        {
                            Return.Step6.Relationships.Add(TempView.AddViewRelationship(ObjClass, false));
                        }
                        foreach (CswNbtMetaDataPropertySet PropSet in _CswNbtResources.MetaData.getPropertySets().OrderBy(PS => PS.Name))
                        {
                            Return.Step6.Relationships.Add(TempView.AddViewRelationship(PropSet, false));
                        }
                        Return.Step6.RootNode = (CswNbtViewRoot)foundNode;
                    }
                    else if (foundNode is CswNbtViewProperty && CswEnumNbtFieldType.Button != ((CswNbtViewProperty)foundNode).FieldType)
                    {
                        Return.Step6.PropertyNode = (CswNbtViewProperty)foundNode;
                        Request.Relationship      = (CswNbtViewRelationship)foundNode.Parent; //getFilterProps needs Request.Relationship to be populated
                        _getFilterProps(Return);
                    }
                }
            }
            else if (Request.Action == "AddProp")
            {
                ICswNbtMetaDataProp prop = null;
                if (Request.Property.Type == CswEnumNbtViewPropType.NodeTypePropId)
                {
                    prop = _CswNbtResources.MetaData.getNodeTypeProp(Request.Property.NodeTypePropId);
                }
                else
                {
                    prop = _CswNbtResources.MetaData.getObjectClassProp(Request.Property.ObjectClassPropId);
                }
                CswNbtViewRelationship relToAddTo = (CswNbtViewRelationship)CurrentView.FindViewNodeByArbitraryId(Request.Relationship.ArbitraryId);
                CurrentView.AddViewProperty(relToAddTo, prop, CurrentView.getOrderedViewProps(false).Count + 1);
            }
            else if (Request.Action == "AddRelationship")
            {
                CswNbtViewRelationship relToAddTo = (CswNbtViewRelationship)CurrentView.FindViewNodeByArbitraryId(Request.ArbitraryId);
                ICswNbtMetaDataProp    prop       = null;
                if (Request.Relationship.PropType == CswEnumNbtViewPropIdType.NodeTypePropId)
                {
                    prop = _CswNbtResources.MetaData.getNodeTypeProp(Request.Relationship.PropId);
                }
                else
                {
                    prop = _CswNbtResources.MetaData.getObjectClassProp(Request.Relationship.PropId);
                }
                CurrentView.AddViewRelationship(relToAddTo, Request.Relationship.PropOwner, prop, true);
            }
            else if (Request.Action == "AddFilter")
            {
                CswNbtViewProperty propNode = (CswNbtViewProperty)CurrentView.FindViewNodeByArbitraryId(Request.PropArbId);
                if (false == _hasFilter(propNode))
                {
                    CurrentView.AddViewPropertyFilter(propNode,
                                                      Conjunction: (CswEnumNbtFilterConjunction)Request.FilterConjunction,
                                                      SubFieldName: (CswEnumNbtSubFieldName)Request.FilterSubfield,
                                                      FilterMode: (CswEnumNbtFilterMode)Request.FilterMode,
                                                      Value: Request.FilterValue
                                                      );
                }
                Return.Step6.PropertyNode = propNode;
            }
            else if (Request.Action == "RemoveNode")
            {
                CswNbtViewNode nodeToRemove = CurrentView.FindViewNodeByArbitraryId(Request.ArbitraryId);
                CswNbtViewNode parent       = nodeToRemove.Parent;
                parent.RemoveChild(nodeToRemove);

                if (parent.ViewNodeType == CswEnumNbtViewNodeType.CswNbtViewProperty)
                {
                    Return.Step6.PropertyNode = (CswNbtViewProperty)parent;
                }
                else if (parent.ViewNodeType == CswEnumNbtViewNodeType.CswNbtViewRelationship)
                {
                    Return.Step6.RelationshipNode = (CswNbtViewRelationship)parent;
                }
                else if (parent.ViewNodeType == CswEnumNbtViewNodeType.CswNbtViewRoot)
                {
                    Return.Step6.RootNode = (CswNbtViewRoot)parent;
                }
            }
            else if (Request.Action == "UpdateView")
            {
                string grp = string.Empty;
                if (null != Request.Property)
                {
                    CswNbtViewRelationship selectedPropsParent = (CswNbtViewRelationship)CurrentView.FindViewNodeByArbitraryId(Request.Property.ParentArbitraryId);
                    Request.Property.Parent = selectedPropsParent;
                    CswNbtViewProperty rel = (CswNbtViewProperty)CurrentView.FindViewNodeByArbitraryId(Request.Property.ArbitraryId);
                    if (null == rel)
                    {
                        CswNbtViewRelationship parent = (CswNbtViewRelationship)CurrentView.FindViewNodeByArbitraryId(Request.Property.ParentArbitraryId);
                        ICswNbtMetaDataProp    prop   = null;
                        if (Request.Property.Type == CswEnumNbtViewPropType.NodeTypePropId)
                        {
                            prop = _CswNbtResources.MetaData.getNodeTypeProp(Request.Property.NodeTypePropId);
                        }
                        else
                        {
                            prop = _CswNbtResources.MetaData.getObjectClassProp(Request.Property.ObjectClassPropId);
                        }
                        rel = CurrentView.AddViewProperty(parent, prop);
                    }
                    grp = rel.TextLabel;
                }

                CurrentView.GridGroupByCol = grp;
            }

            base.Finalize(Return);
            return(Return);
        }
Ejemplo n.º 16
0
 public CswNbtViewEditorRuleViewAttributes(CswNbtResources CswNbtResources, CswNbtViewEditorData IncomingRequest)
     : base(CswNbtResources, IncomingRequest)
 {
     RuleName = CswEnumNbtViewEditorRuleName.ViewAttributes;
 }
Ejemplo n.º 17
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();
        }
        private void _removeFilter(CswNbtViewEditorData Return)
        {
            Dictionary <string, CswNbtViewPropertyFilter> filtersToRemove = new Dictionary <string, CswNbtViewPropertyFilter>();
            Collection <ICswNbtMetaDataProp> propsToRemove = new Collection <ICswNbtMetaDataProp>();

            CswNbtViewRoot.forEachProperty eachProperty = prop =>
            {
                foreach (CswNbtViewPropertyFilter filter in prop.Filters)
                {
                    if (filter.TextLabel == Request.FilterToRemove.TextLabel)
                    {
                        if (prop.ShowInGrid || prop.Filters.Count > 1)  //if ShowInGrid == true, just remove the filter
                        {
                            filtersToRemove.Add(prop.UniqueId, filter);
                        }
                        else //otherwise, remove the property as well
                        {
                            ICswNbtMetaDataProp propToRemove;
                            if (prop.Type.Equals(CswEnumNbtViewPropType.ObjectClassPropId))
                            {
                                propToRemove = _CswNbtResources.MetaData.getObjectClassProp(prop.ObjectClassPropId);
                            }
                            else
                            {
                                propToRemove = _CswNbtResources.MetaData.getNodeTypeProp(prop.NodeTypePropId);
                            }

                            if (null != propToRemove)
                            {
                                propsToRemove.Add(propToRemove);
                            }
                        }
                    }
                }
            };
            CurrentView.Root.eachRelationship(null, eachProperty);

            foreach (var propAndFilter in filtersToRemove)
            {
                CswNbtViewProperty prop = (CswNbtViewProperty)CurrentView.FindViewNodeByUniqueId(propAndFilter.Key);
                prop.removeFilter(propAndFilter.Value);
            }
            foreach (ICswNbtMetaDataProp propToRemove in propsToRemove)
            {
                CurrentView.removeViewProperty(propToRemove);
            }

            _getFilters(Return, CurrentView);

            HashSet <string> seenRels = new HashSet <string>();

            CswNbtViewRoot.forEachRelationship eachRelationship = relationship =>
            {
                if (false == seenRels.Contains(relationship.TextLabel))
                {
                    seenRels.Add(relationship.TextLabel);
                    Return.Step4.Relationships.Add(relationship);
                }
            };
            CurrentView.Root.eachRelationship(eachRelationship, null);

            Return.Step4.ViewJson = CswConvert.ToString(CurrentView.ToJson());
        }
 public CswNbtViewEditorRuleSetFilters(CswNbtResources CswNbtResources, CswNbtViewEditorData IncomingRequest)
     : base(CswNbtResources, IncomingRequest)
 {
     RuleName = CswEnumNbtViewEditorRuleName.SetFilters;
 }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
0
 public CswNbtViewEditorRuleAddViewLevels(CswNbtResources CswNbtResources, CswNbtViewEditorData IncomingRequest)
     : base(CswNbtResources, IncomingRequest)
 {
     RuleName = CswEnumNbtViewEditorRuleName.AddViewLevels;
 }
Ejemplo n.º 22
0
 public virtual void Finalize(CswNbtViewEditorData Return)
 {
     Return.CurrentView = CurrentView;
 }
        public static CswNbtViewEditorRule Make(CswNbtResources CswNbtResources, string RuleName, CswNbtViewEditorData Request)
        {
            CswNbtViewEditorRule Ret = null;

            if (RuleName.Equals(CswEnumNbtViewEditorRuleName.FirstViewLevel._Name))
            {
                Ret = new CswNbtViewEditorRuleFirstViewLevel(CswNbtResources, Request);
            }
            else if (RuleName.Equals(CswEnumNbtViewEditorRuleName.AddViewLevels._Name))
            {
                Ret = new CswNbtViewEditorRuleAddViewLevels(CswNbtResources, Request);
            }
            else if (RuleName.Equals(CswEnumNbtViewEditorRuleName.SetFilters._Name))
            {
                Ret = new CswNbtViewEditorRuleSetFilters(CswNbtResources, Request);
            }
            else if (RuleName.Equals(CswEnumNbtViewEditorRuleName.ViewAttributes._Name))
            {
                Ret = new CswNbtViewEditorRuleViewAttributes(CswNbtResources, Request);
            }
            else if (RuleName.Equals(CswEnumNbtViewEditorRuleName.FineTuning._Name))
            {
                Ret = new CswNbtViewEditorRuleFineTuning(CswNbtResources, Request);
            }
            else
            {
                throw new CswDniException(CswEnumErrorType.Warning, "Cannot interpret the supplied View Editor rule name.", "An invalid rule name: " + RuleName + " was passed to CswNbtViewRuleFactory");
            }

            return(Ret);
        }
 public static CswNbtViewEditorRule Make(CswNbtResources CswNbtResources, CswEnumNbtViewEditorRuleName RuleName, CswNbtViewEditorData Request)
 {
     return(Make(CswNbtResources, RuleName._Name, Request));
 }
 public CswNbtViewEditorRuleFirstViewLevel(CswNbtResources CswNbtResources, CswNbtViewEditorData IncomingRequest)
     : base(CswNbtResources, IncomingRequest)
 {
     RuleName = CswEnumNbtViewEditorRuleName.FirstViewLevel;
 }