From: Richard B. <rb...@us...> - 2004-10-11 22:51:29
|
Update of /cvsroot/jcframework/dotnet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23200 Modified Files: CPersistentObject.vb Log Message: Some changes to getAll and new method for deleteAll. Code contributed by Marcos De Oliviera (mfo) Index: CPersistentObject.vb =================================================================== RCS file: /cvsroot/jcframework/dotnet/CPersistentObject.vb,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** CPersistentObject.vb 28 Sep 2004 04:19:04 -0000 1.38 --- CPersistentObject.vb 11 Oct 2004 22:50:56 -0000 1.39 *************** *** 956,959 **** --- 956,983 ---- End Sub + ''' ----------------------------------------------------------------------------- + ''' <summary> + ''' Remove all objects for a class. + ''' </summary> + ''' <remarks></remarks> + ''' <history> + ''' [mfo] 27/09/2004 Created + ''' </history> + ''' ----------------------------------------------------------------------------- + Public Overridable Sub deleteAll() + Dim obj As CPersistentObject + Dim obRC As CRetrieveCriteria + Dim obCursor As CCursor + + obRC = New CRetrieveCriteria + obCursor = obRC.perform(Me) + Do While Not obCursor.EOF + obj = Me.getNewObject + obCursor.loadProxy(obj) + obj.Delete() + obCursor.nextCursor() + Loop + End Sub + '''----------------------------------------------------------------------------- ''' <summary> *************** *** 1303,1306 **** --- 1327,1331 ---- obRC = New AToMSFramework.CRetrieveCriteria obRC.ClassMap = Me.getClassMap + obRC.ReturnFullObjects = True ' If the collection isn't nothing. *************** *** 1320,1324 **** End If - obCursor.HoldsProxies = False obCursor = obRC.perform(Me) obCol = New CPersistentCollection --- 1345,1348 ---- *************** *** 1348,1366 **** '''----------------------------------------------------------------------------- Public Function getCollectionByAttributesWithEqualTo(ByVal colAttributes As Collection) As CPersistentCollection Dim obAux As Object Dim obCol As CPersistentCollection Dim obRC As New CRetrieveCriteria Dim obCursor As CCursor - Dim obCC As New CCriteriaCondition Dim stAttribute As String obRC.ClassMap = Me.getClassMap(Me) - obCC.ClassMap = Me.getClassMap(Me) For Each stAttribute In colAttributes ! obCC.addSelectEqualTo(stAttribute, Me.getValueByAttribute(stAttribute)) Next ! obRC.WhereCondition = obCC obCursor = obRC.perform(Me) obCursor.HoldsProxies = False --- 1372,1428 ---- '''----------------------------------------------------------------------------- Public Function getCollectionByAttributesWithEqualTo(ByVal colAttributes As Collection) As CPersistentCollection + Return getCollectionByAttributesWithEqualTo(colAttributes, Nothing, Nothing) + End Function + + '''----------------------------------------------------------------------------- + ''' <summary> + ''' Gets all objects for a class that match an number of attribute values. + ''' </summary> + ''' <param name="colAttributes">A collection of attributes names</param> + ''' <param name="pOrderCol">Collection of attributes (strings) to order by.</param> + ''' <param name="pOrderAscCol">Collection of boolean flags to indicate sort order (true = ascending).</param> + ''' <returns>A CPersistentCollection containing the matching objects.</returns> + ''' <remarks>The object that the method is called against must have the + ''' values of the named attributes set. These values are used to build a + ''' retrieveCriteria object. + ''' <para>The retrieveCriteria is then performed and the resulting objects + ''' instantiated and added to the CPersistentCollection.</para></remarks> + ''' <history> + ''' [Marcos Flavio de Oliviera - mf...@cd...] 18/12/2003 Created + ''' [Marcos Flavio de Oliviera - mf...@cd...] 01/10/2004 Include ordering. + ''' </history> + '''----------------------------------------------------------------------------- + Public Function getCollectionByAttributesWithEqualTo(ByVal colAttributes As Collection, ByVal pOrderCol As Collection, ByVal pOrderAscCol As Collection) As CPersistentCollection Dim obAux As Object Dim obCol As CPersistentCollection Dim obRC As New CRetrieveCriteria Dim obCursor As CCursor Dim stAttribute As String + Dim inIndex As Integer + Dim boAscend As Boolean obRC.ClassMap = Me.getClassMap(Me) For Each stAttribute In colAttributes ! obRC.WhereCondition.addSelectEqualTo(stAttribute, Me.getValueByAttribute(stAttribute)) Next ! ' If the collection isn't nothing. ! If Not IsNothing(pOrderCol) Then ! ' For each attribute in collection, add a order attribute in retrieve criteria. ! For inIndex = 1 To pOrderCol.Count ! boAscend = True ! If Not IsNothing(pOrderAscCol) Then ! If inIndex <= pOrderAscCol.Count Then ! ' If the item for ascend is false. ! If TypeOf (pOrderAscCol(inIndex)) Is Boolean Then ! boAscend = pOrderAscCol(inIndex) ! End If ! End If ! End If ! obRC.addOrderAttributeByAscend(pOrderCol(inIndex), boAscend) ! Next ! End If ! obCursor = obRC.perform(Me) obCursor.HoldsProxies = False |