KiWi: - fix label for date literals of type xsd:date (without time)
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/749bc563 Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/749bc563 Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/749bc563 Branch: refs/heads/develop Commit: 749bc563459270aeb05802935d5dcaf6c6f95508 Parents: 7a82455 Author: Sebastian Schaffert <[email protected]> Authored: Mon Nov 10 18:20:26 2014 +0100 Committer: Sebastian Schaffert <[email protected]> Committed: Mon Nov 10 18:39:34 2014 +0100 ---------------------------------------------------------------------- .../apache/marmotta/kiwi/model/rdf/KiWiDateLiteral.java | 12 ++++++++++-- .../marmotta/kiwi/persistence/KiWiConnection.java | 9 +++++---- 2 files changed, 15 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/marmotta/blob/749bc563/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiDateLiteral.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiDateLiteral.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiDateLiteral.java index f28d3dc..8617ae8 100644 --- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiDateLiteral.java +++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiDateLiteral.java @@ -88,7 +88,15 @@ public class KiWiDateLiteral extends KiWiStringLiteral { */ @Override public String getContent() { - return DateUtils.getXMLCalendar(dateContent).toXMLFormat(); + if(XSD.DateTime.equals(getDatatype())) { + return DateUtils.getXMLCalendar(this.dateContent).toXMLFormat(); + } else if(XSD.Date.equals(getDatatype())) { + return ISODateTimeFormat.date().print(dateContent); + } else if(XSD.Time.equals(getDatatype())) { + return ISODateTimeFormat.time().print(dateContent); + } else { + return DateUtils.getXMLCalendar(this.dateContent).toXMLFormat(); + } } /** @@ -109,7 +117,7 @@ public class KiWiDateLiteral extends KiWiStringLiteral { */ @Override public String getLabel() { - return calendarValue().toXMLFormat(); + return getContent(); } /** http://git-wip-us.apache.org/repos/asf/marmotta/blob/749bc563/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java ---------------------------------------------------------------------- diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java index b5203c5..0ddf28f 100644 --- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java +++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java @@ -1849,12 +1849,13 @@ public class KiWiConnection implements AutoCloseable { cacheNode(result); return result; } else if("date".equals(ntype)) { - KiWiDateLiteral result = new KiWiDateLiteral(new DateTime(row.getTimestamp(6, calendarUTC).getTime(), DateTimeZone.forOffsetMillis(row.getInt(7)*1000)), null, new Date(row.getTimestamp(11, calendarUTC).getTime())); - result.setId(id); - + KiWiDateLiteral result; if(row.getLong(10) != 0) { - result.setType((KiWiUriResource) loadNodeById(row.getLong(10))); + result = new KiWiDateLiteral(new DateTime(row.getTimestamp(6, calendarUTC).getTime(), DateTimeZone.forOffsetMillis(row.getInt(7)*1000)), (KiWiUriResource) loadNodeById(row.getLong(10)), new Date(row.getTimestamp(11, calendarUTC).getTime())); + } else { + result = new KiWiDateLiteral(new DateTime(row.getTimestamp(6, calendarUTC).getTime(), DateTimeZone.forOffsetMillis(row.getInt(7)*1000)), null, new Date(row.getTimestamp(11, calendarUTC).getTime())); } + result.setId(id); cacheNode(result); return result;
