3094f764c0ef2fb46cd66d97da196a3124fc7777
[mir.git] / source / mircoders / storage / DatabaseMedia.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 DatabaseMedia extends Database implements StorageObject{
21
22   private static DatabaseMedia instance;
23   private static EntityRelation         relationMediaType;
24
25   public static DatabaseMedia getInstance() throws StorageObjectException {
26     if (instance == null) {
27       instance = new DatabaseMedia();
28       instance.myselfDatabase = instance;
29     }
30     return instance;
31   }
32
33   private DatabaseMedia() throws StorageObjectException
34   {
35     super();
36     this.cache = new HashMap();
37     this.hasTimestamp = false;
38     this.theTable="media*";
39     relationMediaType = new EntityRelation("to_media_type", "id", DatabaseMediaType.getInstance(), EntityRelation.TO_ONE);
40     try {
41       this.theEntityClass = Class.forName("mircoders.entity.EntityMedia");
42     }
43     catch (Exception e) {
44       throw new StorageObjectException(e.toString());
45     }
46   }
47
48   // methods
49
50
51   /**
52    * returns the comments that belong to the article (via entityrelation)
53    * where db-flag is_published is true
54    */
55   public Entity getMediaType(Entity ent) {
56     Entity type=null;
57     try {
58       type = relationMediaType.getOne(ent);
59     }
60     catch (StorageObjectException e) {
61       theLog.printError("DatabaseUploadedMedia :: failed to get media_type");
62     }
63     return type;
64   }
65
66 }