diff --git a/.gitmodules b/.gitmodules index 95d2a39..a0693e9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,12 @@ [submodule "includes/boz-mw"] path = includes/boz-mw url = https://github.com/valerio-bozzolan/boz-mw.git [submodule "2018-06-wikidata-volleyball-players/includes/boz-mw"] path = 2018-06-wikidata-volleyball-players/includes/boz-mw url = https://github.com/valerio-bozzolan/boz-mw [submodule "2018-06-wikidata-soccer-serie-a/includes/boz-mw"] path = 2018-06-wikidata-soccer-serie-a/includes/boz-mw url = https://github.com/valerio-bozzolan/boz-mw.git +[submodule "2018-02-italian-parks/includes/boz-mw"] + path = 2018-02-italian-parks/includes/boz-mw + url = https://github.com/valerio-bozzolan/boz-mw.git diff --git a/2018-02-italian-parks/data/italian-natura-ids.csv b/2018-02-italian-parks/data/italian-natura-ids.csv new file mode 100644 index 0000000..944df1d --- /dev/null +++ b/2018-02-italian-parks/data/italian-natura-ids.csv @@ -0,0 +1,123 @@ +Q55238384,ITB010001 +Q55239024,ITB010002 +Q55239026,ITB010003 +Q55239027,ITB010004 +Q55239029,ITB010006 +Q55239030,ITB010007 +Q55239108,ITB010009 +Q55239109,ITB010043 +Q52942871,ITB010082 +Q55239110,ITB011102 +Q55239111,ITB011155 +Q55239141,ITB012211 +Q55239547,ITB010008 +Q55239523,ITB010010 +Q55239524,ITB010011 +Q55239525,ITB010042 +Q55239526,ITB011109 +Q55239528,ITB011113 +Q55239529,ITB012212 +Q55239530,ITB012213 +Q55239449,ITB013011 +Q55239450,ITB013012 +Q55239451,ITB013018 +Q55239454,ITB013019 +Q55239455,ITB013044 +Q55239457,ITB013048 +Q55239459,ITB013049 +Q55239671,ITB020012 +Q55239672,ITB020013 +Q55239674,ITB020040 +Q55254303,ITB020041 +Q55254231,ITB021101 +Q55254233,ITB021107 +Q55254164,ITB021156 +Q55254166,ITB022215 +Q55254168,ITB022217 +Q55254537,ITB022212 +Q55254439,ITB020015 +Q55254441,ITB022214 +Q55254795,ITB020014 +Q55254797,ITB021103 +Q55254663,ITB023037 +Q55254666,ITB023049 +Q55254668,ITB023050 +Q55254670,ITB023051 +Q55254978,ITB030033 +Q55254980,ITB030036 +Q55254983,ITB032201 +Q55254985,ITB032229 +Q55255188,ITB030016 +Q55255190,ITB030032 +Q55255192,ITB030034 +Q55255194,ITB030035 +Q55255197,ITB030037 +Q55255199,ITB030038 +Q55255201,ITB030080 +Q55255203,ITB031104 +Q55255205,ITB032219 +Q55255207,ITB032228 +Q55255211,ITB032239 +Q55255213,ITB032240 +Q55256102,ITB030039 +Q55256103,ITB033036 +Q55256104,ITB034001 +Q55256107,ITB034004 +Q55256109,ITB034005 +Q55256110,ITB034006 +Q55256111,ITB034007 +Q55261110,ITB040026 +Q55261111,ITB040081 +Q55260914,ITB040027 +Q55260915,ITB040028 +Q55260916,ITB040029 +Q55260917,ITB040030 +Q55260918,ITB040031 +Q55260919,ITB040071 +Q55260921,ITB041111 +Q55260922,ITB042208 +Q55260923,ITB042209 +Q55260924,ITB042210 +Q55260925,ITB042218 +Q55260926,ITB042220 +Q55260927,ITB042223 +Q55260928,ITB042225 +Q55260930,ITB042226 +Q55260931,ITB042230 +Q55260932,ITB042237 +Q55260933,ITB042247 +Q55260934,ITB042250 +Q55262393,ITB040017 +Q55262394,ITB040018 +Q55262395,ITB040019 +Q55262397,ITB040020 +Q55262398,ITB040024 +Q55262399,ITB040025 +Q55262400,ITB041112 +Q55262401,ITB042233 +Q55262402,ITB042234 +Q55262403,ITB042236 +Q55262404,ITB042251 +Q55263111,ITB043025 +Q55263112,ITB043026 +Q55263113,ITB043027 +Q55263114,ITB043028 +Q55263115,ITB043032 +Q55263116,ITB043035 +Q55263117,ITB043054 +Q55263118,ITB043056 +Q55266239,ITB040022 +Q55266241,ITB040023 +Q55266243,ITB040051 +Q55266245,ITB041106 +Q55266277,ITB042207 +Q55266247,ITB042216 +Q55266249,ITB042231 +Q55266250,ITB042241 +Q55266251,ITB042242 +Q55266252,ITB042243 +Q55266349,ITB040021 +Q55266351,ITB041105 +Q55266353,ITB043055 +Q55266356,ITB044002 +Q55266358,ITB044003 diff --git a/2018-02-italian-parks/import-only-natura-ids.php b/2018-02-italian-parks/import-only-natura-ids.php new file mode 100755 index 0000000..e0db867 --- /dev/null +++ b/2018-02-italian-parks/import-only-natura-ids.php @@ -0,0 +1,68 @@ +#!/usr/bin/php +. + +$ALWAYS = true; + +require 'includes/boz-mw/autoload.php'; +require '../config.php'; + +$REFERENCES = [ [ + 'snaks' => ( + new wb\Snaks( [ + // stated in: Ministry of the Environment + new wb\SnakItem( 'P248', 'Q3858479' ), + + // retrieved + new wb\SnakTime( 'P813', '+2018-06-00T00:00:00Z', wb\DataValueTime::PRECISION_MONTHS ) + ] ) + )->getAll() +] ]; + +$wikidata = \wm\Wikidata::getInstance()->login(); +foreach( explode( "\n", trim( file_get_contents( 'data/italian-natura-ids.csv' ) ) ) as $park ) { + + list( $entity_id, $natura_id ) = explode( ',', $park ); + + // Data old + $data_old = $wikidata->fetch( [ + 'action' => 'wbgetentities', + 'props' => 'claims', + 'ids' => $entity_id, + ] ); + $data_old = wb\DataModel::createFromObject( $data_old->entities->{ $entity_id } ); + + // Data new + $data = ( new wb\DataModel() ) + ->addClaim( + ( new wb\StatementString( 'P3425', $natura_id ) ) + ->setReferences( $REFERENCES ) + ); + + if( ! $data_old->hasClaimsInProperty( 'P3425' ) ) { + echo "https://www.wikidata.org/wiki/$entity_id $natura_id\n"; + if( $ALWAYS || 'y' === cli\Input::yesNoQuestion( "Save?" ) ) { + $wikidata->post( [ + 'action' => 'wbeditentity', + 'summary' => 'Bot: [[Wikidata:Requests for permissions/Bot/Valerio Bozzolan bot 4|importing Natura 2000 site ID]]', + 'token' => $wikidata->getToken( mw\Tokens::CSRF ), + 'bot' => 1, + 'id' => $entity_id, + 'data' => $data->getJSON() + ] ); + } + } +} diff --git a/2018-02-italian-parks/includes/boz-mw b/2018-02-italian-parks/includes/boz-mw new file mode 160000 index 0000000..989b19c --- /dev/null +++ b/2018-02-italian-parks/includes/boz-mw @@ -0,0 +1 @@ +Subproject commit 989b19c1671170cae39f8959c7cf921d24a9615b