list forums in admin limited to two rows ?

View: New views
5 Messages — Rating Filter:   Alert me  

list forums in admin limited to two rows ?

by Jérémy Lal-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

description : admin page for listing forums shows only two rows max.

steps to reproduce : in
/atleap/rw/forum/forum/list.en.do
create three forums.
The last one won't appear, but will appear in the frontend.

Regards,

Jeremy.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: list forums in admin limited to two rows ?

by Roman Puchkovskiy-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is a bug, patch is attached.

Jérémy Lal пишет:

> description : admin page for listing forums shows only two rows max.
>
> steps to reproduce : in
> /atleap/rw/forum/forum/list.en.do
> create three forums.
> The last one won't appear, but will appear in the frontend.
>
> Regards,
>
> Jeremy.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
> .
>
Roman Puchkovskiy

Index: src/dao/com/blandware/atleap/persistence/hibernate/forum/ForumDAOHibernate.java
===================================================================
--- src/dao/com/blandware/atleap/persistence/hibernate/forum/ForumDAOHibernate.java (revision 1.10)
+++ src/dao/com/blandware/atleap/persistence/hibernate/forum/ForumDAOHibernate.java Thu Jan 17 15:50:29 AMT 2008
@@ -336,6 +336,8 @@
                 .append("where ")
                 .append("titleField.identifier = 'title' ")
                 .append("and annotationField.identifier = 'annotation' ")
