Update of 
/var/cvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository
In directory 
james.mmbase.org:/tmp/cvs-serv20483/cmsc/contentrepository/src/java/com/finalist/cmsc/repository

Modified Files:
        RepositoryUtil.java 
Log Message:
CMSC-1313  Assets: Sorting problems in list views.


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository
See also: http://www.mmbase.org/jira/browse/CMSC-1313


Index: RepositoryUtil.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/RepositoryUtil.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- RepositoryUtil.java 5 Mar 2009 08:01:38 -0000       1.38
+++ RepositoryUtil.java 5 Mar 2009 08:42:54 -0000       1.39
@@ -76,6 +76,7 @@
    public static final String CONTENTREL = "contentrel";
    public static final String DELETIONREL = "deletionrel";
    public static final String CREATIONREL = "creationrel";
+   public static final String TYPEDEF = "typedef";
 
    public static final String ALIAS_ROOT = "repository.root";
    public static final String ALIAS_TRASH = "repository.trash";
@@ -850,8 +851,15 @@
          if (orderby == null) {
             orderby = CONTENTREL + ".pos";
          }
+         if("otype".equals(orderby)){
+            query = SearchUtil.createRelatedNodeListQuery(channel, 
destinationManager, CONTENTREL);
+            query.addStep(query.getCloud().getNodeManager("typedef"));
+            Queries.addConstraints(query, 
destinationManager+".otype="+TYPEDEF+".number");
+            Queries.addSortOrders(query, TYPEDEF+".name", direction);
+         }else {
          query = SearchUtil.createRelatedNodeListQuery(channel, 
destinationManager, CONTENTREL, null, null, orderby,
                direction);
+         }
       } else {
          if (orderby == null) {
             orderby = CONTENTREL + ".pos";
@@ -861,10 +869,19 @@
          if (contentchannels.isEmpty()) {
             throw new IllegalArgumentException("contentchannels or 
collectionchannel is empty; should be at least one.");
          }
+         if("otype".equals(orderby)){
+            query = SearchUtil.createRelatedNodeListQuery(channel, 
destinationManager, CONTENTREL);
+            SearchUtil.addFeatures(query, contentchannels.getNode(0), 
destinationManager, CONTENTREL, null, null, null,
+                  null);
+            query.addStep(query.getCloud().getNodeManager("typedef"));
+            Queries.addConstraints(query, 
destinationManager+".otype="+TYPEDEF+".number");
+            Queries.addSortOrders(query, TYPEDEF+".name", direction);
+         }else {
          query = SearchUtil.createRelatedNodeListQuery(contentchannels, 
destinationManager, CONTENTREL);
          SearchUtil.addFeatures(query, contentchannels.getNode(0), 
destinationManager, CONTENTREL, null, null, orderby,
                direction);
       }
+      }
 
       if (contenttypes != null && contenttypes.size() > 1) {
          SearchUtil.addTypeConstraints(query, contenttypes);
@@ -952,17 +969,36 @@
 
       NodeQuery query;
       if (isContentChannel(channel)) {
+         if("otype".equals(orderby)){
+            query = SearchUtil.createRelatedNodeListQuery(channel, 
sourceManager, CREATIONREL, null, null, null,
+               null, SOURCE);
+            query.addStep(query.getCloud().getNodeManager("typedef"));
+            Queries.addConstraints(query, 
sourceManager+".otype="+TYPEDEF+".number");
+            Queries.addSortOrders(query, TYPEDEF+".name", direction);
+         }else {
          query = SearchUtil.createRelatedNodeListQuery(channel, sourceManager, 
CREATIONREL, null, null, orderby,
                direction, SOURCE);
+         }
       } else {
          NodeList contentchannels = SearchUtil.findRelatedNodeList(channel, 
CONTENTCHANNEL, COLLECTIONREL);
          if (contentchannels.isEmpty()) {
             throw new IllegalArgumentException("contentchannels or 
collectionchannel is empty; should be at least one.");
          }
-         query = SearchUtil.createRelatedNodeListQuery(contentchannels, 
sourceManager, CREATIONREL);
+         if("otype".equals(orderby)){
+            query = SearchUtil.createRelatedNodeListQuery(channel, 
sourceManager, CREATIONREL, null, null, null,
+                  null, SOURCE);
+            SearchUtil.addFeatures(query, contentchannels.getNode(0), 
sourceManager, CREATIONREL, null, null, null,
+                  null);
+            query.addStep(query.getCloud().getNodeManager("typedef"));
+            Queries.addConstraints(query, 
sourceManager+".otype="+TYPEDEF+".number");
+            Queries.addSortOrders(query, TYPEDEF+".name", direction);
+         }else {
+            query = SearchUtil.createRelatedNodeListQuery(channel, 
sourceManager, CREATIONREL, null, null, null,
+                  null, SOURCE);
          SearchUtil.addFeatures(query, contentchannels.getNode(0), 
sourceManager, CREATIONREL, null, null, orderby,
                direction);
       }
+      }
 
       if (assettypes != null && assettypes.size() > 1) {
          SearchUtil.addTypeConstraints(query, assettypes);
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to