You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Cameron Cole <cw...@yahoo.com> on 2002/02/26 23:00:14 UTC

Extending Turbine User

Good day all,

I have been having great success with Turbine over the past bit but have
hit a bit of a roadblock yesterday and today. First I needed to extend
Turbine user to include some extra fields, phone numbers to be exact, so
I read the how-to and everything went fine, I created a NebulaUser and
extended TurbineUser. However now, I am attempting to have a Turbine
user be part of a "Team", and I am now having some trouble :) I modified
my nebula-schema.xml as follows: (nebula is my app/project name, b/c it
is ill defined and nebulous :)

  <table name="TURBINE_USER" idMethod="idbroker">
    <column name="USER_ID" required="true" primaryKey="true"
type="INTEGER"/>
    <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
    <column name="PASSWORD_VALUE" required="true" size="32"
type="VARCHAR"/>
    <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
    <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
    <column name="EMAIL" size="99" type="VARCHAR"/>
    <column name="HOMEPHONE" size="20" type="VARCHAR"/>
    <column name="WORKPHONE" size="20" type="VARCHAR"/>
    <column name="CELLPHONE" size="20" type="VARCHAR"/>
    <column name="PAGER" size="20" type="VARCHAR"/>
    <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
    <column name="MODIFIED" type="TIMESTAMP"/>
    <column name="CREATED" type="TIMESTAMP"/>
    <column name="LAST_LOGIN" type="TIMESTAMP"/>
    <column name="OBJECTDATA" type="VARBINARY"/>
    <column name="TEAM_ID" required="true" type="INTEGER"/>
    <unique>
        <unique-column name="LOGIN_NAME"/>
    </unique>        
    <foreign-key foreignTable="TEAM">
        <reference local="TEAM_ID" foreign="ID"/>
    </foreign-key>    
  </table>

  <table name="TEAM">
    <column name="ID" required="true" autoIncrement="true"
primaryKey="true" type="INTEGER"/>
    <column name="NAME" required="true" type="VARCHAR" size="255"/>
    <column name="DESCRIPTION" required="true" type="VARCHAR"
size="255"/>
  </table>

<table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
	baseClass="<package>.nebula.om.TurbineUserAdapter"
	basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
    <column name="USER_ID" primaryKey="true" required="true"
type="INTEGER" autoIncrement="true"/>
  </table>

Everything gets defined correctly, and I have added the definitions to
my TurbineMapBuilderAdapter and both my TurbineUserAdapter and
TurbinePeerAdapter classes. The problem is that torque when
autogenerating the BaseTeam.java files, casts all of its "Users" to
TurbineUsers and hence cannot find the setTeamId(NumberKey key) method.
Is there a better way to do this? Is there a way to do this? (I didn't
want to change the cast statements in the generated code, cause I would
lose it each time I regened from torque.) Or am I just asking to hit my
head against a wall? 

Thanks in advance,

-cam.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Diederik de Groot <dd...@talon.nl>.
I am adding a foreignkey at this moment following cameron's lead. I need one
as well. Hopefully i can use his examples and not run into to much trouble.
I have been fighting with turbine all day now so i'm just going to try and
implement this last bit and call it quits.

Thanks anyway for giving me the feeling that somebody is actually reading
what i write. I have enough trouble explaining to my users that this was
actually a lot of work. Thanks a lot,

Diederik

----- Original Message -----
From: "Scott Eade" <se...@backstagetech.com.au>
To: "turbine-user" <tu...@jakarta.apache.org>
Sent: Sunday, March 03, 2002 11:46 PM
Subject: Re: Extending Turbine User


> > From: "Diederik de Groot" <dd...@talon.nl>
> >
> > Now i'll be starting to and company_id to my system. Hopefull Camerons
> > Problems will help me in my quest to furthermore extend User again. It's
a
> > bit of a pain i must say. Can't we just add a parameter to torque to
tell it
> > that this entry is a Extention of User, so it can do all the hard crap ?
> >
> Cam had a specific problem - he wanted to extend TurbineUser with a
foreign
> key to another table.  If you don't need a foreign key to another table
then
> the standard extend-user-howto should suffice.
>
> I haven't been reading your posts as they tend to begin with "just
answering
> my own question" ;-)
>
> HTH,
>
> Scott
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Scott Eade <se...@backstagetech.com.au>.
> From: "Diederik de Groot" <dd...@talon.nl>
> 
> Now i'll be starting to and company_id to my system. Hopefull Camerons
> Problems will help me in my quest to furthermore extend User again. It's a
> bit of a pain i must say. Can't we just add a parameter to torque to tell it
> that this entry is a Extention of User, so it can do all the hard crap ?
> 
Cam had a specific problem - he wanted to extend TurbineUser with a foreign
key to another table.  If you don't need a foreign key to another table then
the standard extend-user-howto should suffice.

I haven't been reading your posts as they tend to begin with "just answering
my own question" ;-)

HTH,

Scott


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Diederik de Groot <dd...@talon.nl>.
Just answering my own question again. Thanks for paying attention guys. Only
cost me another hour to find out how this worked. Just kidding.

I redid all my all my code and where i used capitals i use UnderScores
aswell. And now it finally works.

Now i'll be starting to and company_id to my system. Hopefull Camerons
Problems will help me in my quest to furthermore extend User again. It's a
bit of a pain i must say. Can't we just add a parameter to torque to tell it
that this entry is a Extention of User, so it can do all the hard crap ?

Greetings,

DIederik

P.S. I'll be reading Scott's and Cameron's tale for a while.

----- Original Message -----
From: "Diederik de Groot" <dd...@talon.nl>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Sunday, March 03, 2002 10:06 PM
Subject: Re: Extending Turbine User


I actually found out how to update users now. I must say it's quite a bit of
typing. I have one question though. I used underscores in my fieldnames in
the database descriptions so they come out to be nice JavaNames. Problem in
the sample on "Extend User Howto" the implement "Initials". I recreated this
to the best of my ability. Problem is where do i define what in what case.

  <table name="TURBINE_USER" idMethod="idbroker">
    <column name="USER_ID" required="true" primaryKey="true"
type="INTEGER"/>
    <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
    <column name="PASSWORD_VALUE" required="true" size="32" type="VARCHAR"/>
    <column name="INITIALS" size="8" type="VARCHAR"/>
    <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
    <column name="MIDDLE_NAME" size="15" type="VARCHAR"/>
    <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
    <column name="EMAIL" size="99" type="VARCHAR"/>
    <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
    <column name="MODIFIED" type="TIMESTAMP"/>
    <column name="CREATED" type="TIMESTAMP"/>
    <column name="LAST_LOGIN" type="TIMESTAMP"/>
    <column name="HOME_STREET" size="70" type="VARCHAR"/>
    <column name="HOME_NUMBER" size="5" type="VARCHAR"/>
    <column name="HOME_POSTAL_CODE" size="6" type="VARCHAR"/>
    <column name="HOME_CITY" size="35" type="VARCHAR"/>
    <column name="HOME_PROVINCE" size="35" type="VARCHAR"/>
    <column name="HOME_COUNTRY" size="35" type="VARCHAR"/>
    <column name="PHONE_NUMBER" size="14" type="VARCHAR"/>
    <column name="MOBILE_NUMBER" size="14" type="VARCHAR"/>
    <column name="GENDER" size="1" type="CHAR"/>
    <column name="PLACE_OF_BIRTH" size="35" type="VARCHAR"/>
    <column name="PAYMENT_METHOD" type="CHAR" size="1"/>
    <column name="BANK_ACCOUNT_NUMBER" type="VARCHAR" size="11"/>
    <column name="CARD_NUMBER" type="VARCHAR" size="16"/>
    <column name="CARD_HOLDER_NAME" type="VARCHAR" size="35"/>
    <column name="OBJECTDATA" type="VARBINARY"/>
    <unique>
        <unique-column name="LOGIN_NAME"/>
    </unique>
  </table>

For now i only added String like fields. Later i want to add Others aswell,
but still have to find out how to define them as Integer, Blob etc...

TurbineUserAdapter looks like this :

public class TurbineUserAdapter extends TurbineUser
{
    public static final String MIDDLENAME    = "MIDDLE_NAME";
    ......
    ......
    ......

    public NumberKey getUserId()
    {
        return (NumberKey) getPrimaryKey();
    }

 //MIDDLENAME
    public void setMiddleName(String middleName)
    {
        setPerm(MIDDLENAME, middleName);
    }

    public String getMiddleName()
    {
        String tmp = null;
        try
        {
            tmp = (String) getPerm(MIDDLENAME);
            if ( tmp.length() == 0 )
                tmp = null;
        }
        catch ( Exception e )
        {
        }
        return tmp;
    }

    .....
    .....
    .....
}

TurbineUserPeerAdapter looks like this :
public class TurbineUserPeerAdapter extends TurbineUserPeer
{
    private static final TurbineMapBuilderAdapter mapBuilder =
        (TurbineMapBuilderAdapter) getMapBuilder();

    public static final String MIDDLENAME = mapBuilder.getUser_MiddleName();
    .....
    .....
    .....

}

TurbineMapBuilderAdapter looks like this :
public class TurbineMapBuilderAdapter extends TurbineMapBuilder
{
    /*
     * Note: The getUser_*() methods in this class should be static, but
     * getTableUser() and the initial field level methods are incorrectly
     * declared in TurbineMapBuilder and hence we must use non-static
methods
     * here.
     */

