From: Richard B. <rb...@us...> - 2004-10-21 23:35:34
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5715 Modified Files: CPersistenceBroker.vb CPersistentObject.vb Log Message: Fixed bug in deleting non-inherited objects. Fixed problem with duplicates in multiple collections. Made some attributes of CPersistentObject advanced using EditorBrowsable attribute (for IDE) Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.70 retrieving revision 1.71 diff -u -d -r1.70 -r1.71 --- CPersistenceBroker.vb 20 Oct 2004 06:44:23 -0000 1.70 +++ CPersistenceBroker.vb 21 Oct 2004 23:35:23 -0000 1.71 @@ -40,6 +40,7 @@ Public Event LoginDetailsNeeded(ByVal sender As Object, ByRef User As String, ByRef Password As String) Private m_disposed As Boolean + Private m_inPersistChangesLoop As Boolean '''----------------------------------------------------------------------------- ''' <summary> @@ -476,10 +477,10 @@ '(prevents duplicates when multiple one-to-many associations exist) gotValue = False For Each tmpColObj As Object In col - If Not tmpColObj.GetType.IsSubclassOf(GetType(IPersistableObject)) Then - tmpObj = LocateOrCreateInjObject(tmpColObj) - Else + If tmpColObj.GetType.IsSubclassOf(GetType(CPersistentObject)) Then tmpObj = tmpColObj + Else + tmpObj = LocateOrCreateInjObject(tmpColObj) End If If tmpObj.Equals(targetobj) Then gotValue = True @@ -495,8 +496,6 @@ End If If targetobj.AssociationsLoaded Then col.Add(targetobj.GetSourceObject) - 'the object is found and added to the collection - ' Exit For End If End If End If @@ -517,10 +516,10 @@ '(prevents duplicates when multiple one-to-many associations exist) gotValue = False For Each tmpColObj As Object In col - If Not tmpColObj.GetType.IsSubclassOf(GetType(IPersistableObject)) Then - tmpObj = LocateOrCreateInjObject(tmpColObj) - Else + If tmpColObj.GetType.IsSubclassOf(GetType(CPersistentObject)) Then tmpObj = tmpColObj + Else + tmpObj = LocateOrCreateInjObject(tmpColObj) End If If tmpObj.Equals(targetobj) Then gotValue = True @@ -773,6 +772,7 @@ obj.ResetOriginalDates() obj.Persistent = True obj.IsDirty = False + obj.IsQueued = False 'Update cache key in-case primary key fields have changed value obj.OriginalCacheKey = New CCacheKey(obj) If m_useCache Then @@ -2451,12 +2451,15 @@ Me.startTransaction() Try Dim injObj As CInjectedObject + m_inPersistChangesLoop = True For Each de As DictionaryEntry In m_injectedObjects injObj = de.Value PersistChanges(injObj.ReferencedObject) Next + m_inPersistChangesLoop = False Me.commit() Catch ex As Exception + m_inPersistChangesLoop = False Me.rollback() Throw ex End Try @@ -2478,6 +2481,9 @@ If injObj.MarkedForDeletion Then deleteObject(injObj, injObj.WillDeleteParents) + If Not m_inPersistChangesLoop Then + m_injectedObjects.Remove(obj) + End If Else queue = getObjectsToSave(injObj, True, checkAssociationsRecursively) 'All objects to be saved must be saved in a single transaction. Index: CPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentObject.vb,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- CPersistentObject.vb 20 Oct 2004 06:44:23 -0000 1.45 +++ CPersistentObject.vb 21 Oct 2004 23:35:23 -0000 1.46 @@ -487,6 +487,7 @@ ''' [rbanks] 25/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Sub setAttributeValue(ByVal pName As String, ByRef Value As Object) Implements IPersistentObject.setAttributeValue If TypeOf (Value) Is System.DBNull Then @@ -536,6 +537,7 @@ ''' [rbanks] 25/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Function getValueByAttribute(ByVal pName As String) As Object Implements IPersistentObject.getValueByAttribute Dim dotPos As Integer dotPos = pName.IndexOf(".") @@ -565,6 +567,7 @@ ''' [rbanks] 25/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Function getObjectByAttribute(ByVal pName As String) As IPersistableObject Implements IPersistableObject.getObjectByAttribute Dim dotPos As Integer dotPos = pName.IndexOf(".") @@ -596,6 +599,7 @@ ''' [rbanks] 26/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public MustOverride Function getNewObject() As CPersistentObject Implements IPersistentObject.getNewObject '''----------------------------------------------------------------------------- @@ -616,6 +620,7 @@ ''' [rbanks] 26/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overridable Function hasValidKey() As Boolean If m_oid Is Nothing Then Return False @@ -635,6 +640,7 @@ ''' [rbanks] 26/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overloads Function getCollectionByAttribute(ByVal pName As String) As IList Implements IPersistentObject.getCollectionByAttribute Dim dotPos As Integer dotPos = pName.IndexOf(".") @@ -668,6 +674,7 @@ ''' [rbanks] 26/11/2003 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Private Function getObjectFromCollectionByAttribute(ByVal pName As String) As CPersistentObject Dim colAux As Collection Dim dotPos As Integer @@ -1558,6 +1565,7 @@ ''' [danymayer] 19/07/2004 Created ''' </history> '''----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Function getObjectByClassMap(ByVal classMap As CClassMap) As IPersistableObject Implements IPersistentObject.getObjectByClassMap Dim obj, Value As CPersistentObject Dim col As CPersistentCollection @@ -1621,6 +1629,7 @@ Return obj End Function + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overridable Function GetBaseCopy() As CPersistentObject 'Use reflection to copy all of the fields from Obj to me (by value) If Me.getClassMap.SuperClass Is Nothing Then @@ -1668,6 +1677,7 @@ ''' [rbanks] 16/08/2004 Created ''' </history> ''' ----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overridable Sub BeginEdit() Implements System.ComponentModel.IEditableObject.BeginEdit If Not m_editing Then m_preEditCopy = Me.getNewObject @@ -1688,6 +1698,7 @@ ''' [rbanks] 16/08/2004 Created ''' </history> ''' ----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overridable Sub CancelEdit() Implements System.ComponentModel.IEditableObject.CancelEdit m_editing = False Me.ReplaceWith(m_preEditCopy) @@ -1708,6 +1719,7 @@ ''' [rbanks] 16/08/2004 Created ''' </history> ''' ----------------------------------------------------------------------------- + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Overridable Sub EndEdit() Implements System.ComponentModel.IEditableObject.EndEdit m_editing = False m_isNew = False @@ -1728,7 +1740,8 @@ ''' [rbanks] 16/08/2004 Created ''' </history> ''' ----------------------------------------------------------------------------- - <Browsable(False)> Public Overridable ReadOnly Property [Error]() As String Implements System.ComponentModel.IDataErrorInfo.Error + <Browsable(False), EditorBrowsable(EditorBrowsableState.Advanced)> _ + Public Overridable ReadOnly Property [Error]() As String Implements System.ComponentModel.IDataErrorInfo.Error Get If Me.IsValid Then Return "" @@ -1750,7 +1763,8 @@ ''' [rbanks] 16/08/2004 Created ''' </history> ''' ----------------------------------------------------------------------------- - <Browsable(False)> Default Public Overridable ReadOnly Property Item(ByVal columnName As String) As String Implements System.ComponentModel.IDataErrorInfo.Item + <Browsable(False), EditorBrowsable(EditorBrowsableState.Advanced)> _ + Default Public Overridable ReadOnly Property Item(ByVal columnName As String) As String Implements System.ComponentModel.IDataErrorInfo.Item Get Return "" End Get @@ -1761,7 +1775,8 @@ Public Event Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Implements System.ComponentModel.IComponent.Disposed Private m_curCPSite As ISite - <Browsable(False)> Public Property Site() As System.ComponentModel.ISite Implements System.ComponentModel.IComponent.Site + <Browsable(False), EditorBrowsable(EditorBrowsableState.Advanced)> _ + Public Property Site() As System.ComponentModel.ISite Implements System.ComponentModel.IComponent.Site Get Return m_curCPSite End Get @@ -1775,10 +1790,12 @@ End Sub #End Region + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Function GetObjectType() As System.Type Implements IPersistableObject.GetObjectType Return Me.GetType End Function + <EditorBrowsable(EditorBrowsableState.Advanced)> _ Public Function GetSourceObject() As Object Implements IPersistableObject.GetSourceObject Return Me End Function |