From: Richard B. <rb...@us...> - 2005-04-06 06:35:00
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25386 Modified Files: AssemblyInfo.vb CCriteriaCondition.vb CInjectedObject.vb CPersistenceBroker.vb CPersistentObject.vb Log Message: Fix for type mismatch error in GetObjectsToSave Handle exceptions thrown by user classes when performing object IValidation checks Add Assembly versioning to Providers Add AssemblyFileVersion to framework. Index: CCriteriaCondition.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CCriteriaCondition.vb,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- CCriteriaCondition.vb 1 Apr 2005 00:04:06 -0000 1.19 +++ CCriteriaCondition.vb 6 Apr 2005 06:34:20 -0000 1.20 @@ -159,7 +159,6 @@ MyBase.New() m_Simple = True m_Parts = New Collection - m_parent = Nothing End Sub '''----------------------------------------------------------------------------- @@ -190,6 +189,9 @@ ''' </history> ''' ----------------------------------------------------------------------------- Public Sub addSubCriteria(ByVal subCriteria As CCriteriaCondition, ByVal useOr As Boolean) + If subCriteria Is Nothing Then + Exit Sub + End If m_Simple = False If subCriteria.ClassMap Is Nothing Then subCriteria.ClassMap = Me.ClassMap @@ -278,7 +280,7 @@ '''----------------------------------------------------------------------------- Private Sub SetCriteriaParams(ByVal attributeName As String, ByRef selCri As CSelectionCriteria, ByRef ValueA As Object, ByRef ValueB As Object, ByVal tblAlias As String) Dim AttrMap As CAttributeMap - Dim myArrayStrings As Object + Dim myArrayStrings() As String myArrayStrings = Split(attributeName, ".", -1, CompareMethod.Text) Dim clMap As CClassMap clMap = m_classMap @@ -677,6 +679,9 @@ ''' </history> '''----------------------------------------------------------------------------- Public Sub fillStatement(ByRef statement As CSqlStatement) + If statement Is Nothing Then + Exit Sub + End If If Not m_Simple Then statement.addSqlClause("(") End If Index: CPersistenceBroker.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistenceBroker.vb,v retrieving revision 1.105 retrieving revision 1.106 diff -u -d -r1.105 -r1.106 --- CPersistenceBroker.vb 4 Apr 2005 23:49:43 -0000 1.105 +++ CPersistenceBroker.vb 6 Apr 2005 06:34:20 -0000 1.106 @@ -1228,10 +1228,13 @@ cm = clMap If GetType(IValidation).IsInstanceOfType(obj.GetSourceObject) Then + Try If Not CType(obj.GetSourceObject, IValidation).IsValidToDelete Then - Debug.WriteLine("Not valid to delete object") - Return 'Do not delete if object + Throw New DeleteException("Delete Validation Failed for " & obj.GetObjectType.FullName & vbCrLf & "No further information available") End If + Catch ex As Exception + Throw New DeleteException("Delete Validation Failed" & obj.GetObjectType.FullName & vbCrLf & ex.Message) + End Try End If Debug.WriteLine("Deleting object " & cm.Name) @@ -2600,6 +2603,7 @@ Dim col As IList 'Dim stack As New Stack Dim q As New Queue + Dim resultQueue As Queue Dim i, k As Integer Dim tmpObj As Object Dim injObj As IPersistableObject @@ -2629,7 +2633,13 @@ End If If obj.IsProxy Then Return q 'Do not save if object is proxied If GetType(IValidation).IsInstanceOfType(obj.GetSourceObject) Then - If Not CType(obj.GetSourceObject, IValidation).IsValid Then Return q 'Do not save if object is not valid + Try + If Not CType(obj.GetSourceObject, IValidation).IsValid Then + Throw New SaveException("Save Validation Failed for " & obj.GetObjectType.FullName & vbCrLf & "No further information available") + End If + Catch ex As Exception + Throw New SaveException("Save Validation Failed for " & obj.GetObjectType.FullName & vbCrLf & ex.Message) + End Try End If If obj.IsReadOnly Then Return q @@ -2649,9 +2659,15 @@ If includeBaseObject AndAlso _ (obj.IsDirty AndAlso Not obj.IsProxy AndAlso Not obj.IsReadOnly AndAlso Not obj.IsModifyOnly) Then If GetType(IValidation).IsInstanceOfType(obj.GetSourceObject) Then + Try If CType(obj.GetSourceObject, IValidation).IsValid Then 'Do not save if object is not valid AddToQueue(obj, q) + Else + Throw New SaveException("Save Validation Failed for " & obj.GetObjectType.FullName & vbCrLf & "No further information available") End If + Catch ex As Exception + Throw New SaveException("Save Validation Failed for " & obj.GetObjectType.FullName & vbCrLf & ex.Message) + End Try Else AddToQueue(obj, q) End If @@ -2673,9 +2689,11 @@ Else value = injObj End If - For Each o In getObjectsToSave(value, True, checkAssociationsRecursivly) - q.Enqueue(o) - Next + resultQueue = getObjectsToSave(value, True, checkAssociationsRecursivly) + Do While resultQueue.Count > 0 + qObj = resultQueue.Dequeue + q.Enqueue(qObj) + Loop End If ElseIf udamap.Cardinality = CUDAMap.CardinalityEnum.ONE_TO_MANY Then col = obj.GetCollectionByAttribute(udamap.FromClassTarget) @@ -2687,9 +2705,11 @@ Else value = tmpObj End If - For Each o In getObjectsToSave(value, True, checkAssociationsRecursivly) - q.Enqueue(o) - Next + resultQueue = getObjectsToSave(value, True, checkAssociationsRecursivly) + Do While resultQueue.Count > 0 + qObj = resultQueue.Dequeue + q.Enqueue(qObj) + Loop Next k End If 'Now go through and find out which objects have been removed from the collection @@ -2738,9 +2758,11 @@ End If aObj = Nothing isNewManyToMany = state.ValidateObject(value) - For Each qObj In getObjectsToSave(value, True, checkAssociationsRecursivly) + resultQueue = getObjectsToSave(value, True, checkAssociationsRecursivly) + Do While resultQueue.Count > 0 + qObj = resultQueue.Dequeue q.Enqueue(qObj) - Next + Loop If isNewManyToMany Then 'We need to create an association object here for the class. aObj = New CAssociationObject @@ -2759,6 +2781,13 @@ cm = cm.SuperClass End While + If Not obj.IsDirty And q.Count > 0 Then + 'This object isn't dirty and won't be saved. The queue length is non-zero which + 'indicates that associations have changed. + 'Because the object won't be saved it won't be updated in the cache, so we'll + 'do it here to make sure the cache version has the updated associations. + m_cache.Add(obj) + End If Return q End Function @@ -3079,6 +3108,7 @@ m_objectsToDelete.Clear() End If Else + Try q = getObjectsToSave(injObj, True, checkAssociationsRecursively) 'All objects to be saved must be saved in a single transaction. If q.Count > 0 Then @@ -3126,6 +3156,17 @@ Loop commit() End If + Catch sx As SaveException + If Not m_inPersistChangesLoop Then + m_injectedObjects.CleanUp() + End If + Throw sx + Catch ex As Exception + If Not m_inPersistChangesLoop Then + m_injectedObjects.CleanUp() + End If + Throw New SaveException("Persist Changes Failed" & vbCrLf & ex.Message) + End Try End If If Not m_inPersistChangesLoop Then m_injectedObjects.CleanUp() Index: CInjectedObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CInjectedObject.vb,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- CInjectedObject.vb 4 Apr 2005 23:49:42 -0000 1.23 +++ CInjectedObject.vb 6 Apr 2005 06:34:20 -0000 1.24 @@ -398,7 +398,7 @@ Private Function getObjectByAttribute(ByVal srcObj As Object, ByVal pName As String) As IPersistableObject Dim dotPos As Integer Dim obj As Object - Dim injobj As CInjectedObject + Dim injobj As IPersistableObject Dim pbroker As CPersistenceBroker dotPos = pName.IndexOf(".") @@ -682,19 +682,23 @@ Dim injObj As IPersistableObject Try - origColl = m_oneToManyCollections.Item(propertyName) + If m_oneToManyCollections.Count = 0 Then + origColl = Nothing + Else + origColl = m_oneToManyCollections.Item(PropertyName) + End If Catch origColl = Nothing End Try If origColl Is Nothing Then Return toColl - p = Me.GetObjectType.GetProperty(propertyName, BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) + p = Me.GetObjectType.GetProperty(PropertyName, BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) iListType = p.PropertyType.GetInterface("IList", True) iDicType = p.PropertyType.GetInterface("IDictionary", True) If Not iListType Is Nothing OrElse Not iDicType Is Nothing Then If Not iListType Is Nothing Then origIList = CType(origColl, IList) - fromIList = CType(Me.getValueByAttribute(propertyName), IList) + fromIList = CType(Me.getValueByAttribute(PropertyName), IList) For Each collItem In origIList If NotInCollection(fromIList, collItem) Then If Not TypeOf collItem Is IPersistableObject Then @@ -707,7 +711,7 @@ Next Else origDict = CType(origColl, IDictionary) - fromDict = CType(Me.getValueByAttribute(propertyName), IDictionary) + fromDict = CType(Me.getValueByAttribute(PropertyName), IDictionary) For Each de As DictionaryEntry In origColl If NotInCollection(fromDict, de.Key) Then If Not TypeOf collItem Is IPersistableObject Then Index: CPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentObject.vb,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- CPersistentObject.vb 4 Apr 2005 23:49:43 -0000 1.63 +++ CPersistentObject.vb 6 Apr 2005 06:34:20 -0000 1.64 @@ -925,8 +925,8 @@ Dim ckey As CCacheKey persistentBroker = getPersistenceBrokerInstance() + Try queue = persistentBroker.getObjectsToSave(obj, True, checkAssociationsRecursivly) - 'All objects to be saved must be saved in a single transaction. If queue.Count > 0 Then persistentBroker.startTransaction() @@ -970,6 +970,11 @@ Loop persistentBroker.commit() End If + Catch sx As SaveException + Throw sx + Catch ex As Exception + Throw New SaveException("Save Failed" & vbCrLf & ex.Message) + End Try End Sub '''----------------------------------------------------------------------------- Index: AssemblyInfo.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/AssemblyInfo.vb,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- AssemblyInfo.vb 23 Dec 2004 01:14:44 -0000 1.14 +++ AssemblyInfo.vb 6 Apr 2005 06:34:20 -0000 1.15 @@ -13,6 +13,8 @@ <Assembly: AssemblyTrademark("")> <Assembly: AssemblyCulture("")> <Assembly: AssemblyKeyFile("..\..\AtomsFramework.snk")> +<Assembly: CLSCompliant(True)> +<Assembly: System.Runtime.InteropServices.ComVisible(False)> ' Version information for an assembly consists of the following four values: @@ -26,6 +28,7 @@ <Assembly: AssemblyVersion("2.1.0.0")> +<Assembly: AssemblyFileVersion("2.1.0.1")> ''' ----------------------------------------------------------------------------- ''' Project : AToMSFramework |