2 * Created on 2005-03-21
4 * $Log: Tidsreservation.java,v $
5 * Revision 1.1 2006-12-25 14:55:21 tobibobi
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
;
24 * The model version of Tidsreservationer.
26 * More docs are to come...
29 * @version $LastChangedBy:$
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
;
42 public Tidsreservation(){
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());
57 mType
= TYPE_CONSULTATION
;
60 public IPatient
getPatient(){
63 public IEmployee
getEmployee(){
66 public Timestamp
getTidStart(){
69 public Timestamp
getTidSlut(){
73 public Timestamp
getReelTidStart(){
76 public Timestamp
getReelTidSlut(){
79 public String
getEmne(){
86 public void setPatient(IPatient patient
) throws ConsistanceException
{
87 checkPatient(patient
);
92 * @throws ConsistanceException
94 private void checkPatient(IPatient patient
) throws ConsistanceException
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
;
106 * @throws ConsistanceException
108 private void checkDoctor(IEmployee employee
) throws ConsistanceException
111 throw new ConsistanceException("Cannot add an empty employee to the database");
114 public void setTidStart(Timestamp t
) throws ConsistanceException
{
117 public void setTidSlut(Timestamp t
) throws ConsistanceException
{
120 public void setReelTidStart(Timestamp t
) throws ConsistanceException
{
123 public void setReelTidSlut(Timestamp t
) throws ConsistanceException
{
126 public void setEmne(String emne
) throws ConsistanceException
{
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");
136 public String
asString() throws RemoteException
{
141 case TYPE_CONSULTATION
:
142 stype
= "Konsultation";
147 case TYPE_PHONECONSULTATION
:
148 stype
= "Telefon konsultation";
153 "Ansat: " + mEmployee
.getFornavn() + " " + mEmployee
.getEfternavn() + ", " +
154 "Patient: " + mPatient
.getFornavn() + " " + mPatient
.getEfternavn()+ ", " +
155 "Tidstart: " + mTidStart
+ ", " +
156 "Tidslut: " + mTidSlut
+
162 * @see drno.server.database.persistence.PersistentObject#verify()
164 public void verify() throws ConsistanceException
{
165 checkPatient(mPatient
);
166 checkDoctor(mEmployee
);