Transforming Model Oriented Program into Android Source Code Based on Drools Rule Engine

Model transformation is one of the prominent features and the rising research area of Model Driven Engineering (MDE). MDE promotes models to primary artifacts that drive the whole development process. This paper presents the model transformation approach for textual model oriented programs Umple (UML Programming Language) to generate android applications (apps). The proposed approach improved the generation of android source code by using Drools transformation rules and introducing new concern in model driven mobile engineering. The major objective of proposed transformation approach intends to address consistency between source and target model and also intends to handle productivity issues in model driven software development. The main results of model transformation approach are Java class for model layer, XML file for view layer and android activity class for controller layer. Results show that proposed approach achieves high consistency between source and target model and also improves model transformation productivity.


Introduction
The mobile application development industry is increasingly growing up due to the intensive use of applications in mobile devices.Most of these devices run on Android operating system.Due to increasingly intensive use of mobile apps, the development of mobile apps demands additional worries about the short timeto-market and to improve the productivity [1].Software engineering process aims to help leading an IT project from the perspective of transforming design model to code implementation in a specific platform.Indeed, the model driven architecture (MDA) is a new discipline of software engineering that has emerged to ensure the development of productive model [2].
Model transformation is considered as one of the key technologies in MDE.
The transformation rules map the input model to output model.These rules can be specified in transformation language such as ATLAS, Acceleo, Drools [3], etc.Moreover, the MDA allows the code generation from platform specific models by means of generators that automatically transform models into source code for chosen platform [4].An infrastructure for model-driven development has a high potential for accelerating the development of software applications.MDA does not concentrate on technical detail but lifts software development to a higher abstraction level.A high quality MDA infrastructure can considerably reduce the time to market in consequence.
In this paper, we propose a model transformation framework based on drools rule engine.In our approach, UMPLE' class diagram considered as a primary model artifact that used to generate android source code.UMPLE blurs the distinction between code and modeling, enabling modelers and coders to collaborate on models in a way similar to code-based collaboration.The result of the transformation considered as model layer, view layer, controller layer and persistency layer.Model layer consists of plain old java object (POJO) class, view layer includes XML for android user interfaces, controller layer comprises with android activity classes and persistency layer considered as apps data management.In summary, the proposed approach transforms Umple class diagram to android mobile apps which contain create-retrieve-update-delete (CRUD) operations based on model-view-controller (MVC) architecture.

Model Driven Mobile Apps Development
The authors [5] proposed a MDD approach for generating android applications from UML class diagram using Acceleo transformation languages.But their approach generates only two screens for the given class diagram.Their code generation approach is in progress and still need to complete for other mobile platforms.In literature [6], the authors proposed a model transformation approach based code generator for state machine diagram.Their approach generates Enterprise Java Bean (EJB) from model using ATLAS transformation language.
Although the authors argued that their approach improves the quality and productivity of MDA concepts, they did not described the any measurements for proposed transformation approach.In literature [7], they proposed code generation method from UML message sequence diagram based on Meta Object Facility (MOF).They proposed meta-model for message sequence diagram and six model transformation rules written by Acceleo.They also described that MDE absolutely needs automatic tools and methods to transform platform-independent model into platform-specific model.
The researchers [8] described the model oriented programming as a new pa-radigm to reduce the ever-present tension between model-centric and codecentric development styles.UMPLE is a model-oriented programming language that supports modeling using a textual notation just like other high-level programming languages.Therefore, Umple is a multi-faceted technology allowing users to integrate modeling into software development straightforwardly.
Although there are already some approaches to model-driven development of mobile apps, there is still gap in model transformation approach for mobile applications.Individual approaches are in moving target.In contrast to our proposed approach, the previous approaches are focused on concrete syntax based process and defined transformation rule specifications in template-based approach.In this paper, our approach will mainly focus on abstract syntax based approach.It traverse and parse source model in visitor based approach instead of defining concrete syntax grammar and specify transformation rules in object pattern matching approach by using Drools rule language [3].The technical space of model transformations still needs to do 80% to get complete transformations [9].
From the perspective of evaluation, the authors [10] proposed the approach for empirical evaluation of model driven engineering in multiple dimensions.Their empirical studies included qualitative (expert judgments) and quantitative data (metrics) evaluations.They supposed that the productivity and defect detection rate are the effective metrics for measuring automation degree of model driven development process.A cost estimation approach is therefore needed that can incorporate characteristics of MDE that affect economies of scale and effort in application development with the size computation of various artifacts in MDE [11].Therefore we measure our proposed model driven approach's automation degree from productivity quality criteria.In order to estimate the code generator effort, we use COCOMOII tool [12].

Model Transformation Approach Based on
Drools Rule Engine

Architecture
The main components of model transformation framework are parser, model transformer and code generator.

Parser and Syntax Tree Model Constructor
The main architecture of parser is composed with visitor-based parser which use for extracting abstract syntax tree (AST) from input model and code generator which generate the respective android source code using extracted AST model of input file [13].AST traverse and collect the information of source code by using the AST visitor method.Firstly, the AST parser creates the compilation unit (CU) and it accepts the visitor node.The visitor node traverses the source code to extract the package declaration, type declaration, field declaration and variable declaration.The input/output relationship of parser and syntax model constructor is shown in Figure 2.

Transformer
The transformer is composed with Drools inference engine that is able to scale

