Ejemplo n.º 1
0
        } // InitActionPermissionOptions()

        private void _deleteRelatedPermissionNodes()
        {
            CswNbtView PermissionsView = new CswNbtView( _CswNbtResources );
            CswNbtMetaDataPropertySet PermissionPS = _CswNbtResources.MetaData.getPropertySet( CswEnumNbtPropertySetName.PermissionSet );
            CswNbtViewRelationship RootVR = PermissionsView.AddViewRelationship( PermissionPS, false );
            CswNbtViewPropertyFilter Filter = null;
            foreach( CswNbtMetaDataObjectClass PermOC in PermissionPS.getObjectClasses() )
            {
                if( Filter == null )
                {
                    CswNbtMetaDataNodeType PermNT = PermOC.FirstNodeType;
                    if( null != PermNT )
                    {
                        CswNbtMetaDataNodeTypeProp RoleOCP = PermNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetPermission.PropertyName.Role );
                        Filter = PermissionsView.AddViewPropertyAndFilter( RootVR,
                                                                           MetaDataProp: RoleOCP,
                                                                           Value: NodeId.PrimaryKey.ToString(),
                                                                           SubFieldName: CswEnumNbtSubFieldName.NodeID,
                                                                           FilterMode: CswEnumNbtFilterMode.Equals );
                    }
                }
                else
                {
                    break;
                }
            }
            ICswNbtTree PermissionsTree = _CswNbtResources.Trees.getTreeFromView( PermissionsView, false, true, true );
            for( int i = 0; i < PermissionsTree.getChildNodeCount(); i++ )
            {
                PermissionsTree.goToNthChild( i );
                CswNbtNode PermissionNode = PermissionsTree.getNodeForCurrentPosition();
                PermissionNode.delete();
                PermissionsTree.goToRoot();
            }
        }
Ejemplo n.º 2
0
        public void beforeDeleteNode(bool DeleteAllRequiredRelatedNodes, bool ValidateRequiredRelationships)
        {
            beforeDeleteNodeLogic();
            if (ValidateRequiredRelationships)
            {
                // case 22486 - Don't allow deleting targets of required relationships
                CswTableSelect JctSelect = _CswNbtResources.makeCswTableSelect("defaultBeforeDeleteNode_jnp_select", "jct_nodes_props");
                // Case CIS-52536 - Delete validation should ignore temp nodes
                string WhereClause = @"np 
                                        WHERE  nodetypepropid IN (SELECT nodetypepropid 
                                                                  FROM   nodetype_props 
                                                                  WHERE  isrequired = '1') 
                                               AND field1_fk = " + _CswNbtNode.NodeId.PrimaryKey.ToString() + @" 
                                               AND (SELECT istemp 
                                                    FROM   nodes n 
                                                    WHERE  n.nodeid = np.nodeid) <> '1' ";
                CswCommaDelimitedString SelectClause = new CswCommaDelimitedString()
                {
                    "nodeid"
                };
                DataTable MatchTable = JctSelect.getTable(SelectClause, WhereClause);

                if (MatchTable.Rows.Count > 0)
                {
                    CswCommaDelimitedString InUseStr = new CswCommaDelimitedString();
                    foreach (DataRow MatchRow in MatchTable.Rows)
                    {
                        CswPrimaryKey MatchNodePk = new CswPrimaryKey("nodes", CswConvert.ToInt32(MatchRow["nodeid"]));
                        if (DeleteAllRequiredRelatedNodes)
                        {
                            CswNbtNode NodeToDelete = _CswNbtResources.Nodes.GetNode(MatchNodePk);
                            if (null != NodeToDelete)
                            {
                                NodeToDelete.delete(DeleteAllRequiredRelatedNodes: DeleteAllRequiredRelatedNodes);
                            }
                        }
                        else
                        {
                            CswNbtNode RelatedNode = _CswNbtResources.Nodes[MatchNodePk];
                            if (null != RelatedNode)
                            {
                                InUseStr.Add(RelatedNode.NodeLink);
                            }
                        }
                    } // foreach( DataRow MatchRow in MatchTable.Rows )

                    if (false == DeleteAllRequiredRelatedNodes)
                    {
                        throw new CswDniException(CswEnumErrorType.Warning,
                                                  "This " + _CswNbtNode.getNodeType().NodeTypeName +
                                                  " cannot be deleted because it is in use by: " + InUseStr,
                                                  "Current user (" + _CswNbtResources.CurrentUser.Username +
                                                  ") tried to delete a " + _CswNbtNode.getNodeType().NodeTypeName +
                                                  " that is in use by: " + InUseStr);
                    }
                } // if( MatchTable.Rows.Count > 0 )
            }     // if( ValidateRequiredRelationships )
        }         // baseBeforeDeleteNode()
