From 598321b8aa93d583845ccd24ca96d474adc246be Mon Sep 17 00:00:00 2001 From: Rafael Bey Date: Mon, 25 Nov 2024 21:24:10 -0500 Subject: [PATCH] Reuse existing mapper/coder rather than creating new one --- .../v1/model/data/DataElementReference.java | 18 +++----- .../pure/v1/model/data/ModelStoreData.java | 11 +++-- .../ClassInstanceWrapper.java | 43 +++++++++---------- .../v1/model/valueSpecification/Variable.java | 20 ++++----- .../valueSpecification/deprecated/Class.java | 2 +- .../valueSpecification/deprecated/Enum.java | 2 +- .../deprecated/HackedClass.java | 6 ++- .../deprecated/HackedUnit.java | 2 +- .../deprecated/MappingInstance.java | 2 +- .../deprecated/PrimitiveType.java | 4 +- .../valueSpecification/raw/ClassInstance.java | 3 +- .../raw/datatype/CBoolean.java | 2 +- .../raw/datatype/CDateTime.java | 2 +- .../raw/datatype/CDecimal.java | 2 +- .../raw/datatype/CFloat.java | 2 +- .../raw/datatype/CInteger.java | 2 +- .../raw/datatype/CLatestDate.java | 2 +- .../raw/datatype/CStrictDate.java | 2 +- .../raw/datatype/CString.java | 2 +- .../datatype/PrimitiveValueSpecification.java | 17 +++++--- .../GenericTypeInstance.java | 10 ++--- .../PackageableElementPtr.java | 9 ++-- .../valueSpecification/DatabaseInstance.java | 5 +-- 23 files changed, 80 insertions(+), 90 deletions(-) diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/data/DataElementReference.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/data/DataElementReference.java index c907f369388..bb7aa303bd5 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/data/DataElementReference.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/data/DataElementReference.java @@ -15,19 +15,17 @@ package org.finos.legend.engine.protocol.pure.v1.model.data; import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.finos.legend.engine.protocol.pure.v1.PureProtocolObjectMapperFactory; +import java.io.IOException; +import java.util.Objects; import org.finos.legend.engine.protocol.pure.v1.model.SourceInformation; import org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementPointer; import org.finos.legend.engine.protocol.pure.v1.model.context.PackageableElementType; -import java.io.IOException; -import java.util.Objects; - @JsonDeserialize(using = DataElementReference.DataElementReferenceDeserializer.class) public class DataElementReference extends EmbeddedData { @@ -35,13 +33,11 @@ public class DataElementReference extends EmbeddedData public static class DataElementReferenceDeserializer extends JsonDeserializer { - - private static ObjectMapper objectMapper = PureProtocolObjectMapperFactory.getNewObjectMapper(); - @Override public DataElementReference deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { - JsonNode node = jsonParser.getCodec().readTree(jsonParser); + ObjectCodec codec = jsonParser.getCodec(); + JsonNode node = codec.readTree(jsonParser); JsonNode dataElementNode = node.get("dataElement"); DataElementReference dataElementReference = new DataElementReference(); if (dataElementNode != null) @@ -51,12 +47,12 @@ public DataElementReference deserialize(JsonParser jsonParser, DeserializationCo dataElementReference.dataElement = new PackageableElementPointer( PackageableElementType.DATA, dataElementNode.textValue(), - Objects.isNull(node.get("sourceInformation")) ? null : objectMapper.treeToValue(node.get("sourceInformation"), SourceInformation.class) + Objects.isNull(node.get("sourceInformation")) ? null : codec.treeToValue(node.get("sourceInformation"), SourceInformation.class) ); } else if (dataElementNode.isObject()) { - dataElementReference.dataElement = objectMapper.treeToValue(dataElementNode, PackageableElementPointer.class); + dataElementReference.dataElement = codec.treeToValue(dataElementNode, PackageableElementPointer.class); } else { diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/data/ModelStoreData.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/data/ModelStoreData.java index aec5310b48c..beda6a04f15 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/data/ModelStoreData.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/data/ModelStoreData.java @@ -15,6 +15,7 @@ package org.finos.legend.engine.protocol.pure.v1.model.data; import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; @@ -39,13 +40,11 @@ public class ModelStoreData extends EmbeddedData public static class ModelStoreDeserializer extends JsonDeserializer { - - private static ObjectMapper objectMapper = PureProtocolObjectMapperFactory.getNewObjectMapper(); - @Override public ModelStoreData deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { - JsonNode node = jsonParser.getCodec().readTree(jsonParser); + ObjectCodec codec = jsonParser.getCodec(); + JsonNode node = codec.readTree(jsonParser); JsonNode instances = node.get("instances"); JsonNode modelDataJsonNode = node.get("modelData"); ModelStoreData result = new ModelStoreData(); @@ -58,7 +57,7 @@ public ModelStoreData deserialize(JsonParser jsonParser, DeserializationContext Iterator elements = modelDataNode.elements(); while (elements.hasNext()) { - result.modelData.add(objectMapper.treeToValue(elements.next(), ModelTestData.class)); + result.modelData.add(codec.treeToValue(elements.next(), ModelTestData.class)); } } else @@ -78,7 +77,7 @@ else if (instances != null) Map.Entry instance = itr.next(); String model = instance.getKey(); JsonNode instanceVal = instance.getValue(); - ValueSpecification val = objectMapper.treeToValue(instanceVal, ValueSpecification.class); + ValueSpecification val = codec.treeToValue(instanceVal, ValueSpecification.class); ModelInstanceTestData modelInstanceTestData = new ModelInstanceTestData(); modelInstanceTestData.model = model; modelInstanceTestData.instances = val; diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/ClassInstanceWrapper.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/ClassInstanceWrapper.java index 00d10823d32..360a678b24b 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/ClassInstanceWrapper.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/ClassInstanceWrapper.java @@ -15,17 +15,18 @@ package org.finos.legend.engine.protocol.pure.v1.model.valueSpecification; import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.node.NullNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.fasterxml.jackson.databind.node.TextNode; import com.fasterxml.jackson.databind.node.POJONode; -import com.fasterxml.jackson.databind.node.NullNode; +import com.fasterxml.jackson.databind.node.TextNode; +import java.io.IOException; +import java.util.List; import org.eclipse.collections.api.factory.Lists; -import org.finos.legend.engine.protocol.pure.v1.PureProtocolObjectMapperFactory; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.ClassInstance; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.classInstance.AggregateValue; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.classInstance.ExecutionContextInstance; @@ -41,20 +42,16 @@ import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.classInstance.graph.RootGraphFetchTree; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.classInstance.path.Path; -import java.io.IOException; -import java.util.List; - @JsonDeserialize(using = ClassInstanceWrapper.ClassInstanceWrapperDeserializer.class) public class ClassInstanceWrapper extends ValueSpecification { - protected static ObjectMapper om = PureProtocolObjectMapperFactory.getNewObjectMapper(); - public static class ClassInstanceWrapperDeserializer extends JsonDeserializer { @Override public ValueSpecification deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { - JsonNode node = jsonParser.getCodec().readTree(jsonParser); + ObjectCodec codec = jsonParser.getCodec(); + JsonNode node = codec.readTree(jsonParser); JsonNode jtype = node.get("_type"); String type = jtype == null ? null : jtype.asText(); if (!(node instanceof NullNode)) @@ -69,68 +66,68 @@ public ValueSpecification deserialize(JsonParser jsonParser, DeserializationCont node.fieldNames().forEachRemaining(fields::add); if ("path".equals(type) || node.get("path") != null) { - Path p = om.treeToValue(node, Path.class); + Path p = codec.treeToValue(node, Path.class); return new ClassInstance("path", p, p.sourceInformation); } if ("rootGraphFetchTree".equals(type) || node.get("class") != null) { ((ObjectNode) node).set("_type", new TextNode("rootGraphFetchTree")); - RootGraphFetchTree p = om.treeToValue(node, RootGraphFetchTree.class); + RootGraphFetchTree p = codec.treeToValue(node, RootGraphFetchTree.class); return new ClassInstance("rootGraphFetchTree", p, p.sourceInformation); } if ("listInstance".equals(type) || node.get("values") != null || fields.isEmpty() || (fields.size() == 1 && "sourceInformation".equals(fields.get(0)))) { - PureList p = om.treeToValue(node, PureList.class); + PureList p = codec.treeToValue(node, PureList.class); return new ClassInstance("listInstance", p, p.sourceInformation); } if ("pair".equals(type) || node.get("first") != null) { - Pair p = om.treeToValue(node, Pair.class); + Pair p = codec.treeToValue(node, Pair.class); return new ClassInstance("pair", p, p.sourceInformation); } if ("aggregateValue".equals(type) || node.get("mapFn") != null && node.get("name") == null) { - AggregateValue p = om.treeToValue(node, AggregateValue.class); + AggregateValue p = codec.treeToValue(node, AggregateValue.class); return new ClassInstance("aggregateValue", p, p.sourceInformation); } if ("tdsAggregateValue".equals(type) || node.get("mapFn") != null && node.get("name") != null) { - TDSAggregateValue p = om.treeToValue(node, TDSAggregateValue.class); + TDSAggregateValue p = codec.treeToValue(node, TDSAggregateValue.class); return new ClassInstance("tdsAggregateValue", p, p.sourceInformation); } if ("tdsColumnInformation".equals(type) || node.get("columnFn") != null) { - TDSColumnInformation p = om.treeToValue(node, TDSColumnInformation.class); + TDSColumnInformation p = codec.treeToValue(node, TDSColumnInformation.class); return new ClassInstance("tdsColumnInformation", p, p.sourceInformation); } if ("tdsSortInformation".equals(type) || node.get("direction") != null) { - TDSSortInformation p = om.treeToValue(node, TDSSortInformation.class); + TDSSortInformation p = codec.treeToValue(node, TDSSortInformation.class); return new ClassInstance("tdsSortInformation", p, p.sourceInformation); } if ("tdsOlapRank".equals(type) || node.get("function") != null && node.get("columnName") == null) { - TdsOlapRank p = om.treeToValue(node, TdsOlapRank.class); + TdsOlapRank p = codec.treeToValue(node, TdsOlapRank.class); return new ClassInstance("tdsOlapRank", p, p.sourceInformation); } if ("tdsOlapAggregation".equals(type) || node.get("function") != null && node.get("columnName") != null) { - TdsOlapAggregation p = om.treeToValue(node, TdsOlapAggregation.class); + TdsOlapAggregation p = codec.treeToValue(node, TdsOlapAggregation.class); return new ClassInstance("tdsOlapAggregation", p, p.sourceInformation); } if ("runtimeInstance".equals(type) || node.get("runtime") != null) { - RuntimeInstance p = om.treeToValue(node, RuntimeInstance.class); + RuntimeInstance p = codec.treeToValue(node, RuntimeInstance.class); return new ClassInstance("runtimeInstance", p, p.sourceInformation); } if ("executionContextInstance".equals(type) || node.get("executionContext") != null) { - ExecutionContextInstance p = om.treeToValue(node, ExecutionContextInstance.class); + ExecutionContextInstance p = codec.treeToValue(node, ExecutionContextInstance.class); return new ClassInstance("executionContextInstance", p, p.sourceInformation); } if ("alloySerializationConfig".equals(type) || node.get("typeKeyName") != null) { - SerializationConfig p = om.treeToValue(node, SerializationConfig.class); + SerializationConfig p = codec.treeToValue(node, SerializationConfig.class); return new ClassInstance("alloySerializationConfig", p, p.sourceInformation); } throw new RuntimeException("NOT SUPPORTED\n" + node.toPrettyString()); diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/Variable.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/Variable.java index 86f53709d91..eef315160bf 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/Variable.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/Variable.java @@ -15,25 +15,20 @@ package org.finos.legend.engine.protocol.pure.v1.model.valueSpecification; import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.eclipse.collections.api.factory.Lists; -import org.finos.legend.engine.protocol.pure.v1.PureProtocolObjectMapperFactory; +import java.io.IOException; import org.finos.legend.engine.protocol.pure.v1.model.SourceInformation; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Multiplicity; import org.finos.legend.engine.protocol.pure.v1.model.type.GenericType; import org.finos.legend.engine.protocol.pure.v1.model.type.PackageableType; -import java.io.IOException; - @JsonDeserialize(using = Variable.VariableDeserializer.class) public class Variable extends ValueSpecification { - private static ObjectMapper om = PureProtocolObjectMapperFactory.getNewObjectMapper(); - public String name; public GenericType genericType; public Multiplicity multiplicity; @@ -69,7 +64,8 @@ public static class VariableDeserializer extends JsonDeserializer classMap = PureProtocolObjectMapperFactory.getClassInstanceTypeMappings(); public String type; @@ -77,7 +76,7 @@ public ClassInstance deserialize(JsonParser jsonParser, DeserializationContext d { ((ObjectNode) node.get("value")).set("_type", new TextNode(result.type)); // For backward compatibility } - result.value = om.treeToValue(node.get("value"), _class); + result.value = oc.treeToValue(node.get("value"), _class); return result; } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CBoolean.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CBoolean.java index 7354afded50..4d9a22e3b64 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CBoolean.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CBoolean.java @@ -48,7 +48,7 @@ public static class CBooleanDeserializer extends JsonDeserializer new CBoolean(Boolean.parseBoolean(x.asText()))); + return customParsePrimitive(jsonParser, x -> new CBoolean(Boolean.parseBoolean(x.asText()))); } } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CDateTime.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CDateTime.java index 2537af20838..ee73ab8cf6d 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CDateTime.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CDateTime.java @@ -48,7 +48,7 @@ public static class CDateTimeDeserializer extends JsonDeserializer new CDateTime(x.asText())); + return customParsePrimitive(jsonParser, x -> new CDateTime(x.asText())); } } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CDecimal.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CDecimal.java index d4c5377b2ca..c73e9de0067 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CDecimal.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CDecimal.java @@ -49,7 +49,7 @@ public static class CDecimalDeserializer extends JsonDeserializer new CDecimal(new BigDecimal((x.asText())))); + return customParsePrimitive(jsonParser, x -> new CDecimal(new BigDecimal((x.asText())))); } } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CFloat.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CFloat.java index 4eba4d0b6ab..b2e557fd8bf 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CFloat.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CFloat.java @@ -48,7 +48,7 @@ public static class CFloatDeserializer extends JsonDeserializer new CFloat(Double.parseDouble((x.asText())))); + return customParsePrimitive(jsonParser, x -> new CFloat(Double.parseDouble((x.asText())))); } } } \ No newline at end of file diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CInteger.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CInteger.java index 9fcfb6340d7..8f228b7bbf4 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CInteger.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CInteger.java @@ -48,7 +48,7 @@ public static class CIntegerDeserializer extends JsonDeserializer new CInteger(x.asLong())); + return customParsePrimitive(jsonParser, x -> new CInteger(x.asLong())); } } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CLatestDate.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CLatestDate.java index 0e4cc8b6b48..83529bbbe8f 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CLatestDate.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CLatestDate.java @@ -37,7 +37,7 @@ public static class CLatestDateDeserializer extends JsonDeserializer new CLatestDate()); + return customParsePrimitive(jsonParser, x -> new CLatestDate()); } } } \ No newline at end of file diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CStrictDate.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CStrictDate.java index c5baae3c709..37c80e90976 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CStrictDate.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CStrictDate.java @@ -48,7 +48,7 @@ public static class CStrictDateDeserializer extends JsonDeserializer new CStrictDate(x.asText())); + return customParsePrimitive(jsonParser, x -> new CStrictDate(x.asText())); } } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CString.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CString.java index 6a83ecb8ef9..f2ae65850f3 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CString.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/CString.java @@ -57,7 +57,7 @@ public ValueSpecification deserialize(JsonParser jsonParser, DeserializationCont { return new CString(""); } - return customParsePrimitive(node, x -> new CString(x.asText())); + return customParsePrimitive(jsonParser.getCodec(), node, x -> new CString(x.asText())); } } } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/PrimitiveValueSpecification.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/PrimitiveValueSpecification.java index 7d757868e59..12db09b5fe9 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/PrimitiveValueSpecification.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/datatype/PrimitiveValueSpecification.java @@ -14,23 +14,26 @@ package org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.datatype; +import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.util.function.Function; import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.impl.utility.Iterate; -import org.finos.legend.engine.protocol.pure.v1.PureProtocolObjectMapperFactory; import org.finos.legend.engine.protocol.pure.v1.model.SourceInformation; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.ValueSpecification; import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.Collection; -import java.util.function.Function; - public abstract class PrimitiveValueSpecification extends DataTypeValueSpecification { - private static ObjectMapper om = PureProtocolObjectMapperFactory.getNewObjectMapper(); + public static ValueSpecification customParsePrimitive(JsonParser parser, Function func) throws IOException + { + return customParsePrimitive(parser.getCodec(), parser.readValueAsTree(), func); + } - public static ValueSpecification customParsePrimitive(JsonNode node, Function func) throws JsonProcessingException + public static ValueSpecification customParsePrimitive(ObjectCodec oc, JsonNode node, Function func) throws JsonProcessingException { JsonNode values = node.get("values"); ValueSpecification result; @@ -56,7 +59,7 @@ else if (values.size() == 1) JsonNode sourceInformation = node.get("sourceInformation"); if (sourceInformation != null) { - result.sourceInformation = om.treeToValue(sourceInformation, SourceInformation.class); + result.sourceInformation = oc.treeToValue(sourceInformation, SourceInformation.class); } return result; } diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/packageableElement/GenericTypeInstance.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/packageableElement/GenericTypeInstance.java index 66e3f361864..bcd5bc569ba 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/packageableElement/GenericTypeInstance.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-protocol-pure/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/raw/packageableElement/GenericTypeInstance.java @@ -15,6 +15,7 @@ package org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.packageableElement; import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; @@ -33,8 +34,6 @@ @JsonDeserialize(using = GenericTypeInstance.GenericTypeInstanceDeserializer.class) public class GenericTypeInstance extends One { - protected static ObjectMapper om = PureProtocolObjectMapperFactory.getNewObjectMapper(); - public GenericType genericType; public GenericTypeInstance() @@ -62,7 +61,8 @@ public static class GenericTypeInstanceDeserializer extends JsonDeserializer T accept(ValueSpecificationVisitor visitor) } - protected static ValueSpecification convert(JsonNode node) throws IOException + protected static ValueSpecification convert(JsonParser parser) throws IOException { + JsonNode node = parser.readValueAsTree(); JsonNode name = node.get("fullPath"); ValueSpecification result = new PackageableElementPtr(name.asText()); JsonNode sourceInformation = node.get("sourceInformation"); if (sourceInformation != null) { - result.sourceInformation = om.treeToValue(sourceInformation, SourceInformation.class); + result.sourceInformation = parser.getCodec().treeToValue(sourceInformation, SourceInformation.class); } return result; } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/DatabaseInstance.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/DatabaseInstance.java index c234bb055b8..c5e21942579 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/DatabaseInstance.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-protocol/src/main/java/org/finos/legend/engine/protocol/pure/v1/model/valueSpecification/DatabaseInstance.java @@ -18,9 +18,8 @@ import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.packageableElement.PackageableElementPtr; - import java.io.IOException; +import org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.packageableElement.PackageableElementPtr; @Deprecated @JsonDeserialize(using = DatabaseInstance.DatabaseInstanceDeserializer.class) @@ -37,7 +36,7 @@ public static class DatabaseInstanceDeserializer extends JsonDeserializer