Ejemplo n.º 1
0
 public void clearModifiedFlag()
 {
     foreach (CswNbtNodePropWrapper CurrentProp in _Props)
     {
         CurrentProp.clearSubFieldModifiedFlags();
     } //iterate props
 }     //_clearModifiedFlag()
Ejemplo n.º 2
0
        }//afterWriteNode()

        private void _runMailReportEvents()
        {
            Collection <CswNbtNodePropWrapper> ModifiedProps = new Collection <CswNbtNodePropWrapper>();

            foreach (CswNbtNodePropWrapper CurrentProp in _CswNbtNode.Properties)
            {
                if (CurrentProp.wasAnySubFieldModified(IncludePendingUpdate: false))
                {
                    ModifiedProps.Add(CurrentProp);
                }
            }
            if (ModifiedProps.Count > 0)
            {
                _CswNbtResources.runMailReportEvents(this.NodeType, CswEnumNbtMailReportEventOption.Edit, _CswNbtNode, ModifiedProps);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Executes functions to perform on nodes where pendingevents is true
        /// </summary>
        public void triggerUpdateEvents()
        {
            Collection <CswNbtNodePropWrapper> ModifiedProps = new Collection <CswNbtNodePropWrapper>();

            foreach (CswNbtNodePropWrapper CurrentProp in _CswNbtNode.Properties)
            {
                if (CswTools.IsPrimaryKey(CurrentProp.NodeId) && CurrentProp.wasAnySubFieldModified())
                {
                    _markExternalPropRefsDirty(CurrentProp);
                    _markExternalRelatedPropsDirty(CurrentProp);
                    ModifiedProps.Add(CurrentProp);
                }
            }
            if (ModifiedProps.Count > 0)
            {
                _CswNbtResources.runMailReportEvents(_CswNbtNode.NodeTypeId, CswEnumNbtMailReportEventOption.Edit, _CswNbtNode, ModifiedProps);
            }
        }
Ejemplo n.º 4
0
 public void beforeWriteNode(bool IsCopy, bool OverrideUniqueValidation, bool Creating)
 {
     beforeWriteNodeLogic(Creating, OverrideUniqueValidation);
     if (false == Creating)
     {
         foreach (CswNbtNodePropWrapper CurrentProp in _CswNbtNode.Properties)
         {
             if (CurrentProp.wasAnySubFieldModified())
             {
                 _updateExternalRelatedProps(CurrentProp);
             }
         }
     }
     if (false == OverrideUniqueValidation)
     {
         _validateCompoundUniqueProps(IsCopy);
     }
 } // beforeWriteNode()
Ejemplo n.º 5
0
        }             //PropsTable


        public void update(CswNbtNode Node, bool IsCopy, bool OverrideUniqueValidation, bool Creating, bool AllowAuditing, bool SkipEvents)
        {
            // Do BeforeUpdateNodePropRow on each row
            //Case 29857 - we have to use a traditional for-loop here. onBeforeUpdateNodePropRow() can cause new rows in PropCollData.PropsTable to be created
            // see Document.ArchivedDate
            for (int i = 0; i < PropsTable.Rows.Count; i++)
            {
                DataRow CurrentRow = PropsTable.Rows[i];
                if (CurrentRow.IsNull("nodetypepropid"))
                {
                    throw (new CswDniException("A node prop row is missing its nodetypepropid"));
                }
                if (false == SkipEvents)
                {
                    this[CswConvert.ToInt32(CurrentRow["nodetypepropid"])].onBeforeUpdateNodePropRow(Node, IsCopy, OverrideUniqueValidation, Creating);
                }
            }

            // Sync GestaltSearch (this has to be done after -- see case 31586)
            foreach (CswNbtNodePropWrapper CurrentProp in _Props)
            {
                if (CurrentProp.wasAnySubFieldModified())
                {
                    CurrentProp.SyncGestaltSearch();
                }
            }

            // Do the Update
            if (null != _CswNbtNode)
            {
                _PropsUpdate.update(PropsTable, (AllowAuditing && false == _CswNbtNode.IsTemp));

                if (CswTools.IsPrimaryKey(_CswNbtNode.RelationalId) && "nodes" != _CswNbtNode.RelationalId.TableName.ToLower())
                {
                    _propCollRelational.update(_CswNbtNode.NodeTypeId, _CswNbtNode.RelationalId, PropsTable);
                }
            }
        }
Ejemplo n.º 6
0
        public override void beforeWriteNode(bool IsCopy, bool OverrideUniqueValidation)
        {
            List <CswNbtNodePropWrapper> CompoundUniqueProps = new List <CswNbtNodePropWrapper>();

            foreach (CswNbtNodePropWrapper CurrentProp in _CswNbtNode.Properties)
            {
                if (CurrentProp.WasModified)
                {
                    // When a property changes, we need to:
                    // 1. recalculate composite property values which include changed properties on this node
                    foreach (CswNbtNodePropWrapper CompositeProp in _CswNbtNode.Properties[(CswEnumNbtFieldType)CswEnumNbtFieldType.Composite])
                    {
                        if (
                            CompositeProp.AsComposite.TemplateValue.Contains(
                                CswNbtMetaData.MakeTemplateEntry(CurrentProp.NodeTypePropId.ToString())))
                        {
                            CompositeProp.AsComposite.RecalculateCompositeValue();
                        }
                    }

                    // 2. recalculate property references attached to relationships whose values changed
                    if (CurrentProp.getFieldTypeValue() == CswEnumNbtFieldType.Relationship)
                    {
                        foreach (CswNbtNodePropWrapper PropRefPropWrapper in _CswNbtNode.Properties[(CswEnumNbtFieldType)CswEnumNbtFieldType.PropertyReference])
                        {
                            CswNbtNodePropPropertyReference PropRefProp = PropRefPropWrapper.AsPropertyReference;
                            if ((PropRefProp.RelationshipType == CswEnumNbtViewPropIdType.NodeTypePropId &&
                                 PropRefProp.RelationshipId == CurrentProp.NodeTypePropId) ||
                                (PropRefProp.RelationshipType == CswEnumNbtViewPropIdType.ObjectClassPropId &&
                                 PropRefProp.RelationshipId == CurrentProp.ObjectClassPropId))
                            {
                                PropRefProp.RecalculateReferenceValue();
                            }
                        }
                    }

                    // 3. mark any property references to this property on other nodes as pending update
                    if (CswTools.IsPrimaryKey(CurrentProp.NodeId))
                    {
                        //BZ 10239 - Fetch the cached value field name.
                        CswNbtFieldTypeRulePropertyReference PropRefFTR = (CswNbtFieldTypeRulePropertyReference)_CswNbtResources.MetaData.getFieldTypeRule(CswEnumNbtFieldType.PropertyReference);
                        CswEnumNbtPropColumn PropRefColumn = PropRefFTR.CachedValueSubField.Column;

                        string SQL = @"update jct_nodes_props 
                                      set pendingupdate = '" + CswConvert.ToDbVal(true) + @"',
                                          " + PropRefColumn.ToString() + @" = ''
                                    where jctnodepropid in (select j.jctnodepropid
                                                              from jct_nodes_props j
                                                              join nodes n on n.nodeid = j.nodeid
                                                              join nodetype_props p on p.nodetypepropid = j.nodetypepropid
                                                              join field_types f on p.fieldtypeid = f.fieldtypeid
                                                              left outer join jct_nodes_props jntp on (jntp.nodetypepropid = p.fkvalue
                                                                                                  and jntp.nodeid = n.nodeid
                                                                                                  and jntp.field1_fk = " + CurrentProp.NodeId.PrimaryKey.ToString() + @")
                                                              left outer join (select jx.jctnodepropid, ox.objectclasspropid, jx.nodeid
                                                                                  from jct_nodes_props jx
                                                                                  join nodetype_props px on jx.nodetypepropid = px.nodetypepropid
                                                                                  join object_class_props ox on px.objectclasspropid = ox.objectclasspropid
                                                                              where jx.field1_fk = " + CurrentProp.NodeId.PrimaryKey.ToString() + @") jocp 
                                                                                                  on (jocp.objectclasspropid = p.fkvalue 
                                                                                                  and jocp.nodeid = n.nodeid)
                                                              where f.fieldtype = 'PropertyReference'
                                                              and ((lower(p.fktype) = 'nodetypepropid' and jntp.jctnodepropid is not null)
                                                                  or (lower(p.fktype) = 'objectclasspropid' and jocp.jctnodepropid is not null))
                                                              and ((lower(p.valueproptype) = 'nodetypepropid' and p.valuepropid = " + CurrentProp.NodeTypePropId.ToString() + @") 
                                                                  or (lower(p.valueproptype) = 'objectclasspropid' and p.valuepropid = " + CurrentProp.ObjectClassPropId + @")))";

                        // We're not doing this in a CswTableUpdate because it might be a large operation,
                        // and we don't care about auditing for this change.
                        _CswNbtResources.execArbitraryPlatformNeutralSql(SQL);
                    }

                    // 4. For locations, if this node's location changed, we need to update the pathname on the children
                    if (CurrentProp.getFieldTypeValue() == CswEnumNbtFieldType.Location &&
                        CswTools.IsPrimaryKey(_CswNbtNode.NodeId))
                    {
                        _CswNbtResources.CswNbtNodeFactory.CswNbtNodeWriter.updateRelationsToThisNode(_CswNbtNode);
                    }

                    // 5. Prepare for compound unique validation
                    if (CswConvert.ToBoolean(CurrentProp[CswEnumNbtPropertyAttributeName.CompoundUnique]))
                    {
                        CompoundUniqueProps.Add(CurrentProp);
                    }
                } // if(CurrentProp.WasModified)
            }     // foreach (CswNbtNodePropWrapper CurrentProp in _CswNbtNode.Properties)

            if (CompoundUniqueProps.Count > 0 && NodeId != null)
            {
                if (false == IsCopy && false == OverrideUniqueValidation)
                {
                    //check for other compound unique props that were _not_ modified
                    foreach (CswNbtNodePropWrapper CurrentProp in _CswNbtNode.Properties)
                    {
                        if (CswConvert.ToBoolean(CurrentProp[CswEnumNbtPropertyAttributeName.CompoundUnique]) && (false == CompoundUniqueProps.Contains(CurrentProp)))
                        {
                            CompoundUniqueProps.Add(CurrentProp);
                        }
                    }

                    CswNbtView CswNbtView = this.NodeType.CreateDefaultView();
                    CswNbtView.ViewName = "For compound unique";

                    CswNbtViewRelationship ViewRelationship = CswNbtView.Root.ChildRelationships[0];

                    if (CswTools.IsPrimaryKey(NodeId))
                    {
                        ViewRelationship.NodeIdsToFilterOut.Add(NodeId);
                    }


                    foreach (CswNbtNodePropWrapper CurrentCompoundUniqueProp in CompoundUniqueProps)
                    {
                        //case 27670 - in order to reserve the right for compound unique props to be empty, it has to be explicitly stated when creating the ForCompundUnique view
                        CswNbtViewProperty   CswNbtViewProperty = CswNbtView.AddViewProperty(ViewRelationship, CurrentCompoundUniqueProp.NodeTypeProp);
                        ICswNbtFieldTypeRule ftRule             = CurrentCompoundUniqueProp.NodeTypeProp.getFieldTypeRule();
                        ftRule.AddUniqueFilterToView(CswNbtView, CswNbtViewProperty, CurrentCompoundUniqueProp, true);
                    }

                    ICswNbtTree NodeTree = _CswNbtResources.Trees.getTreeFromView(_CswNbtResources.CurrentNbtUser, CswNbtView, true, false, false);

                    if (NodeTree.getChildNodeCount() > 0)
                    {
                        NodeTree.goToNthChild(0);
                        CswNbtNode DuplicateValueNode = NodeTree.getNodeForCurrentPosition();

                        CswCommaDelimitedString CompoundUniquePropNames  = new CswCommaDelimitedString();
                        CswCommaDelimitedString CompoundUniquePropValues = new CswCommaDelimitedString();
                        foreach (CswNbtNodePropWrapper CurrentUniqueProp in CompoundUniqueProps)
                        {
                            CompoundUniquePropNames.Add(CurrentUniqueProp.PropName);
                            CompoundUniquePropValues.Add(CurrentUniqueProp.Gestalt);
                        }

                        string ExotericMessage = "The following properties must have unique values:  " + CompoundUniquePropNames.ToString();
                        string EsotericMessage = "The " + CompoundUniquePropNames.ToString() +
                                                 " of node " + NodeId.ToString() + " are the same as for node " + DuplicateValueNode.NodeId.ToString() + ": " + CompoundUniquePropValues.ToString();

                        if (false == _CswNbtNode.IsTemp && false == DuplicateValueNode.IsTemp)  //only throw an error if we're comparing two REAL nodes
                        {
                            throw (new CswDniException(CswEnumErrorType.Warning, ExotericMessage, EsotericMessage));
                        }
                    }//we have a duplicate value situation
                }

                else
                {
                    foreach (CswNbtNodePropWrapper CurrentPropWrapper in CompoundUniqueProps)
                    {
                        CurrentPropWrapper.ClearValue();
                        CurrentPropWrapper.clearModifiedFlag();
                    }
                } //if-else we're not a copy and not overridding
            }     //if we have at leaste one modified compound unique prop

            //_synchNodeName();
            // can't do this here, because we miss some of the onBeforeUpdateNodePropRow events
            // we do it in writer now instead
        } // beforeWriteNode()