[opencms-dev] Sorting of elements with cms:contentload

Rüdiger Kurz r.kurz at alkacon.com
Thu May 20 16:35:53 CEST 2010


Frank,

it is possible to write your own ResourceCollector by extending the 
abstract class A_CmsResourceCollector. You can use the class 
org.opencms.file.collectors.CmsDefaultResourceCollector as template for 
your individual collector. add an additional parameter to this collector 
which indicates the column you want to search for.

Don't forget to add the new Collector into the <collectors> node of the 
file opencms-vfs.xml.

For Implementation you need a comparator which compares the content of 
your XML Content. For performance reasons I would recommend you to map 
the Company name and the Location on a property because unmarshaling of 
XML contents is an expensive Task and very complicated.

good luck ...


Am 19.05.2010 16:51, schrieb Frank Pertack:
> Hello,
>
> I have a slight problem with sorting a list of xml-documents.
> I constructed a jsp, that shows all employees of our company-group in
> alphabetical order of their lastnames.
>
> Additionally to that, I like to have a sorting by company
> (=Gesellschaft) and by location (=Standort),how do I realize this?
>
>
> When I use the following maentry.xsd, how can I change this, to make the
> contentload sort the xml-files according to a different field?
>
> code
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> <!--
> XSD file for the MaEntry content type
> -->
> <!-- 1. Root Element -->
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
>
> <!-- 2. Define the location of the schema location -->
> <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"/>
> <!--<xsd:include
> schemaLocation="opencms://system/modules/org.vug.templates/schemas/maentry.xsd"/>-->
>
> <!-- 3. Root element name and type of our XML type -->
> <xsd:element name="MaEntrys" type="OpenCmsMaEntrys"/>
>
> <!-- 4. Definition of the type described above -->
> <xsd:complexType name="OpenCmsMaEntrys">
> <xsd:sequence>
> <xsd:element name="MaEntry" type="OpenCmsMaEntry" minOccurs="0"
> maxOccurs="unbounded"/>
> </xsd:sequence>
> </xsd:complexType>
>
> <!-- 5. Data field definitions -->
> <xsd:complexType name="OpenCmsMaEntry">
> <xsd:sequence>
> <xsd:element name="Title" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> <!-- Personendaten:-->
> <xsd:element name="LastName" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> <xsd:element name="FirstName" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> <!-- Kontaktdaten:-->
> <xsd:element name="Phone" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> <xsd:element name="Fax" type="OpenCmsString" minOccurs="0" maxOccurs="1" />
> <xsd:element name="Mobile" type="OpenCmsString" minOccurs="0"
> maxOccurs="1" />
> <xsd:element name="Email" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> <xsd:element name="PrivatePhone" type="OpenCmsString" minOccurs="0"
> maxOccurs="1" />
> <!-- Category named "Company":-->
> <xsd:element name="Company" type="OpenCmsString" minOccurs="0"
> maxOccurs="20" />
> <xsd:element name="Location" type="OpenCmsString" minOccurs="0"
> maxOccurs="10" />
> <xsd:element name="Function" type="OpenCmsString" minOccurs="0"
> maxOccurs="1" />
> <!-- Zusatzdaten:-->
> <xsd:element name="Image" type="OpenCmsVfsFile" minOccurs="0"
> maxOccurs="1" />
> <xsd:element name="Alignment" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> <xsd:element name="Birthday" type="OpenCmsDateTime" minOccurs="0"
> maxOccurs="1" />
> <xsd:element name="Date" type="OpenCmsDateTime" minOccurs="1"
> maxOccurs="1" />
> <xsd:element name="Comments" type="OpenCmsString" minOccurs="0"
> maxOccurs="1" />
> </xsd:sequence>
> <xsd:attribute name="language" type="OpenCmsLocale" use="required"/>
> </xsd:complexType>
>
> <!-- 6. Annotations are used to define additional settings for our
> content type -->
> <xsd:annotation>
> <xsd:appinfo>
> <!-- 7. Mappings allow data fields to be mapped to content properties -->
> <mappings>
> <mapping element="LastName" mapto="property:Title" />
> <mapping element="FirstName" mapto="property:Text" />
> <mapping element="Date" mapto="attribute:datereleased" />
> </mappings>
>
> <!-- 8. Validation rules may be create for field entry -->
> <validationrules>
> <!--
> <rule element="BlogText" regex="!.*[Bl]og.*" type="warning"
> message="${key.editor.warning.BlogEntry.dontallowblog|${validation.path}}"/>
> -->
> </validationrules>
>
> <!-- 9. Default values can be set for each field type -->
> <defaults>
> <default element="Date" value="${currenttime}"/>
> <default element="Alignment" value="left"/>
> </defaults>
>
> <!-- 10. This section controls which widgets are used to edit the data
> fields -->
> <layouts>
> <layout element="Title" widget="StringWidget"/>
> <layout element="LastName" widget="StringWidget"/>
> <layout element="FirstName" widget="StringWidget"/>
> <layout element="Phone" widget="StringWidget"/>
> <layout element="Fax" widget="StringWidget"/>
> <layout element="Mobile" widget="StringWidget"/>
> <layout element="Email" widget="StringWidget"/>
> <layout element="PrivatePhone" widget="StringWidget"/>
> <layout element="Birthday" widget="DateTimeWidget"/>
> <layout element="Date" widget="DateTimeWidget"/>
> <layout element="Image" widget="ImageGalleryWidget"/>
> <layout element="Alignment" widget="SelectorWidget"
> configuration="left|right|center" />
> <layout element="Company" widget="SelectorWidget"
> configuration="Vater 4Office GmbH|Vater Bankenberatung GmbH|Vater Bank
> IT|Vater BizCon GmbH|Vater ERPteam GmbH|
> Vater ESN Business Academy GmbH|Vater Holding GmbH|Vater KNS GmbH|Vater
> NetCom GmbH|Vater pcs GmbH|
> Vater Solution GmbH|Vater SysCon GmbH" />
> <layout element="Location" widget="SelectorWidget"
> configuration="Bremen, Herrmann-Ritter-Straße 106-114|Hamburg,
> Schellingstraße 17|Kiel, Am Kiel-Kanal 1|Kiel, Boschstraße 5|
> Kiel-Wellsee, Liebigstraße 26|Kiel-Schwentinental, Lise-Meitner-Straße
> 25-29|
> Kiel-Schwentinental, Wasserwerksweg 18" />
> <layout element="Function" widget="StringWidget"/>
> <layout element="Comments" widget="TextareaWidget"/>
> </layouts>
>
> <!-- 11. UI Localization -->
> <resourcebundle name="org.vug.templates.workplace"/>
>
> <!-- 12. this section controls relationship checking -->
> <relations>
> <relation element="Image" type="strong" invalidate="node" />
> </relations>
>
> <!-- 13. Previewing URI -->
> <preview uri="${previewtempfile}" />
>
> <!-- 14. Model Folder -->
> <modelfolder uri="/system/modules/org.vug.templates/models/" />
> </xsd:appinfo>
> </xsd:annotation>
>
> </xsd:schema>
>
> end of
> code--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Somehow I realized, it could be working by changing the mapping of the
> title, but I don't know what to change here...:
>
> Do you have any ideas?
>
> Mit freundlichen Grüßen
>
>
>
> Frank Pertack
>
>
> Vater Solution GmbH
> Liebigstraße 26
> 24145 Kiel
>
> Telefon: +49 431 20084-210
> Telefax: +49 431 20084-222
> Mobil: +49 151 16353519
> mailto: fpertack at vater-gruppe.de
> http://www.vater-gruppe.de
>
>
>
> Amtsgericht Kiel, HRB 6403
> Geschäftsführer:
> Klaus-Hinrich Vater
> Michael Wiese
> -----
> Diese Email enthält ggfs. vertrauliche und/oder rechtlich geschützte
> Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
> Email irrtümlich erhalten haben, informieren Sie bitte sofort den
> Absender und vernichten Sie diese Email. Das unerlaubte Kopieren sowie
> die unbefugte Weitergabe dieser Email sind nicht gestattet.
>
>
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev

-- 
Kind Regards,
Rüdiger

-------------------
Rüdiger Kurz

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org



More information about the opencms-dev mailing list