Skip to content
jeanphilippe-p edited this page Aug 13, 2016 · 41 revisions

Table of Contents

  1. Serialization list
  2. Serialization description
  3. Serialization Person example

Serialization list

The list of all your serializations must be referenced in an XML file. The path to this file must be defined in the file config.json with the key serializationList (see [Installation] (https://github.com/jeanphilippe-p/ObjectManagerLib/wiki/Installation) page for more informations).

File look like :

<list>
    <serialization type="person">relative/path/to/person/manifest.xml</serialization>
    <serialization type="house">relative/path/to/house/manifest.xml</serialization>
</list>

Each serialization node must have an attribut type (name of your model) and the path where we can found this serialization. the path must be relative to the folder that contain this XML file.

Serialization description

A Serialization is attached to a model and permit to serialize/deserialize (save/load) object in/from a specific input/output. For exemple I have defined a manifest Person and I want to serialize persons in sql database; I have to define table name and database connection.

A loaded serialization is an instance of a class that extends from class SerializationUnit that extends from Object. So serializations models are described in manifests and can be serialized/deserialized (you can find them in manifestCollection folder).

<manifest>
    <serialization/>
    <properties/>
</manifest>
  • serialization node describe your serialization
  • properties node describe some needed properties informations for serialization

managed serializations

  • table in sql database : sqlTable (local or distant)
  • json file : jsonFile (local)

serialization node

There is two way to define your serialization :

  1. describe directly you serialization (see corresponding manifest to know how to describe your serialization)
<manifest>
    <serialization type="jsonFile">
        <jsonFile saticPath="/asolute/path/to/a/folder" staticName="a_file_name.json"/>
    </serialization>
    <properties/>
</manifest>
  1. reference an id of a serialization (obviously reference a serialization that has been serialized)
<manifest>
    <serialization type="sqlTable">a_table_id</serialization>
    <properties/>
</manifest>

properties node

Properties node is a list of properties. Each property node refer to a property in corresponding Model.
For the following explanations we will build a serialization Person like example.

serialization name

some serialization doesn't manage certain characters so you can replace a property name when you serialize your Object. For exemple pgsql doesn't manage columns with uppercase, so if you have a property name APropertyName you can define a serialization name a_property_name that will match with your column name.

<manifest>
    <serialization type="sqlTable">person</serialization>
    <properties/>
        <firstName serializationName="first_name"/>
    </properties>
</manifest>

composition

composition is a way to associate a model to others models by matching properties (this information is used only for slqTable serialization and for sql database request). for example model Person has a property homes (see [Manifest] (https://github.com/jeanphilippe-p/ObjectManagerLib/wiki/Manifest) page), model Home would have a property owner (serialized in a column like owner_id or person_id), so composition would refer owner and look like :

<manifest>
    <serialization type="sqlTable">person</serialization>
    <properties>
        <homes>
            <compositions>
                <composition>owner</composition>
            </compositions>
        </homes>
    </properties>
</manifest>

A property can refer to several compositions :

<manifest>
    <serialization type="sqlTable">person</serialization>
    <properties>
        <children>
            <compositions>
                <composition>mother</composition>
                <composition>father</composition>
            </compositions>
        </children>
    </properties>
</manifest>

Serialization Person example

<manifest>
    	<serialization type="sqlTable">person</serialization>
    	<properties>
    		<firstName serializationName="first_name"/>
    		<birthPlace serializationName="birth_place"/>
    		<father serializationName="father_id"/>
    		<mother serializationName="mother_id"/>
    		<children>
        		<compositions>
            		<composition>mother</composition>
            		<composition>father</composition>
        		</compositions>
    		</children>
    		<homes>
        		<compositions>
            		<composition>person</composition>
        		</compositions>
    		</homes>
    	</properties>
</manifest>

Clone this wiki locally