    public static String getMiddleName()
    {
        return "MIDDLE_NAME";
    }

    public String getUser_MiddleName()
    {
        return getTableUser() + '.' + getMiddleName();
    }

}

I can't seem to find out which one does represent entries in the database
and which ones are just intermediate variables. So where should i use
underscores, capitals etc... Maybe one of you can help me out.

Thanks,

Diederik



----- Original Message -----
From: "Diederik de Groot" <dd...@talon.nl>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Sunday, March 03, 2002 5:20 PM
Subject: Re: Extending Turbine User


Having read all this information about extending Turbine User. How do i
actually use the new user. I can't figure out how to use my new Member user.

I've extended User conform to the Extend User Howto specification. Calling
my new user "Member". I'm using flux so i added a some new fields to the
userform and hoped that i could save these fields using this syntax.

public void doUpdate(RunData data, Context context)
        throws Exception
{
         Member member = (Member)TurbineSecurity.getUser(username);
         data.getParameters().setProperties(member);
         Date now = new Date();
         member.setCreateDate(now);
         member.setLastLogin(new Date(0));
         member.save();
}

Do i have to Extend TurbineSecurity and Flux's SecurityTool to incorporate
the new fields I added or is there a more direct way to achieve my goal. Can
i for example simply get all the fields i added from the form post and use

member.middlename=data.getParameters().getString("middlename");

(this doesn't seem to work by the way). Is there any way to rethink this
whole extending procedure and maybe have ant recreate the whole extention
for us. Including flux i hope.

I'm getting a bit frustrated here. Not banging my head into the wall just
now, but getting there.

Thanks,

Diederik de Groot
Talon V.o.F



----- Original Message -----
From: "Cameron Cole" <cw...@yahoo.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Tuesday, February 26, 2002 11:00 PM
Subject: Extending Turbine User


> Good day all,
>
> I have been having great success with Turbine over the past bit but have
> hit a bit of a roadblock yesterday and today. First I needed to extend
> Turbine user to include some extra fields, phone numbers to be exact, so
> I read the how-to and everything went fine, I created a NebulaUser and
> extended TurbineUser. However now, I am attempting to have a Turbine
> user be part of a "Team", and I am now having some trouble :) I modified
> my nebula-schema.xml as follows: (nebula is my app/project name, b/c it
> is ill defined and nebulous :)
>
>   <table name="TURBINE_USER" idMethod="idbroker">
>     <column name="USER_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>     <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
>     <column name="PASSWORD_VALUE" required="true" size="32"
> type="VARCHAR"/>
>     <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
>     <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
>     <column name="EMAIL" size="99" type="VARCHAR"/>
>     <column name="HOMEPHONE" size="20" type="VARCHAR"/>
>     <column name="WORKPHONE" size="20" type="VARCHAR"/>
>     <column name="CELLPHONE" size="20" type="VARCHAR"/>
>     <column name="PAGER" size="20" type="VARCHAR"/>
>     <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
>     <column name="MODIFIED" type="TIMESTAMP"/>
>     <column name="CREATED" type="TIMESTAMP"/>
>     <column name="LAST_LOGIN" type="TIMESTAMP"/>
>     <column name="OBJECTDATA" type="VARBINARY"/>
>     <column name="TEAM_ID" required="true" type="INTEGER"/>
>     <unique>
>         <unique-column name="LOGIN_NAME"/>
>     </unique>
>     <foreign-key foreignTable="TEAM">
>         <reference local="TEAM_ID" foreign="ID"/>
>     </foreign-key>
>   </table>
>
>   <table name="TEAM">
>     <column name="ID" required="true" autoIncrement="true"
> primaryKey="true" type="INTEGER"/>
>     <column name="NAME" required="true" type="VARCHAR" size="255"/>
>     <column name="DESCRIPTION" required="true" type="VARCHAR"
> size="255"/>
>   </table>
>
> <table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
> baseClass="<package>.nebula.om.TurbineUserAdapter"
> basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
>     <column name="USER_ID" primaryKey="true" required="true"
> type="INTEGER" autoIncrement="true"/>
>   </table>
>
> Everything gets defined correctly, and I have added the definitions to
> my TurbineMapBuilderAdapter and both my TurbineUserAdapter and
> TurbinePeerAdapter classes. The problem is that torque when
> autogenerating the BaseTeam.java files, casts all of its "Users" to
> TurbineUsers and hence cannot find the setTeamId(NumberKey key) method.
> Is there a better way to do this? Is there a way to do this? (I didn't
> want to change the cast statements in the generated code, cause I would
> lose it each time I regened from torque.) Or am I just asking to hit my
> head against a wall?
>
> Thanks in advance,
>
> -cam.
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Diederik de Groot <dd...@talon.nl>.
I actually found out how to update users now. I must say it's quite a bit of typing. I have one question though. I used underscores in my fieldnames in the database descriptions so they come out to be nice JavaNames. Problem in the sample on "Extend User Howto" the implement "Initials". I recreated this to the best of my ability. Problem is where do i define what in what case.

  <table name="TURBINE_USER" idMethod="idbroker">
    <column name="USER_ID" required="true" primaryKey="true" type="INTEGER"/>
    <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
    <column name="PASSWORD_VALUE" required="true" size="32" type="VARCHAR"/>
    <column name="INITIALS" size="8" type="VARCHAR"/>
    <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
    <column name="MIDDLE_NAME" size="15" type="VARCHAR"/>
    <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
    <column name="EMAIL" size="99" type="VARCHAR"/>
    <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
    <column name="MODIFIED" type="TIMESTAMP"/>
    <column name="CREATED" type="TIMESTAMP"/>
    <column name="LAST_LOGIN" type="TIMESTAMP"/>
    <column name="HOME_STREET" size="70" type="VARCHAR"/>
    <column name="HOME_NUMBER" size="5" type="VARCHAR"/>
    <column name="HOME_POSTAL_CODE" size="6" type="VARCHAR"/>
    <column name="HOME_CITY" size="35" type="VARCHAR"/>
    <column name="HOME_PROVINCE" size="35" type="VARCHAR"/>
    <column name="HOME_COUNTRY" size="35" type="VARCHAR"/>
    <column name="PHONE_NUMBER" size="14" type="VARCHAR"/>
    <column name="MOBILE_NUMBER" size="14" type="VARCHAR"/>
    <column name="GENDER" size="1" type="CHAR"/>
    <column name="PLACE_OF_BIRTH" size="35" type="VARCHAR"/>
    <column name="PAYMENT_METHOD" type="CHAR" size="1"/>
    <column name="BANK_ACCOUNT_NUMBER" type="VARCHAR" size="11"/>
    <column name="CARD_NUMBER" type="VARCHAR" size="16"/>
    <column name="CARD_HOLDER_NAME" type="VARCHAR" size="35"/>
    <column name="OBJECTDATA" type="VARBINARY"/>
    <unique>
        <unique-column name="LOGIN_NAME"/>
    </unique>        
  </table>

For now i only added String like fields. Later i want to add Others aswell, but still have to find out how to define them as Integer, Blob etc...

TurbineUserAdapter looks like this :

public class TurbineUserAdapter extends TurbineUser
{
    public static final String MIDDLENAME    = "MIDDLE_NAME";
    ......
    ......
    ......

    public NumberKey getUserId()
    {
        return (NumberKey) getPrimaryKey();
    }

 //MIDDLENAME
    public void setMiddleName(String middleName)
    {
        setPerm(MIDDLENAME, middleName);
    }

    public String getMiddleName()
    {
        String tmp = null;
        try
        {
            tmp = (String) getPerm(MIDDLENAME);
            if ( tmp.length() == 0 )
                tmp = null;
        }
        catch ( Exception e )
        {
        }
        return tmp;
    }

    .....
    .....
    .....
}

TurbineUserPeerAdapter looks like this :
public class TurbineUserPeerAdapter extends TurbineUserPeer
{
    private static final TurbineMapBuilderAdapter mapBuilder =
        (TurbineMapBuilderAdapter) getMapBuilder();

    public static final String MIDDLENAME = mapBuilder.getUser_MiddleName();
    .....
    .....
    .....

}

TurbineMapBuilderAdapter looks like this :
public class TurbineMapBuilderAdapter extends TurbineMapBuilder
{
    /*
     * Note: The getUser_*() methods in this class should be static, but
     * getTableUser() and the initial field level methods are incorrectly
     * declared in TurbineMapBuilder and hence we must use non-static methods
     * here.
     */

    public static String getMiddleName()
    {
        return "MIDDLE_NAME";
    }

    public String getUser_MiddleName()
    {
        return getTableUser() + '.' + getMiddleName();
    }

}

I can't seem to find out which one does represent entries in the database and which ones are just intermediate variables. So where should i use underscores, capitals etc... Maybe one of you can help me out.

Thanks,

Diederik



----- Original Message ----- 
From: "Diederik de Groot" <dd...@talon.nl>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Sunday, March 03, 2002 5:20 PM
Subject: Re: Extending Turbine User


Having read all this information about extending Turbine User. How do i actually use the new user. I can't figure out how to use my new Member user.

I've extended User conform to the Extend User Howto specification. Calling my new user "Member". I'm using flux so i added a some new fields to the userform and hoped that i could save these fields using this syntax. 

public void doUpdate(RunData data, Context context)
        throws Exception
{
         Member member = (Member)TurbineSecurity.getUser(username);
         data.getParameters().setProperties(member);
         Date now = new Date();
         member.setCreateDate(now);
         member.setLastLogin(new Date(0));
         member.save();
}