Code Generator
Code generation can be defined as the technique in which we write program that create another programs.After the object pattern matching process, the   the internal operation design of code generator.In order to generate java class and android from AST fragment, the proposed generator creates new compilation unit and construct the target language sentence structure by using Java Language Specification (JLS8) application programming interface (API).That API allows generator to create language statements such as Method Declaration, Variable Declaration, Expression Statement declaration, Method Invocation, Super Method Invocation, Field Access, Cast Expression, Class Instance Creation, etc.

Drools Transformation Rules
A transformation rule is a description of how one or more constructs in the source language can be transformed into one or more constructs in the target language.A transformation rule is the smallest entity within a model transformation.A rule contains a source pattern and a target pattern.For each occurrence of the source pattern in the source model, a target pattern is created in the target model.In our proposed transformation approach, transformation rules are defined on drools rule engine which is a production rule system and enhanced implementation of the Rete algorithm [3].Drools rules are defined using Java-like language.The main rules in our proposed rule engine are Umple2Model.drl,Umple2View.drl and Umple2Controller.drl.Umple2Model.drltransforms incoming abstract syntax model (ASM) into plain old java object (POJO), Um-ple2View.drltransforms ASM into android user interface XML file and Um-ple2Controller.drl transforms ASM into android activity class.Table 1 illustrates the smallest entity of simple variable transformation process.The second row in table shows the transformation rule that use to transform ASM into variable declaration.The third row shows the resulted code for that variable declaration, the fourth row shows the generated user interface in android screen and the final row shows the generated SQL command that used to create database in generated application.

Parser Analysis
To illustrate the ability of proposed parser, we have conducted the parser statistics with time efficiency and compare with Umple code analyzer [14].As a case study of transformation process, we choose a Library Management System as Umple input source file.It contains number of 6 classes with 19 attributes.Figure 5 shows the implemented screen of proposed parser.
In order to measure the proposed parser performance, we extract the source file metrics from the input Umple file.The measurable metrics include number of classes, number of lines of code, number of variables and its data type.And then, we also conducted the proposed parser precision and recall using the following equations.Figure 6 depicts the parser analysis for Library Management System case study.

No.correct consituents identified by parser Precision
Total no.consituents identified by parser = No.correct consituents identified by parser Recall Total no.consituents identified by Code Analyzer = (2) At this stage, we measured the proposed parser performance because of the parser accuracy can improve the later transformation and code generation processes.And also, this measurement can validate that whether the target model' attributes are consistent with source model' attributes or not.Maintaining consistency between documentation and the corresponding code is challenging task.Table 2 shows the proposed parser gets the average 100% of preci-   sion and 95.33% of recall rate.Therefore, we have the high consistent between source documents and target code.

Code Generator Analysis
For practical use in model-driven engineering, the quality of model transformations is a key issue.In this paper, we also conducted the quantitative measurement from the perspective of productivity criteria.Because of the productivity criteria is the effective metrics to ensure the automation degree of model transformation.The generated source code result for case study is show in Table 3.
Figure 7 shows the implemented screen of code generator.
In order to calculate the estimated value in time and effort, we use the COCOMOII tool [12].For this measurement, we set 616 SLOC and set the

Results and Discussion
In order to ensure the quality of proposed model driven transformation approach, we have conducted relevant measurement with step by step.The proposed transformation approach is developed and successfully tested over 20 UMPLE model projects.Firstly, we have measured the proposed parser efficiency with precision and recall.The results show that the parser precision rate from 99% to 100% and also the recall rate from 90% to 100%.Therefore, our proposed parser achieves high consistency between source file and parsed syntax.Table 4 shows the results analysis for parser efficiency, code generation efficiency and cost estimation value for each project.Secondly, we have conducted the statistical analysis for code generation process with number of lines of code metrics, number of files and code generation time for each phase.The main purpose of our proposed approach is to achieve high productivity quality.According to the cost estimation tool results, our approach can significantly reduce the time and developer effort.Therefore the proposed approach also reaches the satisfactory in productivity measurement.

Conclusions
Model transformation can be used for different tasks throughout the development process for manipulating models.The field of model transformation is an active research field and it is necessary to exploit the model transformation approach for the development of mobile applications.In this paper, an approach capable of generating MVC-based android source code from Umple class diagram is developed.This approach involves Drools model transformation rules that can address the technical space of MDE.Drools transformation rules make the proposed approach efficient, simple and faster in implementation.The parser analysis results show that the parsed source code is consistent with input Umple file.The evaluation results with COCOMOII estimator show that the transformation approach significantly reduces the effort and improves the productivity.Therefore, the proposed transformation approach is suitable for short timeto-market software development environment.
In this paper, we address the proposed parser consistency and productivity issues in model driven transformation process.As a future work, we plan to address the internal transformation rule quality measurement.The measurement of internal transformation rule quality is still challenging task in model driven engineering process.
to a large number of rules and facts.The inference component matches facts and data (syntax tree model).Facts may be modified, removed or added by executing rules or from external sources.The transformer receives the partial pieces of source code (package declaration, type declaration, field declaration and variable declaration) with syntax tree model.This model is transformed using predefined set of mapping rules in Drools Rule engine.The rule engine interprets and executes the mapping rules on the source model and produce target model.The relationships between transformer and Drools rule engine can be seen in Figure3.
product cost parameters settings with the default nominal value.The tool showed a needed effort of 2 Person-months, a required 4months' time frame for 616 SLOC.The proposed transformation approach can generate 616 SLOC within 2 seconds.Therefore, by using our transformation approach we could reduce time and effort in development process by 4 months and effort of 2 Person-months.

Table 3 .
Generated source code result.