ListQueryExpression serialize/deserialize
 
Forums / SmartComponent Library - Developer Forum / ListQueryExpression serialize/deserialize

ListQueryExpression serialize/deserialize

4 posts, 0 answered
  1. Bert Strobbe
    Bert Strobbe avatar
    19 posts
    Registered:
    25 Oct 2018
    12 Jan 2022
    Link to this post
    In the context of cloning a ListQueryExpression I tried serializing and deserializing the object. I've come to the conclusion, that the list (and count) is already lost after serialization.

    In the following code:
    define variable lListQueryExpression as Consultingwerk.ListQueryExpression no-undo.
    define variable lListQueryExpression2 as Consultingwerk.ListQueryExpression no-undo.
    define variable lOutputStream as Consultingwerk.LongcharOutputStream no-undo.
    define variable lSerializer as Progress.IO.JsonSerializer no-undo.
    define variable lInputStream as Consultingwerk.LongcharInputStream no-undo.

    lListQueryExpression = new Consultingwerk.ListQueryExpression().
    lListQueryExpression:add(new Consultingwerk.QueryExpression("eTable.Field", Consultingwerk.OperatorEnum:GE, "Test")).

    // Serialize lListQueryExpression       
    lOutputStream = newConsultingwerk.LongcharOutputStream().
    lSerializer = new Progress.IO.JsonSerializer (true).
    lSerializer:Serialize(lListQueryExpression, lOutputStream).
            
    lOutputStream:Close().
           
    // Deserialize lListQueryExpression in lListQueryExpression2
    lInputStream = new Consultingwerk.LongcharInputStream(lOutputStream:getLongchar()).
    lListQueryExpression2 = CAST(lSerializer:Deserialize(lInputStream), Consultingwerk.ListQueryExpression).
            
    message lListQueryExpression:count lListQueryExpression:GetExpression() skip
    lListQueryExpression2:count lListQueryExpression2:GetExpression()
    view-as alert-box.

    I would assume that Count and GetExpression would give the same results for lListQueryExpression and lListQueryExpression2, as lListQueryExpression2 is the deserialized version of serialized lListQueryExpression.
    This is not the case. The serialized version of lListQueryExpression only has ListHash and Operator as properties, but not oList and iCount. 
    After changing GenericList.cls to include the serializable keywords for oList and iCount as follows it does work:
        DEFINE {&SERIALIZABLE} variable oList       AS Progress.Lang.Object NO-UNDO extent.
        DEFINE {&SERIALIZABLE} variable iCount      AS INTEGER              NO-UNDO INITIAL 0.

    @CW: Do you want me to create a case for this? 
    Can anyone find a reason why this isn't needed for Progress' native serialization when passing the PASOE border?
    Last modified on 12 Jan 2022 14:01 by Bert Strobbe
  2. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    12 Jan 2022 in reply to Bert Strobbe
    Link to this post
    We don't use OpenEdge's (manual) object serialization. If you want to use Serialization/Deserialization as a (IMHO poor) workaround to cloning an object, I'd suggest to use our JSON based serialization/deserialization. 
  3. Bert Strobbe
    Bert Strobbe avatar
    19 posts
    Registered:
    25 Oct 2018
    12 Jan 2022 in reply to Mike Fechner
    Link to this post
    But as GenericList is indicated to be serializable wouldn't you expect the actual list itself to be serializable? 
  4. Mike Fechner
    Mike Fechner avatar
    342 posts
    Registered:
    14 Sep 2016
    12 Jan 2022 in reply to Bert Strobbe
    Link to this post
    I would suggest you log a ticket for the Clone() ticket - as that's your actual use-case. I'm pretty sure that can be implemented.
4 posts, 0 answered