Do i have to Extend TurbineSecurity and Flux's SecurityTool to incorporate the new fields I added or is there a more direct way to achieve my goal. Can i for example simply get all the fields i added from the form post and use 

member.middlename=data.getParameters().getString("middlename");

(this doesn't seem to work by the way). Is there any way to rethink this whole extending procedure and maybe have ant recreate the whole extention for us. Including flux i hope. 

I'm getting a bit frustrated here. Not banging my head into the wall just now, but getting there.

Thanks,

Diederik de Groot
Talon V.o.F



----- Original Message ----- 
From: "Cameron Cole" <cw...@yahoo.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Tuesday, February 26, 2002 11:00 PM
Subject: Extending Turbine User


> Good day all,
> 
> I have been having great success with Turbine over the past bit but have
> hit a bit of a roadblock yesterday and today. First I needed to extend
> Turbine user to include some extra fields, phone numbers to be exact, so
> I read the how-to and everything went fine, I created a NebulaUser and
> extended TurbineUser. However now, I am attempting to have a Turbine
> user be part of a "Team", and I am now having some trouble :) I modified
> my nebula-schema.xml as follows: (nebula is my app/project name, b/c it
> is ill defined and nebulous :)
> 
>   <table name="TURBINE_USER" idMethod="idbroker">
>     <column name="USER_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>     <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
>     <column name="PASSWORD_VALUE" required="true" size="32"
> type="VARCHAR"/>
>     <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
>     <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
>     <column name="EMAIL" size="99" type="VARCHAR"/>
>     <column name="HOMEPHONE" size="20" type="VARCHAR"/>
>     <column name="WORKPHONE" size="20" type="VARCHAR"/>
>     <column name="CELLPHONE" size="20" type="VARCHAR"/>
>     <column name="PAGER" size="20" type="VARCHAR"/>
>     <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
>     <column name="MODIFIED" type="TIMESTAMP"/>
>     <column name="CREATED" type="TIMESTAMP"/>
>     <column name="LAST_LOGIN" type="TIMESTAMP"/>
>     <column name="OBJECTDATA" type="VARBINARY"/>
>     <column name="TEAM_ID" required="true" type="INTEGER"/>
>     <unique>
>         <unique-column name="LOGIN_NAME"/>
>     </unique>        
>     <foreign-key foreignTable="TEAM">
>         <reference local="TEAM_ID" foreign="ID"/>
>     </foreign-key>    
>   </table>
> 
>   <table name="TEAM">
>     <column name="ID" required="true" autoIncrement="true"
> primaryKey="true" type="INTEGER"/>
>     <column name="NAME" required="true" type="VARCHAR" size="255"/>
>     <column name="DESCRIPTION" required="true" type="VARCHAR"
> size="255"/>
>   </table>
> 
> <table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
> baseClass="<package>.nebula.om.TurbineUserAdapter"
> basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
>     <column name="USER_ID" primaryKey="true" required="true"
> type="INTEGER" autoIncrement="true"/>
>   </table>
> 
> Everything gets defined correctly, and I have added the definitions to
> my TurbineMapBuilderAdapter and both my TurbineUserAdapter and
> TurbinePeerAdapter classes. The problem is that torque when
> autogenerating the BaseTeam.java files, casts all of its "Users" to
> TurbineUsers and hence cannot find the setTeamId(NumberKey key) method.
> Is there a better way to do this? Is there a way to do this? (I didn't
> want to change the cast statements in the generated code, cause I would
> lose it each time I regened from torque.) Or am I just asking to hit my
> head against a wall? 
> 
> Thanks in advance,
> 
> -cam.
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


Re: Extending Turbine User

Posted by Diederik de Groot <dd...@talon.nl>.
Having read all this information about extending Turbine User. How do i actually use the new user. I can't figure out how to use my new Member user.

I've extended User conform to the Extend User Howto specification. Calling my new user "Member". I'm using flux so i added a some new fields to the userform and hoped that i could save these fields using this syntax. 

public void doUpdate(RunData data, Context context)
        throws Exception
{
         Member member = (Member)TurbineSecurity.getUser(username);
         data.getParameters().setProperties(member);
         Date now = new Date();
         member.setCreateDate(now);
         member.setLastLogin(new Date(0));
         member.save();
}

Do i have to Extend TurbineSecurity and Flux's SecurityTool to incorporate the new fields I added or is there a more direct way to achieve my goal. Can i for example simply get all the fields i added from the form post and use 

member.middlename=data.getParameters().getString("middlename");

(this doesn't seem to work by the way). Is there any way to rethink this whole extending procedure and maybe have ant recreate the whole extention for us. Including flux i hope. 

I'm getting a bit frustrated here. Not banging my head into the wall just now, but getting there.

Thanks,

Diederik de Groot
Talon V.o.F



----- Original Message ----- 
From: "Cameron Cole" <cw...@yahoo.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Tuesday, February 26, 2002 11:00 PM
Subject: Extending Turbine User


> Good day all,
> 
> I have been having great success with Turbine over the past bit but have
> hit a bit of a roadblock yesterday and today. First I needed to extend
> Turbine user to include some extra fields, phone numbers to be exact, so
> I read the how-to and everything went fine, I created a NebulaUser and
> extended TurbineUser. However now, I am attempting to have a Turbine
> user be part of a "Team", and I am now having some trouble :) I modified
> my nebula-schema.xml as follows: (nebula is my app/project name, b/c it
> is ill defined and nebulous :)
> 
>   <table name="TURBINE_USER" idMethod="idbroker">
>     <column name="USER_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>     <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
>     <column name="PASSWORD_VALUE" required="true" size="32"
> type="VARCHAR"/>
>     <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
>     <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
>     <column name="EMAIL" size="99" type="VARCHAR"/>
>     <column name="HOMEPHONE" size="20" type="VARCHAR"/>
>     <column name="WORKPHONE" size="20" type="VARCHAR"/>
>     <column name="CELLPHONE" size="20" type="VARCHAR"/>
>     <column name="PAGER" size="20" type="VARCHAR"/>
>     <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
>     <column name="MODIFIED" type="TIMESTAMP"/>
>     <column name="CREATED" type="TIMESTAMP"/>
>     <column name="LAST_LOGIN" type="TIMESTAMP"/>
>     <column name="OBJECTDATA" type="VARBINARY"/>
>     <column name="TEAM_ID" required="true" type="INTEGER"/>
>     <unique>
>         <unique-column name="LOGIN_NAME"/>
>     </unique>        
>     <foreign-key foreignTable="TEAM">
>         <reference local="TEAM_ID" foreign="ID"/>
>     </foreign-key>    
>   </table>
> 
>   <table name="TEAM">
>     <column name="ID" required="true" autoIncrement="true"
> primaryKey="true" type="INTEGER"/>
>     <column name="NAME" required="true" type="VARCHAR" size="255"/>
>     <column name="DESCRIPTION" required="true" type="VARCHAR"
> size="255"/>
>   </table>
> 
> <table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
> baseClass="<package>.nebula.om.TurbineUserAdapter"
> basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
>     <column name="USER_ID" primaryKey="true" required="true"
> type="INTEGER" autoIncrement="true"/>
>   </table>
> 
> Everything gets defined correctly, and I have added the definitions to
> my TurbineMapBuilderAdapter and both my TurbineUserAdapter and
> TurbinePeerAdapter classes. The problem is that torque when
> autogenerating the BaseTeam.java files, casts all of its "Users" to
> TurbineUsers and hence cannot find the setTeamId(NumberKey key) method.
> Is there a better way to do this? Is there a way to do this? (I didn't
> want to change the cast statements in the generated code, cause I would
> lose it each time I regened from torque.) Or am I just asking to hit my
> head against a wall? 
> 
> Thanks in advance,
> 
> -cam.
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

Re: Extending Turbine User

Posted by Scott Eade <se...@backstagetech.com.au>.
If it is your first time extending turbine_user you may be better off
applying the exact example from the howto to the newapp application to see a
working example.  From there you can move on to trying it on your own
creation.

Scott



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Cameron Cole <cw...@yahoo.com>.
On Tue, 2002-02-26 at 18:51, Scott Eade wrote:
> Cam,
> 
> I'm scratching my head here.  What methods in BaseTeam.java return
> TurbineUser objects instead of NebulaUser objects?
> 
> Scott
> 
Hi Scott,

Actually there are two errors. The first is that BaseTeam is unable to
resolve the symbol for TurbineUser at compile time. I then manually add
in:

import org.apache.turbine.om.security.TurbineUser;
import org.apache.turbine.om.security.peer.TurbineUserPeer;

and BaseTeam.setId(NumberKey v) can't be found. It appears that when the
id is set on the BaseTeam it attempts to update all TurbineUsers that
contained within the team (correctly). However it fails to find the
TurbineUser.setTeamId(v) method, so I get a compile time error that it
is unable to resolve the symbol Method: setTeamId()

    /**
     * Set the value of Id
     */
     public void setId(NumberKey v ) throws Exception
     {
          // update associated TurbineUser
          if (collTurbineUsers != null )
          {
              for (int i=0; i<collTurbineUsers.size(); i++)
              {
                  ((TurbineUser)collTurbineUsers.get(i))
                      .setTeamId(v);
              }
          }
         if ( !ObjectUtils.equals(this.id, v) )
        {
                       if (this.id == null)
            {
                this.id = new NumberKey(v);
            }
            else
            {
                this.id.setValue(v);
            }
                      setModified(true);
        }
     }

