jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • GeoServer
  • GEOS-4853

KML Time template does not work anymore due to XSDateTimeBinding changes

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: 2.1.2
  • Fix Version/s: 2.1.3
  • Component/s: Google Earth KML Output
  • Labels:
    None

Description

The XSDateTimeBinding used to take a Calendar as a parameter, but recent changes made it work only with a Date instead.

The following code in the KMLMapTransformer broke as a result:

protected String encodeDateTime(Date date) {
            if (date != null) {
                Calendar c = Calendar.getInstance();
                c.setTime(date);
                return new XSDateTimeBinding().encode(c, null);
            } else {
                return null;
            }
        }

Issue Links

depends upon

Bug - A problem which impairs or prevents the functions of the product. GEOT-3957 Regression: XSDateTimeBinding cannot handle calendar anymore

  • Major - Major loss of function.
  • Resolved - A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Andrea Aime added a comment - 18/Nov/11 8:46 AM

We can change the KML code to avoid building the calendar, but I'm wondering if other code might have been broken by the XSDateTimeBinding implementation changes?

The old code in XSDateTimeBinding used to be:

public String encode(Object object, String value) {
        Calendar datetime = (Calendar) object;

        return DatatypeConverterImpl.getInstance().printDateTime(datetime);
    }

while the new code is:

final Date timestamp = (Date) object;// lets catch up java.util.Date as well as
                                             // java.sql.Timestamp
        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
        cal.clear();
        cal.setTimeInMillis(timestamp.getTime());
        return DatatypeConverterImpl.getInstance().printDateTime(cal);

The KML call results in a ClassCastException

Show
Andrea Aime added a comment - 18/Nov/11 8:46 AM We can change the KML code to avoid building the calendar, but I'm wondering if other code might have been broken by the XSDateTimeBinding implementation changes? The old code in XSDateTimeBinding used to be:
public String encode(Object object, String value) {
        Calendar datetime = (Calendar) object;

        return DatatypeConverterImpl.getInstance().printDateTime(datetime);
    }
while the new code is:
final Date timestamp = (Date) object;// lets catch up java.util.Date as well as
                                             // java.sql.Timestamp
        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
        cal.clear();
        cal.setTimeInMillis(timestamp.getTime());
        return DatatypeConverterImpl.getInstance().printDateTime(cal);
The KML call results in a ClassCastException
Hide
Permalink
Andrea Aime added a comment - 18/Nov/11 8:48 AM

Btw, having attributes as Calendar is not forbidden in our object model, the shapefile data store in particular can write them out, it checks if the object value is a Date or a Calendar and acts consequently.

Show
Andrea Aime added a comment - 18/Nov/11 8:48 AM Btw, having attributes as Calendar is not forbidden in our object model, the shapefile data store in particular can write them out, it checks if the object value is a Date or a Calendar and acts consequently.
Hide
Permalink
Justin Deoliveira added a comment - 18/Nov/11 10:07 AM

Yeah... this was my worry when making the change, which is why I insisted that full tests (including cite) were run... but it seems not everything was caught, side affect of the poor test coverage in KML i suppose.

I guess a good way forward would be to have the bindings handle the calendar case, rather then straight cast to Date. A good measure for backwards compatibility. Do we have a converter that properly converts from Calendar to Date? If so it should be easy enough, just one liners in each of the bindings.

Gabriel?

Show
Justin Deoliveira added a comment - 18/Nov/11 10:07 AM Yeah... this was my worry when making the change, which is why I insisted that full tests (including cite) were run... but it seems not everything was caught, side affect of the poor test coverage in KML i suppose. I guess a good way forward would be to have the bindings handle the calendar case, rather then straight cast to Date. A good measure for backwards compatibility. Do we have a converter that properly converts from Calendar to Date? If so it should be easy enough, just one liners in each of the bindings. Gabriel?
Hide
Permalink
Andrea Aime added a comment - 18/Nov/11 10:20 AM

I don't think we have it, but writing one, or just add the manual conversion in XSDateTimeBinding, should be trivial.
I agree having XSDateTimeBinding just call Converters.convert(whateverObject, Date.class) would look cleaner

Show
Andrea Aime added a comment - 18/Nov/11 10:20 AM I don't think we have it, but writing one, or just add the manual conversion in XSDateTimeBinding, should be trivial. I agree having XSDateTimeBinding just call Converters.convert(whateverObject, Date.class) would look cleaner
Hide
Permalink
Andrea Aime added a comment - 19/Nov/11 1:41 AM

Upping priority as it is a regression on the stable series

Show
Andrea Aime added a comment - 19/Nov/11 1:41 AM Upping priority as it is a regression on the stable series
Hide
Permalink
Andrea Aime added a comment - 19/Nov/11 1:46 AM

Ah, forgot that Gabriel is away (vacation right?)

Show
Andrea Aime added a comment - 19/Nov/11 1:46 AM Ah, forgot that Gabriel is away (vacation right?)
Hide
Permalink
Gabriel Roldán added a comment - 19/Nov/11 9:20 AM

Hello. Yeah unfortunately on vacation right now so no dev env at hand.
But feel free to replace the direct cast to a Converters call. AFAIK there is a converter for Calendar <--> Date.
Also, afaict it´s ok that feature attributes are Calendar like in the shapefile case. It just looks like calling DatatypeConverterImpl.getInstance().printDateTime() doesn´t go through the whole converting cycle Encoder does. So GML encoding should already be safe. By using Converters in the binding as you propsed we should be coevred either case.

Cheers,
Gabriel

Show
Gabriel Roldán added a comment - 19/Nov/11 9:20 AM Hello. Yeah unfortunately on vacation right now so no dev env at hand. But feel free to replace the direct cast to a Converters call. AFAIK there is a converter for Calendar <--> Date. Also, afaict it´s ok that feature attributes are Calendar like in the shapefile case. It just looks like calling DatatypeConverterImpl.getInstance().printDateTime() doesn´t go through the whole converting cycle Encoder does. So GML encoding should already be safe. By using Converters in the binding as you propsed we should be coevred either case. Cheers, Gabriel
Hide
Permalink
Andrea Aime added a comment - 21/Nov/11 7:19 AM

I've found out the converter was already in place. Adding test cases both in gt2 and in geoserver

Show
Andrea Aime added a comment - 21/Nov/11 7:19 AM I've found out the converter was already in place. Adding test cases both in gt2 and in geoserver
Hide
Permalink
Andrea Aime added a comment - 21/Nov/11 7:52 AM

Fixed in GeoTools, added one kml time template test to make sure it does not come back (at least, not in the current form)

Show
Andrea Aime added a comment - 21/Nov/11 7:52 AM Fixed in GeoTools, added one kml time template test to make sure it does not come back (at least, not in the current form)
Hide
Permalink
Andrea Aime added a comment - 27/Jan/12 3:29 AM

Mass transition all resolved issue that did not see any further comment in the last month to closed status

Show
Andrea Aime added a comment - 27/Jan/12 3:29 AM Mass transition all resolved issue that did not see any further comment in the last month to closed status

People

  • Assignee:
    Andrea Aime
    Reporter:
    Andrea Aime
Vote (0)
Watch (2)

Dates

  • Created:
    18/Nov/11 8:43 AM
    Updated:
    27/Jan/12 3:29 AM
    Resolved:
    21/Nov/11 7:52 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.