1-n-relation content to topic
[mir.git] / source / mircoders / servlet / ServletModuleContent.java
index f6c3a82..a4e0465 100755 (executable)
@@ -180,7 +180,7 @@ public class ServletModuleContent extends ServletModule
                        if (withValues.get("creator").toString().equals(""))
                                withValues.put("creator","Anonym");
                        String id = mainModule.add(withValues);
-                       DatabaseContentToTopics.getInstance().setTopics(id,req.getParameter("to_topic"));
+                       DatabaseContentToTopics.getInstance().setTopics(id,req.getParameterValues("to_topic"));
                        //theLog.printDebugInfo(":: content :: inserted");
                        _showObject(id, req, res);
                }
@@ -295,7 +295,8 @@ public class ServletModuleContent extends ServletModule
                        if (idParam == null) throw new ServletModuleException("Falscher Aufruf: (id) nicht angegeben");
 
                        HashMap withValues = getIntersectingValues(req, DatabaseContent.getInstance());
-                       String topic_id = req.getParameter("to_topic");
+                       //String topic_id = req.getParameter("to_topic");
+                       String[] topic_id = req.getParameterValues("to_topic");
                        String content_id = req.getParameter("id");
                        // withValues.put("publish_path", StringUtil.webdbDate2path((String)withValues.get("date")));
                        if(user != null) withValues.put("user_id", user.getId());
@@ -308,7 +309,7 @@ public class ServletModuleContent extends ServletModule
                                withValues.put("creator","Anonym");
                        //theLog.printDebugInfo("updating. ");
                        String id = mainModule.set(withValues);
-                       DatabaseContentToTopics.getInstance().setTopics(req.getParameter("id"),req.getParameter("to_topic"));
+                       DatabaseContentToTopics.getInstance().setTopics(req.getParameter("id"),topic_id);
                        //theLog.printDebugInfo("update done. ");
                        String whereParam = req.getParameter("where");
                        String orderParam = req.getParameter("order");
@@ -334,8 +335,14 @@ public class ServletModuleContent extends ServletModule
                        SimpleHash mergeData =  HTMLTemplateProcessor.makeSimpleHash(entContent);
                        EntityList topicToContent = DatabaseContentToTopics.getInstance().getTopics(entContent);
                        if (topicToContent!=null && topicToContent.size()>0){
-                               Entity topics = (EntityTopics)topicToContent.elementAt(0);
-                               mergeData.put("to_topic",topics.getId());
+        theLog.printDebugInfo("topicanzahl: "+topicToContent.size());
+        Entity topics = null;
+        SimpleList topicList = new SimpleList();
+        for(int i=0;i<topicToContent.size();i++){
+          topics = (EntityTopics)topicToContent.elementAt(i);
+          topicList.add(topics.getId());
+        }
+                               mergeData.put("to_topic",topicList);
                        }
                        //obsolete, because of psqgl 7.1.x
       //mergeData.put("content_data", entContent.getContentData());