moved src dirs right
[educational.data.git] / src / Dr.NO / src / drno / server / model / Tidsreservation.java
blob03f095effd75bf7764b6c838436718924c91df85
1 /*
2 * Created on 2005-03-21
4 * $Log: Tidsreservation.java,v $
5 * Revision 1.1 2006-12-25 14:55:21 tobibobi
6 * Initial checkin
8 */
9 package drno.server.model;
10 import java.rmi.RemoteException;
11 import java.sql.Timestamp;
12 import java.util.Calendar;
13 import java.util.GregorianCalendar;
15 import drno.exception.ConsistanceException;
16 import drno.interfaces.IEmployee;
17 import drno.interfaces.IPatient;
18 import drno.interfaces.ITidsreservationEditable;
19 import drno.server.database.persistence.PersistentObject;
23 /**
24 * The model version of Tidsreservationer.
25 * <p>
26 * More docs are to come...
28 * @author Leo
29 * @version $LastChangedBy:$
30 * @since 1
32 public class Tidsreservation extends PersistentObject implements ITidsreservationEditable{
33 private IPatient mPatient;
34 private IEmployee mEmployee;
35 private Timestamp mTidStart;
36 private Timestamp mTidSlut;
37 private Timestamp mReelTidStart;
38 private Timestamp mReelTidSlut;
39 private String mEmne;
40 private int mType;
42 public Tidsreservation(){
43 mPatient = null;
44 mEmployee = null;
45 GregorianCalendar c = new GregorianCalendar();
47 Timestamp t = new Timestamp(c.getTimeInMillis());
48 c.add(Calendar.MINUTE,20);
49 Timestamp t2 = new Timestamp(c.getTimeInMillis());
52 mTidStart = t;
53 mTidSlut = t2;
54 mReelTidStart = t;
55 mReelTidSlut = t2;
56 mEmne = "";
57 mType = TYPE_CONSULTATION;
60 public IPatient getPatient(){
61 return mPatient;
63 public IEmployee getEmployee(){
64 return mEmployee;
66 public Timestamp getTidStart(){
67 return mTidStart;
69 public Timestamp getTidSlut(){
70 return mTidSlut;
73 public Timestamp getReelTidStart(){
74 return mReelTidStart;
76 public Timestamp getReelTidSlut(){
77 return mReelTidSlut;
79 public String getEmne(){
80 return mEmne;
82 public int getType(){
83 return mType;
86 public void setPatient(IPatient patient) throws ConsistanceException{
87 checkPatient(patient);
88 mPatient = patient;
90 /**
91 * @param patient
92 * @throws ConsistanceException
94 private void checkPatient(IPatient patient) throws ConsistanceException
96 if(patient == null)
97 throw new ConsistanceException("Cannot add an empty patient to the database");
100 public void setEmployee(IEmployee employee) throws ConsistanceException{
101 checkDoctor(employee);
102 mEmployee = employee;
105 * @param employee
106 * @throws ConsistanceException
108 private void checkDoctor(IEmployee employee) throws ConsistanceException
110 if(employee == null)
111 throw new ConsistanceException("Cannot add an empty employee to the database");
114 public void setTidStart(Timestamp t) throws ConsistanceException{
115 mTidStart = t;
117 public void setTidSlut(Timestamp t) throws ConsistanceException{
118 mTidSlut = t;
120 public void setReelTidStart(Timestamp t) throws ConsistanceException{
121 mReelTidStart = t;
123 public void setReelTidSlut(Timestamp t) throws ConsistanceException{
124 mReelTidSlut = t;
126 public void setEmne(String emne) throws ConsistanceException {
127 mEmne = emne;
129 public void setType(int type) throws ConsistanceException {
130 if( (type != TYPE_CONSULTATION) &&
131 (type != TYPE_PHONECONSULTATION) &&
132 (type != TYPE_HOLIDAY))
133 throw new ConsistanceException("Type må være enten TYPE_CONSULTATION, TYPE_PHONECONSULTATION eller TYPE_HOLIDAY");
134 mType = type;
136 public String asString() throws RemoteException {
137 String endl = ",";
139 String stype = "";
140 switch(mType) {
141 case TYPE_CONSULTATION:
142 stype = "Konsultation";
143 break;
144 case TYPE_HOLIDAY:
145 stype = "Ferie";
146 break;
147 case TYPE_PHONECONSULTATION:
148 stype = "Telefon konsultation";
149 break;
152 return "["+
153 "Ansat: " + mEmployee.getFornavn() + " " + mEmployee.getEfternavn() + ", " +
154 "Patient: " + mPatient.getFornavn() + " " + mPatient.getEfternavn()+ ", " +
155 "Tidstart: " + mTidStart+ ", " +
156 "Tidslut: " + mTidSlut +
157 "Art: " + stype +
158 "]";
162 * @see drno.server.database.persistence.PersistentObject#verify()
164 public void verify() throws ConsistanceException {
165 checkPatient(mPatient);
166 checkDoctor(mEmployee);