|
Actionkit Project |
Task #3 - Data Level Integration
Introduction
The data level integration project looks at ways of integrating Drupal and ActionApps on the database level. The objective is to make ActionApps items available as Drupal nodes. Structure of Items in the ActionApps DatabaseItems in the ActionApps database are stored in two tables:
ActionApps offers a simple API for retrieving and storing items. Structure of Nodes in the Drupal Database
"Basic node information, such as a node id, node type, title, created by and when, etc., is saved in the node table. The node body is saved in the node_revisions table."
* Approaches
ActionApps Item Module (aaitem)Implementation of a Drupal module that displays content from an ActionApps database. The aaitem module uses a partial import. In order to use an AA item in Drupal the user has to enter the long AA item ID. Once this has been entered it cannot be changed anymore (this is a limitation of this implementation, not a principle one). A Drupal node is created representing the AA item. In a more advanced implementation the user could be given a list of AA headlines to choose the item ID from, set up mappings (see below), and customise the way the AA data is displayed. The code for this module is based on the Drupal tutorial Creating new node types. The ActionApps abstraction layer developed for Task #2 now allows for retrieving and storing items from the ActionApps database:
/** * Return an ActionApps item object * @param item_id AA item ID * @return AAItem Object or false if not found */ function getItem($item_id) /** * Store an ActionApps item object * @param item_id AA item ID * @param content_array content (key=>value) * @return item_id or false if failed */ function updateItem($item_id,$content_array) In Drupal the following hooks are used:
Todos
Developing Migration ToolsThe aaitem module shows that it is possible to use data stored in a different database with Drupal nodes. It even allows for editing the content and saving it back to the original database. Nevertheless, it has shortcomings, e.g. it is limited to a couple of predefined AA fields, there is no support for date fields etc. For real world use it would need a configuration interface for mapping AA fields to Drupal fields and options of how to interpret and display them. A possible solution for a migration script could be one that iterates through one ActionApps slice and creates an aaitem node for each item ID. This would allow to run both systems in parallel. Thus reducing the need to train users, schedule downtime, or freeze a web site. One question in this scenario is where the data should stay. There is two options: the current aaitem implementation keeps the data in the AA database. But with a few changes to the code it would be possible to store data to Drupal - overwriting the default Drupal node fields. Since Drupal would require any extra information to be stored in a new table this does not seem to be the best approach. Especially, since the partial import approach still allows using the ActionApps Item Manager and Views while a site runs on Drupal. aaitem Module WalkthroughIn this example an item from ActionApps is being used in Drupal using the aaitem module. The item data will stay in the ActionApps database. The only information stored in Drupal is the ActionApps Item ID.
After activating the aaitem module in Drupal and assigning appropriate access permissions the aaitem content type shows up in the Drupal create content section.
Next it is asking for the ActionApps Item ID. Finding this out is more complicated than expected. To find this out it is necessary to change to the ActionApps Admin interface.
In Slice Admin | Item Manager View the default view is changed to display the Item ID (_#ITEM_ID#).
Now the Item IDs show up in the ActionApps Item Manager interface. This is the ID quired by the aaitem Drupal module.
Back in Drupal.
And after pressing submit the content of the ActionApps item is being displayed. Note that as headline of the node in Drupal it uses the ActionApps Item ID - not very user friendly.
It is interesting that the content can be edited in Drupal and will also be updated in ActionApps.
Her the Headline of the article is being changed.
After updating the node in Drupal the changed headline shows up in the ActionApps Item Manager.
Finally, the ActionApps item is diplayed on the Drupal page.
Conclusion
The approach taken for the development of the aaitem module makes integration of ActionApps and Drupal very easy. Though it is only a prototype at the moment, it already shows that keeping data in ActionApps while allowing to view and edit it in Drupal is worthwile for cases where a smooth transition from ActionApps to Drupal is necessary. Furthermore, it even allows for the running of both systems in parallel and friendly co-existence. |