Roberta Falone <robertafalone@gmail.com> a écrit :
Dear Orekit Community, I have an issue with saving configuration's scenario data into the DB. I am trying to serialize a list of "complex" Orekit objects (such as SpacecraftState, Reference Frame, Propagators, Force Models, and so on) in order to directly retrieve them from DB once the Application has started. Obviously, SQLite is not an Object DB System, so Blob structure and Object's Serialization seemed to me the only solution. However, Serialization in Java seems to require the creation of a temporary file for each object I want to serialize and store in the DB, with a consequent more complex management of temporary files, too. Do you have suggestions about storing and retrieving Orekit's Data without resort to Blob data and Serialization?
You can look at the testSerialization test cases, there is one for example in TabulatedProviderTest in the junit tests for attitude package.
The basic idea is to create a ByteArrayOutputStream, then wrap it in a ObjectOutputStream and finally to serialize the object by calling the writeObject method in this ObjectOutputStream. The serialized bytes are indeed in the ByteArrayOutputStream and can be retrieved using its toByteArray method, so you can store them as a blob in your database.
On the other hand, when you retrieve your blob from the database, you create aByteArrayInputStream from this retrieved bytes array, you wrap it in a ObjectInputStream and you call readObject to get the deserialized object.
The testSerialization test cases does both, by first serailizing and object, checking the size, desserializing the object, and comaring the deserialized object with the original object.
Hope this helps, Luc
Thank you so much for any kind of suggestion of yours, My best regards, Roberta
---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.