|
From: Richard B. <rb...@ar...> - 2004-04-20 08:48:40
|
Hi everyone,
Sitting in hotels with nothing to watch means you get time to cut some
code :-)
As a result I have made some new additions to the framework recently as
follows:
1. Added a new method to CCriteriaCondition to allow joining of
subclasses using AND.
This allows you to create SQL where clauses in the form of (A=1 OR
B=2) AND (C=3 AND D=4), etc
2. A number of minor bug fixes
3. Added a number of custom attributes to OPTIONALLY move class
mappings from XML to code.
The idea behind this being that currently changes to a business class
require changes in the code, in the XML file and in the database. By
incorporating the mapping into the business object there are now only
two places that need changing - namely the code and the database. This
should make business objects and applications more portable and reduces
the XML file to database declarations only.
You can now decorate a class definition using attributes as follows:
'-----------
<AFTable("jobs", "MSA", AFTableAttribute.KeyType.useOIDValue,
OIDcolumn:="oidvalue")> _
Public Class CJob
Inherits CPersistentObject
Private m_description As String
<AFColumn("description", Find:=True)> _
Public Property Description() As String
Get
Return m_description
End Get
Set(ByVal Value As String)
m_description = Value
SetDirtyFlag()
End Set
End Property
Public Overrides Function getNewObject() As
AToMSFramework.CPersistentObject
Return New CJob
End Function
Public Overrides Function IsValid() As Boolean
Return True
End Function
End Class
'----------------
The AFTable attribute defines the table mapping for the class and the
AFColumn attribute defines column mappings.
You only need to map columns that are actually represented in the
database (also in the XML). If an class attribute is used only as an
association target then it does not need to be mapped (either in the XML
or using attributes).
This replaces <Class .../> and <Attribute .../> declarations in the XML.
Associations can also be declared using attributes as follows:
'---------------
<AFTable("teams", "MSA", AFTableAttribute.KeyType.useOIDValue,
oidcolumn:="oidvalue"), _
AFAssociation(GetType(CAttrEmployee), "TeamLeader",
CUDAMap.CardinalityEnum.ONE_TO_ONE, Retrieve:=True), _
AFAssociationEntry("TeamLeader", "TeamLeaderOID", "OIDValue"), _
AFAssociation(GetType(CJob), "Job", CUDAMap.CardinalityEnum.ONE_TO_ONE,
Retrieve:=True), _
AFAssociationEntry("Job", "jobOID", "OIDValue"), _
AFAssociation(GetType(CAttrEmployee), "Members",
CUDAMap.CardinalityEnum.ONE_TO_MANY, Retrieve:=True, Save:=False), _
AFAssociationEntry("Members", "OIDValue", "TeamOID")> _
Public Class CTeam
Inherits CPersistentObject
.....
'-----------
The AFAssociation defines the association in general terms and the
AFAssociationEntry defines the properties that are used in the
association. This replaces <Association .../> and <Entry .../> in the
XML file.
Note that some of this is still experimental (superclasses aren't
properly tested yet), but it works for the majority of cases.
Of course, the current XML mapping files still work as they are. Custom
Attributes are only processed after the XML file has been read.
The new attributes are:
<AFTable>
<AFColumn>
<AFAssociation>
<AFAssociationEntry>
If you use the new attributes and notice any problems please contact me
immediately.
- Richard.
|