KickJava   Java API By Example, From Geeks To Geeks.

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


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.EventData;
33 import net.killingar.forum.internal.managers.PlanningManager;
34
35 public class Decide extends ActionPlanningSupport
36 {
37     // Private --------------------------------------------------------
38

39     // Attributes -----------------------------------------------------
40
private long event = -1;
41     private int answer = -1;
42     String JavaDoc name;
43     int year = -1, month = -1, date = -1;
44     long group = -1;
45     boolean clear, frozen;
46
47     // Types ----------------------------------------------------------
48

49     // Setters --------------------------------------------------------
50
public void setEvent(long inEvent) { event = inEvent; }
51     public void setAnswer(int inAnswer) { answer = inAnswer; }
52     public void setName(String JavaDoc inName) { name = inName; }
53     public void setYear(int inYear) { year = inYear; }
54     public void setMonth(int inMonth) { month = inMonth; }
55     public void setDate(int inDate) { date = inDate; }
56     public void setGroup(long inGroup) { group = inGroup; }
57     public void setClear(boolean inClear) { clear = inClear; }
58     public void setFrozen(boolean inFrozen) { frozen = inFrozen; }
59
60     // Getters --------------------------------------------------------
61
public long getEvent() { return event; }
62     public int getAnswer() { return answer; }
63     public String JavaDoc getName () { return name; }
64     public int getYear () { return year; }
65     public int getMonth() { return month; }
66     public int getDate () { return date; }
67     public long getGroup() { return group; }
68     public boolean getClear() { return clear; }
69     public boolean getFrozen() { return frozen; }
70
71     // Implementation -------------------------------------------------
72
protected String JavaDoc doExecute()
73     {
74         try
75         {
76             PlanningManager planningMgr = (PlanningManager)manager.getManager(PlanningManager.class.getName());
77
78             Event e = planningMgr.getEvent(event);
79
80             if (event == -1 || e == null)
81             {
82                 addErrorMessage("no or invalid event specified");
83                 return ERROR;
84             }
85
86             if (answer == -1)
87             {
88                 year = e.time.getYear()+1900;
89                 month = e.time.getMonth();
90                 date = e.time.getDate();
91                 name = e.name;
92                 group = e.groupID;
93                 frozen = e.frozen;
94
95                 EventData d = planningMgr.getEventData(event, manager.getUserID());
96                 if (d != null)
97                     answer = d.data;
98                 return INPUT;
99             }
100
101             planningMgr.setEventData(manager.getUserID(), event, answer);
102         }
103         catch (Exception JavaDoc e)
104         {
105             e.printStackTrace();
106             addErrorMessage("executing "+getClass().toString()+" action failed, exception thrown: "+e.toString());
107             return ERROR;
108         }
109
110         return SUCCESS;
111     }
112 }
113
Popular Tags