first cut of merge of STABLE-pre1_0 into HEAD. I won't even guarantee that it
[mir.git] / source / mircoders / entity / EntityComment.java
1 package mircoders.entity;
2
3 import java.lang.*;
4 import java.io.*;
5 import java.util.*;
6 import java.sql.*;
7
8 import mir.entity.*;
9 import mir.misc.*;
10 import mir.storage.*;
11
12 import mir.storage.*;
13
14 /**
15  * This class maps one line of the comment-table to a java-object.
16  *
17  * @author RK
18  * @version 1.0
19  */
20
21
22 public class EntityComment extends Entity
23 {
24
25   public EntityComment()
26   {
27     super();
28   }
29
30   public EntityComment(StorageObject theStorage) {
31     this();
32     setStorage(theStorage);
33   }
34
35
36   /**
37    * overridden method setValues to patch creator_main_url
38    */
39   public void setValues(HashMap theStringValues)
40   {
41     if (theStringValues != null) {
42       if (!theStringValues.containsKey("is_published")) {
43        theStringValues.put("is_published","0");
44                         }
45
46                         if (theStringValues.containsKey("main_url")){
47                                 if (((String)theStringValues.get("main_url")).equalsIgnoreCase("http://")) {
48                                         theStringValues.remove("main_url");
49                                 } else if ((!((String)theStringValues.get("main_url")).startsWith("http://"))
50                                                                         && ((String)theStringValues.get("main_url")).length()>0){
51                                         theStringValues.put("main_url","http://"+((String)theStringValues.get("main_url")));
52                                 }
53                         }
54
55     }
56     super.setValues(theStringValues);
57   }
58
59         /**
60          * overridden method getValue to include formatted date into every
61          * entityContent
62          */
63
64         public String getValue(String field)
65   {
66     String returnField = null;
67     if (field!=null)
68     {
69       if (field.equals("date_formatted"))
70       {
71                   if (hasValueForField("date"))
72         returnField = StringUtil.webdbDate2readableDate(getValue("date"));
73                 }
74       else if (field.equals("description_parsed")) {
75         /** @todo the config stuff should be moved to StringUtil */
76         String extLinkName = MirConfig.getProp("Producer.ExtLinkName");
77         String intLinkName = MirConfig.getProp("Producer.IntLinkName");
78         String mailLinkName = MirConfig.getProp("Producer.MailLinkName");
79         String imageRoot = MirConfig.getProp("Producer.ImageRoot");
80         returnField = StringUtil.createHTML(getValue("description"),imageRoot,mailLinkName,extLinkName,intLinkName);
81       }
82       else
83         return super.getValue(field);
84     }
85     return returnField;
86         }
87
88
89 }