KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > killingar > forum > actions > planning > Add


1 /* Copyright 2000-2005 Anders Hovmöller
2  *
3  * The person or persons who have associated their work with
4  * this document (the "Dedicator") hereby dedicate the entire
5  * copyright in the work of authorship identified below (the
6  * "Work") to the public domain.
7  *
8  * Dedicator makes this dedication for the benefit of the
9  * public at large and to the detriment of Dedicator's heirs
10  * and successors. Dedicator intends this dedication to be an
11  * overt act of relinquishment in perpetuity of all present
12  * and future rights under copyright law, whether vested or
13  * contingent, in the Work. Dedicator understands that such
14  * relinquishment of all rights includes the relinquishment of
15  * all rights to enforce (by lawsuit or otherwise) those
16  * copyrights in the Work.
17  *
18  * Dedicator recognizes that, once placed in the public
19  * domain, the Work may be freely reproduced, distributed,
20  * transmitted, used, modified, built upon, or otherwise
21  * exploited by anyone for any purpose, commercial or non-
22  * commercial, and in any way, including by methods that have
23  * not yet been invented or conceived.
24  */

25
26 /**
27  *
28  */

29 package net.killingar.forum.actions.planning;
30
31 import net.killingar.forum.internal.Event;
32 import net.killingar.forum.internal.managers.PlanningManager;
33
34 import java.util.Date JavaDoc;
35
36 public class Add extends ActionPlanningSupport
37 {
38     // Private --------------------------------------------------------
39

40     // Attributes -----------------------------------------------------
41
private String JavaDoc name;
42     private int year, month, date;
43     private long group = -1;
44     private String JavaDoc description;
45
46     // Types ----------------------------------------------------------
47

48     // Setters --------------------------------------------------------
49
public void setName(String JavaDoc inName) { name = inName; }
50     public void setDescription(String JavaDoc in) { description = in; }
51     public void setYear(int inYear) { year = inYear; }
52     public void setMonth(int inMonth) { month = inMonth; }
53     public void setDate(int inDate) { date = inDate; }
54     public void setGroup(long inGroup) { group = inGroup; }
55
56     // Getters --------------------------------------------------------
57
public String JavaDoc getName () { return name; }
58     public String JavaDoc getDescription () { return description; }
59     public int getYear () { return year; }
60     public int getMonth() { return month; }
61     public int getDate () { return date; }
62     public long getGroup() { return group; }
63
64     // Implementation -------------------------------------------------
65
protected String JavaDoc doExecute()
66     {
67         try
68         {
69             PlanningManager planningMgr = (PlanningManager)manager.getManager(PlanningManager.class.getName());
70
71             if (name == null)
72             {
73                 Date JavaDoc d = new Date JavaDoc();
74                 year = d.getYear()+1900;
75                 month = d.getMonth();
76                 date = d.getDate();
77                 return INPUT;
78             }
79
80             Event event = new Event(group, name, description, new java.sql.Timestamp JavaDoc(System.currentTimeMillis()));
81             event.time.setYear(year-1900);
82             event.time.setMonth(month);
83             event.time.setDate(date);
84             planningMgr.addEvent(event);
85         }
86         catch (Exception JavaDoc e)
87         {
88             e.printStackTrace();
89             addErrorMessage("executing "+getClass().toString()+" action failed, exception thrown: "+e.toString());
90             return ERROR;
91         }
92
93         return SUCCESS;
94     }
95 }
96
Popular Tags