This diagram
shows the interaction between the Controller
object, the
InsertEvent
object and all the other actors that are used
to process this database event.
Note:
InsertEvent
works similar to
UpdateEvent
and DeleteEvent
,
so the diagram above should explain the sequence
of class messages for all those events. For further details, see the
public void processEvent(Connection con) throws SQLException, MultipleValidationException
method of the selected DatabaseEvent class.
This database event is initialized by the following parameters and example values:
Table 32.3. initialization parameters and their meaning
action string | the input action string generated by the parent jsp page |
event type | the string identifying the event type |
table id | the dbforms' table identifier (used to build the query string) |
key id | the dbforms' key identifier related to the current table |
insert button count | button count used to identify individual insert buttons |
Table 32.4. insert event parameters generated by a main form
action string | ac_insert_0_root_5 |
event type | ac_insert |
table id | 0 |
key id | root |
button count | 5 |
Table 32.5. insert event parameters generated by a subform
action | ac_insert_1_0@root_17 |
event type | ac_insert |
table id | 1 |
key id | 0@root |
button count | 17 |
The Controller
servlet calls the InsertEvent's
processEvent
method.
The InsertEvent
object checks if the current user
has got the INSERT privilege.
The InsertEvent
object builds a
FieldValues
object representing
the set of FieldValue
objects to process.
Then it copy the FieldValues
data into a new fieldValueHashTable
object that will be used as interceptor's input parameter.
The InsertEvent
object
checks if there is any interceptor object binded to the current main table.
If yes, executes its PRE_INSERT
hook method.
Then the InsertEvent
object
synchronizes data from the fieldValueHashTable
structure used as
interceptor's input parameter (the hash table could contains values modified by the interceptor code)
to the original FieldValues
object
(that will be used by the database insert operation).
The InsertEvent
object builds a
FieldValues
object representing
the set of FieldValue
objects to process.
Then it copy the FieldValues
data into a new fieldValueHashTable
object that will be used as interceptor's input parameter.
The InsertEvent
object calls the
checkSufficentValues
method to
check a list of conditions on the the input FieldValues object:
it must contains the same number of fields as the current main Table
any autoInc field must NOT have a related FieldValue object (generated by a request parameter) because that field value must be calculated by the underlying RDBMS
if all the conditions above are true, the system continues the execution of the event flow,
else it generates a SQLException
that stops the event procession.
The InsertEvent
object retrieve the
DataSourceFactory
and executes its
doInsert
method to store the data
contained into the FieldValues
object
(the new record to insert) into the underlying database.
The InsertEvent
object
checks (again) if there is any interceptor object binded to the current main table.
If yes, executes its POST_INSERT
hook method.