Sorted object list

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Sorted object list

jjanssen
Hello,

I've got a generic question. In my wiki I'm using many sorted lists. But there must be a smarter way of creating these lists then what I'm doing now. Currently I'm doing the following:

Form 1 used to fill out object of type Project, with several attributes such as the project name and status. On a overview page I want to order the projects by name based on their status. This will create something like:

- active:
     - project1
     - project4
- closed:
     - project2
     - project5
- deprecated:
     - project3

In which all the projects are links to the pages of the projects, containing all the project information.

Has anybody any idea of a smart way of doing this. Currently I'm looping through all project objects for every possible status. This is way too much overhead.

Thanks,

Joep



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Sorted object list

jeremi joslin
On 3/14/06, [hidden email] <[hidden email]> wrote:

> Hello,
>
> I've got a generic question. In my wiki I'm using many sorted lists. But there must be a smarter way of creating these lists then what I'm doing now. Currently I'm doing the following:
>
> Form 1 used to fill out object of type Project, with several attributes such as the project name and status. On a overview page I want to order the projects by name based on their status. This will create something like:
>
> - active:
>      - project1
>      - project4
> - closed:
>      - project2
>      - project5
> - deprecated:
>      - project3
>
> In which all the projects are links to the pages of the projects, containing all the project information.
>
> Has anybody any idea of a smart way of doing this. Currently I'm looping through all project objects for every possible status. This is way too much overhead.
>
You can restrict you query to the selected status of project.


here is a sample I used in a project :
#macro (showCandidatStatus $status)
#set ($sql = ", BaseObject as obj, StringProperty as prop,
IntegerProperty as ended where obj.name=doc.fullName and
obj.className='XWiki.CandidatAnnounceClass' and
obj.name<>'XWiki.CandidatAnnounceClassTemplate' and obj.id=prop.id.id
and prop.id.name='status' and prop.value='$status' and
ended.id.id=obj.id and ended.value!=1 order by prop.value desc")


#foreach ($item in $xwiki.searchDocuments($sql))
#set($bentrydoc = $xwiki.getDocument($item))
#set($bentryobj = $bentrydoc.getObject("XWiki.CandidatClass"))
#set($CAobjs = $bentrydoc.getObjects("XWiki.CandidatAnnounceClass"))

  #foreach ($obj in $CAobjs)
    #if ($obj.status == $status)
      1.1.1 [$bentrydoc.display("name","view",
$bentryobj)>$bentrydoc.FullName]
$bentrydoc.display("AnnounceName","view", $obj)
    #end
  #end
#end
#end


Jérémi

--
Blog: http://www.jeremi.info
LinkedIn: https://www.linkedin.com/profile?viewProfile=&key=1437724
Project Manager XWiki: http://www.xwiki.org
skype: jeremi23 -- msn et gtalk : [hidden email]


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Sorted object list

THOMAS, BRIAN M (ATTSI)
In reply to this post by jjanssen
An enhancement that I made to the default Main.AllDocs page illustrates
how to do what you ask, which is to modify the sorting order of items.
It's done by composing a modification to the SQL string passed to
xwiki.searchDocuments().  There is, to the best of my knowledge, no
documentation on how exactly this string affects the database query
inside the search, but generally it looks like it gets parsed into
clauses that are inserted and/or merged into the default query at
syntactically appropriate places.  In your case, a simple "order by"
clause would appear to be all that's needed, and of course if the status
field doesn't sort in the order you want it to appear in, you have to
give them sequence numbers or something similar.

The "order by" field is passed to the doc by a parameter named "ordby",
and the page provides links that invoke it with popular values.

By the way, I do have a project management page that does something very
similar, with a table of projects containing links to plan documents and
status, priority and other fields, plus a link to a status page that
sucks journal entries from the plan docs, displaying the same table but
with internal links to the latest journal entries for that project.
I've been intending to add the ordering feature to it, but since it's in
the bells-and-whistles category from my boss's point of view, I haven't
got to that.  Of course, you are probably not doing the
xwiki.searchDocuments (although that's certainly one way of doing it),
but I believe there's a similar facility in the doc.getObjects method.

----------------------------------------------------------

#set ($ordby = $request.getParameter("ordby"))  ##
#if (!$ordby)
  #set ($ordby = "doc.web, doc.name")
#end

#set ($sql = "$where order by $ordby")

1 All Documents of this Wiki

Order by:
    [Document Name>$doc.fullName?ordby=doc.web,doc.name]
    [Creator>$doc.fullName?ordby=doc.creator]
    [Last Author>$doc.fullName?ordby=doc.author]
    [Date>$doc.fullName?ordby=doc.date desc]

#foreach ($item in $xwiki.searchDocuments($sql))
  ## display each item, keeping track of the status and displaying it
when it's different
#end

------------------------------------------------------------

brain[sic]

-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: Tuesday, March 14, 2006 12:14 AM
To: [hidden email]
Subject: [xwiki-users] Sorted object list


Hello,

I've got a generic question. In my wiki I'm using many sorted lists. But
there must be a smarter way of creating these lists then what I'm doing
now. Currently I'm doing the following:

Form 1 used to fill out object of type Project, with several attributes
such as the project name and status. On a overview page I want to order
the projects by name based on their status. This will create something
like:

- active:
     - project1
     - project4
- closed:
     - project2
     - project5
- deprecated:
     - project3

In which all the projects are links to the pages of the projects,
containing all the project information.

Has anybody any idea of a smart way of doing this. Currently I'm looping
through all project objects for every possible status. This is way too
much overhead.

Thanks,

Joep




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws