Coverage details for ui.command.information.SearchSessionCommand

LineHitsSource
1 /*******************************************************************************
2  * InternetCafe is a software solution that helps the management of Cybercafes
3  * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005.
4  * Copyright (C) 2006 Guido Angelo Ingenito
5  
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *******************************************************************************/
20 package ui.command.information;
21  
22 import java.util.Date;
23  
24 import ui.Messages;
25 import ui.command.Command;
26 import ui.table.model.SessionTableModel;
27 import ui.util.SortStrategy;
28 import base.InternetCafe;
29 import base.InternetCafeManager;
30 import base.session.Session;
31  
32 public class SearchSessionCommand extends Command {
33  
34     private final SessionTableModel sessionTableModel;
35  
36     private final String text;
37  
38     private final Date date;
39  
40     /**
41      * @param sessionTableModel
42      * @param text
43      * @param date
44      */
45     public SearchSessionCommand(SessionTableModel sessionTableModel,
460            String text, Date date) {
470        super();
480        // TODO Auto-generated constructor stub
490        this.sessionTableModel = sessionTableModel;
500        this.text = text;
510        this.date = date;
520    }
53  
54     /*
55      * (non-Javadoc)
56      *
57      * @see ui.command.Command#prologo()
58      */
59     @Override
600    protected void prologo() {
610        String message = (text != null && date == null) ? Messages.getString("command.searchsessioncommand.search.byspecifiedtext") //$NON-NLS-1$
620                : (text == null && date != null) ? Messages.getString("command.searchsessioncommand.search.byspecifieddateascending") //$NON-NLS-1$
630                        : Messages.getString("command.searchsessioncommand.search.byspecifiedtextanddateascending"); //$NON-NLS-1$
640        InternetCafe
650                .setStatusBarMessage(Messages.getString("command.searchsessioncommand.searchingsession") + message + "..."); //$NON-NLS-1$ //$NON-NLS-2$
660        setStatus(EXECUTE_STATUS);
670    }
68  
69     /*
70      * (non-Javadoc)
71      *
72      * @see ui.command.Command#execution()
73      */
74     @Override
750    protected void execution() throws Exception {
760        switch (getStatus()) {
770        case ABORT_STATUS:
780            break;
790        case VETOED_STATUS:
800            break;
810        case EXECUTE_STATUS:
820            if (text != null && date == null) {
830                sessionTableModel.setData(SortStrategy.searchSessionByText(
840                        text, InternetCafeManager.getInstance().getSession()));
850                sessionTableModel.fireTableDataChanged();
860            } else if (text == null && date != null) {
870                sessionTableModel.setData(SortStrategy.searchSessionByDate(
880                        date, InternetCafeManager.getInstance().getSession()));
890                sessionTableModel.fireTableDataChanged();
900            } else if (text != null && date != null) {
910                Session[] sByText = SortStrategy.searchSessionByText(text,
920                        InternetCafeManager.getInstance().getSession());
930                sessionTableModel.setData(SortStrategy.searchSessionByDate(
940                        date, sByText));
950                sessionTableModel.fireTableDataChanged();
960            }
970            setStatus(SUCCESS_STATUS);
98             break;
990        }
1000    }
101 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.