You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Gary Lawrence Murphy <ga...@canada.com> on 2001/06/20 05:12:44 UTC

Panic attack: How to select date < now?

Oh oh.  time to see if Turbine truly does let you do anything ;)

I need to delete (expire) records based on the clocktime column being
less than now, but there is no family of Criteria.addDate( column,
java.util.Date, comparison ) methods ... the only methods provided
have a one-day resolution :(

How do I create a Criteria for a timestamp?

Is my only recourse to use long-int column types?

-- 
Gary Lawrence Murphy <ga...@teledyn.com> TeleDynamics Communications Inc
Business Innovations Through Open Source Systems: http://www.teledyn.com
"Computers are useless.  They can only give you answers."(Pablo Picasso)


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


Re: Panic attack: How to select date < now?

Posted by Leon Messerschmidt <le...@opticode.co.za>.
Hi Gary,

Sorry that I have missed this thread earlier.  I solved the problem by
adding Prepared Statements to BasePeer, although I can't recall if I have
added this to torque (I'll have a look as soon as I have some time free).
Luckily it is fairly easy to do by hand: in your Base*Peer classes you just
replace:

          return BasePeer.doSelect(criteria);

with:

          return BasePeer.doPSSelect(criteria);


This lets BasePeer use PreparedStatements rather than normal statements.
You can then use add(String,Object,String) for your dates.  The added code
will then check the type of the Object added and it will use the addDate()
method for the PreparedStatement, in effect shifting the date conversion
responsibility to the JDBC driver.  Saves you all the work!

~ Leon

----- Original Message -----
From: "Gary Lawrence Murphy" <ga...@canada.com>
To: <tu...@jakarta.apache.org>
Sent: Thursday, June 21, 2001 7:06 AM
Subject: Re: Panic attack: How to select date < now?


>
> This is one reason I'm reluctant to submit a patch: There's far too
> much of the architecture that I don't understand.  It does seem
> reasonable that add(String,Date,String) would require at least an API
> that makes it possible to vary the date string format (some formats
> are _nearly_ universal), but to do this within the plugin architecture
> of the Torque API, well, right now, that's a lane I just don't have
> time to explore.
>
> What I need is a job that doesn't interfer with my work ;)
>
> >>>>> "J" == John McNally <jm...@collab.net> writes:
>
>     J> ...  The only way (other than writing adaptor code for each db)
>     J> is to use the PreparedStatement methods when working with
>     J> Dates, you should still be able to add them to the Criteria
>     J> with the generic add.
>
> I understand PreparedStatements from JDBC and I remember seeing
> references to them in the Turbine code, but can you elaborate just a
> bit on "still be able to add them to the criteria with the generic
> add"?
>
> --
> Gary Lawrence Murphy <ga...@teledyn.com> TeleDynamics Communications Inc
> Business Innovations Through Open Source Systems: http://www.teledyn.com
> "Computers are useless.  They can only give you answers."(Pablo Picasso)
>
>
> ---------------------------------------------------------------------
> 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: Panic attack: How to select date < now?

Posted by Gary Lawrence Murphy <ga...@canada.com>.
This is one reason I'm reluctant to submit a patch: There's far too
much of the architecture that I don't understand.  It does seem
reasonable that add(String,Date,String) would require at least an API
that makes it possible to vary the date string format (some formats
are _nearly_ universal), but to do this within the plugin architecture
of the Torque API, well, right now, that's a lane I just don't have
time to explore.

What I need is a job that doesn't interfer with my work ;) 

>>>>> "J" == John McNally <jm...@collab.net> writes:

    J> ...  The only way (other than writing adaptor code for each db)
    J> is to use the PreparedStatement methods when working with
    J> Dates, you should still be able to add them to the Criteria
    J> with the generic add.

I understand PreparedStatements from JDBC and I remember seeing
references to them in the Turbine code, but can you elaborate just a
bit on "still be able to add them to the criteria with the generic
add"?

-- 
Gary Lawrence Murphy <ga...@teledyn.com> TeleDynamics Communications Inc
Business Innovations Through Open Source Systems: http://www.teledyn.com
"Computers are useless.  They can only give you answers."(Pablo Picasso)


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


Re: Trouble with default framework settings in Turbine

Posted by Scott Eade <se...@backstagetech.com.au>.
> I'm having problems getting started with Turbine.  I'm attempting to
> change the default screen that users see when first accessing the
> web app by changing screen.homepage in tr.props to the name of the
> screen template (Index.vm) I want loaded.  However, it's still loading
> the default Login.  Index.vm is located in /templates/app/screens.
> 
> If I set Index.vm to be the default template for an invalid login
> attempt, it loads. (Proving it can be found).
> 
> I've also attempted to change the default login action to MyLoginUser
> located at /WEB-INF/classes/ca/bcit/cstwebproject/modules/actions and
> Turbine is still loading the default LoginUser class.
> 
> Am I just missing something obvious here?

This is similar to the battle I have been fighting over the last
couple of days.  I suggest you look at the code in
org.apache.newapp.modules.screens.SecureScreen.isAuthorised()
and
org.apache.turbine.modules.actions.LoginUser.doPerform()

These interact with the properties defined in TR.properties
to provide the behaviour you are interested in.

I think there may be a bug in LoginUser but I am not completely
sure - check one of my messages earlier today with the 
subject "Frustrating Problem"

As you are using a different initial screen your problem may not
be exactly the same as mine, but I think this information may
be of some help to you.

Scott






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


Re: Looking for Flux docs

Posted by Jason van Zyl <jv...@apache.org>.
On 6/26/01 6:08 PM, "Frank Marcus" <fm...@datacomm.bcit.ca> wrote:

> Thanks to Scott and Jason for helping with the layout stuff.  The ball's
> rolling now :)
> 
> I'm looking for some information on Flux.  I gather from what I've been
> reading on the list that parts of Flux aren't fully implemented.  Aside
> from the source code (which I'm currently reading through) is there
> another source of documentation on how to use/extend Flux?  Also, am I
> correct in assuming that the FluxTool class is the main implementation
> class for Flux?  Thanks!

Flux was originally written to try and stem the tide of questions
relating to security. It is fully functional, but beyond that it
doesn't provide many amenities. The searching and filtering are
still lacking and it's not terribly pleasing to the eye.

That being the case, there isn't much documentation. Flux
will probably change a little due to the fact that Martin
just checked in torque generated security classes.

Flux will eventually be documented in a book, but that's a way
off. For now I'd be glad to try and answer and questions and
any patches to Flux people want to make :-) John already has
helped flux a great deal by making a flux pull tool. So, yes
the FluxTool class is where all the logic is.
 
> - Frank
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



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


Looking for Flux docs

Posted by Frank Marcus <fm...@datacomm.bcit.ca>.
Thanks to Scott and Jason for helping with the layout stuff.  The ball's
rolling now :)