I may have just done something really dumb here, but I have been looking
at it too long and am unable to see the forest for the trees. :) Please
tell me if it looks like I have done something foolish.

I have been tooling through the source code for the generated peers and
the TurbineUser, TurbineUserPeer and TurbineMapBuilder but I don't think
I have a firm grasp of how all of these pieces fit together to form the
peers system. It works nice and magically, but could someone explain
what each of these classes performs from a functional perspective?

Thanks everyone,

-cam.

> > From: Cameron Cole <cw...@yahoo.com>
> > Reply-To: "Turbine Users List" <tu...@jakarta.apache.org>
> > Date: 26 Feb 2002 17:00:14 -0500
> > To: Turbine Users List <tu...@jakarta.apache.org>
> > Subject: Extending Turbine User
> > 
> > Good day all,
> > 
> > I have been having great success with Turbine over the past bit but have
> > hit a bit of a roadblock yesterday and today. First I needed to extend
> > Turbine user to include some extra fields, phone numbers to be exact, so
> > I read the how-to and everything went fine, I created a NebulaUser and
> > extended TurbineUser. However now, I am attempting to have a Turbine
> > user be part of a "Team", and I am now having some trouble :) I modified
> > my nebula-schema.xml as follows: (nebula is my app/project name, b/c it
> > is ill defined and nebulous :)
> > 
> > <table name="TURBINE_USER" idMethod="idbroker">
> >   <column name="USER_ID" required="true" primaryKey="true"
> > type="INTEGER"/>
> >   <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
> >   <column name="PASSWORD_VALUE" required="true" size="32"
> > type="VARCHAR"/>
> >   <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
> >   <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
> >   <column name="EMAIL" size="99" type="VARCHAR"/>
> >   <column name="HOMEPHONE" size="20" type="VARCHAR"/>
> >   <column name="WORKPHONE" size="20" type="VARCHAR"/>
> >   <column name="CELLPHONE" size="20" type="VARCHAR"/>
> >   <column name="PAGER" size="20" type="VARCHAR"/>
> >   <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
> >   <column name="MODIFIED" type="TIMESTAMP"/>
> >   <column name="CREATED" type="TIMESTAMP"/>
> >   <column name="LAST_LOGIN" type="TIMESTAMP"/>
> >   <column name="OBJECTDATA" type="VARBINARY"/>
> >   <column name="TEAM_ID" required="true" type="INTEGER"/>
> >   <unique>
> >       <unique-column name="LOGIN_NAME"/>
> >   </unique>      
> >   <foreign-key foreignTable="TEAM">
> >       <reference local="TEAM_ID" foreign="ID"/>
> >   </foreign-key> 
> > </table>
> > 
> > <table name="TEAM">
> >   <column name="ID" required="true" autoIncrement="true"
> > primaryKey="true" type="INTEGER"/>
> >   <column name="NAME" required="true" type="VARCHAR" size="255"/>
> >   <column name="DESCRIPTION" required="true" type="VARCHAR"
> > size="255"/>
> > </table>
> > 
> > <table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
> > baseClass="<package>.nebula.om.TurbineUserAdapter"
> > basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
> >   <column name="USER_ID" primaryKey="true" required="true"
> > type="INTEGER" autoIncrement="true"/>
> > </table>
> > 
> > Everything gets defined correctly, and I have added the definitions to
> > my TurbineMapBuilderAdapter and both my TurbineUserAdapter and
> > TurbinePeerAdapter classes. The problem is that torque when
> > autogenerating the BaseTeam.java files, casts all of its "Users" to
> > TurbineUsers and hence cannot find the setTeamId(NumberKey key) method.
> > Is there a better way to do this? Is there a way to do this? (I didn't
> > want to change the cast statements in the generated code, cause I would
> > lose it each time I regened from torque.) Or am I just asking to hit my
> > head against a wall?
> > 
> > Thanks in advance,
> > 
> > -cam.
> > 
> > 
> > 
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> > 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Scott Eade <se...@backstagetech.com.au>.
Cam,

I'm scratching my head here.  What methods in BaseTeam.java return
TurbineUser objects instead of NebulaUser objects?

Scott

> From: Cameron Cole <cw...@yahoo.com>
> Reply-To: "Turbine Users List" <tu...@jakarta.apache.org>
> Date: 26 Feb 2002 17:00:14 -0500
> To: Turbine Users List <tu...@jakarta.apache.org>
> Subject: Extending Turbine User
> 
> Good day all,
> 
> I have been having great success with Turbine over the past bit but have
> hit a bit of a roadblock yesterday and today. First I needed to extend
> Turbine user to include some extra fields, phone numbers to be exact, so
> I read the how-to and everything went fine, I created a NebulaUser and
> extended TurbineUser. However now, I am attempting to have a Turbine
> user be part of a "Team", and I am now having some trouble :) I modified
> my nebula-schema.xml as follows: (nebula is my app/project name, b/c it
> is ill defined and nebulous :)
> 
> <table name="TURBINE_USER" idMethod="idbroker">
>   <column name="USER_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>   <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
>   <column name="PASSWORD_VALUE" required="true" size="32"
> type="VARCHAR"/>
>   <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
>   <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
>   <column name="EMAIL" size="99" type="VARCHAR"/>
>   <column name="HOMEPHONE" size="20" type="VARCHAR"/>
>   <column name="WORKPHONE" size="20" type="VARCHAR"/>
>   <column name="CELLPHONE" size="20" type="VARCHAR"/>
>   <column name="PAGER" size="20" type="VARCHAR"/>
>   <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
>   <column name="MODIFIED" type="TIMESTAMP"/>
>   <column name="CREATED" type="TIMESTAMP"/>
>   <column name="LAST_LOGIN" type="TIMESTAMP"/>
>   <column name="OBJECTDATA" type="VARBINARY"/>
>   <column name="TEAM_ID" required="true" type="INTEGER"/>
>   <unique>
>       <unique-column name="LOGIN_NAME"/>
>   </unique>      
>   <foreign-key foreignTable="TEAM">
>       <reference local="TEAM_ID" foreign="ID"/>
>   </foreign-key> 
> </table>
> 
> <table name="TEAM">
>   <column name="ID" required="true" autoIncrement="true"
> primaryKey="true" type="INTEGER"/>
>   <column name="NAME" required="true" type="VARCHAR" size="255"/>
>   <column name="DESCRIPTION" required="true" type="VARCHAR"
> size="255"/>
> </table>
> 
> <table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
> baseClass="<package>.nebula.om.TurbineUserAdapter"
> basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
>   <column name="USER_ID" primaryKey="true" required="true"
> type="INTEGER" autoIncrement="true"/>
> </table>
> 
> Everything gets defined correctly, and I have added the definitions to
> my TurbineMapBuilderAdapter and both my TurbineUserAdapter and
> TurbinePeerAdapter classes. The problem is that torque when
> autogenerating the BaseTeam.java files, casts all of its "Users" to
> TurbineUsers and hence cannot find the setTeamId(NumberKey key) method.
> Is there a better way to do this? Is there a way to do this? (I didn't
> want to change the cast statements in the generated code, cause I would
> lose it each time I regened from torque.) Or am I just asking to hit my
> head against a wall?
> 
> Thanks in advance,
> 
> -cam.
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Cameron Cole <cw...@yahoo.com>.
On Sun, 2002-03-03 at 17:15, Scott Eade wrote:

> > 
> >> 3. Make the same substitution on the following line.
> > 
> > What line? :)
> > 
> Should I have said "the next line", "the line following" or "line 248"? ;-)
> > <!-- SNIP -->
> > 

HAHAAHAH, funny when you read something but totally interpret it differently :)) Sorry about that, my bad :)

-cam.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Scott Eade <se...@backstagetech.com.au>.
> From: Cameron Cole <cw...@yahoo.com>
> <!-- SNIP -->
>> 
>> 1. In Object.vm, search for (including the quotes):
>>         "!ObjectUtils.equals(this."
>> This is the first of the two problem lines.
>> 2. On the line that was just found (line 247 in my cut) change:
>>         $clo
>> to (include the quotes):
>>         "get${column.JavaName}()"
> 
> Done.
> 
>> 3. Make the same substitution on the following line.
> 
> What line? :)
> 
Should I have said "the next line", "the line following" or "line 248"? ;-)
> <!-- SNIP -->
> 
>> Not sure which 4 classes you mean.  If it was the classes mentioned in the
>> class hierarchy above then (and I don't think it is):
>> 
> 
> I meant the 4 peer classes( X.java, XPeer.java, BaseX.java,
> BaseXPeer.java) but I don't need an explaination of X.java or
> XPeer.java, I understand their purpose. I just wanted to know what
> BaseX.java and BaseXPeer.java's purpose in life was.

BaseX.java provides the accessor methods for the data that make up the
object as well as methods for getting at related objects and convenience
methods that assist with saving the object.  Look at the methods it defines
- this is what it is for. ;-)  X.java extends BaseX.java to provide you with
somewhere to extend the generated class - your code should only ever refer
to X.java.

