4 Replies Latest reply: Mar 14, 2013 1:06 AM by Jörg Hoh RSS

    Query for fetching assets with the same ordering as used in DAM

    jkmgbrt Community Member

      We are using the QueryBuilder API and are trying to write a query that should return assets ordered by the same order as they have in the DAM (i.e. by the index number shown in the leftmost column when viewing the assets underneath a folder in the DAM). If we do not specify an "order by" predicate the assets are ordered ascending by last modified date. Looking at the asset nodes in CRX, they don´t seem to have any property containing the index which could be used for such an ordering. Is such a query possible to write?

       

      Thanks

      Joakim

        • 1. Re: Query for fetching assets with the same ordering as used in DAM
          Yogesh Upadhyay Community Member

          I don't think there is any special predicate to do that, Code is simply getting all children of given asset and returning them (Offcource there is some ordering logic). If You want exact informaiton I would suggest to use json call that DAM is making i.e.

           

          HOST:POST/<PATH OF DAM>.assets.json

           

          Or decompile AssetListServlet.java ans see how it is implemeted

           

          Yogesh

          www.wemblog.com

          • 2. Re: Query for fetching assets with the same ordering as used in DAM
            jkmgbrt Community Member

            Thanks for your reply Yogesh, that servlet obviously lists the assets in the same order as displayed in the DAM, but we need to execute a query using the Query Builder API (in which we use parameters to filter the result on path, tags, properties etc) and need a sorted result. If you just grab the parent sling:OrderedFolder JCR node in the DAM which contains the assets and do folder.getNodes() (or if you grab it as a Resource and do resource.listChildren()), the assets are returned in the correct order (I guess that might be what the AssetListServlet does behind the scenes?)

             

            Joakim

            • 3. Re: Query for fetching assets with the same ordering as used in DAM
              chaack

              Hi Joakim

               

              i'm pretty sure (without decompiling) that the AssetListServlet "lists" the children of the node (resolver.listChildren(res)) - this would give you the natural order (which is used in the DAM admin).

               

              so to your last question: no - it is not possible to write such a query - and it is not necessary ;-).

               

              Anyway - using the given hierarchy in crx and accessing the stuff direct with the JCR api's without querying is always the prefered (optimized) way to get content out of the repository.

              • 4. Re: Query for fetching assets with the same ordering as used in DAM
                Jörg Hoh Adobe Employee

                If you want to list assets of a given folder in the order they appear in the DAM admin, do not use a query! Use either the JCR API or the Sling Resource API, as the first one returns the children in the order they are saved in teh Repository, and the Sling API only abstracts from the nodes, but does not change the ordering.

                 

                In general do not write a query in that case. The performance penalty compared to simple using JCR API might be very high, especially with large repositories.

                 

                Jörg