Template:AssignPest
The template takes the following 4 parameters from the fields of the subform "Pest records" in the "Publication" form:
- assigned pest
- assigned crop (may be blank)
- assigned country (may be blank)
- assigned quarantined property (may be blank)
and assigns an internal object to these parameters. In addition, it checks if the pest entry (parameter 1) belongs to a higher category (see Template:GetCategory). If yes, it makes additional SemanticMW assignments. A higher category is only found if parameter 1 is not itself already a category, e.g. the pest "Helicoverpa (genus)" will not cause additional assignments. The following additional assignments are made:
- A normal SemanticMW assignment for the first category found. E.g. if the the pest is "Helicoverpa armigera" then the literature record is also assigned to "Helicoverpa (genus)".
- An additional internal object assignment to the first higher category found, using the parameters 2 to 4.
- If the assigned crop (parameter 2) belongs to the category "Grasses/turf/rangeland" or to the category "Mushrooms" (see Template:GetCategory2), then the original internal object assignment is also repeated with this crop category.
Note: The assignments to higher categories do not become available immediately after a new genus has been entered into the system. This requires the "Data repair and upgrade" action on Special:SMWAdmin which is only available to administrators. This upgrade is done routinely several times per year.
The template has the following structure:
1. Internal object assignment with the above 4 parameters. {{#set_internal:Pest record|Pest={{{1}}}|Crop={{{2}}}|Country={{{3}}}|Quarantined={{{4}}} }} 2. Define the variable "Category" to take a higher pest category (and later also a higher crop category) {{#vardefine:Category|{{GetCategory|{{{1}}} }} }} 3. If a higher category has been found... {{#if:{{#var:Category}}| 3a. Make an additional normal SematicMW assignment with the category [[Publication on pest::{{#var:Category}}| ]] 3b. Make an additional internal object assignment {{#set_internal:Pest record|Pest={{#var:Category}}|Crop={{{2}}}| Country={{{3}}}|Quarantined={{{4}}} }} }} (end of "{{#if:{{#var:Category}} ...") 4. If parameter 2 is not blank... {{#if:{{{2}}}| re-define the variable "Category" to take the string "Grasses/turf/rangeland" or "Mushrooms", if one of them is found as a higher category for the crop parameter {{#vardefine:Category|{{GetCategory2|{{{2}}} }} }} 4a. If the crop category "Grasses/turf/rangeland" and "Mushrooms" has been found, make an additional internal object assignment {{#if:{{#var:Category}}| {{#set_internal:Pest record|Pest={{{1}}}|Crop={{#var:Category}}| Country={{{3}}}|Quarantined={{{4}}} }} }} }} (end of "{{#if:{{{2}}}...")