[opencms-dev] How to convert/use a String field as a Date field?
Jose Ignacio Yarza
jiyarza at opensistemas.com
Fri Apr 27 13:45:11 CEST 2012
I would like to code a custom collector from inside my own module, I
have been looking at the opencms code and I would like to check if I am
assuming right the steps. This is the plan (for opencms 7.5.0):
* Write a custom class that extends the A_CmsResourceCollector.java
* Put the custom .class file inside the /classes folder in my module (or
in the /lib if I had a jar file)
* Register that custom class in the <collectors> section in
* Then we can use the tag cms:contentload normally, specifiyng one of
the collector names returned by getCollectorNames() from the custom
Would that be correct?
On Thu, 2012-04-26 at 12:38 +0200, Jose Ignacio Yarza wrote:
> Dear List,
> Briefly, this is about finding a good strategy for
> migrating/converting/using a string field as a date field for all the
> xml content in a production site (opencms 7.5.0, ~3gb).
> Long story. A field of type OpenCmsString is storing a DATE with the
> format "dd/MM/yy":
> <xsd:element name="EventDate" type="OpenCmsString" minOccurs="1"
> maxOccurs="1" />
> We need it as OpenCmsDateTime for sorting and other business logic.
> So far, I am looking at these options:
> 1- Create a new field of type OpenCmsDateTime and convert and copy the
> value through a java task or some other way. It's tricky and dirty,
> because from then on it will be necessary to keep both fields
> synchronized in the code. And eventually get rid of the string version.
> 2- Create a custom collector with a comparator to order the string field
> as date instead of alphabetically. This would solve the listings and I
> think this is cleaner, but I am not all that happy to keep the field as
> a string.
> I am unsure about both. I was wondering if we can get somewhere mapping
> the field to a property such as releasedate, as it is, or if we could
> perform a conversion somewhere, before the mapping.
> So, before I set sail to these swampy waters, I would like some advice
> from ye ol' wise List.
> Thank you so much.
Jose Ignacio Yarza Vidal
Telf: 649 157 537
More information about the opencms-dev