I'm looking for some information on Flux.  I gather from what I've been
reading on the list that parts of Flux aren't fully implemented.  Aside
from the source code (which I'm currently reading through) is there
another source of documentation on how to use/extend Flux?  Also, am I
correct in assuming that the FluxTool class is the main implementation
class for Flux?  Thanks!

- Frank

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


Re: Trouble with default framework settings in Turbine

Posted by Frank Marcus <fm...@datacomm.bcit.ca>.
I appreciate your help.  My deadline is approaching rapidly :)

Jason van Zyl wrote:
> 
> When you generated the sample app you probably noticed that
> 
> screen.homepage
> 
> didn't have a value and that is intentional. If you want to change
> what the user sees after a successful login you change the
> 
> template.homepage
> 
> property. We should probably just remove the screen.homepage
> property all together.
> 

I'm actually attempting to have a default screen load and make the login
screen accessible via a link.  A requirement of the site is to have an
initial area that a user does not need to be logged into.  I know I
could probably use a standalone jsp as the initial page, but I'd like to
stay in my template.

> > If I set Index.vm to be the default template for an invalid login
> > attempt, it loads. (Proving it can be found).
> >
> > I've also attempted to change the default login action to MyLoginUser
> > located at /WEB-INF/classes/ca/bcit/cstwebproject/modules/actions and
> > Turbine is still loading the default LoginUser class.
> 
> Did you adjust the module.packages property and change the
> action.login property?
> 
module.packages is assigned to ca.bcit.cstwebproject.modules.  The
MyLoginUser class is located in
classes/ca/bcit/cstwebpage/modules/actions 

Should I specifically reference the actions directory or the class name?

The action.login property has been set to MyLoginUser



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


Re: Trouble with default framework settings in Turbine

Posted by Jason van Zyl <jv...@apache.org>.
On 6/20/01 8:35 PM, "fmarcus" <fm...@datacomm.bcit.ca> wrote:

> I'm having problems getting started with Turbine.  I'm attempting to
> change the default screen that users see when first accessing the
> web app by changing screen.homepage in tr.props to the name of the
> screen template (Index.vm) I want loaded.  However, it's still loading
> the default Login.  Index.vm is located in /templates/app/screens.

When you generated the sample app you probably noticed that

screen.homepage

didn't have a value and that is intentional. If you want to change
what the user sees after a successful login you change the

template.homepage

