Demo VisualData 1.0 / Dependent values

Dependent values: Difference between revisions

From Wikisphere
Jump to navigation Jump to search
No edit summary
No edit summary
Tag: 2017 source edit
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
The following form demonstrates the use of VisualData to query and record dependent values (the classical case is the country-state-city relationship) and to easily create and store them on your wiki through a couple of maintenance scripts. It uses the schema [[VisualDataSchema:Dependent_values]] created through the Schema Builder (see special page [[Special:ManageSchemas]] then open the schema "Dependent values").


The following form demonstrates the use of PageProperties to query and record dependent values (the classical case is the country-state-city relationship) and to easily create and store them on your wiki through a couple of maintenance scripts. It uses the schema [[PagePropertiesSchema:Dependent_values]].


 
{{#visualdataform: Dependent values
{{#pagepropertiesform: Dependent values
|title = Dependent values
|title = Dependent values
|action = create
|action = create
Line 15: Line 15:
|edit-categories = false
|edit-categories = false
|edit-content-model = false
|edit-content-model = false
|default-categories = tasks
|default-categories =  
|default-content-model = json
|default-content-model = json
|layout-align = top
|layout-align = top
Line 33: Line 33:
</pre>
</pre>


where <code><nowiki><country></nowiki></code> is the name of the first field and <code><nowiki><value></nowiki></code> is the value being inserted in the input.<!-- Note that the field names if nested have to be expressed using a path, for instance -->. The requested printout is <code>states/name</code> that matches the path <code>properties/states/items/properties/name</code> in the schema [[PagePropertiesSchema:Country]]. (where only relevant property names have to be concatenated, leaving aside <code>properties</code> and <code>items</code> that belong to the schema structure). The query will search json data related to the schema "Country" with value of the property <code>name</code> equal to the value of the first field, and value of the property <code>states/name</code> equal to the state input value.
where <code><nowiki><country></nowiki></code> is the name of the first field and <code><nowiki><value></nowiki></code> is the value being inserted in the input.<!-- Note that the field names if nested have to be expressed using a path, for instance -->. The requested printout is <code>states/name</code> that matches the path <code>properties/states/items/properties/name</code> in the schema [[VisualDataSchema:Country]]. (where only relevant property names have to be concatenated, leaving aside <code>properties</code> and <code>items</code> that belong to the schema structure). The query will search json data related to the schema "Country" with value of the property <code>name</code> equal to the value of the first field, and value of the property <code>states/name</code> equal to the state input value.


The third field (city) uses this query
The third field (city) uses this query
Line 43: Line 43:




'''The query searches within a database of 250 wiki pages with json content model as the following [[Data:Countries/Afghanistan]], that contain more than 620,000 entries in total.'''
'''The query searches within a database of [[Data:Countries|250 wiki pages]] with json content model like [[Data:Countries/Afghanistan]], containing more than 620,000 entries in total.'''


The database can been created downloading this data [https://github.com/dr5hn/countries-states-cities-database/blob/master/countries%2Bstates%2Bcities.json countries%2Bstates%2Bcities.json] from [https://github.com/dr5hn/countries-states-cities-database github.com/dr5hn/countries-states-cities-database] and then importing them on your wiki using the following maintenance command:
The database can been created downloading this data [https://github.com/dr5hn/countries-states-cities-database/blob/master/countries%2Bstates%2Bcities.json countries%2Bstates%2Bcities.json] from [https://github.com/dr5hn/countries-states-cities-database github.com/dr5hn/countries-states-cities-database] and then importing them on your wiki using the following maintenance command:


<pre>
<pre>
php extensions/PageProperties/maintenance/ImportData.php --file "[path-to-the following-file]/countries+states+cities.json" --schema Country --pagename-formula "Data:countries/<name>" --main-slot
php extensions/VisualData/maintenance/ImportData.php --file "[path-to-the following-file]/countries+states+cities.json" --schema Country --pagename-formula "Data:countries/<name>" --main-slot
</pre>
</pre>


The script takes only a few minutes to create all the required entries (including the related schema if it does not exist) and the data can be rebuild any time through the following command:
The script takes only a few minutes to create all the required entries (including the related schema if it does not exist) and the data can be rebuilt any time through the following command:
<pre>
<pre>
php extensions/PageProperties/maintenance/RebuildData.php
php extensions/VisualData/maintenance/RebuildData.php
</pre>
</pre>


Line 61: Line 61:
<pre>
<pre>


{{#pagepropertiesform: Dependent values
{{#visualdataform: Dependent values
|title = Dependent values
|title = Dependent values
|action = create
|action = create
Line 73: Line 73:
|edit-categories = false
|edit-categories = false
|edit-content-model = false
|edit-content-model = false
|default-categories = tasks
|default-categories =
|default-content-model = json
|default-content-model = json
|layout-align = top
|layout-align = top
Line 83: Line 83:
}}
}}
</pre>
</pre>
Have fun using your wiki as an open-source database management system !!
== See also ==
{{Demo VisualData footer}}

Latest revision as of 11:49, 4 February 2024

The following form demonstrates the use of VisualData to query and record dependent values (the classical case is the country-state-city relationship) and to easily create and store them on your wiki through a couple of maintenance scripts. It uses the schema VisualDataSchema:Dependent_values created through the Schema Builder (see special page Special:ManageSchemas then open the schema "Dependent values").


form is loading...


The first field (country) is a OOUI DropdownInputWidget with items taken from the template Template:Countries.

The second field (state) is a LookupElement with query

[[name::<country>]][[states/name::<value>~]]

where <country> is the name of the first field and <value> is the value being inserted in the input.. The requested printout is states/name that matches the path properties/states/items/properties/name in the schema VisualDataSchema:Country. (where only relevant property names have to be concatenated, leaving aside properties and items that belong to the schema structure). The query will search json data related to the schema "Country" with value of the property name equal to the value of the first field, and value of the property states/name equal to the state input value.

The third field (city) uses this query

[[name::<country>]][[states/name::<state>]][[states/cities/name::<value>~]]

The query as above will search json data related to the schema "Country" with value of the property name equal to the value of the first field, value of the property states/name equal to the second field, and value of the property states/cities/name equal to the city input value. The requested printout in this case is states/cities/name.


The query searches within a database of 250 wiki pages with json content model like Data:Countries/Afghanistan, containing more than 620,000 entries in total.

The database can been created downloading this data countries%2Bstates%2Bcities.json from github.com/dr5hn/countries-states-cities-database and then importing them on your wiki using the following maintenance command:

php extensions/VisualData/maintenance/ImportData.php --file "[path-to-the following-file]/countries+states+cities.json" --schema Country --pagename-formula "Data:countries/<name>" --main-slot

The script takes only a few minutes to create all the required entries (including the related schema if it does not exist) and the data can be rebuilt any time through the following command:

php extensions/VisualData/maintenance/RebuildData.php


This is the wikitext used to create the form itself:


{{#visualdataform: Dependent values
|title = Dependent values
|action = create
|edit-page = 
|return-page = 
|view = inline
|popup-size = medium
|css-class =
|pagename-formula = 
|edit-freetext = false
|edit-categories = false
|edit-content-model = false
|default-categories =
|default-content-model = json
|layout-align = top
|popup-help = true 
|submit-button-text =
|layout = tabs
|submit-button-text =
|validate-button-text =
}}


Have fun using your wiki as an open-source database management system !!


See also[edit | edit source]