BaseXPeer.java provides convenience methods for retrieving individual or
collections of X objects.  Xpeer.java again provides you with somewhere to
extend the generated class.  I understand from a recent post to turbine-dev
that the long term plan is to move away from the static peers, but I don't
know what will be used in its place nor the reasoning behind the plan.
> 
>> Good luck,
> 
> This should work, if we change the way the torque gen'd classes access
> their object properties. However won't this change everything that is
> generated from getting properties directly (ie: this.property) to via
> the accessor (this.getProperty()). Isn't this the "right" way to do
> this? Shouldn't you always access properties via their accessors and not
> directly?

I have provided you with a hack in the worst sense of the word.  There are
plenty of other places where code is generated that accesses the properties
directly.  One thing to remember is that torque is generating the code that
deals directly with the properties (e.g. the code for setDescription() for
Team) as well as code that use them (e.g. code that uses setDescription()).
The code that uses the properties outside the accessor method being defined
should probably use the accessor methods.

> BTW, thanks for all your time and effort on this so far Scott, :) I'll
> test this and report back as soon as I get that last line to modify in
> Object.vm. Gotta run for a bit, so I'll try later on tonight.

No problem - just following the path of those before me.
> 
> Take it easy,
> 
> -cam.
> 
Cheers,

Scott


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Cameron Cole <cw...@yahoo.com>.
On Sun, 2002-03-03 at 04:28, Scott Eade wrote:


> // Confession: Not sure if you should be putting the NumberKey or the
> // underlying number into the perm hashtable.

According to some code I wrote, it appears numberkeys are stored as
Integers in the perm hash.

<!-- SNIP -->
> 
> 1. In Object.vm, search for (including the quotes):
>         "!ObjectUtils.equals(this."
> This is the first of the two problem lines.
> 2. On the line that was just found (line 247 in my cut) change:
>         $clo
> to (include the quotes):
>         "get${column.JavaName}()"

Done.

> 3. Make the same substitution on the following line.

What line? :)

> 
> That's it.  After making this change I can "ant init" and both the sql and
> the generated methods look good.  Give it a whirl and let me know how you
> get on.

I'll test as soon as I get that last line. Or tell me which line you are
now searching for and I'll run with it myself.

<!-- SNIP -->

> Not sure which 4 classes you mean.  If it was the classes mentioned in the
> class hierarchy above then (and I don't think it is):
> 

I meant the 4 peer classes( X.java, XPeer.java, BaseX.java,
BaseXPeer.java) but I don't need an explaination of X.java or
XPeer.java, I understand their purpose. I just wanted to know what
BaseX.java and BaseXPeer.java's purpose in life was. 

> Good luck,

This should work, if we change the way the torque gen'd classes access
their object properties. However won't this change everything that is
generated from getting properties directly (ie: this.property) to via
the accessor (this.getProperty()). Isn't this the "right" way to do
this? Shouldn't you always access properties via their accessors and not
directly?

BTW, thanks for all your time and effort on this so far Scott, :) I'll
test this and report back as soon as I get that last line to modify in
Object.vm. Gotta run for a bit, so I'll try later on tonight.

Take it easy,

-cam.

> 
> Scott
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Scott Eade <se...@backstagetech.com.au>.
Cam,

I have some code that compiles and I think it will work too.  Due to other
commitments however I cannot test it for you ;-)

> After doing a bunch more testing over the last little while, I have come
> to the conclusion that this is easier to implement without foreign keys
> and by coding up the accessor methods on my own. There were several
> problems. First you have an inheritance hierarchy like this:
> 
> TurbineUser
>   |
>   |
> TurbineUserAdapter
>   |
>   |
> BaseNebulaUser
>   |
>   |
> NebulaUser

I myself have a foreign key column included in my TurbineUser table, but in
my case I hadn't even noticed the missing methods to exploit the
relationship.

> BaseNebulaUser is a torque generated class and as such I didn't want to
> touch it at all. It wanted the NumberKey team_id property available to
> it, so I had to add that to TurbineUserAdapter, but that property was
> not automatically set when you fetched an object from the database
> (TurbineUser plays differently then most torque objects it appears), as
> the actual data for the TEAM_ID field appears to be put into the
> permStorage Hashtable, so when you attempted to do something like:
> 
> NebulaUser user = (NebulaUser)data.getUser();
> Team team = user.getTeam();
> String name = team.getName(); // <----- NullPointer here
> 

Yes, you don't want to go editing the Base* classes - the reason
TurbineUserAdapter is introduced in the extend-user-howto is to provide us
with somewhere to define the columns we are adding.

> The user.getTeam() returns null because the torque generated code in
> BaseNebulaUser required the presence of the team_id field, and that
> field *must* be set or it returns null. The gen'd code is something
> like: (I am tired and pulling this from memory so it won't be exact :)
> 
> // in BaseNebulaUser
> 
> public Team getTeam() {
> aTeam = null;
> if (aTeam == null && !ObjectUtils.equals(this.team_id, null)) {
> aTeam = TeamPeer.retrieveByPK(this.team_id);
> // blah blah
> }
> setModified(true);
> return aTeam;
> }

The problem here is that this.team_id is not defined because TurbineUser is
implemented differently to the other OM classes.  What we really need is for
the "this.team_id" to become "this.getTeamId()", and this is in fact the fix
you can try (see below for how to achieve this).

> and because this.team_id was always null, getTeam always returned null.
> I could have solved this by putting the getTeam() method in NebulaUser
> and changing it so that is called getPerm(...) and set team_id properly
> before actually talking to TeamPeer. However then I had to have my
> setters in TurbineUserAdapter as I had to modify them to make certain
> that they updated the permStorage of TurbineUser properly. All in all,
> it just wasn't very clean. I think the long and short of it is, don't
> extend TurbineUser *and* try to create any kind of a composite/super
> classing (?) with your extended user.

TurbineUserAdapter is all about providing the get/set methods for the
columns you are adding.  You should be providing:

// Confession: Not sure if you should be putting the NumberKey or the
// underlying number into the perm hashtable.
public void setTeamId(NumberKey teamId)
{
    setPerm("TEAM_ID", teamId);
}

public NumberKey getTeamId()
{
    return (NumberKey) getPerm("TEAM_ID");
}

In the schema files you want to define TEAM_ID and its foreign key
relationship in both turbine-schema.xml (TURBINE_USER) and nebula-schema.xml
(NEBULA_USER).  The entry in TURBINE_USER will result in the correct sql
being generated and the entry in NEBULA_USER will result in the correct
methods being generated in BaseNebulaUser.

So having done the standard changes as listed in the extend-user-howto, I
had three compile errors.  One of the errors was caused by the save()
methods not being generated in BaseNebulaUser - the fix for this is to apply
the patch at the bottom of the extend-user-howto.  The remaining two errors
were those relating to "this.team_id" that are mentioned above.  The fix for
these involved updating build/bin/torque/templates/om/Object.vm so that
BaseNebulaUser.getTeam() uses "this.getTeamId()" instead of "this.team_id".
I don't have a patch for you, but see if you can make it work from this
description:

1. In Object.vm, search for (including the quotes):
        "!ObjectUtils.equals(this."
This is the first of the two problem lines.
2. On the line that was just found (line 247 in my cut) change:
        $clo
to (include the quotes):
        "get${column.JavaName}()"
3. Make the same substitution on the following line.

That's it.  After making this change I can "ant init" and both the sql and
the generated methods look good.  Give it a whirl and let me know how you
get on.

> Any way, I fought with this enough tonight ;) and if this is not
> legible/sensible blame it on the hour :) If you have some more ideas, I
> would love to hear them. I would also love to hear from someone who can
> explain to me, at a reasonably high level what each of the 4 classes
> generated for the peers actually does, (well, skip the two that contain
> end user code, I get those :) and why is TurbineUser and TurbineUserPeer
> so different? They use the permStorage, where as the other om objects
> are gen'd by torque.

Not sure which 4 classes you mean.  If it was the classes mentioned in the
class hierarchy above then (and I don't think it is):

> TurbineUser
This class and the associated TurbineUserPeer are not generated by torque
because they are part of the base security service which provide an
interface to which user implementations can be written.  It happens that the
default implementation uses the database and that the only other
implementation doesn't work (ldap).  There have been some major discussions
going on over in turbine-dev about a redesigned security service and an ldap
implementation, but this is for turbine 3 (still a fair way off I think).  I
am unsure if the discussions have included any thoughts about doing the
equivalent of extending TurbineUser or perhaps including TurbineUser
operations in application transactions, it won't surprise me if the answer
is No.
>   |
>   |
> TurbineUserAdapter
This allows us to alter what will be seen by BaseNebulaUser.
>   |
>   |
> BaseNebulaUser
Obvious - generated methods.
>   |
>   |
> NebulaUser
Obvious - somewhere for you to add code that won't be wiped out with a
regen.


I actually think this stuff is a total hack.  The only saving grace is that
once you have made the changes you don't often need to give it any thought -
well not until someone starts asking questions ;-).  I'm sure I will have to
think about it further when I migrate to standalone torque in turbine 2.2,
but I'll cross that bridge later.

> Either way, time for some Zzz's
> 
> Talk to you tommorrow,
> 
> -cam.

Good luck,

Scott


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Cameron Cole <cw...@yahoo.com>.
Scott,

After doing a bunch more testing over the last little while, I have come
to the conclusion that this is easier to implement without foreign keys
and by coding up the accessor methods on my own. There were several
problems. First you have an inheritance hierarchy like this:

TurbineUser
    |
    |
TurbineUserAdapter
    |
    |
BaseNebulaUser
    |
    |