property. We should probably just remove the screen.homepage
property all together.
 
> If I set Index.vm to be the default template for an invalid login
> attempt, it loads. (Proving it can be found).
> 
> I've also attempted to change the default login action to MyLoginUser
> located at /WEB-INF/classes/ca/bcit/cstwebproject/modules/actions and
> Turbine is still loading the default LoginUser class.

Did you adjust the module.packages property and change the
action.login property?

 
> Am I just missing something obvious here?

I imagine a combination of misconfiguration and misunderstanding.
I will try and simplify the configuration a bit.
 
> tdk version: 2.1 (I downloaded it from jakarta.apache.org/turbine this
> morning)
> 
> - Frank.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

-- 

jvz.

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



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


Trouble with default framework settings in Turbine

Posted by fmarcus <fm...@datacomm.bcit.ca>.
I'm having problems getting started with Turbine.  I'm attempting to
change the default screen that users see when first accessing the
web app by changing screen.homepage in tr.props to the name of the
screen template (Index.vm) I want loaded.  However, it's still loading
the default Login.  Index.vm is located in /templates/app/screens.

If I set Index.vm to be the default template for an invalid login
attempt, it loads. (Proving it can be found).

I've also attempted to change the default login action to MyLoginUser
located at /WEB-INF/classes/ca/bcit/cstwebproject/modules/actions and
Turbine is still loading the default LoginUser class.

Am I just missing something obvious here?

tdk version: 2.1 (I downloaded it from jakarta.apache.org/turbine this
morning)

- Frank.

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


Re: Panic attack: How to select date < now?

Posted by John McNally <jm...@collab.net>.
There is a add(String, Object, String) method which will take a Date. 
As Gary has said though a straight conversion of the Date using toString
is not acceptable to MySQL or probably any other db.  He had to format
the date properly.  The only way (other than writing adaptor code for
each db) is to use the PreparedStatement methods when working with
Dates,  you should still be able to add them to the Criteria with the
generic add.

john mcnally

Daniel Rall wrote:
> 
> Gary Lawrence Murphy <ga...@canada.com> writes:
> 
> > >>>>> "J" == John McNally <jm...@collab.net> writes:
> >
> >     J> you can try criteria.add(column, Date, comparison).
> >
> > this causes the Date item to be rendered toString(), and the
> > default java Date format is read by MySQL as a zero date.
> >
> > there is no add(String, Date, String) method.  IMHO, there should be.
> 
> I agree.  Please submit a patch.
> 
> Thanks Gary,
> 
> Daniel
> 
> ---------------------------------------------------------------------
> 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: Panic attack: How to select date < now?

Posted by Daniel Rall <dl...@finemaltcoding.com>.
Gary Lawrence Murphy <ga...@canada.com> writes:

> >>>>> "J" == John McNally <jm...@collab.net> writes:
> 
>     J> you can try criteria.add(column, Date, comparison).
> 
> this causes the Date item to be rendered toString(), and the
> default java Date format is read by MySQL as a zero date.
> 
> there is no add(String, Date, String) method.  IMHO, there should be.

I agree.  Please submit a patch.

Thanks Gary,

Daniel

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


Re: Panic attack: How to select date < now?

Posted by Gary Lawrence Murphy <ga...@canada.com>.
>>>>> "J" == John McNally <jm...@collab.net> writes:

    J> you can try criteria.add(column, Date, comparison).

this causes the Date item to be rendered toString(), and the
default java Date format is read by MySQL as a zero date.

there is no add(String, Date, String) method.  IMHO, there should be.

-- 
Gary Lawrence Murphy <ga...@teledyn.com> TeleDynamics Communications Inc
Business Innovations Through Open Source Systems: http://www.teledyn.com
"Computers are useless.  They can only give you answers."(Pablo Picasso)


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


Re: Panic attack: How to select date < now?

Posted by John McNally <jm...@collab.net>.
you can try criteria.add(column, Date, comparison).

Gary Lawrence Murphy wrote:
> 
> Oh oh.  time to see if Turbine truly does let you do anything ;)
> 
> I need to delete (expire) records based on the clocktime column being
> less than now, but there is no family of Criteria.addDate( column,
> java.util.Date, comparison ) methods ... the only methods provided
> have a one-day resolution :(
> 
> How do I create a Criteria for a timestamp?
> 
> Is my only recourse to use long-int column types?
> 
> --
> Gary Lawrence Murphy <ga...@teledyn.com> TeleDynamics Communications Inc
> Business Innovations Through Open Source Systems: http://www.teledyn.com
> "Computers are useless.  They can only give you answers."(Pablo Picasso)
> 
> ---------------------------------------------------------------------
> 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