Index: openacs-4/packages/acs-core-docs/www/objects.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/objects.html,v diff -u -r1.8.2.1 -r1.8.2.2 --- openacs-4/packages/acs-core-docs/www/objects.html 24 Nov 2002 21:29:17 -0000 1.8.2.1 +++ openacs-4/packages/acs-core-docs/www/objects.html 29 Mar 2003 20:44:54 -0000 1.8.2.2 @@ -1,11 +1,11 @@ -OpenACS 4.6 Data Models and the Object System

OpenACS 4.6 Data Models and the Object System

+OpenACS 4.6.2 Data Models and the Object System

OpenACS 4.6.2 Data Models and the Object System

By Pete Su
OpenACS docs are written by the named authors, but may be edited by OpenACS documentation staff.

Overview

-Developing data models in OpenACS 4.6 is much like developing data models +Developing data models in OpenACS 4.6.2 is much like developing data models for OpenACS 3, save for the implementation. As usual, you need to examine how to model the information that the application must store and manipulate, and define a suitable set of SQL tables. In our Notes @@ -28,12 +28,12 @@ Thinking further ahead, we can imagine doing any of the following things with Notes as well:

  • Define access control policies on notes.

  • Attach user comments on notes.

  • Allow users to define custom fields to store on their notes.

  • Automatically generate input forms or output displays for notes.

  • Allow other applications to use notes in ways we don't know of yet.

-In OpenACS 4.6, the key to enabling these types of services on your +In OpenACS 4.6.2, the key to enabling these types of services on your application data is to take advantage of the Object System. The first question, then, is "Just what are objects, and what do you use them for anyway?". The short answer: objects are anything represented in the application's data model that will need to be -managed by any central service in OpenACS 4.6, or that may be reusable in +managed by any central service in OpenACS 4.6.2, or that may be reusable in the context of future applications. Every object in the system is represented using a row in the acs_objects table. This table defines all the standard attributes that are stored on every @@ -63,7 +63,7 @@ new object type. Object types are analogous to classes in programming languages such as C++ and Java. In Java, a class defines a set of attributes that store data and a set of methods -that run code. In OpenACS 4.6, we use one or more Oracle tables to store the +that run code. In OpenACS 4.6.2, we use one or more Oracle tables to store the data attributes, and we define a PL/SQL package to hold procedures to define the programming interface to the data model.

@@ -80,8 +80,8 @@

Fire up your text editor and open the ROOT/packages/notes/sql/oracle/notes-create.sql (ROOT/packages/notes/sql/postgresql/notes-create.sql for the PG version) file created -when we created the package. Then, do the following: -

Describe the new type to the type system

+when we created the package. Then, do the following: +

Describe the new type to the type system

First, add an entry to the acs_object_types table with the following PL/SQL call:

 begin  
@@ -141,7 +141,7 @@
 because the new type note is a subtype of
 acs_object, it will inherit these attributes, so there is
 no need for us to define them.
-

Define a table in which to store your objects

+

Define a table in which to store your objects

The next thing we do is make a small modification to the data model to reflect the fact that each row in the notes table represents something that is not only an object of type @@ -166,7 +166,7 @@ use the acs_objects table to find objects will transparently find any objects that are instances of any subtype of acs_objects. -

Define a package for type specific procedures

+

Define a package for type specific procedures

The next step is to define a PL/SQL package for your new type, and write some basic procedures to create and delete objects. Here is a package definition for our new type: @@ -197,7 +197,7 @@ You might be wondering what all the extra parameters are to these calls, since we haven't mentioned them before. These parameters are needed to fill out information that will be stored about the object -that's not stored directly in the table you defined. The OpenACS 4.6 Object +that's not stored directly in the table you defined. The OpenACS 4.6.2 Object System defines these attributes on the type acs_object since all objects should have these attributes. Internally, there are tables that store this information for you. Most of the data is pretty @@ -214,7 +214,7 @@ object OBJ was "read only", then any other object that used OBJ as its context would also be "read only" by default. We'll talk about this more later. -

Define a package body for type specific procedures

+

Define a package body for type specific procedures

The PL/SQL package body contains the implementations of the procedures defined above. The only subtle thing going on here is that we must use acs_object.new to insert a row into @@ -317,7 +317,7 @@ models that are meant to be integrated with the OpenACS object system.

-There are two basic rules you should follow when designing OpenACS 4.6 data +There are two basic rules you should follow when designing OpenACS 4.6.2 data models: @@ -372,7 +372,7 @@ requires a good amount of thought at design time even for simple applications.

Summary

-Hooking into the OpenACS 4.6 object system brings the application developer +Hooking into the OpenACS 4.6.2 object system brings the application developer numerous benefits, and doing it involves only four easy steps: @@ -396,4 +396,4 @@ especially true for the context_id field.

-

($Id$)
View comments on this page at openacs.org
+

($Id$)
View comments on this page at openacs.org