SSDM - Sibilo Software Development Model

Search 
(by Google)
     

Developer's Corner - Shared Methods
  1. Introduction
    1. Overview (N-tier Architecture)
    2. Downloads
  2. Requirements Capture
    1. Natural Language Text to UML
  3. UML Static Data Model
    1. Object / Class
    2. Relationships
    3. Data Type / Enumeration
    4. Supported Data Types
  4. Application Design
    1. Database (UML-DB Mapping)
    2. Business Objects (UML-Class Mapping)
    3. User Interface (UML-User Control Mapping)
  5. Sibilo Software Development Environment (Sibilo.SDE)
    1. Sibilo.SDE User Guide
  6. Sibilo.DBL Programming
    1. Introduction
      1. Background Information
      2. The Clist Class
    2. Core Objects
      1. Common Constructors
      2. Common Destructors
      3. Common Properties
      4. Common Methods
        • Add
        • Update
        • Remove
        • GetDetails
        • Load
        • Equals
      5. Shared Methods
        • GetAll
        • Remove
        • RemoveAll
        • Exists
        • Search
        • ObjectCount
        • CreateInstance
      6. User Defined Attributes
        • AddAttribute
        • RemoveAttribute
        • GetAttributeList
        • GetClassList
        • GetAttribute
        • SetAttribute
    3. Relationships
      1. Overview
      2. One-to-One Relationships
      3. One-to-Many and Many-to-Many Relationships
        • Add
        • Remove
        • RemoveAll
        • Exists
      4. Default Object of a Relationship
        • SetDefault
        • GetDefault

6.2.5 Shared Methods

SSDM classes also have a number of shared methods you can use without creating instances of objects. This makes learning to code with classes created from SSDM very easy and fast.

SSDM objects have the following shared methods:
GetAll
Remove, RemoveAll
Exists
Search
ObjectCount
CreateInstance

We will now go over how each of these methods can be used for the class CUser.

Shared Function GetAll(ByVal SearchSettings AsCSearchSettings) As CList

Returns a ISList of IDs of all the objects of a type. If ReturnObjects property of CSearchSettings is set to True, objects of current type are returned instead of IDs.

Example:

Dim oSettings As New CSearchSettings()
Dim clPeople As ISList = CUser.GetAll(oSettings)

If clPeople.Count > 0 Then
    For Each oUser As CUser In clPeople
        Response.Write("<br>" & oUser.ID & "-" & oUser.FirstName)
    Next
Else
    Response.Write("No user found in the database")
End If

Shared Function Remove(ByVal ID As Integer) As Boolean

Deletes an object and returns True if successful or if the object does not exist. Note that the object must be in the database, i.e. have an ID, in order to be removed.

Example:

Response.Write(CUser.Remove(103))

Shared Function RemoveAll() As Boolean

Removes all the objects of a type and returns True if successful.

Example:

Response.Write(CUser.RemoveAll())

Shared Function Exists(ByVal ID As Integer) As Boolean

Returns True if an object of a type with the given ID exists.

Example:

Response.Write(CUser.Exists(103))

Shared Function Search(ByVal SearchSettings AsCSearchSettings) As ISList

Searches for objects of a type and returns a CList of IDs of the objects found. If ReturnObjects property of CSearchSettings is set to True (default), objects of current type are returned instead of IDs. Other properties of SearchSettings are SearchParams (CList), SearchOrders (CList), RelationsToLoad (CList), and LoadAttributes (Boolean).

SearchParams CList should contain at least one CSearchParam class where {PropertyName, Operation, Value} tuples are defined. The following example returns a ISList of CUser objects of all the people in the database with the first name "John" and last name "Smith". If more than one CSearchParams objects / criteria exist they are related with a logical "AND".

Example:

' Define search criteria
Dim oSearchSettings As New CSearchSettings()
oSearchSettings.SearchParams.Add(New CSearchParameter("FirstName", "=", "John")) 
oSearchSettings.SearchParams.Add(New CSearchParameter("LastName", "=", "Smith")) 

'Perform the search operation
Dim clRet As ISList = CUser.Search(oSearchSettings)

' Show the results
If Not IsNothing(clRet) Then
    For Each oUser As CUser in clRet
        Response.Write("<br>" & oUser.ID)
    Next
Else
    Response.Write("No results found that match the given criteria")
End If

SearchOrder parameter under CSearchSettings is used to sort the results of the Search and is a CList of CSearchSort objects. CSearchSort has the following properties: OrderBy (Name of the field to sort by), Direction (Ascending/Descending). Example: You can sort the results by the LastName property as follows.

oSearchSettings.SearchOrders.Add(New CSearchSort("LastName", CSearchSort.EnumSortDirection.Ascending))
...
Dim clRet As ISList = CUser.Search(colSearchParams)