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