diff --git a/main/src/com/google/refine/model/metadata/AbstractMetadata.java b/main/src/com/google/refine/model/metadata/AbstractMetadata.java index 43a5ac9b5..5433cdbd0 100644 --- a/main/src/com/google/refine/model/metadata/AbstractMetadata.java +++ b/main/src/com/google/refine/model/metadata/AbstractMetadata.java @@ -6,10 +6,16 @@ import java.time.LocalDateTime; import org.apache.commons.beanutils.PropertyUtils; import org.json.JSONObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + public abstract class AbstractMetadata implements IMetadata { + @JsonIgnore private MetadataFormat formatName = MetadataFormat.UNKNOWN; + @JsonIgnore protected LocalDateTime written = null; + @JsonProperty("modified") protected LocalDateTime _modified; public MetadataFormat getFormatName() { diff --git a/main/src/com/google/refine/util/ParsingUtilities.java b/main/src/com/google/refine/util/ParsingUtilities.java index 06a605729..f4426a989 100644 --- a/main/src/com/google/refine/util/ParsingUtilities.java +++ b/main/src/com/google/refine/util/ParsingUtilities.java @@ -59,8 +59,6 @@ import org.json.JSONException; import org.json.JSONObject; import org.json.JSONTokener; -import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; -import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.DeserializationFeature; @@ -80,11 +78,10 @@ public class ParsingUtilities { SimpleModule module = new SimpleModule(); module.addSerializer(Double.class, new SerializationFilters.DoubleSerializer()); module.addSerializer(double.class, new SerializationFilters.DoubleSerializer()); - module.addSerializer(OffsetDateTime.class, new SerializationFilters.DateSerializer()); - + module.addSerializer(OffsetDateTime.class, new SerializationFilters.OffsetDateSerializer()); + module.addSerializer(LocalDateTime.class, new SerializationFilters.LocalDateSerializer()); mapper.registerModule(module); - // mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); } diff --git a/main/src/com/google/refine/util/SerializationFilters.java b/main/src/com/google/refine/util/SerializationFilters.java index 984f2ca96..4c937c25f 100644 --- a/main/src/com/google/refine/util/SerializationFilters.java +++ b/main/src/com/google/refine/util/SerializationFilters.java @@ -1,6 +1,7 @@ package com.google.refine.util; import java.io.IOException; +import java.time.LocalDateTime; import java.time.OffsetDateTime; import com.fasterxml.jackson.core.JsonGenerator; @@ -90,10 +91,10 @@ public class SerializationFilters { /** * Serialize dates by ISO format. */ - public static class DateSerializer extends StdSerializer { + public static class OffsetDateSerializer extends StdSerializer { private static final long serialVersionUID = 93872874L; - public DateSerializer() { + public OffsetDateSerializer() { super(OffsetDateTime.class); } @@ -103,4 +104,21 @@ public class SerializationFilters { gen.writeString(ParsingUtilities.dateToString(arg0)); } } + + /** + * Serialize dates by ISO format. + */ + public static class LocalDateSerializer extends StdSerializer { + private static final long serialVersionUID = 93872874L; + + public LocalDateSerializer() { + super(LocalDateTime.class); + } + + @Override + public void serialize(LocalDateTime arg0, JsonGenerator gen, SerializerProvider s) + throws IOException { + gen.writeString(ParsingUtilities.localDateToString(arg0)); + } + } }