You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Dan Bachelder <ch...@chowda.net> on 2001/08/19 20:21:59 UTC

changing the User object

I was just wondering if I am correct in the following.

If I want to add some application specific stuff to my User object I need
to:

1) change turbine-schema.xml to reflect the new column I want

2) write a implementation of the User interface to replace the TurbineUser
implementation

3) set the services.SecurityService.user.class property in TurbineResources
to reflect the new implementation

4) run "ant init" to regenerate the TurbineUserPeer stuff...

Then I should be good to go?

thanks,
dan


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: changing the User object - can't validate HOWTO

Posted by John McNally <jm...@collab.net>.
When using the alias attribute, torque does not create a new table.  So
if you want to add new columns do that in the original xml schema for
TurbineUser.  The alias attribute only causes the om/peer classes to be
created with references to the fk relationships in the new schema.

john mcnally

Dan Bachelder wrote:
> 
> Has anyone done this with the current release of the TDK(2.1)? these
> instructions reference the fulcrum package, which doesn't exist... When I
> put the new table element in my project-schema.xml file the SQL generator
> seems to skip that table with no error or message on the console or in the
> report file... the map, base classes and implementation classes do get
> generated... however they do not default to implementing the interface I
> wrote.. I add that manually... and I can get my system up and running using
> the new objects.. but I cant add new functionality because the new table
> does not exist, therefor neither do my new columns...
> 
> this is the element I added...
> 
>     <table name="LAW_USER" javaName="LawUserImpl" alias="TurbineUser"
>             baseClass="org.apache.turbine.om.security.TurbineUser"
>             basePeer="org.apache.turbine.om.security.peer.TurbineUserPeer">
> 
>         <column name="USER_ID" required="true" primaryKey="true"
> type="INTEGER"/>
> 
>         <column name="APPLY_TO_USER" type="INTEGER"/>
>         <column name="MIDDLE_I" size="1" type="VARCHAR"/>
>     </table>
> 
> ----- Original Message -----
> From: "Dan Bachelder" <ch...@chowda.net>
> To: <tu...@jakarta.apache.org>
> Sent: Sunday, August 19, 2001 7:49 PM
> Subject: Re: changing the User object
> 
> > NP.. love to... I haven't actually implemented this change yet so I can't
> > really add to the description.. but I am going to do it tonight... here is
> > something to put up right now though... I haven't got CVS set up yet so I
> > dont have the tools to check out the 2 HTML conversion... but I think it's
> > pretty good... Is there xdoc documentation somewhere? (note: I haven't
> > looked :))
> >
> > > good idea!!
> > > send me the extend_user_howto.xml file and i'll check it in!! ;-)
> > >
> > > martin
> >
> >
> 
> ----------------------------------------------------------------------------
> ----
> 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: changing the User object - can't validate HOWTO

Posted by to...@austin.rr.com.
I just recently went through this.  I wasn't adding any information, but
wanted to use TURBINE_USER.USER_ID as a foreign key in some of my tables.

I followed the HOWTO, but since, as you mention, it uses the fulcrum classes
which apparently already have a getUserID() function, etc, I made some
minor changes.  Here's what I did:

In my schema:

  <table name="CORNUCOPIA_USER" javaName="CornucopiaUser" alias="TurbineUser"
        baseClass="net.criticalnode.cornucopia.om.CornucopiaUserBase"
        basePeer="org.apache.turbine.om.security.peer.TurbineUserPeer">
    <column name="USER_ID" primaryKey="true" required="true" type="INTEGER"/>
  </table>

I skipped the making an interface, and just made a class, since I needed to 
implement the getUserId().  For CornucopiaUserBase.java:

public class CornucopiaUserBase extends TurbineUser
{
    public NumberKey getUserId()
    {
        return (NumberKey)getPrimaryKey();
    }
}

After torque generates my (Base)CornucopiaUser and (Base)CornucopiaUserPeer 
classes, I added this to the Peer, since they didn't seem to be generated
for an alias class:

    public static CornucopiaUser retrieveByPK(ObjectKey pk)
        throws Exception
    {
        DBConnection db = null;
        CornucopiaUser retVal = null;

        try
            {
                db = TurbineDB.getConnection(getMapBuilder().getDatabaseMap().getName());
                retVal = retrieveByPK(pk, db);
            } finally {
                if (db != null)
                    TurbineDB.releaseConnection(db);
            }
        return(retVal);
    }

    public static CornucopiaUser retrieveByPK( ObjectKey pk, DBConnection dbcon )
        throws Exception
    {

        Criteria criteria = new Criteria();
        criteria.add( USER_ID, pk );
        Vector v = doSelect(criteria, dbcon);
        if ( v.size() != 1)
            {
                throw new Exception("Failed to select one and only one row.");
            }
        else
            {      
                return (CornucopiaUser)v.firstElement();
            }
    }

And finally, I made the changes in the HOWTO to my properties.  Everything seems
to be working well this way.  I'm not sure what else you'll have to do, since 
you're actually extending the TURBINE_USER table.



On Mon, Aug 20, 2001 at 12:51:14AM -0400, Dan Bachelder wrote:
> Has anyone done this with the current release of the TDK(2.1)? these
> instructions reference the fulcrum package, which doesn't exist... When I
> put the new table element in my project-schema.xml file the SQL generator
> seems to skip that table with no error or message on the console or in the
> report file... the map, base classes and implementation classes do get
> generated... however they do not default to implementing the interface I
> wrote.. I add that manually... and I can get my system up and running using
> the new objects.. but I cant add new functionality because the new table
> does not exist, therefor neither do my new columns...
> 
> this is the element I added...
> 
>     <table name="LAW_USER" javaName="LawUserImpl" alias="TurbineUser"
>             baseClass="org.apache.turbine.om.security.TurbineUser"
>             basePeer="org.apache.turbine.om.security.peer.TurbineUserPeer">
> 
>         <column name="USER_ID" required="true" primaryKey="true"
> type="INTEGER"/>
> 
>         <column name="APPLY_TO_USER" type="INTEGER"/>
>         <column name="MIDDLE_I" size="1" type="VARCHAR"/>
>     </table>
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: changing the User object - can't validate HOWTO