NebulaUser

BaseNebulaUser is a torque generated class and as such I didn't want to
touch it at all. It wanted the NumberKey team_id property available to
it, so I had to add that to TurbineUserAdapter, but that property was
not automatically set when you fetched an object from the database
(TurbineUser plays differently then most torque objects it appears), as
the actual data for the TEAM_ID field appears to be put into the
permStorage Hashtable, so when you attempted to do something like:

NebulaUser user = (NebulaUser)data.getUser();
Team team = user.getTeam(); 
String name = team.getName(); // <----- NullPointer here

The user.getTeam() returns null because the torque generated code in
BaseNebulaUser required the presence of the team_id field, and that
field *must* be set or it returns null. The gen'd code is something
like: (I am tired and pulling this from memory so it won't be exact :)

// in BaseNebulaUser

public Team getTeam() {
	aTeam = null;
	if (aTeam == null && !ObjectUtils.equals(this.team_id, null)) {
		aTeam = TeamPeer.retrieveByPK(this.team_id);
		// blah blah
	}
	setModified(true);
	return aTeam;
}

and because this.team_id was always null, getTeam always returned null.
I could have solved this by putting the getTeam() method in NebulaUser
and changing it so that is called getPerm(...) and set team_id properly
before actually talking to TeamPeer. However then I had to have my
setters in TurbineUserAdapter as I had to modify them to make certain
that they updated the permStorage of TurbineUser properly. All in all,
it just wasn't very clean. I think the long and short of it is, don't
extend TurbineUser *and* try to create any kind of a composite/super
classing (?) with your extended user.

Any way, I fought with this enough tonight ;) and if this is not
legible/sensible blame it on the hour :) If you have some more ideas, I
would love to hear them. I would also love to hear from someone who can
explain to me, at a reasonably high level what each of the 4 classes
generated for the peers actually does, (well, skip the two that contain
end user code, I get those :) and why is TurbineUser and TurbineUserPeer
so different? They use the permStorage, where as the other om objects
are gen'd by torque.

Either way, time for some Zzz's

Talk to you tommorrow,

-cam.

On Fri, 2002-03-01 at 02:32, Scott Eade wrote:
> Cam,
> 
> I have added ones small comment below.
> 
> I'll try and have a look at this soon - I've just been to busy to get to it
> today.
> 
> Cheers,
> 
> Scott
> 
> > From: Cameron Cole <cw...@yahoo.com>
> > 
> > OK, got it working now, but I am not terribly happy with what I had to
> > do and I am not certain that I have done everything "correctly", perhaps
> > someone can look at what I have done and add some insight into better
> > ways to accomplish this.
> > 
> > Firstly, there was one thing I forgot to add to my last note (isn't that
> > always the case :) As per the Extending Turbine User how-to, I patched
> > my Object.vm torque template with the patch at the bottom of the how-to
> > so that I could persist objects that I added to my user. (I haven't
> > tested that yet, but am assuming it still works.) This however may have
> > effected how and what methods were gen'd but I am too green at this as
> > yet to intelligently comment on that :)
> > 
> > We were close Scott, but there was one small modification that had to be
> > made when I changed the nebula-schema.xml. I had to remove the
> > foreign-key definition from the TURBINE_USER table as this caused torque
> > to generate Peers that expected lists of TurbineUsers *and* lists of
> > NebulaUsers. So the final working schema was as follows:
> > 
> > <table name="TURBINE_USER" idMethod="idbroker">
> >   <column name="USER_ID" required="true" primaryKey="true"
> > type="INTEGER"/>
> >   <column name="TEAM_ID" required="true" type="INTEGER"/>
> >   <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
> >   <column name="PASSWORD_VALUE" required="true" size="32"
> > type="VARCHAR"/>
> >   <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
> >   <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
> >   <column name="EMAIL" size="99" type="VARCHAR"/>
> >   <column name="HOMEPHONE" size="20" type="VARCHAR"/>
> >   <column name="WORKPHONE" size="20" type="VARCHAR"/>
> >   <column name="CELLPHONE" size="20" type="VARCHAR"/>
> >   <column name="PAGER" size="20" type="VARCHAR"/>
> >   <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
> >   <column name="MODIFIED" type="TIMESTAMP"/>
> >   <column name="CREATED" type="TIMESTAMP"/>
> >   <column name="LAST_LOGIN" type="TIMESTAMP"/>
> >   <column name="OBJECTDATA" type="VARBINARY"/>
> >   <unique>
> >       <unique-column name="LOGIN_NAME"/>
> >   </unique>      
> > </table>
> > 
> > <table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
> >       baseClass="<package>.nebula.om.TurbineUserAdapter"
> >       basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
> >   <column name="USER_ID" primaryKey="true" required="true"
> > type="INTEGER" autoIncrement="true"/>
> >   <column name="TEAM_ID" required="true" type="INTEGER"/>
> >   <foreign-key foreignTable="TEAM">
> >       <reference local="TEAM_ID" foreign="ID"/>
> >   </foreign-key> 
> > </table>
> > 
> > 
> > At this point torque generated all the proper sql and the om classes. I
> 
> Did the generated SQL include a foreign key reference to team_id in
> turbine_user?  My guess is it did not.  This is not an issue for MySQL, but
> could be an issue for other databases - if you care about DB enforced
> referential integrity.
> 
> > went into my TurbineMapBuilderAdapter class and modified it adding a
> > String getTeamId() and String getUser_TeamId() methods. I also modified
> > the doBuild() method to have tMap.addColumn(getTeamId(), new
> > NumberKey()); ( I am still not certain if teamid was supposed to be a
> > numberkey or an integer, but this worked ) I then modified
> > TurbineUserPeerAdapter and added in
> > 
> > public static final String TEAM_ID = mapBuilder.getUser_TeamId();
> > 
> > and in TurbineUserAdapter added one getter (public NumberKey
> > getTeamId()) and two setters (public void setTeamId(String) and public
> > void setTeamId(NumberKey)).
> > 
> > However when I compiled now BaseNebulaUser complained that it could not
> > reference this.team_id (I am assuming this should have been the property
> > generated in TurbineUser but as I didn't have access to TurbineUser I
> > modified TurbineUserAdapter.java to have a protected NumberKey team_id,
> > it couldn't be private b/c sub classes had to have access to it, this
> > was one thing that bothered me and made me think I was doing something
> > incorrectly.) At this point everything compiled.
> > 
> > I could then successfully do something like this in my code: (just
> > making this up, but something like this...)
> > 
> > 
> > Team t =
> > (Team)((Vector)TeamPeer.doSelect(CriteriaWithTeamId)).firstElement();
> > // user was just created via TurbineSecurity.addUser(user, pass);
> > t.addNebulaUser((NebulaUser)user);
> > t.save();
> > 
> > and the proper data was set in the database. I haven't had any free time
> > to continue testing. I am just about to start now. I'll let you know if
> > I run into any other issues.
> > 
> > I did have one more question though... the TEAM_ID field in TURBINE_USER
> > and NEBULA_USER, what should its property be, an integer or a NumberKey
> > from the perspective of intake? I am using intake to validate all of my
> > forms and when I attempt to map the value back from intake into my User
> > object, I get a property mismatch exception, so I am manually hitting
> > the database a second time to pull out the team by id and adding my
> > NebulaUser to the team and saving the team (and consequently the user).
> > 
> > If anyone can add some insight into what could have been done better
> > here it would be most appreciated. I don't mind trying my hand at a
> > "super classing" (?) TurbineUser doc, or making an addenum to the
> > Extending TurbineUser howto doc, but I want to ensure that my
> > information is correct before leading others down the garden path :)
> > 
> > Thanks, and hope this helps someone else as well,
> > 
> > -cam.
> > 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Scott Eade <se...@backstagetech.com.au>.
Cam,

I have added ones small comment below.

I'll try and have a look at this soon - I've just been to busy to get to it
today.

Cheers,

Scott

> From: Cameron Cole <cw...@yahoo.com>
> 
> OK, got it working now, but I am not terribly happy with what I had to
> do and I am not certain that I have done everything "correctly", perhaps
> someone can look at what I have done and add some insight into better
> ways to accomplish this.
> 
> Firstly, there was one thing I forgot to add to my last note (isn't that
> always the case :) As per the Extending Turbine User how-to, I patched
> my Object.vm torque template with the patch at the bottom of the how-to
> so that I could persist objects that I added to my user. (I haven't
> tested that yet, but am assuming it still works.) This however may have
> effected how and what methods were gen'd but I am too green at this as
> yet to intelligently comment on that :)
> 
> We were close Scott, but there was one small modification that had to be
> made when I changed the nebula-schema.xml. I had to remove the
> foreign-key definition from the TURBINE_USER table as this caused torque
> to generate Peers that expected lists of TurbineUsers *and* lists of
> NebulaUsers. So the final working schema was as follows:
> 
> <table name="TURBINE_USER" idMethod="idbroker">
>   <column name="USER_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>   <column name="TEAM_ID" required="true" type="INTEGER"/>
>   <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
>   <column name="PASSWORD_VALUE" required="true" size="32"
> type="VARCHAR"/>
>   <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
>   <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
>   <column name="EMAIL" size="99" type="VARCHAR"/>
>   <column name="HOMEPHONE" size="20" type="VARCHAR"/>
>   <column name="WORKPHONE" size="20" type="VARCHAR"/>
>   <column name="CELLPHONE" size="20" type="VARCHAR"/>
>   <column name="PAGER" size="20" type="VARCHAR"/>
>   <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
>   <column name="MODIFIED" type="TIMESTAMP"/>
>   <column name="CREATED" type="TIMESTAMP"/>
>   <column name="LAST_LOGIN" type="TIMESTAMP"/>
>   <column name="OBJECTDATA" type="VARBINARY"/>
>   <unique>
>       <unique-column name="LOGIN_NAME"/>
>   </unique>      
> </table>
> 
> <table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
>       baseClass="<package>.nebula.om.TurbineUserAdapter"
>       basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
>   <column name="USER_ID" primaryKey="true" required="true"
> type="INTEGER" autoIncrement="true"/>
>   <column name="TEAM_ID" required="true" type="INTEGER"/>
>   <foreign-key foreignTable="TEAM">
>       <reference local="TEAM_ID" foreign="ID"/>
>   </foreign-key> 
> </table>
> 
> 
> At this point torque generated all the proper sql and the om classes. I