+                .append("and title.contentLocale = f.language ")
+                .append("and annotation.contentLocale = f.language ")
                 .toString();
         if (!ignoreParent) {
             if ( parentId != null ) {
@@ -362,30 +364,29 @@
         // we know that there's something that will be found, then fetch data
  if ( total == null || total.intValue() > 0 ) {
  String hql;
-     hql = "select f, title.simpleValue, annotation.value " + hqlPart + orderByClause;
+            hql = "select distinct f, title.simpleValue, annotation.value " + hqlPart + orderByClause;
- list = executeFind(hql, queryInfo, args.toArray());
+            list = executeFind(hql, queryInfo, args.toArray());
-            Map title;
-            Set ids = new HashSet();
-            List forums = new ArrayList();
-            if (list != null) {
+            if (list == null) {
+                list = new ArrayList();
+            }
-                for ( ListIterator i = list.listIterator(); i.hasNext(); ) {
-                    Object[] objects = (Object[]) i.next();
-                    Forum forum = (Forum) objects[0];
+            for ( ListIterator i = list.listIterator(); i.hasNext(); ) {
+                Object[] objects = (Object[]) i.next();
+                Forum forum = (Forum) objects[0];
-                    Long forumId = forum.getId();
-                    if (!ids.contains(forumId)) {
-                        title = new HashMap();
+                Map title = new HashMap();
-                        title.put(forum.getLanguage().getIdentifier(), objects[1]);
-                        forum.setTitle(title);
-                        forum.setAnnotation(ConvertUtil.convertToString((byte[]) objects[2]));
+                title.put(forum.getLanguage().getIdentifier(), objects[1]);
+                forum.setTitle(title);
+                forum.setAnnotation(ConvertUtil.convertToString((byte[]) objects[2]));
-                        forum.setNumberOfTopics(getNumberOfTopics(forumId));
-                        forum.setNumberOfReplies(getNumberOfReplies(forumId));
+                i.set(forum);
+ }
+            List forums = new ArrayList();
+            for ( ListIterator i = list.listIterator(); i.hasNext(); ) {
+                Forum forum = (Forum) i.next();
+                forum.setNumberOfTopics(getNumberOfTopics(forum.getId()));
+                forum.setNumberOfReplies(getNumberOfReplies(forum.getId()));
-                        forum.setUsersSubscribed(getUsersSubscribedMap(forum.getId()));
-                        forum.setLastPost(getLastPost(forum.getId()));
-                        forums.add(forum);
+                forum.setUsersSubscribed(getUsersSubscribedMap(forum.getId()));
+                forum.setLastPost(getLastPost(forum.getId()));
+                forums.add(forum);
-                        ids.add(forumId);
-                    }
+            }
-                }
-            }
             list = forums;
             if ( total == null ) {
                 total = new Integer(list.size());

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

Re: list forums in admin limited to two rows ?

by Jérémy Lal-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

derby version issue ?

i patched, then i got a sql exception :

org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL
[select distinct forum0_."page_id" as id1_0_, forum0_2_."version" as version2_0_, forum0_2_."class_name" as class3_0_, forum0_1_."uri" as uri2_2_, forum0_1_."usage_counter" as usage3_2_, forum0_1_."active" as active4_2_, forum0_."language" as language2_8_, forum0_."parent_id" as parent3_8_, forum0_."pos" as pos4_8_, forum0_."page_id" as col_0_0_, contentfie2_."simple_value" as col_1_0_, contentfie4_."value" as col_2_0_ from "al_forum_forum" forum0_ inner join "al_core_page" forum0_1_ on forum0_."page_id"=forum0_1_."localizable_id" inner join "al_core_localizable" forum0_2_ on forum0_."page_id"=forum0_2_."id" left outer join "al_core_field" contentfie1_ on forum0_."page_id"=contentfie1_."localizable_id" left outer join "al_core_field_value" contentfie2_ on contentfie1_."id"=contentfie2_."field_id" left outer join "al_core_field" contentfie3_ on forum0_."page_id"=contentfie3_."localizable_id" left outer join "al_core_field_value" contentfie4_ on contentfie3_."id"=contentfie4_."
field_id" left outer join "al_core_page_role" roles5_ on forum0_."page_id"=roles5_."page_id" left outer join "al_core_role" role6_ on roles5_."rolename"=role6_."rolename" where (contentfie1_."identifier"='title' )and(contentfie3_."identifier"='annotation' )and(contentfie2_."locale_identifier"=forum0_."language" )and(contentfie4_."locale_identifier"=forum0_."language" )and(forum0_."parent_id" is null ) order by  forum0_."pos"];
SQL state [X0X67]; error code [-1]; Les colonnes de type 'BLOB' ne peuvent pas être utilisées dans CREATE INDEX, ORDER BY, GROUP BY, UNION, INTERSECT, EXCEPT ou DISTINCT parce que les comparaisons ne sont pas prises en charge pour ce type.; nested exception is java.sql.SQLException: Les colonnes de type 'BLOB' ne peuvent pas être utilisées dans CREATE INDEX, ORDER BY, GROUP BY, UNION, INTERSECT, EXCEPT ou DISTINCT parce que les comparaisons ne sont pas prises en charge pour ce type.

which means 'comparisons are not handled for type BLOB'...



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: list forums in admin limited to two rows ?

by Jérémy Lal-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-     hql = "select f, title.simpleValue, annotation.value " + hqlPart + orderByClause;
+            hql = "select distinct f, title.simpleValue, annotation.value " + hqlPart + orderByClause;

the reason seems to be there, i just dropped the "distinct" and it's ok.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: list forums in admin limited to two rows ?

by Roman Puchkovskiy-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You are right, 'distinct' cannot be used in some DBMSs for BLOB columns.
But it's not enough just to remove 'distinct' from the query, because
you will get phantom rows in the list.
Please replace ForumDAOHibernate#listForums() method with attached one.

Jérémy Lal пишет:

> -            hql = "select f, title.simpleValue, annotation.value " +
> hqlPart + orderByClause;
> +            hql = "select distinct f, title.simpleValue,
> annotation.value " + hqlPart + orderByClause;
>
> the reason seems to be there, i just dropped the "distinct" and it's ok.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
> .
>
Roman Puchkovskiy

    /**
     * @see com.blandware.atleap.persistence.forum.ForumDAO#listForums(com.blandware.atleap.common.util.QueryInfo)
     */
    public PartialCollection listForums(QueryInfo queryInfo) {
                String whereClause = "";
                String orderByClause = "";
                if ( queryInfo != null ) {
                        whereClause = queryInfo.getWhereClause();
                        orderByClause = queryInfo.getOrderByClause();
                }

                if ( whereClause == null || whereClause.length() == 0 ) {
                        whereClause = "";
                }
                if ( orderByClause != null && orderByClause.length() != 0 ) {
                        orderByClause = " order by " + orderByClause;
                } else {
                        orderByClause = " order by f.position";
                }

        Long parentId = null;
        boolean ignoreParent = false;
        if ( queryInfo != null ) {
            if ( queryInfo.getQueryParameters() != null ) {
                parentId = (Long) queryInfo.getQueryParameters().get("parentId");
                Boolean ignore = (Boolean) queryInfo.getQueryParameters().get("ignoreParent");
                if (ignore != null) {
                    ignoreParent = ignore.booleanValue();
                }
            }
        }

                List list;
                Integer total = null;

                String hqlPart;
                ArrayList args = new ArrayList();
        hqlPart = new StringBuffer("from Forum as f ")
                .append("left outer join f.contentFields as titleField ")
                .append("left outer join titleField.contentFieldValues as title ")
                .append("left outer join f.contentFields as annotationField ")
                .append("left outer join annotationField.contentFieldValues as annotation ")
                        .append("left outer join f.roles as role ")
                .append("where ")
                .append("titleField.identifier = 'title' ")
                .append("and annotationField.identifier = 'annotation' ")
                .append("and title.contentLocale = f.language ")
                .append("and annotation.contentLocale = f.language ")
                .toString();
        if (!ignoreParent) {
            if ( parentId != null ) {
                hqlPart += "and f.parent.id = ? ";
                args.add(parentId);
            } else {
                hqlPart += "and f.parent is null ";
            }
        }
        if (whereClause.length() > 0) {
            hqlPart = hqlPart + "and " + whereClause;
        }

                if ( queryInfo != null && queryInfo.getLimit() != null && queryInfo.getOffset() != null ) {
                        // query count
                        String hqlForTotal = "select count(distinct f.id) " + hqlPart;
                        total = (Integer) findUniqueResult(hqlForTotal, args.toArray());
                        if ( total == null ) {
                                total = new Integer(0);
                        }
                }

        // If we don't have any info about the total number of results yet or
        // we know that there's something that will be found, then fetch data
                if ( total == null || total.intValue() > 0 ) {
                        String hql;
            hql = "select f, title.simpleValue, annotation.value " + hqlPart + orderByClause;
            list = executeFind(hql, queryInfo, args.toArray());
            if (list == null) {
                list = new ArrayList();
            }
            for ( ListIterator i = list.listIterator(); i.hasNext(); ) {
                Object[] objects = (Object[]) i.next();
                Forum forum = (Forum) objects[0];
                Map title = new HashMap();
                title.put(forum.getLanguage().getIdentifier(), objects[1]);
                forum.setTitle(title);
                forum.setAnnotation(ConvertUtil.convertToString((byte[]) objects[2]));
                i.set(forum);
                        }
            List forums = new ArrayList();
            Set ids = new HashSet();
            for ( ListIterator i = list.listIterator(); i.hasNext(); ) {
                Forum forum = (Forum) i.next();
                if (!ids.contains(forum.getId())) {
                    forum.setNumberOfTopics(getNumberOfTopics(forum.getId()));
                    forum.setNumberOfReplies(getNumberOfReplies(forum.getId()));
                    forum.setUsersSubscribed(getUsersSubscribedMap(forum.getId()));
                    forum.setLastPost(getLastPost(forum.getId()));
                    forums.add(forum);
                    ids.add(forum.getId());
                }
            }
            list = forums;
            if ( total == null ) {
                total = new Integer(list.size());
            }
                } else {
                        list = new ArrayList();
                }

                return new PartialCollection(list, total);

    }
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...
LightInTheBox - Buy quality products at wholesale price