You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@cocoon.apache.org by st...@outerthought.org on 2003/05/01 10:00:04 UTC
[WIKI-UPDATE] ModularDatabaseActions Thu May 1 10:00:04 2003
Page: http://wiki.cocoondev.org/Wiki.jsp?page=ModularDatabaseActions , version: 5 on Thu May 1 07:35:10 2003 by AntonioGallardo
+ # Transactional operations over more than one table
- All the metadata are stored in a XML file, that can contain the description of any number of tables. The tag {{table-set}} define the current used set of tables. Into this file we can include description rules for others Actions like [Form Validator Action]. IN this way we can have all the database metadata in the same file.
? ------------------------------------------------------------- ^
+ All the metadata are stored in a single XML file, that can contain the description of any number of tables. Into this file we can include description rules for others Actions like [Form Validator Action]. In this way we can have all the database metadata in the same file.
? +++++++ ^
- ! The {{alias}} attribute of {{table}} element
- The optional attribute __alias__ in the {{table}} element, is used to create an alternative name of the table, wich can be used inside a {{table-set}}. This tag can be used if a complex join expresions is used as table name.
- Another usage is when different number of columns will be affected by different operations or if a table contains several candidate keys that are used alternatively. This way we can create "different views" of the same table
+ ! The {{<root>}} tag
+ The {{root}} element of the document is ignored, and can have any name. This allows a single document to contain both database description and form validation configuration.
- To find a table, the descriptor file is searched top-down for tables whose {{name}} or {{alias}} match.
+ ! The {{<connection>}} tag
+ This tag identifies a database connection pool, see [ConnectionPooling].
- !Key Columns
+ ! The {{<table>}} tag
+ Describes a complete table. The file can contain several table elements. It has two attributes:
+
+ * {{name}} -- is the name of the table into the database.
+ * {{alias}} -- is and optional attribute. Is used to create an alternative name of a table, wich can be used inside a {{table-set}} element. The {{table-set}} tag can be used if a complex join expresions is used as table name. Another usage is when different number of columns will be affected by different operations or if a table contains several candidate keys that are used alternatively. This way we can create "different views" of the same table.
+
+ To find a table, the descriptor file is searched top-down for tables whose {{name}} or {{alias}} match. The first that matches is used.
+
+ ! The {{<key>}} Tag - Defining Key Columns
- The new __name__ attribute specifies the database column name and corresponds to the {{dbcol}} attribute.
? ^^ ^^
+ * The new {{name}} attribute specifies the database column name and corresponds to the old {{dbcol}} attribute.
? ++ ^^ ^^ ++++
+ * The {{autoincrement}} attribute indicate if a column is of this type. Autoincrement columns will be handled differently on insert operations.
- The __autoincrement__ attribute indicate if a column is of this type. Auto increment columns will be handled differently on insert operations.
-
- Instead of specifying a parameter name, the actions support to use different input modules for each operation through the nested {{mode}} elements.
? ^
+ Instead of specifying a parameter name, the modular actions support the use of different [input modules|InputModules] for each operation through the nested {{mode}} elements.
? ++++++++ ^^ +++ + ++++++++++++++
- !Other Columns
+ ! The {{<value>}} Tag - Defining No key or Other Columns
- Everything said above applies to value columns as well. Except the __autoincrement__ attribute.
+ Everything said above about the __Key Columns__ applies to value columns as well. Except for the __autoincrement__ attribute.
? ++++++++++++++++++++++++++ ++++
- Basically, two different mode types exist: __autoincrement__ which is used only on INSERT when a key has set this attribute and __others__ for all other requirements.
+ Describes the modes of operation against the database. Basically, two different mode types exist:
+ * __autoincrement__ which is used only on INSERT when a key has set this attribute and
+ * __others__ for all other requirements.
- In addition, a table-set can specify different mode types to use instead of the predefined type names. Through this, and the fact that every mode can specify a different input module, it is easy to use different input modules for different tasks and forms.
+ In addition, a {{table-set}} can specify different mode types to use instead of the predefined type names. Through this, and the fact that every mode can specify a different [input module|InputModules], it is easy to use different input modules for different tasks and forms.
? ++ ++ + ++++++++++++++
- One special mode type name exists that matches all requested ones: {{all}}. This makes it easier to configure only some columns differently for each table-set.
? -----
+ One special mode type exists that matches all requested ones: {{all}}. This makes it easier to configure only some columns differently for each table-set.
- !!How to obtain Values
? -
+ !!How to obtain Values
- As said above, the actions default to reading from request parameters with a default parameter name. This can be overridden using __mode__ elements. Any component that implements the InputModule interface can be used to obtain values. How to make such modules known to Apache Cocoon is described in http://xml.apache.org/cocoon/userdocs/concepts/modules.html.
? ^^ ^^ -
+ As said above, the modular actions default to reading from __request parameters__ with a default parameter name. This can be overridden using {{mode}} elements. Any component that implements the InputModule interface can be used to obtain values. How to make such modules known to Apache Cocoon is described in [http://xml.apache.org/cocoon/userdocs/concepts/modules.html].
? ++++++++ ++ ++ ^^ ^^ + +
- <mode name="request" parameter="user_groups.uid" type="request"/>
+ <mode name="request-param" parameter="user_groups.uid" type="request-param"/>
? ++++++ ++++++
- <mode name="attribute"
? -----
+ <mode name="request-attr"
? ++++++++
- parameter="org.apache.cocoon.components.modules.output.OutputModule:user.uid[0]"
? ----
+ parameter="org.apache.cocoon.components.modules.output.OutputModule:user.uid[0]"
- type="attrib"/>
+ type="request-attr"/>
- <mode name="request" parameter="user_groups.gid" type="all"/>
+ <mode name="request-param" parameter="user_groups.gid" type="all"/>
? ++++++
- The above example shows that: the __parameter__ attribute is not read by the database action itself but the complete mode configuration object is passed to the input module. Both the request attribute and the request parameter input modules understand this parameter attribute which takes precedence over the default one.
? ^^ ^^ ^^
+ The above example shows that: the {{parameter}} attribute is not read by the database action itself but the complete mode configuration object is passed to the input module. Both the __request attribute__ and the __request parameter__ input modules understand the {{parameter}} attribute which takes precedence over the default one.
? ^^ ^^ ++ ++ ++ ++ ^ ++ ++
- Another feature when obtaining values is tied to the __type__ attribute: Different modes can be used in different situations. The basic setup uses two different mode types:
? ^^ ^^
+ Another feature when obtaining values is tied to the {{type}} attribute: Different modes can be used in different situations. The basic setup uses two different mode types:
? ^^ ^^
- * __autoincrement__ when inserting in key columns that have an indicator that they are indeed auto increment columns and
+ * __autoincrement__ when inserting into key columns that have an indicator that they are indeed auto increment columns and
? ++
- Table-sets can override the default names for these two mode type name categories with arbitrary names except the special name __all__, wich is used with all requested type names. Lookup obeys first match principle so that all modes are tested from top to bottom and the first that matches is used.
+ __Table-sets__ can override the default names for these two mode type name categories with arbitrary names except the special name __all__, wich is used with all requested type names. Lookup obeys first match principle so that all modes are tested from top to bottom and the first that matches is used.
? ++ ++
- A common task need to work on more than one row. If the rows are in different tables, this is catered for by table-sets. Operating on multiple rows of one table requires to mark columns that should vary and among those one, that determines the number of rows to work on.
+ A common task need to work on more than one row. If the rows are in different tables, this is catered for by __table-sets__. Operating on multiple rows of one table requires to mark columns that should vary and among those one, that determines the number of rows to work on.
? ++ ++
- This is done with sets. All columns that cary a __set__ attribute can vary, those, that don't, are kept fixed during the operation. The column that is used to determine the number of rows is required to have a value of __master__ while all others need to have a value of __slave__ for the set attribute. There may be only one master in a set.
? ^^ ^^ ^^ ^^ ^^ ^^
+ This is done with sets. All columns that cary a {{set}} attribute can vary, those, that don't, are kept fixed during the operation. The column that is used to determine the number of rows is required to have a value of {{master}} while all others need to have a value of {{slave}} for the set attribute. There may be only one master in a set.
? ^^ ^^ ^^ ^^ ^^ ^^
- Tables that should be used during an operation can be grouped together with a table-set. A table-set references tables by their name or their alias.
? -
+ Tables that should be used during an operation can be grouped together with a {{<table-set>}} tag. A table-set references tables by their name or their alias.
? +++ +++++++
- Also, a table-set can override the mode type names for the two categories {{autoincrement}} and {{others}}.
? ^^ ------
+ Also, a table-set can override the {{mode}} attribute for the two categories {{autoincrement}} and {{others}}.
? ++ ++ + ^^^^^^
- Operations spanning multiple tables in a table-set are done in a single transaction. Thus, if one fails, the other is rolled back.
? -
+ Operations spanning multiple tables in a table-set are done in a single transaction. Thus, if one fails, the other is rolled back.
+
- <table name="user_groups" others-mode="attrib"/>
? --
+ <table name="user_groups" others-mode="request-attr"/>
? ++++++++
- <table name="user_groups" others-mode="request"/>
+ <table name="user_groups" others-mode="request-param"/>
? ++++++