[opencms-dev] How to convert/use a String field as a Date field?

Jose Ignacio Yarza jiyarza at opensistemas.com
Fri Apr 27 14:08:17 CEST 2012


Michael, thank you very much for the answer and the heads up about the
export points. 


Best,

Jose

On Fri, 2012-04-27 at 14:01 +0200, Michael Emmerich wrote:
> Jose,
> 
> 
> > Hi again,
> >
> >
> > 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
> 
> Yes, this is correct.
> 
> > * Put the custom .class file inside the /classes folder in my module (or
> > in the /lib if I had a jar file)
> 
> We prefer .jar files as it makes it a bit easier if you have added 
> multiple classes to a module.
> To speed up development, I would suggest to put the .jar or .class files 
> directly into the corresponding folders on the server and only add them 
> to the module once you have completed everything.
> And do not forget to define the export points to your module, so that 
> the .jar/.class files are exported to the server file system.
> 
> > * Register that custom class in the<collectors>  section in
> > opncms-vfs.xml
> 
> Yes, this is correct.
> 
> > * Then we can use the tag cms:contentload normally, specifiyng one of
> > the  collector names returned by getCollectorNames() from the custom
> > class.
> 
> Exactly. This explains it quite good how to add a custom collector.
> 
> Kind regards,
> Michael
> 
> 
> 
> 
> >
> > Would that be correct?
> >
> >
> > Cheers!
> >
> > Jose
> >
> >
> >
> > 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.
> >>
> >
> 

-- 
Open Sistemas
Jose Ignacio Yarza Vidal
Telf: 649 157 537






More information about the opencms-dev mailing list