Ejemplo n.º 3
0
        private void _deleteFutureNodes()
        {
            // BZ 6754 - Delete all future nodes
            CswNbtMetaDataObjectClass GeneratorObjectClass = ObjectClass;

            if( TargetType.SelectedNodeTypeIds.Count == 1 )
            {
                Int32 SelectedTargetNtId = CswConvert.ToInt32( TargetType.SelectedNodeTypeIds[0] );
                if( Int32.MinValue != SelectedTargetNtId )
                {
                    CswNbtMetaDataNodeType TargetNodeType = _CswNbtResources.MetaData.getNodeType( SelectedTargetNtId );
                    if( null != TargetNodeType )
                    {
                        CswNbtMetaDataObjectClass TargetObjectClass = TargetNodeType.getObjectClass();

                        CswNbtObjClass TargetObjClass = CswNbtObjClassFactory.makeObjClass( _CswNbtResources, TargetObjectClass );
                        if( !( TargetObjClass is CswNbtPropertySetGeneratorTarget ) )
                        {
                            throw new CswDniException( "CswNbtObjClassGenerator.beforeDeleteNode() got an invalid object class: " + TargetObjectClass.ObjectClass );
                        }

                        CswNbtMetaDataNodeTypeProp GeneratorProp = TargetNodeType.getNodeTypePropByObjectClassProp( CswNbtPropertySetGeneratorTarget.PropertyName.Generator );
                        CswNbtMetaDataNodeTypeProp IsFutureProp = TargetNodeType.getNodeTypePropByObjectClassProp( CswNbtPropertySetGeneratorTarget.PropertyName.IsFuture );

                        CswNbtView View = new CswNbtView( _CswNbtResources );
                        View.ViewName = "CswNbtObjClassSchedule.beforeDeleteNode()";
                        CswNbtViewRelationship GeneratorRelationship = View.AddViewRelationship( GeneratorObjectClass, false );
                        GeneratorRelationship.NodeIdsToFilterIn.Add( _CswNbtNode.NodeId );
                        CswNbtViewRelationship TargetRelationship = View.AddViewRelationship( GeneratorRelationship, CswEnumNbtViewPropOwnerType.Second, GeneratorProp, false );
                        CswNbtViewProperty IsFutureProperty = View.AddViewProperty( TargetRelationship, IsFutureProp );
                        View.AddViewPropertyFilter( IsFutureProperty, CswNbtFieldTypeRuleLogical.SubFieldName.Checked, CswEnumNbtFilterMode.Equals, CswEnumTristate.True );

                        ICswNbtTree TargetTree = _CswNbtResources.Trees.getTreeFromView( _CswNbtResources.CurrentNbtUser, View, true, false, false );

                        TargetTree.goToRoot();
                        if( TargetTree.getChildNodeCount() > 0 ) // should always be the case
                        {
                            TargetTree.goToNthChild( 0 );
                            if( TargetTree.getChildNodeCount() > 0 ) // might not always be the case
                            {
                                for( int i = 0; i < TargetTree.getChildNodeCount(); i += 1 )
                                {
                                    TargetTree.goToNthChild( i );

                                    CswNbtNode TargetNode = TargetTree.getNodeForCurrentPosition();
                                    TargetNode.delete();

                                    TargetTree.goToParentNode();
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        }//afterWriteNode()

        public override void beforeDeleteNode(bool DeleteAllRequiredRelatedNodes = false)
        {
            // case 22486 - Don't allow deleting targets of required relationships
            CswTableSelect          JctSelect    = _CswNbtResources.makeCswTableSelect("defaultBeforeDeleteNode_jnp_select", "jct_nodes_props");
            string                  WhereClause  = " where nodetypepropid in (select nodetypepropid from nodetype_props where isrequired = '1') and field1_fk = " + _CswNbtNode.NodeId.PrimaryKey.ToString();
            CswCommaDelimitedString SelectClause = new CswCommaDelimitedString()
            {
                "nodeid"
            };
            DataTable MatchTable = JctSelect.getTable(SelectClause, WhereClause);

            if (MatchTable.Rows.Count > 0)
            {
                CswCommaDelimitedString InUseStr = new CswCommaDelimitedString();
                foreach (DataRow MatchRow in MatchTable.Rows)
                {
                    CswPrimaryKey MatchNodePk = new CswPrimaryKey("nodes", CswConvert.ToInt32(MatchRow["nodeid"]));
                    if (DeleteAllRequiredRelatedNodes)
                    {
                        CswNbtNode NodeToDelete = _CswNbtResources.Nodes.GetNode(MatchNodePk);
                        if (null != NodeToDelete)
                        {
                            NodeToDelete.delete(DeleteAllRequiredRelatedNodes: DeleteAllRequiredRelatedNodes);
                        }
                    }
                    else
                    {
                        CswNbtNode RelatedNode = _CswNbtResources.Nodes[MatchNodePk];
                        if (null != RelatedNode)
                        {
                            InUseStr.Add(RelatedNode.NodeLink);
                        }
                    }
                }
                if (false == DeleteAllRequiredRelatedNodes)
                {
                    throw new CswDniException(CswEnumErrorType.Warning,
                                              "This " + _CswNbtNode.getNodeType().NodeTypeName +
                                              " cannot be deleted because it is in use by: " + InUseStr,
                                              "Current user (" + _CswNbtResources.CurrentUser.Username +
                                              ") tried to delete a " + _CswNbtNode.getNodeType().NodeTypeName +
                                              " that is in use by: " + InUseStr);
                }
            }
        } // beforeDeleteNode()