Jump to content

Wikicat Technical Design/MDA

From Meta, a Wikimedia project coordination wiki

Wikicat is engineered using a model-driven architecture (MDA) approach in which a platform-independent UML model of core modules is converted into a specific implementation that handles such functionality as persistence (e.g. basic CRUD database operations) and external data import. The benefits of this approach are portability, quality, and flexibility.


  • Portability: While Wikicat is designed to primarily function as a MediaWiki extension (thus requiring implementation in PHP), other projects may find the Wikicat model useful enough to translate into their own, incompatible platform implementations (e.g. Java, C#, etc.)
  • Quality: Through use of MDA code generators, much of the basic Wikicat infrastructure can avoid the error-prone hand coding process.
  • Flexibility: Dependence on particular components of the techstack is minimized, allowing easy migration (such as to a different persistence framework) as the need arises.


In addition, the MDA infrastructure created for the development of Wikicat will be equally useful in quickly engineering other Wikidata datasets. The MDA code generator used with Wikicat is AndroMDA 3.2.

Wikicat Profile

[edit]

The following are Wikicat/Wikidata extensions to the base AndroMDA 3.2 UML profile.

Stereotypes

[edit]

<<DateRange>>

[edit]
  • Model Elements: Attribute
  • Desc: An extended type indicating a well-defined period, rather than point, of time. For example, a journal's period of publication. The single attribute with this stereotype is implemented with a ***Begin and ***End attribute at the object and database schema levels.

<<FuzzyDate>>

[edit]
  • Model Elements: Attribute
  • Desc: An extended type indicating an uncertain point in time, either when there is not enough information to establish a precise date (e.g. Homer's birthdate), or when the time in question is inherently imprecise (the start of the Jurassic period). The single attribute with this stereotype is implemented with ***Min and ***Max attributes at the object and database schema levels.

<<MultiLang>>

[edit]
  • Model Elements: Attribute
  • Desc: Indicates the text data may be in more than one language. A ***Lang co-attribute is created along with the main attribute at both object and database schema levels. Note that this is different from the <<Translatable>> attribute stereotype, as the latter expresses the requirement for translating the data, particularly for seeded reference datasets. See Multilingual Wikidata for a discussion of the differences.

<<MultiScript>>

[edit]
  • Model Elements: Attribute
  • Desc: Indicates the text data may be in more than one linguistic script. A ***Script co-attribute is created along with the main attribute at both object and database schema levels. Note that this is different from the <<Translatable>> attribute stereotype, as the latter expresses the requirement for translating the data, particularly for seeded reference datasets. See Multilingual Wikidata for a discussion of the differences.

<<Nominal>>

[edit]
  • Model Elements: Attribute
  • Desc: Indicates the data is text transcribed from a source that is possibly unreliable. See the following for a description of information nominality. A ***Nomlty co-attribute is created along with the main attribute at both object and database schema levels.

<<Seeded>>

[edit]
  • Model Elements: Class
  • Desc: The <<Seeded>> stereotype indicates a basic reference entity that is seeded at the time of installation and should not be updated or added to. An example is the Language entity.

<<Translatable>>

[edit]
  • Model Elements: Attribute
  • Desc: Indicates the attribute is translatable text data. All <<Translatable>> attributes are stored in a separate, language-striped child table that joins to the main, untranslatable data table.

Tagged Values

[edit]

@andromda.persistence.schema

[edit]
  • Model Elements: Package
  • Desc: This existing tag is added to the set of applicable tags for package model elements, and is used to hierarchically specify the schema for a set of classes. A class will use the @andromda.persistence.schema tagged value of the most proximate package to which it belongs. Note that for MySQL implementations, this means the schema name is appended to the table name.

Build Instructions

[edit]

AndroMDA is most easily invoked through its Maven plugin. Detailed instructions for installing both Maven and the AndroMDA application plugin are provided here. In brief, after installing Maven and then downloading the AndroMDA application plugin into the new Maven repository (underneath $M2_REPOSITORY/org/andromda/maven/plugins/), run the following command to generate a skeleton project:

  mvn org.andromda.maven.plugins:andromdapp-maven-plugin:3.2:generate

The configuration options the plugin prompts for are immaterial except for the following:

Next, download the Wikicat UML model XMI file from the Wikicat SourceForge project. AndroMDA will have created an empty XMI file beneath the mda/src/main/uml/ subdirectory (the empty file will have a name of the form <project id>.xmi). Either overwrite the empty XMI file with the Wikicat model XMI file, or alter the following configuration directive in mda/pom.xml:

  <model.uri>file:[location of Wikicat model XMI file]</model.uri>

Wikicat MDA piggbacks on the AndroMDA Hibernate cartridge by overriding the templates that come with it to generate its own PHP code. To use the Wikicat MDA templates with the Hibernate cartridge, download the entire contents of the hibernate_custom/ directory in the Wikicat CVS repository, being sure to preserve the relative subdirectory structure. Then add the following configuration directive as the last child element beneath <namespace name="hibernate"> in the mda/src/main/config/andromda.xml configuration file:

  <property name="mergeLocation">[path to hibernate_custom/]</property>

This tells AndroMDA to use the Hibernate templates it finds beneath the hibernate_custom/ directory in place of those that ship with the cartridge. This is technically done through the overwriting of file hibernate_custom/templates/hibernate/HibernateEntity.vsl, which in place of its normal contents has this directive to include the contents of the main Wikicat MDA template:

  #parse ( "templates/php/Class.vsl" )

Template templates/php/Class.vsl is the main template for generating the model files of Wikicat, which replicate the basic structure of each Wikicat entity through PHP objects, as well provide support for object persistence. Most customizations of Wikicat MDA will be performed by editing this template.

See Also

[edit]
[edit]