indy.nl update
authorzapata <zapata>
Sun, 7 Jul 2002 20:28:38 +0000 (20:28 +0000)
committerzapata <zapata>
Sun, 7 Jul 2002 20:28:38 +0000 (20:28 +0000)
source/mirlocal/indymedia.nl/IndyNLDataModelLocalizer.java
source/mirlocal/indymedia.nl/IndyNLProducerLocalizer.java

index 5815fb4..843695b 100755 (executable)
@@ -10,9 +10,11 @@ public class IndyNLDataModelLocalizer extends MirBasicDataModelLocalizer {
     super.constructContentAdapterDefinition( anEntityAdapterDefinition );
 
     try {
-      anEntityAdapterDefinition.addCalculatedField("to_trashedcomments", new ContentToTrashedCommentsField());
-      anEntityAdapterDefinition.addCalculatedField("trashedcommentcount", new ContentTrashedCommentCountField());
-      anEntityAdapterDefinition.addCalculatedField("commentcount", new ContentCommentCountField());
+      anEntityAdapterDefinition.addCalculatedField("to_trashedcomments", new ContentToCommentsField(" and is_published='0'"));
+      anEntityAdapterDefinition.addCalculatedField("trashedcommentcount", new ContentCommentCountField(" and is_published='0'"));
+      anEntityAdapterDefinition.addCalculatedField("commentcount", new ContentCommentCountField(" and is_published='1'"));
+      anEntityAdapterDefinition.addCalculatedField("to_allcomments", new ContentToCommentsField(""));
+      anEntityAdapterDefinition.addCalculatedField("to_comments_reversed", new ContentToCommentsField(" and is_published='1'", "webdb_create desc"));
     }
     catch (Throwable t) {
       throw new MirLocalizerFailure(t.getMessage(), t);
@@ -20,12 +22,27 @@ public class IndyNLDataModelLocalizer extends MirBasicDataModelLocalizer {
   }
 
 
-  protected class ContentToTrashedCommentsField implements EntityAdapterDefinition.CalculatedField {
+  protected class ContentToCommentsField implements EntityAdapterDefinition.CalculatedField {
+    private String extraCondition;
+    private String order;
+
+
+    public ContentToCommentsField(String anExtraCondition, String anOrder) {
+      super();
+
+      order = anOrder;
+      extraCondition = anExtraCondition;
+    }
+
+    public ContentToCommentsField(String anExtraCondition) {
+      this(anExtraCondition, "webdb_create");
+    }
+
     public Object getValue(EntityAdapter anEntityAdapter) {
       try {
         return anEntityAdapter.getRelation(
-                    "to_media="+anEntityAdapter.get("id")+" and is_published='0'",
-                    "webdb_create",
+                    "to_media="+anEntityAdapter.get("id") + " " + extraCondition,
+                    order,
                     "comment" );
       }
       catch (Throwable t) {
@@ -35,24 +52,19 @@ public class IndyNLDataModelLocalizer extends MirBasicDataModelLocalizer {
   }
 
   protected class ContentCommentCountField implements EntityAdapterDefinition.CalculatedField {
-    public Object getValue(EntityAdapter anEntityAdapter) {
-      try {
-        return Integer.toString(
-            DatabaseComment.getInstance().getSize(
-                  "to_media="+anEntityAdapter.get("id")+" and is_published='1'"));
-      }
-      catch (Throwable t) {
-        throw new RuntimeException(t.getMessage());
-      }
+    private String extraCondition;
+
+    public ContentCommentCountField(String anExtraCondition) {
+      super();
+
+      extraCondition = anExtraCondition;
     }
-  }
 
-  protected class ContentTrashedCommentCountField implements EntityAdapterDefinition.CalculatedField {
     public Object getValue(EntityAdapter anEntityAdapter) {
       try {
         return Integer.toString(
             DatabaseComment.getInstance().getSize(
-                  "to_media="+anEntityAdapter.get("id")+" and is_published='0'"));
+                  "to_media="+anEntityAdapter.get("id")+" " + extraCondition));
       }
       catch (Throwable t) {
         throw new RuntimeException(t.getMessage());
index 7533e83..104c316 100755 (executable)
@@ -184,7 +184,7 @@ public class IndyNLProducerLocalizer extends MirBasicProducerLocalizer {
                                       new EvaluatedAssignmentProducerNode( "featuresinclude", "/producer/indymedia.nl/features.template",
                                         new GeneratingProducerNode(
                                             "/producer/indymedia.nl/start.template",
-                                            "${config.storageRoot}/index.shtml"
+                                            "${config.storageRoot}/index.html"
                                         )
                                       )))))
                                     )