1 package mircoders.module;
3 import freemarker.template.SimpleList;
4 import mir.entity.Entity;
5 import mir.entity.EntityList;
6 import mir.misc.Logfile;
7 import mir.misc.MirConfig;
8 import mir.module.AbstractModule;
9 import mir.module.ModuleException;
10 import mir.storage.StorageObject;
11 import mir.storage.StorageObjectException;
12 import mircoders.entity.EntityContent;
13 import mircoders.entity.EntityTopics;
14 import mircoders.storage.DatabaseContent;
15 import mircoders.storage.DatabaseContentToTopics;
16 import mircoders.storage.DatabaseTopics;
18 import java.util.HashMap;
27 public class ModuleTopics extends AbstractModule {
29 static Logfile theLog;
31 public ModuleTopics(StorageObject theStorage) {
32 this.theStorage = theStorage;
34 theLog = Logfile.getInstance(MirConfig.getProp("Home") + MirConfig.getProp("Module.Themen.Logfile"));
37 public SimpleList getTopicsAsSimpleList() throws ModuleException {
39 return ((DatabaseTopics) theStorage).getPopupData();
41 catch (StorageObjectException e) {
42 throw new ModuleException(e.toString());
50 * @return SimpleList of all Topics sorted by title
53 public EntityList getTopicsList() {
54 EntityList returnList = null;
56 returnList = getByWhereClause("", "title", -1);
59 theLog.printWarning("--getTopicsList: topics could not be fetched");
65 * Overrides the AbstractModule.set(),
66 * All dependent ContentEntities are set unproduced.
67 * @param theValues Hash mit Spalte/Wert-Paaren
68 * @return Id des eingefügten Objekts
69 * @exception ModuleException
71 public String set(HashMap theValues) throws ModuleException {
73 Entity theEntity = theStorage.selectById((String) theValues.get("id"));
74 if (theEntity == null) {
75 throw new ModuleException("Kein Objekt mit id in Datenbank id: " + theValues.get("id"));
77 theEntity.setValues(theValues);
78 DatabaseContentToTopics db = DatabaseContentToTopics.getInstance();
79 DatabaseContent dbc = DatabaseContent.getInstance();
80 EntityList contentList = db.getContent((EntityTopics) theEntity);
81 if (contentList!=null) {
82 for (int i = 0; i < contentList.size(); i++) {
83 dbc.setUnproduced("id=" + ((EntityContent) contentList.elementAt(i)).getId());
87 return theEntity.getId();
89 catch (StorageObjectException e) {
90 e.printStackTrace(System.err);
91 throw new ModuleException(e.toString());