Replace Current XML serializer for Catroid
Name : Samitha Jayathilaka.
University : University of Moratuwa, Sri Lanka
Country : Sri Lanka.
Contact data : Email = samjayathilaka@gmail.com
Phone = +94715445739
Twitter = @SamJayathilaka
Irc_nick= SamJay
Problem description
In Catroid the project is saved as an XML file. This is a core logic in Catroid. All the essential data related to the project like sprites, scripts, bricks, sound files (metadata), image files (metadata) etc. is stored in an XML schema in a very organized way.

figure 1.1 The structuring of the XML created from the Project object.
To do this Catroid uses an xml serializer library called Xstream. Xstream is easy to use for serializing and deserializing object from and to XML.
However there are some limitations when it comes to using XStream. One proven limitation the Catroid community has with XStream now is the difficulty of synchronizing between two versions of Catroid. In different versions some changes may be done to the object structure and thereby the XML schema created by XStream. Those changes can happen due to newer Catroid versions having added new brick functionalities and removing old obsolete script elements. So it has been proven difficult to make older version projects compatible with newer versions of Catroid. There are some other flexibility issues as well.
Current Usage
The XML for a project is used to load and save projects. This is handled in the at.tugraz.ist.catroid.io.StorageHandlerclass. XStream is used simply in the public boolean saveProject(Project project) method and the public Project loadProject(String projectName) method. It is done in a single line like xstream. toXML(obj) and xstream.fromXML(stream). The serialized object is at.tugraz.ist.catroid.content.Project which has a spriteList which in turn contains all the relevant data that follows that is related to a particular project. The Project class has @XtreamAlias annotations to define additional fields as well.
Additionally XStream is also used in at.tugraz.ist.catroid.io.CatroidFieldKeySorter class to get the field keys, compare and sort them and store the Field keys in a map structure.
The basic functional requirements of the newly implemented XML serializer are to do these as easily or more easily.
Furthermore the new XML serializer would be more suitable if it had some other features of XStream such as speed and low memory footprint, Clean XML, supporting circular reference, detailed error detection in XML and handling etc.
Solution
The new XML serializer would minimally have to have the same existing support provided by XStream.
So I suggest having a newly added library which contains the XML serializing/deserializing features. And this library would contain all the classes and methods required to store a project and load a project by creating and deserializing XML files.
Like XStream this new library would have to have methods that take a Project object as an input and creates an XML file in the file system. We already have a good XML schema that represents a Project object.
The required functions of the new library would have to do are
1. Create a new file in the file system.
2. Identify different attributes in an object.
3. Create XML tags for the identified attributes. This has to be done uniquely so as not to make two contextually different attributes in the whole xml document have the same name.
4. Iterate through lists in the serialized object.
5. Go down the hierarchy of the object model.
6. Read an input stream from the file system when loading a project.
7. Quickly identify if the tags on the read XML file is contextually identical to the Project object.
8. Create new Project object and populate it with the data read from the XML file.
9. Ignore any minor additional tags that are found when deserializing.
10. Handle exceptions like FileNotFound, UnrecogizedTag etc. This exception handling must be made flexible.
In addition a new focus of the new library is the conversion of XML to another XML schema that is structurally similar. This would solve the problem of projects from different versions having compatibility issues. Furthermore the new XML converter should come hand in hand with an XML validator, which can validate a particular converted/generator with an XML schema. All these requirements are explained in a graphical form below for clarity. The green parts are the parts that the library would have to take care of.

figure 1.2 Functions of the XML serializer
Testing
The development will be done hand in hand with the mentor provided by Catroid. And the development method will be made of Extreme programming and Test driven Development. So development will happen in iterations. Every iteration will give a functional outcome. And unit tests will be written constantly in the ways of Test Driven Development. Testing the new functionalities will be crucial to get the outcome right. Testing will also include every version changes of Catroid that significantly done changes to the project creation as a whole.
And after integrating the new XML serialize/deserialize library additional integration tests would be required. Integration should not harm the functionalities of the other functionalities in any way.
And after integrating the new XML serialize/deserialize library additional integration tests would be required. Integration should not harm the functionalities of the other functionalities in any way.
I emphasize on the usage on logging and javadoc commenting. It is important to have good logs of important functionality done by the new library and in turn it will help in debugging as well. And In a team project like this good commenting is a must in my opinion. Because this is a core functionality of Catroid (project storage handling), it is required to have a comprehensive structure and code.
Schedule:
This schedule is in terms of what milestone we must achieve to complete this project. Those are.
· Research and discovery of a suitable method to use to serialize/deserialize objects.
· Initialization of the new library.
· Saving a project using the new library.
· Loading a project from an XML file from the library.
· Load a project from a different version.
· Define a XML schema for XML conversion.
· Define Convertible tags.
· Conversion of an XML done.
· Create the XML validator.
· Validate a generated XML.
· Handle validation errors.
· Integrate to Catroid.
· Test integration. Tests pass.
The timing of those objectives will have to be discussed more. Any modifications can happen to this schedule in the actual progression of the project.
I think this is a feasible project that can be successfully within the period of GSoC 2012. It is an essential addition for the whole Catroid functionality. I will give high priority for the completion of the Xml serializer/Deserializer.
No comments:
Post a Comment