Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 9677 invoked from network); 13 Feb 2005 15:51:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 13 Feb 2005 15:51:10 -0000 Received: (qmail 53381 invoked by uid 500); 13 Feb 2005 15:51:00 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 53364 invoked by uid 500); 13 Feb 2005 15:51:00 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 53350 invoked by uid 99); 13 Feb 2005 15:50:59 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of jak-struts-user@m.gmane.org designates 80.91.229.2 as permitted sender) Received: from main.gmane.org (HELO ciao.gmane.org) (80.91.229.2) by apache.org (qpsmtpd/0.28) with ESMTP; Sun, 13 Feb 2005 07:50:58 -0800 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1D0Lz4-0008BI-NF for user@struts.apache.org; Sun, 13 Feb 2005 16:48:30 +0100 Received: from adsl-68-94-25-176.dsl.rcsntx.swbell.net ([68.94.25.176]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 13 Feb 2005 16:48:30 +0100 Received: from vin by adsl-68-94-25-176.dsl.rcsntx.swbell.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 13 Feb 2005 16:48:30 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: user@struts.apache.org From: Vic Subject: Re: which tier? Date: Sun, 13 Feb 2005 09:50:34 -0600 Lines: 51 Message-ID: References: <420F6B76.5010702@localhost.nu> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: adsl-68-94-25-176.dsl.rcsntx.swbell.net User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en In-Reply-To: <420F6B76.5010702@localhost.nu> Sender: news X-Gmane-MailScanner: Found to be clean X-Gmane-MailScanner: Found to be clean X-Gmane-MailScanner-SpamCheck: spam, SpamAssassin (score=6.239, required 6, AWL -2.63, BAYES_00 -2.60, HELO_DYNAMIC_DHCP 1.25, HELO_DYNAMIC_HCC 3.74, HELO_DYNAMIC_IPADDR 4.40, RCVD_IN_NJABL_DUL 0.09, RCVD_IN_SORBS_DUL 1.99) X-Gmane-MailScanner-SpamScore: ssssss X-MailScanner-From: jak-struts-user@m.gmane.org X-MailScanner-To: user@struts.apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N You need to write object/class that you can unit test outside of Stuts.Lets call it Calc.java. It would call a DAO (such as iBatis, there are tutorials to iBatis all over the place, try Rick Reuman (spelling?)). That would call SQL. So in Calc you might have private methods: private long getStartTime(Interger userID); private long getEndTime(Integer userID); .... or just private Map getTimes(Integer userID) to get all the times at once. Unit test that. Then write method to compute. Unit test. Then place in Struts. (But before I would implement above, I would create a JSP /Struts mock up with fake data displayed (no db, just hard code), just to get the look and feel right, navigation, etc. That is allways the hard part but it ensurse sucess. Once you know that's what you want, then do above impl.) .V Robin Ericsson wrote: > Hi, > > I'm doing a small timesheet app with struts using PostgreSQL as > backend and as I'm new to struts and also somewhat new to Java I'm > trying to decide where I should put the logic. > > Each row contains a day, start time, end time and break time. Now, I > want the business layer to calculate the duration between start time, > end time minus the break. > > Should this be placed in the SQL-side using a special query, or should > I do this in Java? If so, is it possible to calculate durations and > intervals in Java without using third-party packages? > > I know the question is pretty vague but I'm on thin ice at the moment > and not really knowing what I'm doing :) > > > regards, > Robin -- Forums, Boards, Blogs and News in RiA --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org