|HomeAbout SSDMBusiness BenefitsSSDM = Methodology + Technology + Assistance|| Developer's Corner|
- Requirements Capture
- UML Static Data Model
- Application Design
- Sibilo Software Development Environment (Sibilo.SDE)
- Sibilo.DBL Programming
- Core Objects
6.2.6 User Defined Attributes
There is also support for "User-defined attributes" in SSDM. One can say that he wants to keep, say the hair colour of a person. This property must first be introduced to the model by means of the following method in the CApp:
Function AddAttribute(ByVal ClassName As String, _
ByVal AttributeName As String, _
ByVal AttributeType As String) As Boolean
The ClassName should be the name of the class (i.e. CUser, CEmail, etc.); the AttributeName is the name of the attribute that is initiated; and the AttributeType is the type of the attribute.
The AttributeType should include the assembly name (i.e. System.String). Currently it is not supported to have a SSDM class as an attribute. So AttributeType should typically be System.String, System.Int16, System.Int32, System.Int64, System.Byte, System.Double, System.Boolean, etc.
oSite.AddAttribute("CUser", "HairColour", "System.Int16")
Function RemoveAttribute(ByVal ClassName As String, _
ByVal AttributeName As String, _
Optional ByVal DeleteRecords As Boolean = False) As Boolean
The ClassName should be the name of the class (i.e. CUser, CEmail, etc.); and the AttributeName is the name of the attribute that is to be removed; DeleteRecords parameter is for deleting the records in the database that correspond to the information of the attribute that is being removed. So for example "HairColour" attribute may not be necessary for the moment, but one may not want to delete the information already in the database. So if that is the case, DeleteRecords should be passed as False.
' Delete the records corresponding to HairColour as well
oSite.RemoveAttribute("CUser", "HairColour", True)
Public Function GetAttributeList(ByVal ClassName As String) AsISList
The ClassName should be the name of the class (i.e. CUser, CEmail, etc.); Returns a ISList of names (as String) of the attributes already defined using AddAttribute method. This enables one to list all the attributes for a class for administration purposes. In order to loop all the classes see GetClassList method
For Each oAttributeInfo As SibiloDBL.CAttributeInfo in App.GetAttributeList("CUser")
Response.write(oAttributeInfo.Name & " - " & oAtttibuteInfo.Type & "<br> ")
Public Function GetClassList() As ISList
Returns an ISList of class names stored as String;
Dim sClassName As String
For Each sClassName in App.GetClassList
Response.Write("<b>" & sClassName & "</b><br>")
For Each oAttributeInfo As SibiloDBL.CAttributeInfo in ucSite.oSite.GetAttributeList("CUser")
Response.write(oAttributeInfo.Name & " - " & oAtttibuteInfo.Type & "<br>")
After defining the attributes, they can be accessed using GetAttribute and SetAttribute methods from the Objects.
Public Function GetAttribute(ByVal AttrName As String) As Object
The AtrrName should be the name of the attribute, of which the value we want to get (i.e. "HairColour");
Public Function SetAttribute(ByVal AttrName As String, ByVal ValueAs Object) As Boolean
The AtrrName should be the name of the attribute we want to set (i.e. "HairColour"); The Value should be the same type as it is defined using AddAttribute function of CSite (i.e. System.String). The return will be True if the value is successfully set. The Update function must be called to save the changes to the database.