I read the code, but it doesn't sort by multiple properties. I'm writing components that help sort by properties.
On Fri, Nov 16, 2012 at 11:04 PM, Eduard Moraru <[email protected]>wrote: > Hi, > > I`ve recently published a snippet [1] that provides a macro for sorting > lists of XWiki objects in velocity. > > As for platform, we should probably either include such a macro in > macros.vm, or extend SortTool and expose a method for handling XWiki > objects. > > Hope this helps, > Eduard > > ---------- > [1] > > http://extensions.xwiki.org/xwiki/bin/view/Extension/Sort+a+list+of+XWiki+objects > > > On Fri, Nov 16, 2012 at 7:40 AM, crocket <[email protected]> wrote: > > > OK, $obj.getProperty("prop").getValue() gets the desired values. > > > > $sorttool.sort conforms only to java bean standards. > > > > I'll implement something like > > $sorttool.*sort< > > > http://velocity.apache.org/tools/releases/1.4/javadoc/org/apache/velocity/tools/generic/SortTool.html#sort(java.util.Collection > > , > > java.util.List)>*(java.util.Collection collection, > > java.util.List properties) that conforms to XWiki Object standards. > > > > > > On Fri, Nov 16, 2012 at 3:06 AM, Jerome Velociter <[email protected] > > >wrote: > > > > > Hi, > > > > > > > > > On 11/15/2012 03:00 PM, crocket wrote: > > > > > >> Ouch, there is a typo. $xwiki -> $doc > > >> > > >> #set($services=$xwiki.**getDocument("Private.Snowberry Network > > >> Services").getObjects("**Private.NetworkServices")) > > >> > > >> #foreach($prop in $services[0].getProperties()) > > >> $services[0].getProperty($**prop.getName()).getName() = > > >> $services[0].getProperty($**prop.getName()).getProperty().** > > >> getClassType() > > >> #end > > >> > > >> The velocity snippet above produced an output. > > >> > > >> port = com.xpn.xwiki.objects.**LongProperty > > >> protocol = com.xpn.xwiki.objects.**StringListProperty > > >> application = com.xpn.xwiki.objects.**StringProperty > > >> description = com.xpn.xwiki.objects.**StringProperty > > >> service = com.xpn.xwiki.objects.**StringProperty > > >> firewalled = com.xpn.xwiki.objects.**IntegerProperty > > >> > > >> It appears that objects returned from $doc.getObjects("Class") have > > >> properties that belong to com.xpn.xwiki.objects package. > > >> I perused the package on > > >> http://maven.xwiki.org/site/**docs/xwiki-javadoc-4.2.x/com/** > > >> xpn/xwiki/objects/package-**summary.html< > > > http://maven.xwiki.org/site/docs/xwiki-javadoc-4.2.x/com/xpn/xwiki/objects/package-summary.html > > > > > >> > > >> I guess I will have to implement a Comparator that compares each of > the > > >> following properties in the com.xpn.xwiki.objects package. > > >> > > >> BaseStringProperty > > >> DateProperty > > >> DoubleProperty > > >> FloatProperty > > >> IntegerProperty > > >> LongProperty > > >> NumberProperty > > >> > > >> Am I doing it right? or is it a bad idea to make separate comparison > > codes > > >> for each of those properties? > > >> > > > > > > You might be interested by http://velocity.apache.org/** > > > > tools/devel/javadoc/org/**apache/velocity/tools/generic/**SortTool.html< > > > http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/SortTool.html > > > > > > > > > Hope this helps, > > > Jerome > > > > > > > > >> On Thu, Nov 15, 2012 at 9:57 PM, crocket <[email protected]> > > wrote: > > >> > > >> I want to make such a Comparator so that I can sort objects retrieved > > by > > >>> $xwiki.getObjects("Class") > > >>> If I had the Comparator, I'd be able to pass it to a collection sort > > >>> method and sort objects. > > >>> > > >>> I'm planning to make that Comparator in a groovy snippet. > > >>> I may be able to make a Component for that even. > > >>> > > >>> Is it possible? > > >>> > > >>> If it was possible, would you give me some hints? > > >>> > > >>> ______________________________**_________________ > > >> devs mailing list > > >> [email protected] > > >> http://lists.xwiki.org/**mailman/listinfo/devs< > > http://lists.xwiki.org/mailman/listinfo/devs> > > >> > > > > > > ______________________________**_________________ > > > devs mailing list > > > [email protected] > > > http://lists.xwiki.org/**mailman/listinfo/devs< > > http://lists.xwiki.org/mailman/listinfo/devs> > > > > > _______________________________________________ > > devs mailing list > > [email protected] > > http://lists.xwiki.org/mailman/listinfo/devs > > > _______________________________________________ > devs mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/devs > _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

