cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Haul <h...@dvs1.informatik.tu-darmstadt.de>
Subject Re: MySQL date conversion with modular database action
Date Fri, 21 Feb 2003 14:26:12 GMT
On 19.Feb.2003 -- 11:45 AM, Andre Taube wrote:
> Still the same:
> 
> DEBUG   (2003-02-19) 12:28.28:239   [sitemap.action.DatabaseUpdateAction]
> (/pcm/contract_admin.contract.html) Thread-9/DatabaseAction: Trying to set
> column pcm_contract.contract_status from request-param using getAttribute
> method
> 

OK, let's look at the samples for the database actions. Let's add a
date column to user:

   alter table add column since date;

(use org.hsqldb.util.DatabaseManager to connect to the server at port
9002 to do this or edit cocoondb.script accordingly)

Change database.xml: (Note: a typo prevented specifying parameter and
format like below. Update the Date*Module.java files from CVS -- don't
update everything yet, Stefano is tweaking the build system and you
might not be able to build a new CVS version right away.)

   <table name="user" alias="user">
      <keys>
         <key name="uid" type="int" autoincrement="true">
            <mode name="auto"  type="autoincr"/>
         </key>
      </keys>
      <values>
         <value name="name"      type="string"></value>
         <value name="firstname" type="string"></value>
         <value name="uname"     type="string"></value>

		 <!-- this is new -->
         <value name="since"     type="date">
           <mode name="datemeta" type="all">
             <parameter>user.since</parameter>
             <format>MM/dd/yy</format>
             <input-module name="request-param"/>
           </mode>
         </value>

         <!-- end new stuff -->

      </values>   
   </table>


I have used the @type="all" here, since I alway want to convert dates
here.

Add the following to user-list.xsp:

    <since>
      <esql:get-date column="since" format="MM/dd/yy"/>
    </since>

and

    <since>
      <input type="text" name="user.since" size="20" maxsize="20">
        <xsp:attribute name="value"><!-- <xsp-request:get-parameter default=""
name="user.uname"/> --></xsp:attribute>
      </input>
    </since>

I trust you figure out where to add this ;-)

Please veryfy that this does indeed work for you.

Now, let's look at the other issue: using a different mode for an
operation. Look at the following table-set

   <table-set name="user+groups">
      <table name="user"/>
      <table name="user_groups" others-mode="attrib"/>
   </table-set>

and compare with the table definition below

   <table name="user_groups">
      <keys>
         <key name="uid" type="int">
            <mode name="request-param" type="request"/>
            <mode name="request-attr"  type="attrib">
               <parameter>org.apache.cocoon.components.modules.output.OutputModule:user.uid[0]</parameter>
            </mode>
         </key>
         <key name="gid" type="int" set="master">
            <mode name="request-param" type="all"/>
         </key>
      </keys>
   </table>

Now, look at sitemap.log (note: default recently switched to log level
ERROR, make sure you have set log level in web.xml and logkeit.xconf
to DEBUG)

 DatabaseAction: modeTypes : {1=attrib, 2=request-attr, 0=autoincr}

this line shows that we are really using "attrib" for others-mode,
"request-attr" for output and "autoincr" for autoincrement columns
(when inserting)

 DatabaseAction: i=0
 DatabaseAction: requested mode was "attrib" returning "attrib"

this shows that we're indeed requesting "attrib" as mode for the first
column (-> user_groups.uid) and that it was found.

 DatabaseAction: i=1
 DatabaseAction: requested mode was "attrib" returning "all"

again, "attrib" was requested but "all" is found (first) thus the mode
with @type="all" is used for column 2 (-> user_groups.gid)

 DatabaseAction: query: INSERT INTO user_groups (uid, gid) VALUES (?, ?)
 DatabaseAction: Trying to set column user_groups.uid from request-attr using getAttribute
method
 DatabaseAction: Setting column user_groups.uid [0] 6
 DatabaseAction: Trying to set column user_groups.gid from request-param using getAttributeValues
method
 DatabaseAction: Setting column user_groups.gid [0] 0
 DatabaseAction: ====> row no. 0
 DatabaseAction: Setting column user_groups.uid[0] to 6
 DatabaseAction: Setting column user_groups.gid[0] to 0
 DefaultComponentFactory: ComponentFactory decommissioning instance of org.apache.cocoon.acting.modular.DatabaseAddAction.

HTH

	Chris.
-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org


Mime
View raw message