Posted by Dan Bachelder <ch...@chowda.net>.
Has anyone done this with the current release of the TDK(2.1)? these
instructions reference the fulcrum package, which doesn't exist... When I
put the new table element in my project-schema.xml file the SQL generator
seems to skip that table with no error or message on the console or in the
report file... the map, base classes and implementation classes do get
generated... however they do not default to implementing the interface I
wrote.. I add that manually... and I can get my system up and running using
the new objects.. but I cant add new functionality because the new table
does not exist, therefor neither do my new columns...

this is the element I added...

    <table name="LAW_USER" javaName="LawUserImpl" alias="TurbineUser"
            baseClass="org.apache.turbine.om.security.TurbineUser"
            basePeer="org.apache.turbine.om.security.peer.TurbineUserPeer">

        <column name="USER_ID" required="true" primaryKey="true"
type="INTEGER"/>

        <column name="APPLY_TO_USER" type="INTEGER"/>
        <column name="MIDDLE_I" size="1" type="VARCHAR"/>
    </table>

----- Original Message -----
From: "Dan Bachelder" <ch...@chowda.net>
To: <tu...@jakarta.apache.org>
Sent: Sunday, August 19, 2001 7:49 PM
Subject: Re: changing the User object


> NP.. love to... I haven't actually implemented this change yet so I can't
> really add to the description.. but I am going to do it tonight... here is
> something to put up right now though... I haven't got CVS set up yet so I
> dont have the tools to check out the 2 HTML conversion... but I think it's
> pretty good... Is there xdoc documentation somewhere? (note: I haven't
> looked :))
>
> > good idea!!
> > send me the extend_user_howto.xml file and i'll check it in!! ;-)
> >
> > martin
>
>


----------------------------------------------------------------------------
----


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: changing the User object

Posted by Dan Bachelder <ch...@chowda.net>.
I left Jon S. as the author... since I obviously changed nothing
important....

----- Original Message -----
From: "Dan Bachelder" <ch...@chowda.net>
To: <tu...@jakarta.apache.org>
Sent: Sunday, August 19, 2001 7:49 PM
Subject: Re: changing the User object


> NP.. love to... I haven't actually implemented this change yet so I can't
> really add to the description.. but I am going to do it tonight... here is
> something to put up right now though... I haven't got CVS set up yet so I
> dont have the tools to check out the 2 HTML conversion... but I think it's
> pretty good... Is there xdoc documentation somewhere? (note: I haven't
> looked :))
>
> > good idea!!
> > send me the extend_user_howto.xml file and i'll check it in!! ;-)
> >
> > martin
>
>


----------------------------------------------------------------------------
----


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: changing the User object

Posted by Dan Bachelder <ch...@chowda.net>.
NP.. love to... I haven't actually implemented this change yet so I can't
really add to the description.. but I am going to do it tonight... here is
something to put up right now though... I haven't got CVS set up yet so I
dont have the tools to check out the 2 HTML conversion... but I think it's
pretty good... Is there xdoc documentation somewhere? (note: I haven't
looked :))

> good idea!!
> send me the extend_user_howto.xml file and i'll check it in!! ;-)
>
> martin


Re: changing the User object

Posted by mp...@marmot.at.
Quoting Dan Bachelder <ch...@chowda.net>:

> oops... found this in the archives... it would be helpful on the
> website
> maybe....
> 
> [HOWTO] Extend TurbineUser with your own class...

good idea!!
send me the extend_user_howto.xml file and i'll check it in!! ;-)

martin

> 
> ----- Original Message -----
> From: "Dan Bachelder" <ch...@chowda.net>
> To: <tu...@jakarta.apache.org>
> Sent: Sunday, August 19, 2001 2:21 PM
> Subject: changing the User object
> 
> 
> > I was just wondering if I am correct in the following.
> >
> > If I want to add some application specific stuff to my User object I
> need
> > to:
> >
> > 1) change turbine-schema.xml to reflect the new column I want
> >
> > 2) write a implementation of the User interface to replace the
> TurbineUser
> > implementation
> >
> > 3) set the services.SecurityService.user.class property in
> TurbineResources
> > to reflect the new implementation
> >
> > 4) run "ant init" to regenerate the TurbineUserPeer stuff...
> >
> > Then I should be good to go?
> >
> > thanks,
> > dan
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> turbine-user-help@jakarta.apache.org
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: changing the User object

Posted by Dan Bachelder <ch...@chowda.net>.
oops... found this in the archives... it would be helpful on the website
maybe....

[HOWTO] Extend TurbineUser with your own class...

----- Original Message -----
From: "Dan Bachelder" <ch...@chowda.net>
To: <tu...@jakarta.apache.org>
Sent: Sunday, August 19, 2001 2:21 PM
Subject: changing the User object


> I was just wondering if I am correct in the following.
>
> If I want to add some application specific stuff to my User object I need
> to:
>
> 1) change turbine-schema.xml to reflect the new column I want
>
> 2) write a implementation of the User interface to replace the TurbineUser
> implementation
>
> 3) set the services.SecurityService.user.class property in
TurbineResources
> to reflect the new implementation
>
> 4) run "ant init" to regenerate the TurbineUserPeer stuff...
>
> Then I should be good to go?
>
> thanks,
> dan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org