Did the generated SQL include a foreign key reference to team_id in
turbine_user?  My guess is it did not.  This is not an issue for MySQL, but
could be an issue for other databases - if you care about DB enforced
referential integrity.

> went into my TurbineMapBuilderAdapter class and modified it adding a
> String getTeamId() and String getUser_TeamId() methods. I also modified
> the doBuild() method to have tMap.addColumn(getTeamId(), new
> NumberKey()); ( I am still not certain if teamid was supposed to be a
> numberkey or an integer, but this worked ) I then modified
> TurbineUserPeerAdapter and added in
> 
> public static final String TEAM_ID = mapBuilder.getUser_TeamId();
> 
> and in TurbineUserAdapter added one getter (public NumberKey
> getTeamId()) and two setters (public void setTeamId(String) and public
> void setTeamId(NumberKey)).
> 
> However when I compiled now BaseNebulaUser complained that it could not
> reference this.team_id (I am assuming this should have been the property
> generated in TurbineUser but as I didn't have access to TurbineUser I
> modified TurbineUserAdapter.java to have a protected NumberKey team_id,
> it couldn't be private b/c sub classes had to have access to it, this
> was one thing that bothered me and made me think I was doing something
> incorrectly.) At this point everything compiled.
> 
> I could then successfully do something like this in my code: (just
> making this up, but something like this...)
> 
> 
> Team t =
> (Team)((Vector)TeamPeer.doSelect(CriteriaWithTeamId)).firstElement();
> // user was just created via TurbineSecurity.addUser(user, pass);
> t.addNebulaUser((NebulaUser)user);
> t.save();
> 
> and the proper data was set in the database. I haven't had any free time
> to continue testing. I am just about to start now. I'll let you know if
> I run into any other issues.
> 
> I did have one more question though... the TEAM_ID field in TURBINE_USER
> and NEBULA_USER, what should its property be, an integer or a NumberKey
> from the perspective of intake? I am using intake to validate all of my
> forms and when I attempt to map the value back from intake into my User
> object, I get a property mismatch exception, so I am manually hitting
> the database a second time to pull out the team by id and adding my
> NebulaUser to the team and saving the team (and consequently the user).
> 
> If anyone can add some insight into what could have been done better
> here it would be most appreciated. I don't mind trying my hand at a
> "super classing" (?) TurbineUser doc, or making an addenum to the
> Extending TurbineUser howto doc, but I want to ensure that my
> information is correct before leading others down the garden path :)
> 
> Thanks, and hope this helps someone else as well,
> 
> -cam.
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Cameron Cole <cw...@yahoo.com>.
OK, got it working now, but I am not terribly happy with what I had to
do and I am not certain that I have done everything "correctly", perhaps
someone can look at what I have done and add some insight into better
ways to accomplish this.

Firstly, there was one thing I forgot to add to my last note (isn't that
always the case :) As per the Extending Turbine User how-to, I patched
my Object.vm torque template with the patch at the bottom of the how-to
so that I could persist objects that I added to my user. (I haven't
tested that yet, but am assuming it still works.) This however may have
effected how and what methods were gen'd but I am too green at this as
yet to intelligently comment on that :)

We were close Scott, but there was one small modification that had to be
made when I changed the nebula-schema.xml. I had to remove the
foreign-key definition from the TURBINE_USER table as this caused torque
to generate Peers that expected lists of TurbineUsers *and* lists of
NebulaUsers. So the final working schema was as follows:

  <table name="TURBINE_USER" idMethod="idbroker">
    <column name="USER_ID" required="true" primaryKey="true"
type="INTEGER"/>
    <column name="TEAM_ID" required="true" type="INTEGER"/>
    <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
    <column name="PASSWORD_VALUE" required="true" size="32"
type="VARCHAR"/>
    <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
    <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
    <column name="EMAIL" size="99" type="VARCHAR"/>
    <column name="HOMEPHONE" size="20" type="VARCHAR"/>
    <column name="WORKPHONE" size="20" type="VARCHAR"/>
    <column name="CELLPHONE" size="20" type="VARCHAR"/>
    <column name="PAGER" size="20" type="VARCHAR"/>
    <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
    <column name="MODIFIED" type="TIMESTAMP"/>
    <column name="CREATED" type="TIMESTAMP"/>
    <column name="LAST_LOGIN" type="TIMESTAMP"/>
    <column name="OBJECTDATA" type="VARBINARY"/>
    <unique>
        <unique-column name="LOGIN_NAME"/>
    </unique>        
  </table>

  <table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
        baseClass="<package>.nebula.om.TurbineUserAdapter"
        basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
    <column name="USER_ID" primaryKey="true" required="true"
type="INTEGER" autoIncrement="true"/>
    <column name="TEAM_ID" required="true" type="INTEGER"/>
    <foreign-key foreignTable="TEAM">
        <reference local="TEAM_ID" foreign="ID"/>
    </foreign-key>    
  </table>


At this point torque generated all the proper sql and the om classes. I
went into my TurbineMapBuilderAdapter class and modified it adding a
String getTeamId() and String getUser_TeamId() methods. I also modified
the doBuild() method to have tMap.addColumn(getTeamId(), new
NumberKey()); ( I am still not certain if teamid was supposed to be a
numberkey or an integer, but this worked ) I then modified
TurbineUserPeerAdapter and added in 

public static final String TEAM_ID = mapBuilder.getUser_TeamId();

and in TurbineUserAdapter added one getter (public NumberKey
getTeamId()) and two setters (public void setTeamId(String) and public
void setTeamId(NumberKey)).

However when I compiled now BaseNebulaUser complained that it could not
reference this.team_id (I am assuming this should have been the property
generated in TurbineUser but as I didn't have access to TurbineUser I
modified TurbineUserAdapter.java to have a protected NumberKey team_id,
it couldn't be private b/c sub classes had to have access to it, this
was one thing that bothered me and made me think I was doing something
incorrectly.) At this point everything compiled.

I could then successfully do something like this in my code: (just
making this up, but something like this...)


Team t =
(Team)((Vector)TeamPeer.doSelect(CriteriaWithTeamId)).firstElement();
// user was just created via TurbineSecurity.addUser(user, pass);
t.addNebulaUser((NebulaUser)user);
t.save();

and the proper data was set in the database. I haven't had any free time
to continue testing. I am just about to start now. I'll let you know if
I run into any other issues.

I did have one more question though... the TEAM_ID field in TURBINE_USER
and NEBULA_USER, what should its property be, an integer or a NumberKey
from the perspective of intake? I am using intake to validate all of my
forms and when I attempt to map the value back from intake into my User
object, I get a property mismatch exception, so I am manually hitting
the database a second time to pull out the team by id and adding my
NebulaUser to the team and saving the team (and consequently the user).

If anyone can add some insight into what could have been done better
here it would be most appreciated. I don't mind trying my hand at a
"super classing" (?) TurbineUser doc, or making an addenum to the
Extending TurbineUser howto doc, but I want to ensure that my
information is correct before leading others down the garden path :)

Thanks, and hope this helps someone else as well, 

-cam.

