Adding fields

From AIRWiki
Revision as of 11:12, 15 February 2010 by GiulioFontana (Talk | contribs)

Jump to: navigation, search

Sometimes, you have to modify the semantic description of a category. The typical case happens when you find out that you have left out a crucial feature and you have to add it. To do that, you have to add a field to the semantic description of the category... and go through the additional modification to the wiki required to make the new field fully integrated with AIRWiki, and in particular to make it usable for semantic queries.

As an example, we will describe the operations performed to add a new field to the description of, in order to integrate the new field with the SMW framework of AIRWiki. Of course, the procedure can be easily generalized.

IMPORTANT: this kind of operations introduce structural changes in the AIRWiki. They should be performed only after consultation with professor Bonarini.


Let's add the field "Coordinator" to the Project category, to describe the person that is managing the project (while the "Tutor" is in charge of the students participating to it). These are the steps:

1. Creation of a new category called "Coordinator". By using the Special:CreateCategory page, this is easy, but we are asked to specify which category (if any) Coordinator should be a subcategory of. The general rule is: define a new category B as a subcategory of a category A which includes all the possible elements of B, but the minimum number of elements outside B. If A doesn't exist, do not define B as a subcategory. By applying this rule, we define "Coordinator" as a subcategory of "Person": in fact the coordinator is most certainly a person, but can be even external to Politecnico di Milano.

2. Choice of the forms which are influenced by the change. The forms are used for simplified input of data, and are the preferred method to create new pages (when a form is available for the page, of course). Available forms are listed in the Special:Forms page: in our case, the only form to be changed is Form:Project.

3. Modification of the form for Project. By editing the Form:Project wiki page, we must now insert a field associated to the Coordinator category into the form. Beware: this is a dangerous operation, if you are not an expert of SMW syntax. The best option is to use copy-and-paste judiciously. By adding

 ! <nowiki>[[Property:PrjCoordinator|Coordinator(s)]]:
 (NameSurname1; NameSurname2; ...)
 | {{{field|coordinator|mandatory|autocomplete on category=Coordinator|delimiter=; }}}
 |-
</nowiki>

to the form in a suitable place, we ensure that:

  • a new field (called "coordinator") is added to the form: from now on, any page created or edited using this form will possess a box where the coordinator must (note the "mandatory") be specified;
  • a new property (called PrjCoordinator) has been introduced but not yet defined.

4. Creation of the new property PrjCoordinator associated to category Project. After its definition, the value of the property for a specific page belonging to that category will be usable to perform queries. This is done using the special page Special:CreateProperty. This creation mask asks you to specify the kind of values of the property: in our case, we choose one at random since we are going to replace the property page's wiki code immediately after.

5. Definition of the new property. This is done by editing page Property:PrjCoordinator; in this case we simply substituted the wiki code in it with the following text, adapted from Property:PrjTutor:

This property is used to indicate that a [[:Category:Project|Project]] is managed by one (ore more) [[:Category:Coordinator|Coodinators]].
<!-- Allowed values are all [[:Category:Coordinators|coordinators]]: {{#arraymap: {{#ask: [[Category:Tutor]]|format=list|link=none|sep=;}}|;|
x|[[allows value::x]]}} -->

6. Choice of the templates which are influenced by the change. The templates are used to display in a standardized way the data of a page. Available templates are listed in the Special:Templates page: in our case, the only form to be changed is Template:Project (it must be changed because it defines the category Project).

7. Modification of the template for Project. Beware: this is a dangerous operation, if you are not an expert of SMW syntax. The best option is to use copy-and-paste judiciously. In our case, we perform two modifications. First, alteration of the description of the template by inserting the following text:

| coordinator=Leonardo Da Vinci
|         ***NOTE:*** you can specify a LIST of coordinators, separating them with a semicolon (;). Coordinators and tutors can overlap.

Then, alteration of the graphical description of the template to add a table row showing the coordinator(s). This requires adding the following text:

|-
{{Tablerow|Label=Coordinator|Value={{#ifeq:{{{coordinator|}}}|||{{#arraymap:{{{coordinator|}}}|; |x|[[prjCoordinator::User:x|x]] ({{#show: User:x| ?Email }})}}}}}}