Saturday, August 16, 2014

Implement Registry Extension (RXT) 2.0 + Associated UI support - Project Documentation




Project Idea


The initial project idea was to Implement RXT 2.0, a JSON based model to replace the existing XML based RXT configuration. But due to the complexity and the time limitation of the project, the scope was narrowed down to create a Jaggery Application to Add a new RXT to WSO2 Governance Registry.

Overview


WSO2 Governance Registry is a SOA based registry/repository to manage, govern and store resources. These resources can be any artifact varying from a plain text file to a WSDL, service, URI, API, Schema, policy etc. The artifacts can be associated with lifecycle management, configuration governance, development process governance, design and run-time governance, team collaboration and provided with access control mechanisms.

Configurable Governance Artifacts are one of the many ways of extending the functionality of WSO2 Governance Registry to support modeling any type of asset to suit the user requirements. The RXT model provides an extensible configuration language to create new types of artifacts.

The main objective of this project is to provide enhanced usability when configuring new types of artifacts and introduce a new intermediate JSON based RXT format which can be used when WSO2 Governance Registry is migrating to a JSON based RXT format.

Design


The basic design includes generating a JSON based RXT using the user input and send it to the Registry backend and convert it to the existing XML based RXT format and use it without breaking the current XML based RXT implementation. To achieve the task I came up with the following design. In the Jaggery Application ‘ArtifactBuilder’ user input is read and basic input validation is done. A JSON based RXT is generated from the user input. ManageGenericArtifact Admin Service is called via Jaggery and JSON is sent to the Registry backend. The JSON -> XML conversion is handled by a Util method and finally via the generated XML, RXT, the existing code is executed to add the new Artifact Type. Since the Newly generated JSON based RXT is sent to the Registry, it can be persisted in the registry at a later point of time as well. The diagram below shows a design of the proposed Application.



Implementation


The main Technologies used to create the Jaggery Application are, Bootstrap, Basic HTML/CSS, Javascript, Jquery, JSON and for the communication, Jaggery-JQuery. Bootstrap 2 is the main UI framework used in the Jaggey Application Implementation. To add the drag and drop functionality Bootsnipp Form builder was used [1] and to add/delete dynamic table rows the ‘Dynamic table row creation/deletion’ snippet was used [2]. Both of the snippets comes under the MIT license.

When user logs in to WSO2 Governance Registry and navigate to the List Applications, they can click on the ArtifactBuilder Jaggery Application which will navigate to the below UI, which makes it easier to model their Artifact with only a few clicks without the hazel of editing a XML. The below image show part of the Jaggery application.






User can enter the basic artifact details, drag and drop the content ui elements to build the UI, then add the UI and Relationship information and click ‘Save Artifact’ which will do the input validation and generate a JSON based RXT model to be sent to the backend.

All the input is read from Javascript via the Document Object Model (DOM) and transformed into the JSON format.

I have created a new method addJSONRXTResource in ManageGenericArtifactService and exposed it as a admin service method so that it can be called directly by passing the payload of a RXT JSON. A new Util class was added in order to generate the conventional RXT XML using the JSON string. Inside addJSONRXTResource after generating the xml, addRXTResource admin service method is called and the newly generated XML based artifact is added without breaking the existing XML model.

In the Jaggery application, once the JSON is generated, the addJSONRXTResource is called via a Jaggery WS-Request [3] by passing the JSON string as the payload.

Sample JSON RXT


{  
   "artifactType":{  
      "hasNamespace":"false",
      "iconset":"18",
      "lifecycle":"",
      "nameAttribute":"overview_id",
      "nameSpaceAttribute":"",
      "pluralLabel":"people",
      "shortName":"person",
      "singularLabel":"person",
      "storagePath":"/people/@{name}",
      "type":"application/vnd.wso2-person+xml"
   },
   "content":{  
      "Overview":[  
         {  
            "helptext":"help",
            "id":"id",
            "label":"ID",
            "placeholder":"id",
            "required":"checked",
            "type":"text"
         },
         {  
            "helptext":"help",
            "id":"name",
            "label":"Name",
            "placeholder":"name",
            "required":null,
            "type":"text"
         },
         {  
            "id":"gender",
            "label":"Gender",
            "options":"Male\nFemale",
            "type":"option"
         },
         {  
            "id":"address",
            "label":"Adress",
            "type":"textArea"
         }
      ]
   },
   "relationships":[  
      {  
         "relationship":"Association",
         "source/target":"",
         "type":""
      }
   ],
   "ui":[  
      {  
         "href":"@{stroragePath}",
         "type":"path",
         "value":"overviewa_id"
      },
      {  
         "href":"@{stroragePath}",
         "type":"path",
         "value":"overview_name"
      }
   ]
}



Jaggery App : https://github.com/ireshapm0/ArtifactBuilder/commits/master
Carbon-governance : https://github.com/ireshapm0/carbon-governance/commits/dev-rxt-json

The below screencast shows the basic end to end functionality of the Application when adding a new Artifact Type.



Future Work

  • Multiple Table support for dynamic <content> section. 
  • Minimize user input effort by adding auto-complete data 
  • Generate UI from RXT - Edit RXT UI 
  • Finalize content type fields and their usage


References


[1] http://bootsnipp.com/forms
[2] http://bootsnipp.com/snippets/featured/dynamic-table-row-creation-and-deletion
[3] http://jaggeryjs.org/documentation.jag?api=ws



No comments:

Post a Comment