1-n-relation content to topic
authoridfx <idfx>
Wed, 29 Aug 2001 16:36:03 +0000 (16:36 +0000)
committeridfx <idfx>
Wed, 29 Aug 2001 16:36:03 +0000 (16:36 +0000)
source/mircoders/servlet/ServletModuleContent.java
source/mircoders/servlet/ServletModuleProducer.java
source/mircoders/storage/DatabaseContentToTopics.java
templates-dist/de/content.template
templates-dist/en/content.template

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());
index 10e927c..9004e8f 100755 (executable)
@@ -44,7 +44,7 @@ public class ServletModuleProducer extends ServletModule
                        if (taskParam == null) {
                                throw new ServletModuleException("Kein Task angegeben!");
                        } else {
-        Class producerModule = Class.forName("mir.producer.Producer" + taskParam);
+        Class producerModule = Class.forName("mircoders.producer.Producer" + taskParam);
         Producer producer = (Producer)producerModule.newInstance();
         HttpSession session=req.getSession(false);
                                EntityUsers user = (EntityUsers)session.getAttribute("login.uid");
index d752759..a5a511b 100755 (executable)
@@ -65,11 +65,10 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
        }
 
 
-       public void setTopics(EntityContent content, ArrayList topicId) {
-               if (content == null && topicId == null) {
+       public void setTopics(String contentId, String[] topicId) {
+               if (contentId == null && topicId == null) {
                        return;
                }
-               String contentId = content.getId();
                //first delete all row with content_id=contentId
                String sql = "delete from "+ theTable +" where content_id=" + contentId;
 
@@ -88,9 +87,9 @@ public class DatabaseContentToTopics extends Database implements StorageObject{
                //now insert
                //first delete all row with content_id=contentId
 
-               for (Iterator i = topicId.listIterator(); i.hasNext();) {
+               for (int i=0;i<topicId.length;i++) {
                        sql = "insert into "+ theTable +" (content_id,topic_id) values ("
-                                               + contentId + "," + i.next().toString() + ")";
+                                               + contentId + "," + topicId[i] + ")";
                        try {
                                con = getPooledCon();
                                // should be a preparedStatement because is faster
index 737ab0f..eec3491 100755 (executable)
@@ -18,7 +18,6 @@ p {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt}
        <input type="hidden" name="offset" value="${offset}">
        <input type="hidden" name="order" value="${order}">
        <input type="hidden" name="id" value="${id}">
-  <input type="hidden" name="to_topic2" value="${to_topic}">
        <if new>
                <input type="hidden" name="do" value="insert">
        <else>
@@ -54,10 +53,10 @@ p {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt}
                        <option value="${s.key}" <if (s.key == to_feature)>selected</if>>${s.value}</option>
                </list>
                </select>
-               <select name="to_topic">
-               <list themenPopupData as t>
-                       <option value="${t.key}" <if (t.key == to_topic)>selected</if>>${t.value}</option>
-               </list>
+               <select name="to_topic" size="5" multiple>\r
+               <list themenPopupData as t>\r
+               <option value="${t.key}" <list to_topic as to><if (t.key == to)>selected</if></list>>${t.value}</option>                        
+               </list>\r
                </select>
        </td>
 </tr>
index 5d15a48..21810f2 100755 (executable)
@@ -18,7 +18,6 @@ p {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt}
        <input type="hidden" name="offset" value="${offset}">\r
        <input type="hidden" name="order" value="${order}">\r
        <input type="hidden" name="id" value="${id}">\r
-  <input type="hidden" name="to_topic2" value="${to_topic}">\r
        <if new>\r
                <input type="hidden" name="do" value="insert">\r
        <else>\r
@@ -54,9 +53,9 @@ p {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt}
                        <option value="${s.key}" <if (s.key == to_feature)>selected</if>>${s.value}</option>\r
                </list>\r
                </select>\r
-               <select name="to_topic">\r
+               <select name="to_topic" size="5" multiple>\r
                <list themenPopupData as t>\r
-                       <option value="${t.key}" <if (t.key == to_topic)>selected</if>>${t.value}</option>\r
+               <option value="${t.key}" <list to_topic as to><if (t.key == to)>selected</if></list>>${t.value}</option>                        
                </list>\r
                </select>\r
        </td>\r