On Tue, 2002-02-26 at 20:10, Scott Eade wrote:
> Cam the extend-user-howto deals with the following situations:
> 
> 1. Making use of TURBINE_USER.USER_ID as a foreign key in application
> tables; and 
> 2. Adding user attributes by adding columns to TURBINE_USER.
> 
> You are actually going one step further and adding a foreign key column to
> TURBINE_USER.
> 
> I actually have a similar column in the user class for my own application
> and up to now I have defined the column in the same manner as you have.
> With this approach I do not see any methods generated in my equivalent of
> BaseTeam for obtaining user objects.  The fact that I haven't noticed this
> yet is kind of funny (at least to me).
> 
> Having spent a small amount of time experimenting with this, I offer this
> suggestion/comment:
> 
> The changes to turbine-schema.xml are necessary so that the sql that is
> generated to create the database tables is complete.  The user_id column is
> defined a second time in NebulaUser so that torque can generate code
> necessary to deal with the first of the two situations listed above.  For
> your requirement you should also duplicate the definition of team_id in
> NebulaUser, along with its foreign key so that torque will also generate the
> code you desire.
> 
> So you will have this:
> 
> <table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
> baseClass="<package>.nebula.om.TurbineUserAdapter"
> basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
>   <column name="USER_ID" primaryKey="true" required="true"
> type="INTEGER" autoIncrement="true"/>
>   <column name="TEAM_ID" required="true" type="INTEGER"/>
>   <foreign-key foreignTable="TEAM">
>       <reference local="TEAM_ID" foreign="ID"/>
>   </foreign-key>   
> </table>
> 
> I have tried generating the OM code from this and it looks pretty good.  I
> don't have time right now to retrofit this into my application to ensure
> everything is okay, but it certainly looks good.
> 
> Let me know how you get on.  It would be great if you can confirm that this
> works as intended.  We can then look at updating the extend-user-howto to
> list this additional situation and the solution.
> 
> Cheers,
> 
> Scott
> 
> 
> > From: Cameron Cole <cw...@yahoo.com>
> > Reply-To: "Turbine Users List" <tu...@jakarta.apache.org>
> > Date: 26 Feb 2002 17:00:14 -0500
> > To: Turbine Users List <tu...@jakarta.apache.org>
> > Subject: Extending Turbine User
> > 
> > Good day all,
> > 
> > I have been having great success with Turbine over the past bit but have
> > hit a bit of a roadblock yesterday and today. First I needed to extend
> > Turbine user to include some extra fields, phone numbers to be exact, so
> > I read the how-to and everything went fine, I created a NebulaUser and
> > extended TurbineUser. However now, I am attempting to have a Turbine
> > user be part of a "Team", and I am now having some trouble :) I modified
> > my nebula-schema.xml as follows: (nebula is my app/project name, b/c it
> > is ill defined and nebulous :)
> > 
> > <table name="TURBINE_USER" idMethod="idbroker">
> >   <column name="USER_ID" required="true" primaryKey="true"
> > type="INTEGER"/>
> >   <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
> >   <column name="PASSWORD_VALUE" required="true" size="32"
> > type="VARCHAR"/>
> >   <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
> >   <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
> >   <column name="EMAIL" size="99" type="VARCHAR"/>
> >   <column name="HOMEPHONE" size="20" type="VARCHAR"/>
> >   <column name="WORKPHONE" size="20" type="VARCHAR"/>
> >   <column name="CELLPHONE" size="20" type="VARCHAR"/>
> >   <column name="PAGER" size="20" type="VARCHAR"/>
> >   <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
> >   <column name="MODIFIED" type="TIMESTAMP"/>
> >   <column name="CREATED" type="TIMESTAMP"/>
> >   <column name="LAST_LOGIN" type="TIMESTAMP"/>
> >   <column name="OBJECTDATA" type="VARBINARY"/>
> >   <column name="TEAM_ID" required="true" type="INTEGER"/>
> >   <unique>
> >       <unique-column name="LOGIN_NAME"/>
> >   </unique>      
> >   <foreign-key foreignTable="TEAM">
> >       <reference local="TEAM_ID" foreign="ID"/>
> >   </foreign-key> 
> > </table>
> > 
> > <table name="TEAM">
> >   <column name="ID" required="true" autoIncrement="true"
> > primaryKey="true" type="INTEGER"/>
> >   <column name="NAME" required="true" type="VARCHAR" size="255"/>
> >   <column name="DESCRIPTION" required="true" type="VARCHAR"
> > size="255"/>
> > </table>
> > 
> > <table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
> > baseClass="<package>.nebula.om.TurbineUserAdapter"
> > basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
> >   <column name="USER_ID" primaryKey="true" required="true"
> > type="INTEGER" autoIncrement="true"/>
> > </table>
> > 
> > Everything gets defined correctly, and I have added the definitions to
> > my TurbineMapBuilderAdapter and both my TurbineUserAdapter and
> > TurbinePeerAdapter classes. The problem is that torque when
> > autogenerating the BaseTeam.java files, casts all of its "Users" to
> > TurbineUsers and hence cannot find the setTeamId(NumberKey key) method.
> > Is there a better way to do this? Is there a way to do this? (I didn't
> > want to change the cast statements in the generated code, cause I would
> > lose it each time I regened from torque.) Or am I just asking to hit my
> > head against a wall?
> > 
> > Thanks in advance,
> > 
> > -cam.
> > 
> > 
> > 
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> > 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Extending Turbine User

Posted by Scott Eade <se...@backstagetech.com.au>.
Cam the extend-user-howto deals with the following situations:

1. Making use of TURBINE_USER.USER_ID as a foreign key in application
tables; and 
2. Adding user attributes by adding columns to TURBINE_USER.

You are actually going one step further and adding a foreign key column to
TURBINE_USER.

I actually have a similar column in the user class for my own application
and up to now I have defined the column in the same manner as you have.
With this approach I do not see any methods generated in my equivalent of
BaseTeam for obtaining user objects.  The fact that I haven't noticed this
yet is kind of funny (at least to me).

Having spent a small amount of time experimenting with this, I offer this
suggestion/comment:

The changes to turbine-schema.xml are necessary so that the sql that is
generated to create the database tables is complete.  The user_id column is
defined a second time in NebulaUser so that torque can generate code
necessary to deal with the first of the two situations listed above.  For
your requirement you should also duplicate the definition of team_id in
NebulaUser, along with its foreign key so that torque will also generate the
code you desire.

So you will have this:

<table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
baseClass="<package>.nebula.om.TurbineUserAdapter"
basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
  <column name="USER_ID" primaryKey="true" required="true"
type="INTEGER" autoIncrement="true"/>
  <column name="TEAM_ID" required="true" type="INTEGER"/>
  <foreign-key foreignTable="TEAM">
      <reference local="TEAM_ID" foreign="ID"/>
  </foreign-key>   
</table>

I have tried generating the OM code from this and it looks pretty good.  I
don't have time right now to retrofit this into my application to ensure
everything is okay, but it certainly looks good.

Let me know how you get on.  It would be great if you can confirm that this
works as intended.  We can then look at updating the extend-user-howto to
list this additional situation and the solution.

Cheers,

Scott


> From: Cameron Cole <cw...@yahoo.com>
> Reply-To: "Turbine Users List" <tu...@jakarta.apache.org>
> Date: 26 Feb 2002 17:00:14 -0500
> To: Turbine Users List <tu...@jakarta.apache.org>
> Subject: Extending Turbine User
> 
> Good day all,
> 
> I have been having great success with Turbine over the past bit but have
> hit a bit of a roadblock yesterday and today. First I needed to extend
> Turbine user to include some extra fields, phone numbers to be exact, so
> I read the how-to and everything went fine, I created a NebulaUser and
> extended TurbineUser. However now, I am attempting to have a Turbine
> user be part of a "Team", and I am now having some trouble :) I modified
> my nebula-schema.xml as follows: (nebula is my app/project name, b/c it
> is ill defined and nebulous :)
> 
> <table name="TURBINE_USER" idMethod="idbroker">
>   <column name="USER_ID" required="true" primaryKey="true"
> type="INTEGER"/>
>   <column name="LOGIN_NAME" required="true" size="32" type="VARCHAR"/>
>   <column name="PASSWORD_VALUE" required="true" size="32"
> type="VARCHAR"/>
>   <column name="FIRST_NAME" required="true" size="99" type="VARCHAR"/>
>   <column name="LAST_NAME" required="true" size="99" type="VARCHAR"/>
>   <column name="EMAIL" size="99" type="VARCHAR"/>
>   <column name="HOMEPHONE" size="20" type="VARCHAR"/>
>   <column name="WORKPHONE" size="20" type="VARCHAR"/>
>   <column name="CELLPHONE" size="20" type="VARCHAR"/>
>   <column name="PAGER" size="20" type="VARCHAR"/>
>   <column name="CONFIRM_VALUE" size="99" type="VARCHAR"/>
>   <column name="MODIFIED" type="TIMESTAMP"/>
>   <column name="CREATED" type="TIMESTAMP"/>
>   <column name="LAST_LOGIN" type="TIMESTAMP"/>
>   <column name="OBJECTDATA" type="VARBINARY"/>
>   <column name="TEAM_ID" required="true" type="INTEGER"/>
>   <unique>
>       <unique-column name="LOGIN_NAME"/>
>   </unique>      
>   <foreign-key foreignTable="TEAM">
>       <reference local="TEAM_ID" foreign="ID"/>
>   </foreign-key> 
> </table>
> 
> <table name="TEAM">
>   <column name="ID" required="true" autoIncrement="true"
> primaryKey="true" type="INTEGER"/>
>   <column name="NAME" required="true" type="VARCHAR" size="255"/>
>   <column name="DESCRIPTION" required="true" type="VARCHAR"
> size="255"/>
> </table>
> 
> <table name="NEBULA_USER" javaName="NebulaUser" alias="TurbineUser"
> baseClass="<package>.nebula.om.TurbineUserAdapter"
> basePeer="<package>.nebula.om.TurbineUserPeerAdapter">
>   <column name="USER_ID" primaryKey="true" required="true"
> type="INTEGER" autoIncrement="true"/>
> </table>
> 
> Everything gets defined correctly, and I have added the definitions to
> my TurbineMapBuilderAdapter and both my TurbineUserAdapter and
> TurbinePeerAdapter classes. The problem is that torque when
> autogenerating the BaseTeam.java files, casts all of its "Users" to
> TurbineUsers and hence cannot find the setTeamId(NumberKey key) method.
> Is there a better way to do this? Is there a way to do this? (I didn't
> want to change the cast statements in the generated code, cause I would
> lose it each time I regened from torque.) Or am I just asking to hit my
> head against a wall?
> 
> Thanks in advance,
> 
> -cam.
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>