* Basic webservice interface. */ include 'packLoad.php'; // must be CONFIGURED for your database //$db = new pdo($dsn,$PG_USER,$PG_PW); $basePath = '/var/www/xconv.local/xconv3/_relats'; //realpath(__DIR__ .'/../..'); $reini = true; // re-init all SQL structures of the project (drop and refresh schema) $sqlMode = '1'; $packs = ['packs' => ['aff2' => ['file' => "{$basePath}/data/aff2-2016-01-21.csv", 'sep' => ',']]]; $sqlIni = ["::assert_bysql:data/assert1_mode{$sqlMode}.tsv"]; sql_prepare($sqlIni, "teste de ASSERT", "/home/peter/gits/sql-term"); die("\nOK3232\n"); sql_prepare("\n CREATE TABLE IF NOT EXISTS tmp_aff2 (\n lang text,\n artigo_id int,\n p_aff xml\n );\n "); resourceLoad_run($basePath, ['aff2' => [['prepared_copy', "tmp_aff2"]]], "AFF2 test kit", $packs); // carregar asserts automaticamente, incluir "SELEC onde nao começar por SELECT ou WITH " # see table tstore.assert /* CREATE FUNCTION array_last( -- -- Returns the element of array_upper() -- anyarray, int DEFAULT 0 ) RETURNS anyelement AS $f$ SELECT $1[array_upper($1,1)-$2]; $f$ LANGUAGE SQL IMMUTABLE;
<?php /** * Load CSV data (defined in datapackage.jsob) to the SQL database. * php src/php/prepare.php */ include 'packLoad.php'; // must be CONFIGURED for your database // // // // // // // // // // // CONFIGS: (complement to omLib) $basePath = realpath(__DIR__ . '/../..'); $reini = true; // re-init all SQL structures of the project (drop and refresh schema) $sqlMode = '1'; // // // // // // SQL PREPARE $sqlIni = ["::src/sql_mode{$sqlMode}/step1_libDefs.sql", "::src/sql_mode{$sqlMode}/step2_struct.sql", "::src/sql_mode{$sqlMode}/step3_lib.sql", "SELECT tStore.ns_upsert('test','pt','Test. Portuguese.')", "SELECT tStore.ns_upsert('wayta-pt','pt','Wayta SciELO reference-dataset, Portuguese.',true, '{\"group_unique\":false}'::jsonb)", "SELECT tStore.ns_upsert('wayta-code',' ','Wayta SciELO reference-dataset, no-lang')", "SELECT tStore.ns_upsert('wayta-en','en','Wayta SciELO reference-dataset, English.')", "SELECT tStore.ns_upsert('wayta-es','es','Wayta SciELO reference-dataset, Spanish.')", "UPDATE tStore.ns SET fk_partOf=tlib.nsget_nsid('wayta-pt') WHERE label!='wayta-pt' AND left(label,5)='wayta'", "SELECT tStore.ns_upsert('country-code', ' ', 'Country names reference-dataset, no-lang.', true, '{\"group_unique\":false}'::jsonb)", "SELECT tStore.ns_upsert('country-pt','pt','Country names reference-dataset, Portuguese.')", "SELECT tStore.ns_upsert('country-fr','fr','Country names reference-dataset, French.')", "SELECT tStore.ns_upsert('country-es','es','Country names reference-dataset, Spanish.')", "SELECT tStore.ns_upsert('country-en','en','Country names reference-dataset, English.')", "SELECT tStore.ns_upsert('country-de','de','Country names reference-dataset, Deutsch.')", "SELECT tStore.ns_upsert('country-it','it','Country names reference-dataset, Italian.')", "SELECT tStore.ns_upsert('country-nl','nl','Country names reference-dataset, Dutch.')", "UPDATE tStore.ns SET fk_partOf=tlib.nsget_nsid('country-code') WHERE label!='country-code' AND left(label,7)='country'", "INSERT INTO tstore.source (name,jinfo) VALUES\n\t\t('normalized_aff', tstore.source_add1('Scielo','Wayta institution','https://github.com/scieloorg/wayta/blob/master/processing/normalized_aff.csv') )\n\t\t,('normalized_country', tstore.source_add1('Scielo','Wayta country','https://github.com/scieloorg/wayta/blob/master/processing/normalized_country.csv') )\n\t\t,('country-names-multilang', tstore.source_add1('Unicode','UNICODE CLDR, core, territory','http://www.unicode.org/Public/cldr') )\n\t\t,('country-codes', tstore.source_add1('OKFN','Data Packaged Core Datasets, ISO and other Country Codes','https://raw.github.com/datasets/country-codes/master/data/country-codes.csv') )\n\t\t,('iso3166-1-alpha-2', tstore.source_add1('ISO','ISO-3166-1, Country Codes, Alpha-2','') )\n\t\t,('iso3166-1-alpha-3', tstore.source_add1('ISO','ISO-3166-1, Country Codes, Alpha-3','') )\n\t"]; // // // // // // MAKING DATA: sql_prepare($sqlIni, "SQL SCHEMAS with MODE{$sqlMode}", $basePath, $reini); if (!$reini) { sql_prepare("DELETE FROM tstore.term; DELETE FROM tstore.ns;", "DELETING MAIN TABLES"); } resourceLoad_run($basePath, ['test' => [['prepare_auto', "tlib.tmp_test"]], 'normalized_aff' => [['prepare_jsonb', "tlib.tmp_waytaff"]], 'normalized_country' => [['prepare_jsonb', "tlib.tmp_waytacountry"]], 'country-codes' => [['prepare_jsonb', "tlib.tmp_codes"]], 'country-names-multilang' => [['prepare_jsonb', "tlib.tmp_codes2"]]], "(MODE{$sqlMode})"); sql_prepare(["SELECT tStore.upsert(term, tlib.nsget_nsid('test')) FROM tlib.tmp_test;", "DROP TABLE tlib.tmp_test;", "::src/sql_mode{$sqlMode}/nsCountry_build.sql", "DROP TABLE tlib.tmp_waytacountry; DROP TABLE tlib.tmp_codes; DROP TABLE tlib.tmp_codes2;", "::src/sql_mode{$sqlMode}/nsWayta_build.sql", "DROP TABLE tlib.tmp_waytaff;", "::assert_bysql:data/assert1_mode{$sqlMode}.tsv"], "SQL FINALIZATION", $basePath);