d2368267700bab303e45457ef712c8fe5bc15da2
[mir.git] / source / mircoders / storage / DatabaseOther.java
1 package mircoders.storage;
2
3 import java.lang.*;
4 import java.sql.*;
5 import java.io.*;
6 import java.util.*;
7
8 import freemarker.template.*;
9
10 import mir.storage.*;
11 import mir.entity.*;
12 import mir.misc.*;
13
14 /**
15  * <b>Diese Klasse implementiert die Datenbankverbindung zur MetaObjekt-Tabelle
16  *
17  *
18  */
19
20 public class DatabaseOther extends Database implements StorageObject{
21
22         private static DatabaseOther instance;
23         private static SimpleList publisherPopupData;
24
25         // the following *has* to be sychronized cause this static method
26         // could get preemted and we could end up with 2 instances of DatabaseFoo..
27         // see the "Singletons with needles and thread" article at JavaWorld -mh
28         public synchronized static DatabaseOther getInstance() 
29           throws StorageObjectException
30         {
31                 if (instance == null) {
32                         instance = new DatabaseOther();
33                         instance.myselfDatabase = instance;
34                 }
35                 return instance;
36         }
37
38         private DatabaseOther() throws StorageObjectException
39         {
40                 super();
41                 this.hasTimestamp = true;
42                 this.theTable="other_media";
43                 this.theCoreTable="media";
44                 try {
45                         this.theEntityClass = Class.forName("mircoders.entity.EntityOther");
46                 }
47                 catch (Exception e) { throw new StorageObjectException(e.toString());   }
48         }
49
50         public SimpleList getPopupData() throws StorageObjectException {
51                 return getPopupData("title",true);
52         }
53
54         public void update(Entity theEntity) throws StorageObjectException
55         {
56                 String date = theEntity.getValue("date");
57                 if (date==null){
58                         date = StringUtil.date2webdbDate(new GregorianCalendar());
59                         theEntity.setValueForProperty("date",date);
60                 }
61
62                 super.update(theEntity);
63         }
64
65
66         public String insert(Entity theEntity) throws StorageObjectException
67         {
68                 String date = theEntity.getValue("date");
69                 if (date==null){
70                         date = StringUtil.date2webdbDate(new GregorianCalendar());
71                         theEntity.setValueForProperty("date",date);
72                 }
73                 return super.insert(theEntity);
74         }
75
76         // initialisierungen aus den statischen Tabellen
77
78 }