From 87d6bcfbd4a57b1009edcd9916e22e6ebb30e6e8 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Tue, 19 Jan 2021 12:00:11 +0100 Subject: [PATCH 001/154] scripts to build rpm packages - initial build --- packages/.gitignore | 4 ++ packages/Makefile | 82 ++++++++++++++++++++++ packages/rpm/SOURCES/inforex.httpd.conf | 46 +++++++++++++ packages/rpm/SPECS/inforex.spec | 91 +++++++++++++++++++++++++ 4 files changed, 223 insertions(+) create mode 100644 packages/.gitignore create mode 100644 packages/Makefile create mode 100644 packages/rpm/SOURCES/inforex.httpd.conf create mode 100644 packages/rpm/SPECS/inforex.spec diff --git a/packages/.gitignore b/packages/.gitignore new file mode 100644 index 00000000..8bfcebde --- /dev/null +++ b/packages/.gitignore @@ -0,0 +1,4 @@ +*~ +*.swp +*.rpm +rpm/SOURCES/inforex.tgz diff --git a/packages/Makefile b/packages/Makefile new file mode 100644 index 00000000..f1f55a88 --- /dev/null +++ b/packages/Makefile @@ -0,0 +1,82 @@ +# local path from current dir +RPM_SPEC_DIR = rpm/SPECS +RPM_SOURCES_DIR = rpm/SOURCES + +RPMBUILD = $(shell if [ -e /usr/bin/rpmbuild ]; then echo /usr/bin/rpmbuild; else bin/rpm; fi) +HAVE_RPMBUILD = "no"$(RPMBUILD) +RPM = rpm +PACKAGE = inforex +GITHASH=`git log --oneline |head -1|cut -d" " -f 1` +VERSION = 0.1 +RELNO = 1 +RELEASE = $(shell if [ ! -z '$(GITHASH)' ]; then echo -n "$(RELNO)v.$(GITHASH)"; else echo -n "$(RELNO)";fi) + +RELSPECTAG = RELEASE_TAG + +# glob cannot work here +TARITIFEXISTS = tests phpunit.xml data +FILES2TAR = composer.json apps LICENCE.md local sonar-project.properties config/README.md documentations phpunit engine gfx public_html database INSTALL.md README.md $(foreach wrd,$(TARITIFEXISTS),$(wrd)) + +$(RPM_SOURCES_DIR)/$(PACKAGE).tgz: ../.git/index + @(tar -C .. -cvzf $(RPM_SOURCES_DIR)/$(PACKAGE).tgz $(FILES2TAR) > /dev/null ) + +.PHONY: rpm-local srpm-common rpm-common srpm rpm all clean + +all: rpm + +# to wymaga podania w wywołaniu parametrów w zmiennych środowiska +# rpmbuild="katalog_do_budowania" i rpmspec="nazwa_pliku_spec" +rpm-local: $(RPM_SOURCES_DIR)/$(PACKAGE).tgz + @(if test "${HAVE_RPMBUILD}" = "no"; then \ + echo -e "\n" \ + "*** Required util ${RPMBUILD} missing. Please install the\n" \ + "*** package for your distribution which provides ${RPMBUILD},\n" \ + "*** re-run configure, and try again.\n"; \ + exit 1; \ + fi; \ + mkdir -p $(rpmbuild)/TMP && \ + mkdir -p $(rpmbuild)/BUILD && \ + mkdir -p $(rpmbuild)/RPMS && \ + mkdir -p $(rpmbuild)/SRPMS && \ + mkdir -p $(rpmbuild)/SPECS && \ + cat ${RPM_SPEC_DIR}/$(rpmspec) | sed -e 's/${RELSPECTAG}/${RELEASE}/' > $(rpmbuild)/SPECS/$(rpmspec) && \ + mkdir -p $(rpmbuild)/SOURCES && \ + if ls -A ${RPM_SOURCES_DIR} ; then \ + cp ${RPM_SOURCES_DIR}/* $(rpmbuild)/SOURCES; \ + fi) + +srpm-common: + @(rpmspec=$(PACKAGE).spec; \ + rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \ + $(MAKE) $(AM_MAKEFLAGS) \ + rpmbuild="$$rpmbuild" \ + rpmspec="$$rpmspec" \ + rpm-local || exit 1; \ + LANG=C $(RPMBUILD) \ + --define "_tmppath $$rpmbuild/TMP" \ + --define "_topdir $$rpmbuild" \ + $(def) -bs $$rpmbuild/SPECS/$$rpmspec || exit 1; \ + cp $$rpmbuild/SRPMS/*.src.rpm . || exit 1; \ + rm -R $$rpmbuild) + + +rpm-common: + @(rpmpkg=$(PACKAGE)-$(VERSION)-$(RELEASE)*src.rpm; \ + rpmspec=$(PACKAGE).spec; \ + rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \ + $(MAKE) $(AM_MAKEFLAGS) \ + rpmbuild="$$rpmbuild" \ + rpmspec="$$rpmspec" \ + rpm-local || exit 1; \ + LANG=C ${RPMBUILD} \ + --define "_tmppath $$rpmbuild/TMP" \ + --define "_topdir $$rpmbuild" \ + $(def) --rebuild $$rpmpkg || exit 1; \ + cp $$rpmbuild/RPMS/*/* . || exit 1; \ + rm -R $$rpmbuild) + +rpm: srpm-common rpm-common +srpm: srpm-common + +clean: + rm -f $(PACKAGE)*.rpm diff --git a/packages/rpm/SOURCES/inforex.httpd.conf b/packages/rpm/SOURCES/inforex.httpd.conf new file mode 100644 index 00000000..7961c625 --- /dev/null +++ b/packages/rpm/SOURCES/inforex.httpd.conf @@ -0,0 +1,46 @@ +# To offer inforex via Apache, add the following Alias +# to your server's configuration +# Alias /inforex "INFOREXDIR" + + + Options None + AllowOverride None + + php_admin_flag safe_mode off + php_admin_value open_basedir INFOREXDIR/:INFOREXDATAROOT/:PHPLIBDIR:/tmp + + + = 2.4> + + Order allow,deny + #Allow from 127.0.0.1 + Allow from all + + Require all granted + + + Order allow,deny + #Allow from 127.0.0.1 + Allow from all + + + + + = 2.4> + Require all denied + + + Order allow,deny + Deny from all + + + + + = 2.4> + Require all denied + + + Order allow,deny + Deny from all + + diff --git a/packages/rpm/SPECS/inforex.spec b/packages/rpm/SPECS/inforex.spec new file mode 100644 index 00000000..29f9ba0b --- /dev/null +++ b/packages/rpm/SPECS/inforex.spec @@ -0,0 +1,91 @@ +%define _unpackaged_files_terminate_build 1 +%define __brp_mangle_shebangs /usr/bin/true + +%define httpduser apache +%define httpdgroup apache +%define httpconfdir /etc/httpd +#% define phplibdir %{_datadir}/php +%define phplibdir /var/www/html +%define inforexdir %{phplibdir}/%{name} + +Name: inforex +Version: 0.1 +Release: RELEASE_TAG +Summary: dummy package to testing rpm builds +License: GLGPL v3 +Group: Productivity/Networking/Web/Frontends +URL: https://github.com/CLARIN-PL/Inforex + +Source0: %{name}.tgz +Source1: %{name}.httpd.conf + +BuildRequires: httpd-devel +BuildRequires: httpd +BuildRequires: php-devel + +Requires: httpd +Requires: mysql + +Buildarch: noarch + +%global debug_package %{nil} + +%description +This skeleton is intentionaly developed as absolute minimal specification +to test all phases of building rpm process + +%prep +%setup -q -c + +# remove .htaccess files +#find . -name \.htaccess -print | xargs rm -f + +# remove several scripts not used in the package +#rm -rf vendor/ezyang/htmlpurifier/maintenance/ + +%build + +%install +rm -rf $RPM_BUILD_ROOT +mkdir $RPM_BUILD_ROOT +install -m 755 -d %{buildroot}%{inforexdir} +# data dir may not exists +mkdir %{buildroot}%{inforexdir}/data +# copy all files +cp -r . %{buildroot}%{inforexdir} + +# move data directory to /var/lib/ and set symlink +install -m 755 -d %{buildroot}%{_localstatedir}/lib/ +mv %{buildroot}%{inforexdir}/data %{buildroot}%{_localstatedir}/lib/%{name} +ln -s %{_localstatedir}/lib/%{name} %{buildroot}%{inforexdir}/data + +# install (empty) configuration-file +touch %{buildroot}%{_localstatedir}/lib/%{name}/config.ini.php + +# install apache config-file and fix paths +install -m 755 -d %{buildroot}%{httpconfdir}/conf.d +install -m 644 %{SOURCE1} %{buildroot}%{httpconfdir}/conf.d/%{name}.conf +sed -i -e 's|INFOREXDIR|%{inforexdir}|g ; + s|INFOREXDATAROOT|%{_localstatedir}/lib/%{name}|g ; + s|# Alias|Alias| ; + s|PHPLIBDIR|%{phplibdir}|g' %{buildroot}%{httpconfdir}/conf.d/%{name}.conf + +%post +if [ -x %{_sbindir}/semanage ] ; then + # check is SELinux is installed and update settings + semanage fcontext -a -t httpd_var_lib_t %{_localstatedir}/lib/%{name} +fi + +%files +%defattr(644,root,root,755) + +%dir %{inforexdir} +%{inforexdir}/* + +%{_localstatedir}/lib/%{name}/config.ini.php + +%{httpconfdir}/conf.d/%{name}.conf + +%changelog +* Thu Jan 14 2021 Seweryn Walentynowicz +- Initial rpm spec file From 90d64a8f848b69d394ee1749520167341a900784 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Tue, 19 Jan 2021 21:43:11 +0100 Subject: [PATCH 002/154] set of various problems solved --- .gitignore | 3 ++- engine/Config/Config.php | 2 +- engine/external/pear/Auth.php | 2 +- engine/include/CInforexWeb.php | 9 ++++++--- engine/include/CPage.php | 2 +- engine/page/page_home.php | 2 +- public_html/index.php | 2 +- 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 5afeda68..fc978b20 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ secured_data/import *.aux *.log *.backup -*.swp \ No newline at end of file +*.swp +composer.lock diff --git a/engine/Config/Config.php b/engine/Config/Config.php index 8a793fbc..ed5f29a4 100644 --- a/engine/Config/Config.php +++ b/engine/Config/Config.php @@ -39,7 +39,7 @@ class Config extends Singleton\Singleton{ static private $url = 'http://localhost/inforex'; static private $dsn = array( - 'phptype' => 'mysql', + 'phptype' => 'mysqli', 'username' => 'inforex', 'password' => 'password', 'hostspec' => 'localhost', diff --git a/engine/external/pear/Auth.php b/engine/external/pear/Auth.php index 648880d1..52fe7ae3 100644 --- a/engine/external/pear/Auth.php +++ b/engine/external/pear/Auth.php @@ -466,7 +466,7 @@ function &_factory($driver, $options = '') { $storage_class = 'Auth_Container_' . $driver; include_once 'Auth/Container/' . $driver . '.php'; - $obj =& new $storage_class($options); + $obj = new $storage_class($options); return $obj; } diff --git a/engine/include/CInforexWeb.php b/engine/include/CInforexWeb.php index bd07e706..5921b76b 100644 --- a/engine/include/CInforexWeb.php +++ b/engine/include/CInforexWeb.php @@ -184,7 +184,7 @@ function doPage($page, &$variables) $o->set('user', $user); $o->set('page', $page); $o->set('corpus', $corpus); - $o->set('release', RELEASE); + $o->set('release', defined("RELEASE") ? RELEASE : "RELEASE" ); $o->set('config', Config::Config()); $o->set('rev', $this->getRevisionKey()); @@ -252,7 +252,7 @@ function execute() /* Gather the data about an activity */ $activity_page = array(); - $activity_page['ip_id'] = $db->get_entry_key("ips", "ip_id", array("ip" => $_SERVER["REMOTE_ADDR"])); + $activity_page['ip_id'] = $db->get_entry_key("ips", "ip_id", array("ip" => isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : "CLI local" )); $activity_page['user_id'] = isset($user) ? $user['user_id'] : null; $activity_page['corpus_id'] = isset($corpus) ? $corpus['id'] : null; $activity_page['report_id'] = RequestLoader::getDocumentId(); @@ -284,7 +284,10 @@ function execute() function getRevisionKey() { - $commitHash = exec("git rev-list -n 1 master"); + // last tag + //$commitHash = exec("git describe --tags `git rev-list --tags --max-count=1`"); + // last revision + $commitHash = exec("git rev-list --tags --max-count=1"); $revKey = substr($commitHash, 0, 8); return $revKey; } diff --git a/engine/include/CPage.php b/engine/include/CPage.php index 58b1626b..9afb6e72 100644 --- a/engine/include/CPage.php +++ b/engine/include/CPage.php @@ -78,7 +78,7 @@ function CPage($name=null,$description=null){ $this->description = $description; $this->template = new Smarty(); $this->template->compile_dir = Config::Config()->get_path_engine() . "/templates_c"; - $this->set('RELEASE', "RELEASE"); + $this->set('RELEASE', defined('RELEASE') ? RELEASE : "RELEASE"); /** * Include default JS and CSS files for the page diff --git a/engine/page/page_home.php b/engine/page/page_home.php index 482c3209..fa60a5dd 100644 --- a/engine/page/page_home.php +++ b/engine/page/page_home.php @@ -17,7 +17,7 @@ function __construct() function execute(){ global $user; - $user_id = intval($user[user_id]); + $user_id = intval($user["user_id"]); $private_corpora = DbCorpus::getPrivateCorporaForUser($user_id, intval(hasRole(USER_ROLE_ADMIN))); $public_corpora = DbCorpus::getCorpora(1); diff --git a/public_html/index.php b/public_html/index.php index 87c13113..51ee1987 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -56,7 +56,7 @@ } } - chdir("../engine"); + chdir(__DIR__ . "/../engine/"); $p->execute(); From c5cc67e5632baa14810efa55e32156ff68197c15 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Mon, 25 Jan 2021 19:49:26 +0100 Subject: [PATCH 003/154] bad assign by referencje for object removed from Auth module --- engine/external/pear/Auth/Container/DBLite.php | 4 ++-- engine/external/pear/Auth/Container/MDB.php | 2 +- engine/external/pear/Auth/Container/MDB2.php | 2 +- engine/external/pear/Auth/Container/NetVPOPMaild.php | 2 +- engine/external/pear/Auth/Container/POP3.php | 2 +- engine/external/pear/Auth/Controller.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/engine/external/pear/Auth/Container/DBLite.php b/engine/external/pear/Auth/Container/DBLite.php index 29961089..2f0f17b2 100644 --- a/engine/external/pear/Auth/Container/DBLite.php +++ b/engine/external/pear/Auth/Container/DBLite.php @@ -120,9 +120,9 @@ function _connect(&$dsn) { $this->log('Auth_Container_DBLite::_connect() called.', AUTH_LOG_DEBUG); if (is_string($dsn) || is_array($dsn)) { - $this->db =& DB::connect($dsn, $this->options['db_options']); + $this->db = DB::connect($dsn, $this->options['db_options']); } elseif (is_subclass_of($dsn, "db_common")) { - $this->db =& $dsn; + $this->db = $dsn; } else { return PEAR::raiseError("Invalid dsn or db object given"); } diff --git a/engine/external/pear/Auth/Container/MDB.php b/engine/external/pear/Auth/Container/MDB.php index 019a122a..a6a92d61 100644 --- a/engine/external/pear/Auth/Container/MDB.php +++ b/engine/external/pear/Auth/Container/MDB.php @@ -111,7 +111,7 @@ function _connect($dsn) { $this->log('Auth_Container_MDB::_connect() called.', AUTH_LOG_DEBUG); if (is_string($dsn) || is_array($dsn)) { - $this->db =& MDB::connect($dsn, $this->options['db_options']); + $this->db = MDB::connect($dsn, $this->options['db_options']); } elseif (is_subclass_of($dsn, 'mdb_common')) { $this->db = $dsn; } elseif (is_object($dsn) && MDB::isError($dsn)) { diff --git a/engine/external/pear/Auth/Container/MDB2.php b/engine/external/pear/Auth/Container/MDB2.php index a3c26b7d..0d8a35c7 100644 --- a/engine/external/pear/Auth/Container/MDB2.php +++ b/engine/external/pear/Auth/Container/MDB2.php @@ -111,7 +111,7 @@ function _connect($dsn) { $this->log('Auth_Container_MDB2::_connect() called.', AUTH_LOG_DEBUG); if (is_string($dsn) || is_array($dsn)) { - $this->db =& MDB2::connect($dsn, $this->options['db_options']); + $this->db = MDB2::connect($dsn, $this->options['db_options']); } elseif (is_subclass_of($dsn, 'MDB2_Driver_Common')) { $this->db = $dsn; } elseif (is_object($dsn) && MDB2::isError($dsn)) { diff --git a/engine/external/pear/Auth/Container/NetVPOPMaild.php b/engine/external/pear/Auth/Container/NetVPOPMaild.php index 634fab51..b9d78a13 100644 --- a/engine/external/pear/Auth/Container/NetVPOPMaild.php +++ b/engine/external/pear/Auth/Container/NetVPOPMaild.php @@ -108,7 +108,7 @@ function Auth_Container_Vpopmaild($server=null) function fetchData($username, $password) { $this->log('Auth_Container_Vpopmaild::fetchData() called.', AUTH_LOG_DEBUG); - $vpopmaild =& new Net_Vpopmaild(); + $vpopmaild = new Net_Vpopmaild(); // Connect try { $res = $vpopmaild->connect($this->server, $this->port, $this->method); diff --git a/engine/external/pear/Auth/Container/POP3.php b/engine/external/pear/Auth/Container/POP3.php index 0bfab1b5..5278092d 100644 --- a/engine/external/pear/Auth/Container/POP3.php +++ b/engine/external/pear/Auth/Container/POP3.php @@ -128,7 +128,7 @@ function Auth_Container_POP3($server=null) function fetchData($username, $password) { $this->log('Auth_Container_POP3::fetchData() called.', AUTH_LOG_DEBUG); - $pop3 =& new Net_POP3(); + $pop3 = new Net_POP3(); $res = $pop3->connect($this->server, $this->port, $this->method); if (!$res) { $this->log('Connection to POP3 server failed.', AUTH_LOG_DEBUG); diff --git a/engine/external/pear/Auth/Controller.php b/engine/external/pear/Auth/Controller.php index 92d9f80a..b1c707f8 100644 --- a/engine/external/pear/Auth/Controller.php +++ b/engine/external/pear/Auth/Controller.php @@ -106,7 +106,7 @@ class Auth_Controller */ function Auth_Controller(&$auth_obj, $login='login.php', $default='index.php', $accessList=array()) { - $this->auth =& $auth_obj; + $this->auth = $auth_obj; $this->_loginPage = $login; $this->_defaultPage = $default; @session_start(); From e8176530826358d4636ebcdb4e95128c328e1085 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Fri, 29 Jan 2021 22:14:31 +0100 Subject: [PATCH 004/154] ajax_test_wccl syntax error --- engine/ajax/ajax_test_wccl_rules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/ajax/ajax_test_wccl_rules.php b/engine/ajax/ajax_test_wccl_rules.php index eb797899..1b65acb1 100644 --- a/engine/ajax/ajax_test_wccl_rules.php +++ b/engine/ajax/ajax_test_wccl_rules.php @@ -8,7 +8,7 @@ function execute(){ $offset = intval($_POST['offset']); $rules = strval($_POST['wccl_rules']); $corpus = intval($_POST['corpus']); - $corpus_path = {Config::Config()->get_wccl_match_tester_corpora()}[$corpus]["path"]; + $corpus_path = Config::Config()->get_wccl_match_tester_corpora()[$corpus]["path"]; $cmd = "python ".Config::Config()->get_wccl_match_tester_script()." -s %d -o %d -r %s -c %s 2>&1"; $cmd = sprintf($cmd, $start, $offset, escapeshellarg($rules), $corpus_path); From 98ae7e3caecb5d913e1f61830fb33d59c4f11766 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Mon, 1 Feb 2021 19:31:20 +0100 Subject: [PATCH 005/154] /var/lib/inforex dir added to rpm, some correct to error solving --- engine/ajax/ajax_test_wccl_rules.php | 10 ++++++---- packages/rpm/SPECS/inforex.spec | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/engine/ajax/ajax_test_wccl_rules.php b/engine/ajax/ajax_test_wccl_rules.php index 1b65acb1..ef57413d 100644 --- a/engine/ajax/ajax_test_wccl_rules.php +++ b/engine/ajax/ajax_test_wccl_rules.php @@ -36,10 +36,12 @@ function execute(){ $return = array(); $return["errors"] = $errors; - $return["finished"] = $response->processed == 0; - $return["total_processed"] = $start + $response->processed; - $return["items"] = $response->items; - $return["total_documents"] = $response->total; + if(isset($response->processed)) { + $return["finished"] = $response->processed == 0; + $return["total_processed"] = $start + $response->processed; + } + $return["items"] = isset($response->items) ? $response->items : 0; + $return["total_documents"] = isset($response->total) ? $response->total : 0; return $return; } diff --git a/packages/rpm/SPECS/inforex.spec b/packages/rpm/SPECS/inforex.spec index 29f9ba0b..4ab63da2 100644 --- a/packages/rpm/SPECS/inforex.spec +++ b/packages/rpm/SPECS/inforex.spec @@ -4,7 +4,6 @@ %define httpduser apache %define httpdgroup apache %define httpconfdir /etc/httpd -#% define phplibdir %{_datadir}/php %define phplibdir /var/www/html %define inforexdir %{phplibdir}/%{name} @@ -82,6 +81,7 @@ fi %dir %{inforexdir} %{inforexdir}/* +%dir %{_localstatedir}/lib/%{name} %{_localstatedir}/lib/%{name}/config.ini.php %{httpconfdir}/conf.d/%{name}.conf From aaadf323e7a877b3928e835a7d5562b9a891c691 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Wed, 17 Feb 2021 19:13:14 +0100 Subject: [PATCH 006/154] final rpm cut, solving selinux context problem --- packages/rpm/SOURCES/inforex.httpd.conf | 2 +- packages/rpm/SPECS/inforex.spec | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/rpm/SOURCES/inforex.httpd.conf b/packages/rpm/SOURCES/inforex.httpd.conf index 7961c625..2d6f730c 100644 --- a/packages/rpm/SOURCES/inforex.httpd.conf +++ b/packages/rpm/SOURCES/inforex.httpd.conf @@ -1,6 +1,6 @@ # To offer inforex via Apache, add the following Alias # to your server's configuration -# Alias /inforex "INFOREXDIR" +# Alias /inforex "INFOREXDIR/public_html" Options None diff --git a/packages/rpm/SPECS/inforex.spec b/packages/rpm/SPECS/inforex.spec index 4ab63da2..5cf469a1 100644 --- a/packages/rpm/SPECS/inforex.spec +++ b/packages/rpm/SPECS/inforex.spec @@ -58,6 +58,13 @@ install -m 755 -d %{buildroot}%{_localstatedir}/lib/ mv %{buildroot}%{inforexdir}/data %{buildroot}%{_localstatedir}/lib/%{name} ln -s %{_localstatedir}/lib/%{name} %{buildroot}%{inforexdir}/data +# create one initial sql dump from all patches +rm -rf %{buildroot}/%{inforexdir}/database +mkdir -p %{buildroot}/%{inforexdir}/database/init +SQL_DUMP_FILE=%{buildroot}%{inforexdir}/database/init/initDB.sql +cat ./database/init/inforex-v1.0.sql |grep -v "50013 DEFINER=" > $SQL_DUMP_FILE +cat ./database/inforex-v1.0-changelog.sql |sed -e 's/endDelimiter:#/\nDELIMITER #/' | sed -e 's/^#/#\nDELIMITER ;/' >> $SQL_DUMP_FILE + # install (empty) configuration-file touch %{buildroot}%{_localstatedir}/lib/%{name}/config.ini.php @@ -72,7 +79,11 @@ sed -i -e 's|INFOREXDIR|%{inforexdir}|g ; %post if [ -x %{_sbindir}/semanage ] ; then # check is SELinux is installed and update settings - semanage fcontext -a -t httpd_var_lib_t %{_localstatedir}/lib/%{name} + if ( %{_sbindir}/semanage fcontext -l |grep %{_localstatedir}/lib/%{name} > /dev/null ) ; then + %{_sbindir}/semanage fcontext -d %{_localstatedir}/lib/%{name} + fi + %{_sbindir}/semanage fcontext -a -t httpd_var_lib_t %{_localstatedir}/lib/%{name} + %{_sbindir}/restorecon %{_localstatedir}/lib/%{name} fi %files @@ -87,5 +98,9 @@ fi %{httpconfdir}/conf.d/%{name}.conf %changelog +* Wed Feb 17 2021 Seweryn Walentynowicz +- solved selinux context installation problems +* Mon Feb 15 2021 Seweryn Walentynowicz +- Initial complete sql dump added * Thu Jan 14 2021 Seweryn Walentynowicz - Initial rpm spec file From ad643c4902b5db1a45c03f7bd70a7b15fe1cfc08 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 27 Feb 2021 09:56:58 +0100 Subject: [PATCH 007/154] added composer.lock to .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 5afeda68..fc978b20 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ secured_data/import *.aux *.log *.backup -*.swp \ No newline at end of file +*.swp +composer.lock From 768cdc7935d69acad0c39da4a7f0f3b8729cca3d Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 27 Feb 2021 10:04:40 +0100 Subject: [PATCH 008/154] eliminated ZERO DATE from initial db structure --- database/init/inforex-v1.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/init/inforex-v1.0.sql b/database/init/inforex-v1.0.sql index c45af4ec..a9a02759 100644 --- a/database/init/inforex-v1.0.sql +++ b/database/init/inforex-v1.0.sql @@ -1614,7 +1614,7 @@ DROP TABLE IF EXISTS `tasks`; CREATE TABLE `tasks` ( `task_id` int(11) NOT NULL AUTO_INCREMENT, `datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Data i czas utworzenia zadania.', - `datetime_start` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `datetime_start` timestamp NULL DEFAULT NULL, `type` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Identyfikator zadania.', `description` text COLLATE utf8mb4_unicode_ci, `parameters` text COLLATE utf8mb4_unicode_ci NOT NULL, From d6c7571ad05717962753fe6f4bd588ec1523d1e6 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 27 Feb 2021 17:25:27 +0100 Subject: [PATCH 009/154] DEFINER lines for unexistent DB user removed --- database/init/inforex-v1.0.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/database/init/inforex-v1.0.sql b/database/init/inforex-v1.0.sql index a9a02759..20113c55 100644 --- a/database/init/inforex-v1.0.sql +++ b/database/init/inforex-v1.0.sql @@ -1988,7 +1988,6 @@ UNLOCK TABLES; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`gpw`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `activities_view_users` AS select `u`.`screename` AS `screename`,count(0) AS `COUNT(*)`,max(`a`.`datetime`) AS `last_datetime`,`a`.`activity_page_id` AS `activity_page_id`,`a`.`datetime` AS `datetime`,`a`.`ip_id` AS `ip_id`,`a`.`user_id` AS `user_id`,`a`.`corpus_id` AS `corpus_id`,`a`.`report_id` AS `report_id`,`a`.`activity_type_id` AS `activity_type_id`,`a`.`execution_time` AS `execution_time` from (`activities` `a` join `users` `u` on((`a`.`user_id` = `u`.`user_id`))) group by `a`.`user_id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -2006,7 +2005,6 @@ UNLOCK TABLES; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `reports_annotations` AS select `ra`.`id` AS `id`,`ra`.`report_id` AS `report_id`,`ra`.`type_id` AS `type_id`,`at`.`name` AS `type`,`ra`.`from` AS `from`,`ra`.`to` AS `to`,`ra`.`text` AS `text`,`ra`.`user_id` AS `user_id`,`ra`.`creation_time` AS `creation_time`,`ra`.`stage` AS `stage`,`ra`.`source` AS `source` from (`reports_annotations_optimized` `ra` left join `annotation_types` `at` on((`at`.`annotation_type_id` = `ra`.`type_id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; @@ -2024,7 +2022,6 @@ UNLOCK TABLES; /*!50001 SET character_set_results = utf8 */; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ /*!50001 VIEW `tokens_tags` AS select `tt`.`token_tag_id` AS `token_tag_id`,`tt`.`token_id` AS `token_id`,`b`.`text` AS `base`,`tt`.`base_id` AS `base_id`,`tokens_tags_ctags`.`ctag` AS `ctag`,`tt`.`disamb` AS `disamb` from ((`tokens_tags_optimized` `tt` left join `bases` `b` on((`b`.`id` = `tt`.`base_id`))) left join `tokens_tags_ctags` on((`tt`.`ctag_id` = `tokens_tags_ctags`.`id`))) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; From c22c2b9a0f54970678d868f5a589f714cea0b940 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 27 Feb 2021 17:28:16 +0100 Subject: [PATCH 010/154] DB initialization sql_mode hint is no longer needed --- engine/include/database/MDB2DatabaseEngine.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/engine/include/database/MDB2DatabaseEngine.php b/engine/include/database/MDB2DatabaseEngine.php index 48bd3c56..04dcd0c4 100644 --- a/engine/include/database/MDB2DatabaseEngine.php +++ b/engine/include/database/MDB2DatabaseEngine.php @@ -33,13 +33,6 @@ public function __construct($dsn) { } $this->mdb2->loadModule('Extended'); $this->mdb2->query("SET SESSION query_cache_type = ON"); - // hint for default using '0000-00-00' datetime field in tasks table :o( - $this->mdb2->query("SET @old_sql_mode := @@sql_mode"); - $this->mdb2->query("SET @new_sql_mode := @old_sql_mode"); - $this->mdb2->query("SET @new_sql_mode := TRIM(BOTH ',' FROM REPLACE(CONCAT(',',@new_sql_mode,','),',NO_ZERO_DATE,' ,','))"); - $this->mdb2->query("SET @new_sql_mode := TRIM(BOTH ',' FROM REPLACE(CONCAT(',',@new_sql_mode,','),',NO_ZERO_IN_DATE,',','))"); - $this->mdb2->query("SET @@sql_mode := @new_sql_mode;"); - } // __construct() public function prepareAndExecute($sql,$args=null) { From 636a181544f9a47a1656d01897b63184c32739fe Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Tue, 2 Mar 2021 11:05:26 +0100 Subject: [PATCH 011/154] delete database/update load files for gwp database - no longer needed --- .../update/update_001_user_activities.sql | 10 --- .../update/update_002_report_perspective.sql | 62 -------------- database/update/update_003_images.sql | 13 --- database/update/update_004_relation_types.sql | 36 -------- database/update/update_005_events.sql | 83 ------------------- .../update/update_006_reports_annotations.sql | 17 ---- .../update/update_007_annotation_types.sql | 2 - database/update/update_008_tokens.sql | 19 ----- .../update/update_009_annotation_types.sql | 3 - .../update_010_corpus_perspective_roles.sql | 27 ------ .../update/update_011_report_perspectives.sql | 9 -- .../update/update_012_corpus_subcorpora.sql | 24 ------ database/update/update_013_flags.sql | 69 --------------- database/update/update_014_flags.sql | 1 - .../update/update_015_report_perspectives.sql | 8 -- database/update/update_016_tokens_tags.sql | 13 --- .../update/update_017_reports_annotations.sql | 7 -- database/update/update_018_relations.sql | 4 - .../update/update_019_relations_groups.sql | 13 --- database/update/update_020_tokens.sql | 1 - database/update/update_021_tokens_tags.sql | 2 - database/update/update_022_reports_diffs.sql | 1 - database/update/update_023_reports_groups.sql | 1 - database/update/update_024_flags_sort.sql | 2 - database/update/update_025_statuses.sql | 9 -- .../update_026_reports_tokenization.sql | 1 - database/update/update_027_common_types.sql | 29 ------- .../update/update_028_reports_ext_kpwr.sql | 9 -- database/update/update_029_reports_types.sql | 32 ------- database/update/update_030_1_bases.sql | 56 ------------- .../update_030_2_reports_annotations.sql | 26 ------ .../update_030_reports_annotation_lemma.sql | 40 --------- .../update_031_tokens_tags_ctags_pos.sql | 11 --- .../update/update_033_tokens_tags_reload.sql | 5 -- database/update/update_034_ctag_unique.sql | 1 - ...update_035_no_cascade_delete_for_types.sql | 20 ----- .../update/update_036_report_content_size.sql | 1 - .../update/update_037_shared_attributes.sql | 39 --------- .../update_038_shared_attributes_enum.sql | 48 ----------- ..._reports_annotations_shared_attributes.sql | 54 ------------ ...040_annotation_types_shared_attributes.sql | 49 ----------- database/update/update_041_agreement.sql | 3 - database/update/update_042_create_corpus.sql | 3 - database/update/update_043_email.sql | 1 - database/update/update_044_tasks.sql | 46 ---------- database/update/update_045_tasks_update.sql | 2 - database/update/update_046_wccl_rules.sql | 14 ---- .../update/update_047_user_login_max_size.sql | 1 - .../update_048_tasks_datetime_start.sql | 2 - .../update_048_wccl_match_annotations.sql | 1 - database/update/update_050_no_cascade.sql | 9 -- database/update/update_051_agreement.sql | 14 ---- .../update/update_052_flag_description.sql | 1 - .../update_053_role_delete_annotations.sql | 1 - database/update/update_054_exports.sql | 28 ------- database/update/update_055_checkboxes.sql | 36 -------- database/update/update_055_missing_field.sql | 1 - database/update/update_056_report_lang.sql | 2 - .../update_057_report_user_selection.sql | 1 - .../update/update_058_annotation_types.sql | 12 --- .../update/update_059_annotation_access.sql | 2 - .../update/update_059_users_acitivities.sql | 33 -------- .../update/update_060_annotation_sets.sql | 11 --- database/update/update_061_relation_edit.sql | 1 - database/update/update_062_relation_sets.sql | 6 -- .../update_063_shared_annotation_sets.sql | 4 - .../update_064_private_relation_sets.sql | 2 - .../update_065_annotation_sets_corpora.sql | 7 -- database/update/update_066_morpho_disamb.sql | 53 ------------ database/update/update_066_relations.sql | 1 - .../update_067_federation_login_clarin.sql | 3 - .../update_068_morphodisamb_agreement.sql | 6 -- ..._adding_report_prespectives_for_morpho.sql | 5 -- .../update/update_070_relation_agreement.sql | 2 - .../update_071_annotation_agreement.sql | 1 - database/update/update_071_default_nulls.sql | 1 - .../update/update_072_tonekization_null.sql | 1 - database/update/update_073_reports_nulls.sql | 5 -- database/update/update_074_exports.sql | 19 ----- ...update_075_add_tagger_field_to_exports.sql | 1 - database/update/update_075_corpora_date.sql | 1 - database/update/update_075_upload.sql | 8 -- database/update/update_076_flags.sql | 59 ------------- database/update/update_076_roles.sql | 24 ------ database/update/update_077_tagsets.sql | 2 - ...update_078_annotation_types_attributes.sql | 32 ------- database/update/update_078_message_null.sql | 1 - .../update/update_079_import_annotations.sql | 1 - .../update/update_080_report_translations.sql | 4 - .../update/update_081_import_languages.sql | 21 ----- .../update_082_cascade_flag_history.sql | 4 - ...te_083_reports_uesrs_selection_indices.sql | 9 -- .../update_084_report_annotation_table.sql | 1 - database/update/update_085_tagsets.sql | 2 - database/update/update_086_orths.sql | 34 -------- .../update_087_attribute_value_length.sql | 5 -- ..._088_perspective_annotation_attributes.sql | 1 - .../update/update_089_fix_perspective_id.sql | 1 - database/update/update_091_corpus_css.sql | 1 - database/update/update_092_report_deleted.sql | 1 - 100 files changed, 1411 deletions(-) delete mode 100644 database/update/update_001_user_activities.sql delete mode 100644 database/update/update_002_report_perspective.sql delete mode 100644 database/update/update_003_images.sql delete mode 100644 database/update/update_004_relation_types.sql delete mode 100644 database/update/update_005_events.sql delete mode 100644 database/update/update_006_reports_annotations.sql delete mode 100644 database/update/update_007_annotation_types.sql delete mode 100644 database/update/update_008_tokens.sql delete mode 100644 database/update/update_009_annotation_types.sql delete mode 100644 database/update/update_010_corpus_perspective_roles.sql delete mode 100644 database/update/update_011_report_perspectives.sql delete mode 100644 database/update/update_012_corpus_subcorpora.sql delete mode 100644 database/update/update_013_flags.sql delete mode 100644 database/update/update_014_flags.sql delete mode 100644 database/update/update_015_report_perspectives.sql delete mode 100644 database/update/update_016_tokens_tags.sql delete mode 100644 database/update/update_017_reports_annotations.sql delete mode 100644 database/update/update_018_relations.sql delete mode 100644 database/update/update_019_relations_groups.sql delete mode 100644 database/update/update_020_tokens.sql delete mode 100644 database/update/update_021_tokens_tags.sql delete mode 100644 database/update/update_022_reports_diffs.sql delete mode 100644 database/update/update_023_reports_groups.sql delete mode 100644 database/update/update_024_flags_sort.sql delete mode 100644 database/update/update_025_statuses.sql delete mode 100644 database/update/update_026_reports_tokenization.sql delete mode 100644 database/update/update_027_common_types.sql delete mode 100644 database/update/update_028_reports_ext_kpwr.sql delete mode 100644 database/update/update_029_reports_types.sql delete mode 100644 database/update/update_030_1_bases.sql delete mode 100644 database/update/update_030_2_reports_annotations.sql delete mode 100644 database/update/update_030_reports_annotation_lemma.sql delete mode 100644 database/update/update_031_tokens_tags_ctags_pos.sql delete mode 100644 database/update/update_033_tokens_tags_reload.sql delete mode 100644 database/update/update_034_ctag_unique.sql delete mode 100644 database/update/update_035_no_cascade_delete_for_types.sql delete mode 100644 database/update/update_036_report_content_size.sql delete mode 100644 database/update/update_037_shared_attributes.sql delete mode 100644 database/update/update_038_shared_attributes_enum.sql delete mode 100644 database/update/update_039_reports_annotations_shared_attributes.sql delete mode 100644 database/update/update_040_annotation_types_shared_attributes.sql delete mode 100644 database/update/update_041_agreement.sql delete mode 100644 database/update/update_042_create_corpus.sql delete mode 100644 database/update/update_043_email.sql delete mode 100644 database/update/update_044_tasks.sql delete mode 100644 database/update/update_045_tasks_update.sql delete mode 100644 database/update/update_046_wccl_rules.sql delete mode 100644 database/update/update_047_user_login_max_size.sql delete mode 100644 database/update/update_048_tasks_datetime_start.sql delete mode 100644 database/update/update_048_wccl_match_annotations.sql delete mode 100644 database/update/update_050_no_cascade.sql delete mode 100644 database/update/update_051_agreement.sql delete mode 100644 database/update/update_052_flag_description.sql delete mode 100644 database/update/update_053_role_delete_annotations.sql delete mode 100644 database/update/update_054_exports.sql delete mode 100644 database/update/update_055_checkboxes.sql delete mode 100644 database/update/update_055_missing_field.sql delete mode 100644 database/update/update_056_report_lang.sql delete mode 100644 database/update/update_057_report_user_selection.sql delete mode 100644 database/update/update_058_annotation_types.sql delete mode 100644 database/update/update_059_annotation_access.sql delete mode 100644 database/update/update_059_users_acitivities.sql delete mode 100644 database/update/update_060_annotation_sets.sql delete mode 100644 database/update/update_061_relation_edit.sql delete mode 100644 database/update/update_062_relation_sets.sql delete mode 100644 database/update/update_063_shared_annotation_sets.sql delete mode 100644 database/update/update_064_private_relation_sets.sql delete mode 100644 database/update/update_065_annotation_sets_corpora.sql delete mode 100644 database/update/update_066_morpho_disamb.sql delete mode 100644 database/update/update_066_relations.sql delete mode 100644 database/update/update_067_federation_login_clarin.sql delete mode 100644 database/update/update_068_morphodisamb_agreement.sql delete mode 100644 database/update/update_069_adding_report_prespectives_for_morpho.sql delete mode 100644 database/update/update_070_relation_agreement.sql delete mode 100644 database/update/update_071_annotation_agreement.sql delete mode 100644 database/update/update_071_default_nulls.sql delete mode 100644 database/update/update_072_tonekization_null.sql delete mode 100644 database/update/update_073_reports_nulls.sql delete mode 100644 database/update/update_074_exports.sql delete mode 100644 database/update/update_075_add_tagger_field_to_exports.sql delete mode 100644 database/update/update_075_corpora_date.sql delete mode 100644 database/update/update_075_upload.sql delete mode 100644 database/update/update_076_flags.sql delete mode 100644 database/update/update_076_roles.sql delete mode 100644 database/update/update_077_tagsets.sql delete mode 100644 database/update/update_078_annotation_types_attributes.sql delete mode 100644 database/update/update_078_message_null.sql delete mode 100644 database/update/update_079_import_annotations.sql delete mode 100644 database/update/update_080_report_translations.sql delete mode 100644 database/update/update_081_import_languages.sql delete mode 100644 database/update/update_082_cascade_flag_history.sql delete mode 100644 database/update/update_083_reports_uesrs_selection_indices.sql delete mode 100644 database/update/update_084_report_annotation_table.sql delete mode 100644 database/update/update_085_tagsets.sql delete mode 100644 database/update/update_086_orths.sql delete mode 100644 database/update/update_087_attribute_value_length.sql delete mode 100644 database/update/update_088_perspective_annotation_attributes.sql delete mode 100644 database/update/update_089_fix_perspective_id.sql delete mode 100644 database/update/update_091_corpus_css.sql delete mode 100644 database/update/update_092_report_deleted.sql diff --git a/database/update/update_001_user_activities.sql b/database/update/update_001_user_activities.sql deleted file mode 100644 index 7f18eec4..00000000 --- a/database/update/update_001_user_activities.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE TABLE `gpw`.`user_activities` ( -`user_id` INT NOT NULL , -`started` DATETIME NOT NULL , -`ended` DATETIME NOT NULL , -`counter` INT NOT NULL , -INDEX ( `user_id` , `ended` ) -) ENGINE = MYISAM ; - -ALTER TABLE `user_activities` ADD `login` BOOLEAN NOT NULL ; -ALTER TABLE `user_activities` ADD `id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST ; diff --git a/database/update/update_002_report_perspective.sql b/database/update/update_002_report_perspective.sql deleted file mode 100644 index 0efd08b9..00000000 --- a/database/update/update_002_report_perspective.sql +++ /dev/null @@ -1,62 +0,0 @@ --- --- Struktura tabeli dla `corpus_and_report_perspectives` --- - -CREATE TABLE IF NOT EXISTS `corpus_and_report_perspectives` ( - `perspective_id` varchar(32) NOT NULL, - `corpus_id` int(11) NOT NULL, - `access` enum('public','loggedin','role') NOT NULL, - PRIMARY KEY (`perspective_id`,`corpus_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Zrzut danych tabeli `corpus_and_report_perspectives` --- - -INSERT INTO `corpus_and_report_perspectives` (`perspective_id`, `corpus_id`, `access`) VALUES -('transcription', 3, 'public'), -('preview', 1, 'public'), -('html', 1, 'public'), -('report', 1, 'public'), -('takipi', 1, 'public'), -('edit', 1, 'loggedin'), -('edit_raw', 1, 'loggedin'), -('annotator', 1, 'loggedin'), -('tei', 1, 'public'), -('preview', 5, 'public'), -('html', 5, 'public'), -('report', 5, 'public'), -('takipi', 5, 'public'), -('edit', 5, 'loggedin'), -('edit_raw', 5, 'loggedin'), -('annotator', 5, 'loggedin'), -('tei', 5, 'public'); - --- -------------------------------------------------------- - --- --- Struktura tabeli dla `report_perspectives` --- - -CREATE TABLE IF NOT EXISTS `report_perspectives` ( - `id` varchar(32) NOT NULL, - `title` varchar(255) NOT NULL, - `order` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Zrzut danych tabeli `report_perspectives` --- - -INSERT INTO `report_perspectives` (`id`, `title`, `order`) VALUES -('transcription', 'Transcription', 10), -('preview', 'Text', 20), -('html', 'HTML', 30), -('raw', 'Źródłowy dokument', 40), -('takipi', 'TaKIPI', 50), -('edit', 'Edycja', 60), -('edit_raw', 'Edycja / źródło', 70), -('annotator', 'Anotacja', 80), -('tei', 'TEI', 90); - diff --git a/database/update/update_003_images.sql b/database/update/update_003_images.sql deleted file mode 100644 index c9c4ea3f..00000000 --- a/database/update/update_003_images.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE `images` ( - `id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY , - `corpus_id` INT NOT NULL, - `original_name` VARCHAR(64) NOT NULL , - `hash_name` VARCHAR(32) NOT NULL -) ; - -CREATE TABLE `reports_and_images` ( - `report_id` INT NOT NULL , - `images_id` INT NOT NULL , - `position` INT NOT NULL , - PRIMARY KEY ( `report_id` , `images_id` ) -) ; \ No newline at end of file diff --git a/database/update/update_004_relation_types.sql b/database/update/update_004_relation_types.sql deleted file mode 100644 index 1ab22b11..00000000 --- a/database/update/update_004_relation_types.sql +++ /dev/null @@ -1,36 +0,0 @@ -/* -Tabela typów relacji powinna zawierać: - - * identyfikator relacji (może być liczba, auto increment), - * nazwa relacji, do 64 znaków, - * opis relacji, text, - * identyfikator kategorii (z tabeli annotation_sets) --- informaja, między jakimi typami jednostek będzie można tworzyć relacje. -*/ -CREATE TABLE `relation_types` ( - `id` INT NOT NULL AUTO_INCREMENT, - `name` VARCHAR(64) NOT NULL, - `description` TEXT NOT NULL, - `annotation_set_id` INT NOT NULL, - PRIMARY KEY (`id`) -); - - -/* -Tabela instancji relacji powinna zawierać: - - * identyfikator instancji (liczba, auto increment), - * identyfikator typu relacji (z powyższej tabeli), - * jednostka źródłowa (identyfikator jednostki, z tabeli report_annotations), - * jednostka docelowa (j/w), - * data dodania, - * identyfikator użytkownika, który dodał relację. -*/ -CREATE TABLE `relations` ( - `id` BIGINT(20) NOT NULL AUTO_INCREMENT, - `relation_type_id` INT NOT NULL, - `source_id` BIGINT(20) NOT NULL, - `target_id` BIGINT(20) NOT NULL, - `date` DATE NOT NULL, - `user_id` INT NOT NULL, - PRIMARY KEY (`id`) -); \ No newline at end of file diff --git a/database/update/update_005_events.sql b/database/update/update_005_events.sql deleted file mode 100644 index 4bc9634d..00000000 --- a/database/update/update_005_events.sql +++ /dev/null @@ -1,83 +0,0 @@ -/*Grupy zdarzeń -event_groups -* event_group_id INT KEY AUTO_INREMENT -* name VARCHAR(64) -* description TEXT -*/ -CREATE TABLE `event_groups` ( - `event_group_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , - `name` VARCHAR( 64 ) NOT NULL , - `description` TEXT NOT NULL -); - -/*Typy zdarzeń przypisane do grup: -event_types -* event_type_id INT KEY AUTO_INREMENT -* name VARCHAR(64) -* description TEXT -* event_group_id INT -*/ -CREATE TABLE `event_types` ( - `event_type_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , - `name` VARCHAR( 64 ) NOT NULL , - `description` TEXT NOT NULL , - `event_group_id` INT NOT NULL -); - -/*Typy slotów przypisane do typów zdarzeń: - -event_type_slots -* event_type_slot INT KEY AUTO_INCREMENT -* name VARCHAR(64) -* description TEXT -* event_type_id INT*/ -CREATE TABLE `event_type_slots` ( - `event_type_slot_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , - `name` VARCHAR( 64 ) NOT NULL , - `description` TEXT NOT NULL , - `event_type_id` INT NOT NULL -); - - - -/*Przypisanie grup zdarzeń do korpusów: -corpus_event_groups -* corpus_id INT -* event_group_id INT*/ -CREATE TABLE `corpus_event_groups` ( - `corpus_id` INT NOT NULL, - `event_group_id` INT NOT NULL -); - -/*Instancje zdarzeń: - -reports_events -* report_event_id INT KEY AUTO_INCREMENT -* report_id INT -* event_type_id INT -* user_id INT -* creation_time DATETIME*/ -CREATE TABLE `reports_events` ( - `report_event_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , - `report_id` INT NOT NULL , - `event_type_id` INT NOT NULL , - `user_id` INT NOT NULL , - `creation_time` DATETIME NOT NULL -); - - -/*Sloty instancji zdarzenia: -reports_events_slots -* report_event_slot_id INT KEY AUTO_INCREMENT -* report_event_id INT -* report_annotation_id INT*/ -CREATE TABLE `reports_events_slots` ( - `report_event_slot_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , - `report_event_id` INT NOT NULL , - `report_annotation_id` INT NULL, - `event_type_slot_id` INT NOT NULL, - `user_id` INT NOT NULL, - `creation_time` DATETIME NOT NULL, - `user_update_id` INT NOT NULL, - `update_time` DATETIME NOT NULL -); diff --git a/database/update/update_006_reports_annotations.sql b/database/update/update_006_reports_annotations.sql deleted file mode 100644 index e3da3045..00000000 --- a/database/update/update_006_reports_annotations.sql +++ /dev/null @@ -1,17 +0,0 @@ -/* -Dodanie pola `user_id` dla `report_annotation_attribute` -Należy dodać pole `user_id` do tabeli `report_annotation_attribute` jako klucz obcy do tabeli `users`. Pole ustawiane jest TYLKO przy utworzeniu atrybutu i wartość pola równa jest identyfikatorowi użytkownika, który dodał pole. Edycja nie zmienia wartości tego pola. - -Klucz dla tej tabeli powinien być zmieniony z (annotation_id, annotation_attribute_id) na (annotation_id, annotation_attribute_id, user_id) -*/ -ALTER TABLE `reports_annotations_attributes` ADD `user_id` INT(11) NOT NULL ; -ALTER TABLE `reports_annotations_attributes` ADD CONSTRAINT `user_id` FOREIGN KEY ( `user_id` ) REFERENCES `users` ( `user_id` ) ; -ALTER TABLE `reports_annotations_attributes` DROP PRIMARY KEY; -ALTER TABLE `reports_annotations_attributes` ADD PRIMARY KEY ( `annotation_id` , `annotation_attribute_id` , `user_id` ); - -/* -Pole `stage` w tabeli `report_annotations` będzie polem wyliczeniowym przyjmującym jedną z wartości: candidate, user, final. -Domyślną wartością jest `user`. -*/ -ALTER TABLE `reports_annotations` ADD `stage` ENUM( 'candidate', 'user', 'final' ) NOT NULL DEFAULT 'user'; - diff --git a/database/update/update_007_annotation_types.sql b/database/update/update_007_annotation_types.sql deleted file mode 100644 index c0e61bbe..00000000 --- a/database/update/update_007_annotation_types.sql +++ /dev/null @@ -1,2 +0,0 @@ -/*Kolumna `short_description` typu VARCHAR będzie zawierała skrócony opis typu anotacji.*/ -ALTER TABLE `annotation_types` ADD `short_description` VARCHAR( 64 ) NULL DEFAULT NULL ; \ No newline at end of file diff --git a/database/update/update_008_tokens.sql b/database/update/update_008_tokens.sql deleted file mode 100644 index ff7fa1b9..00000000 --- a/database/update/update_008_tokens.sql +++ /dev/null @@ -1,19 +0,0 @@ -/*Tabela `tokens` definiuje segmentację tekstu na tokeny. Jeżeli dla danego dokumentu została zdefiniowana segmentacja, to anotacje muszą być spójne z określoną segmentacją. - -tokens -* token_id BIGINT -* report_id INT FOREIGN KEY na reports.id -* from INT -* to INT -*/ -CREATE TABLE `tokens` ( - `token_id` BIGINT (20) NOT NULL AUTO_INCREMENT, - `report_id` BIGINT(20) NOT NULL, - `from` INT NOT NULL, - `to` INT NOT NULL, - PRIMARY KEY (`token_id`), - CONSTRAINT `fk_report_id` FOREIGN KEY (`report_id`) - REFERENCES `reports` (`id`) - ON UPDATE CASCADE -) -ENGINE = InnoDB; diff --git a/database/update/update_009_annotation_types.sql b/database/update/update_009_annotation_types.sql deleted file mode 100644 index 0477675b..00000000 --- a/database/update/update_009_annotation_types.sql +++ /dev/null @@ -1,3 +0,0 @@ -/*Do tabeli anotacji należy dodać pole `css`, w którym będą przechowywany styl anotacji (tło, czcionka, ramka, etc.). -Może to być pole typu VARCHAR, w którym będzie przchowywany opis css.*/ -ALTER TABLE `annotation_types` ADD `css` VARCHAR( 255 ) NULL; \ No newline at end of file diff --git a/database/update/update_010_corpus_perspective_roles.sql b/database/update/update_010_corpus_perspective_roles.sql deleted file mode 100644 index 2c6bddff..00000000 --- a/database/update/update_010_corpus_perspective_roles.sql +++ /dev/null @@ -1,27 +0,0 @@ -/* -Jako trzeci typ dostępu do perspektywy będzie `role`. Oznacza to, że perspektywa będzie dostępna wybranym użytkownikom. Do przechowania informacji o dostępie do perspektywy w trybie `role` będzie trzeba utworzyć tablicę: -corpus_perspective_roles - - * user_id - * corpus_id - * report_perspective_id - -Wpis w tej tablicy będzie oznaczał, że użytkownik user_id ma dostęp do perspektywy report_perspective_id w korpusie corpus_id. - -Jeżeli użytkownik nie będzie miał dostępu do perspektywy, to nie powinna być ona widoczna w menu perspektyw. -*/ -CREATE TABLE `corpus_perspective_roles` ( - `user_id` INT NOT NULL, - `corpus_id` INT NOT NULL, - `report_perspective_id` VARCHAR(32) NOT NULL, - CONSTRAINT `fk_user_id` FOREIGN KEY (`user_id`) - REFERENCES `users` (`user_id`) - ON UPDATE CASCADE, - CONSTRAINT `fk_corpus_id` FOREIGN KEY (`corpus_id`) - REFERENCES `corpora` (`id`) - ON UPDATE CASCADE, - CONSTRAINT `fk_report_perspective_id` FOREIGN KEY (`report_perspective_id`) - REFERENCES `report_perspectives` (`id`) - ON UPDATE CASCADE -) -ENGINE = InnoDB; \ No newline at end of file diff --git a/database/update/update_011_report_perspectives.sql b/database/update/update_011_report_perspectives.sql deleted file mode 100644 index e75fd9ad..00000000 --- a/database/update/update_011_report_perspectives.sql +++ /dev/null @@ -1,9 +0,0 @@ -/*Dodać perspektywę dokumentu o nazwie Tokenization.*/ -INSERT INTO `report_perspectives` ( -`id` , -`title` , -`order` -) -VALUES ( -'tokenization', 'Tokenization', '100' -); \ No newline at end of file diff --git a/database/update/update_012_corpus_subcorpora.sql b/database/update/update_012_corpus_subcorpora.sql deleted file mode 100644 index fa4e54a7..00000000 --- a/database/update/update_012_corpus_subcorpora.sql +++ /dev/null @@ -1,24 +0,0 @@ -/*Dodać tabelę*/ - -CREATE TABLE `corpus_subcorpora` ( - `subcorpus_id` INT NULL AUTO_INCREMENT, - `corpus_id` INT NOT NULL, - `name` VARCHAR( 256 ) NOT NULL , - `description` TEXT NOT NULL , - PRIMARY KEY ( `subcorpus_id` ) -) ENGINE = InnoDB; - - -/*Rozszerzyć schemat tabeli `reports` o kolumnę `subcorpus_id`.*/ -ALTER TABLE `reports` ADD `subcorpus_id` INT NULL; - -/*tymczasowo nie ustawialem kluczy obcych!*/ - -ALTER TABLE `reports` ADD CONSTRAINT `fk_subcorpus_id` FOREIGN KEY (`subcorpus_id`) REFERENCES `corpus_subcorpora` (`subcorpus_id`) ON UPDATE CASCADE; - -ALTER TABLE `corpus_subcorpora` ADD INDEX ( `corpus_id` ) ; - -ALTER TABLE `corpus_subcorpora` ADD FOREIGN KEY ( `corpus_id` ) REFERENCES `gpw`.`corpora` ( -`id` -) ON DELETE CASCADE ON UPDATE CASCADE ; - diff --git a/database/update/update_013_flags.sql b/database/update/update_013_flags.sql deleted file mode 100644 index 6613af13..00000000 --- a/database/update/update_013_flags.sql +++ /dev/null @@ -1,69 +0,0 @@ -/*W bazie należy dodać tabelę, która będzie definicją możliwych statusów postępu prac. - -flags - flag_id INT AUTO_INCREMENT - name VARCHAR(64) - description TEXT - - CREATE TABLE `corpus_perspective_roles` ( - `user_id` INT NOT NULL, - `corpus_id` INT NOT NULL, - `report_perspective_id` VARCHAR(32) NOT NULL, - CONSTRAINT `fk_user_id` FOREIGN KEY (`user_id`) - REFERENCES `users` (`user_id`) - ON UPDATE CASCADE, - CONSTRAINT `fk_corpus_id` FOREIGN KEY (`corpus_id`) - REFERENCES `corpora` (`id`) - ON UPDATE CASCADE, - CONSTRAINT `fk_report_perspective_id` FOREIGN KEY (`report_perspective_id`) - REFERENCES `report_perspectives` (`id`) - ON UPDATE CASCADE -) - - - */ - -CREATE TABLE `flags` ( - `flag_id` INT NOT NULL AUTO_INCREMENT , - `name` VARCHAR( 64 ) NOT NULL , - `description` TEXT NOT NULL , - PRIMARY KEY ( `flag_id` ) -) ENGINE = InnoDB; - -CREATE TABLE `corpora_flags` ( - `corpora_flag_id` INT NOT NULL AUTO_INCREMENT , - `corpora_id` INT NOT NULL , - `name` VARCHAR( 128 ) NOT NULL , - PRIMARY KEY (`corpora_flag_id`) , - CONSTRAINT `fk_corpora_id` FOREIGN KEY (`corpora_id`) - REFERENCES `corpora` (`id`) -) ENGINE = InnoDB; - -CREATE TABLE `reports_flags` ( - `corpora_flag_id` INT NOT NULL, - `report_id` BIGINT(20) NOT NULL, - `flag_id` INT NOT NULL, - CONSTRAINT `fk_corpora_flag_id` FOREIGN KEY (`corpora_flag_id`) - REFERENCES `corpora_flags` (`corpora_flag_id`), - CONSTRAINT `fk1_report_id` FOREIGN KEY (`report_id`) - REFERENCES `reports` (`id`), - CONSTRAINT `fk_flag_id` FOREIGN KEY (`flag_id`) - REFERENCES `flags` (`flag_id`) -) ENGINE = InnoDB; - -INSERT INTO `gpw`.`flags` ( -`flag_id` , -`name` , -`description` -) -VALUES ( -1 , 'nowy', 'dokument nie został jeszcze sprawdzony' -), ( -2 , 'w opracowaniu', 'dokument jest w trakcie opracowania' -), ( -3 , 'gotowy', 'praca nad dokumentem została zakończone i wymaga sprawdzenia' -), ( -4 , 'sprawdzony', 'dokument został pomyślnie sprawdzony' -), ( -5 , 'do poprawy', 'dokument wymaga poprawy' -); diff --git a/database/update/update_014_flags.sql b/database/update/update_014_flags.sql deleted file mode 100644 index a8b4f2e6..00000000 --- a/database/update/update_014_flags.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `reports_flags` ADD UNIQUE `corpora_flag_id_unique` ( `corpora_flag_id` , `report_id` ) \ No newline at end of file diff --git a/database/update/update_015_report_perspectives.sql b/database/update/update_015_report_perspectives.sql deleted file mode 100644 index 41eb45e8..00000000 --- a/database/update/update_015_report_perspectives.sql +++ /dev/null @@ -1,8 +0,0 @@ -INSERT INTO `report_perspectives` ( -`id` , -`title` , -`order` -) -VALUES ( -'autoextension', 'Automatic Extension', '110' -); \ No newline at end of file diff --git a/database/update/update_016_tokens_tags.sql b/database/update/update_016_tokens_tags.sql deleted file mode 100644 index 1d28e9a6..00000000 --- a/database/update/update_016_tokens_tags.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE `tokens_tags` ( - `token_tag_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , - `token_id` BIGINT( 20 ) NOT NULL , - `base` VARCHAR( 32 ) NOT NULL , - `ctag` VARCHAR( 32 ) NOT NULL , - `disamb` BOOLEAN NOT NULL , - PRIMARY KEY ( `token_tag_id` ) , - CONSTRAINT `fk_token_id` FOREIGN KEY (`token_id`) - REFERENCES `tokens` (`token_id`) - ON UPDATE CASCADE - ON DELETE CASCADE -) ENGINE = InnoDB; - diff --git a/database/update/update_017_reports_annotations.sql b/database/update/update_017_reports_annotations.sql deleted file mode 100644 index 22fe9747..00000000 --- a/database/update/update_017_reports_annotations.sql +++ /dev/null @@ -1,7 +0,0 @@ -ALTER TABLE `reports_annotations` ADD `source` ENUM( 'user', 'bootstrapping' ) NOT NULL DEFAULT 'user'; -UPDATE `reports_annotations` SET `source` = "user" WHERE `stage` = "user"; -UPDATE `reports_annotations` SET `source` = "bootstrapping" WHERE `stage` = "candidate"; -ALTER TABLE `reports_annotations` CHANGE `stage` `stage` ENUM( 'new', 'final', 'discarded' ) NOT NULL DEFAULT 'final'; -UPDATE `reports_annotations` SET `stage` = "final" WHERE `source` = "user"; -UPDATE `reports_annotations` SET `stage` = "new" WHERE `source` = "bootstrapping"; -UPDATE `report_perspectives` SET `title` = 'Annotation Bootstrapping' WHERE `report_perspectives`.`id` = 'autoextension'; \ No newline at end of file diff --git a/database/update/update_018_relations.sql b/database/update/update_018_relations.sql deleted file mode 100644 index 1fb52994..00000000 --- a/database/update/update_018_relations.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE `relations` DROP FOREIGN KEY `relations_ibfk_2`; -ALTER TABLE `relations` ADD CONSTRAINT `relations_ibfk_2` FOREIGN KEY (`source_id`) REFERENCES `reports_annotations` (`id`) ON DELETE CASCADE; -ALTER TABLE `relations` DROP FOREIGN KEY `relations_ibfk_3`; -ALTER TABLE `relations` ADD CONSTRAINT `relations_ibfk_3` FOREIGN KEY (`target_id`) REFERENCES `reports_annotations` (`id`) ON DELETE CASCADE; \ No newline at end of file diff --git a/database/update/update_019_relations_groups.sql b/database/update/update_019_relations_groups.sql deleted file mode 100644 index f1cdbcf4..00000000 --- a/database/update/update_019_relations_groups.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE `relations_groups` ( - `relation_type_id` int(11) NOT NULL, - `part` enum('source','target') NOT NULL, - `annotation_set_id` int(11) DEFAULT NULL, - `annotation_subset_id` int(11) DEFAULT NULL, - KEY `relation_type_id` (`relation_type_id`), - KEY `annotation_set_id` (`annotation_set_id`), - KEY `annotation_subset_id` (`annotation_subset_id`) -) ENGINE=InnoDB; - -ALTER TABLE `relations_groups` ADD FOREIGN KEY ( `relation_type_id` ) REFERENCES `relation_types` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ; -ALTER TABLE `relations_groups` ADD FOREIGN KEY ( `annotation_set_id` ) REFERENCES `annotation_sets` (`annotation_set_id`) ON DELETE CASCADE ON UPDATE CASCADE ; -ALTER TABLE `relations_groups` ADD FOREIGN KEY ( `annotation_subset_id` ) REFERENCES `annotation_subsets` (`annotation_subset_id`) ON DELETE CASCADE ON UPDATE CASCADE ; \ No newline at end of file diff --git a/database/update/update_020_tokens.sql b/database/update/update_020_tokens.sql deleted file mode 100644 index 2a7cdbc5..00000000 --- a/database/update/update_020_tokens.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `tokens` ADD `eos` BOOLEAN NOT NULL; \ No newline at end of file diff --git a/database/update/update_021_tokens_tags.sql b/database/update/update_021_tokens_tags.sql deleted file mode 100644 index 256cb443..00000000 --- a/database/update/update_021_tokens_tags.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `tokens_tags` CHANGE `base` `base` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; -ALTER TABLE `tokens_tags` CHANGE `ctag` `ctag` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; diff --git a/database/update/update_022_reports_diffs.sql b/database/update/update_022_reports_diffs.sql deleted file mode 100644 index 5ac3e10e..00000000 --- a/database/update/update_022_reports_diffs.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `reports_diffs` ADD `comment` TEXT NULL ; diff --git a/database/update/update_023_reports_groups.sql b/database/update/update_023_reports_groups.sql deleted file mode 100644 index bc9ee4e8..00000000 --- a/database/update/update_023_reports_groups.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO relations_groups (relation_type_id, part, annotation_set_id) SELECT "1" AS relation_type_id, "source" AS part, annotation_set_id FROM annotation_sets UNION SELECT "1" AS relation_type_id, "target" AS part, annotation_set_id FROM annotation_sets; diff --git a/database/update/update_024_flags_sort.sql b/database/update/update_024_flags_sort.sql deleted file mode 100644 index 3040d27c..00000000 --- a/database/update/update_024_flags_sort.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `corpora_flags` ADD `short` VARCHAR( 16 ) NOT NULL , -ADD `sort` INT NOT NULL diff --git a/database/update/update_025_statuses.sql b/database/update/update_025_statuses.sql deleted file mode 100644 index 11d862e5..00000000 --- a/database/update/update_025_statuses.sql +++ /dev/null @@ -1,9 +0,0 @@ -INSERT INTO `gpw`.`reports_statuses` ( -`id` , -`status` , -`description` , -`order` -) -VALUES ( -NULL , 'Do usunięcia', 'Dokument powinien zostać usunięty', '8' -); diff --git a/database/update/update_026_reports_tokenization.sql b/database/update/update_026_reports_tokenization.sql deleted file mode 100644 index 874faf0c..00000000 --- a/database/update/update_026_reports_tokenization.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `reports` ADD `tokenization` VARCHAR( 32 ) NOT NULL ; diff --git a/database/update/update_027_common_types.sql b/database/update/update_027_common_types.sql deleted file mode 100644 index 4cc71c0c..00000000 --- a/database/update/update_027_common_types.sql +++ /dev/null @@ -1,29 +0,0 @@ -CREATE TABLE IF NOT EXISTS `annotation_types_common` ( - `annotation_name` varchar(32) NOT NULL, - KEY `annotation_name` (`annotation_name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- --- Dumping data for table `annotation_types_common` --- - -INSERT INTO `annotation_types_common` (`annotation_name`) VALUES -('admin1_nam'), -('admin2_nam'), -('admin3_nam'), -('award_nam'), -('brand_nam'), -('city_nam'), -('country_nam'), -('event_nam'), -('facility_nam'), -('historical_region_nam'), -('institution_nam'), -('nation_nam'), -('organization_nam'), -('person_add_nam'), -('person_first_nam'), -('person_last_nam'), -('person_nam'), -('road_nam'), -('title_nam'); diff --git a/database/update/update_028_reports_ext_kpwr.sql b/database/update/update_028_reports_ext_kpwr.sql deleted file mode 100644 index 4fd7f21b..00000000 --- a/database/update/update_028_reports_ext_kpwr.sql +++ /dev/null @@ -1,9 +0,0 @@ -CREATE TABLE `gpw`.`reports_ext_kpwr` ( -`id` BIGINT NOT NULL , -`keywords` TEXT NOT NULL , -PRIMARY KEY ( `report_id` ) -) ENGINE = InnoDB; - -ALTER TABLE `reports_ext_kpwr` ADD FOREIGN KEY ( `id` ) REFERENCES `gpw`.`reports` ( -`id` -) ON DELETE CASCADE ON UPDATE CASCADE ; diff --git a/database/update/update_029_reports_types.sql b/database/update/update_029_reports_types.sql deleted file mode 100644 index 8b2e0c8a..00000000 --- a/database/update/update_029_reports_types.sql +++ /dev/null @@ -1,32 +0,0 @@ -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - -CREATE TABLE IF NOT EXISTS `reports_formats` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `format` varchar(32) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; - - -INSERT INTO `reports_formats` (`id`, `format`) VALUES -(1, 'xml'), -(2, 'plain'), -(3, 'premorph'); - - -ALTER TABLE `reports` ADD `format_id` INT NOT NULL DEFAULT '1'; -ALTER TABLE `reports` ADD INDEX ( `format_id` ) ; - -ALTER TABLE `reports` ADD FOREIGN KEY ( `format_id` ) REFERENCES `inforex`.`reports_formats` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT ; - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; - - diff --git a/database/update/update_030_1_bases.sql b/database/update/update_030_1_bases.sql deleted file mode 100644 index 507172ed..00000000 --- a/database/update/update_030_1_bases.sql +++ /dev/null @@ -1,56 +0,0 @@ -CREATE TABLE `bases` ( - `id` BIGINT(20) NOT NULL AUTO_INCREMENT, - `text` VARCHAR(255) NOT NULL COLLATE 'utf8_bin', - PRIMARY KEY (`id`), - UNIQUE INDEX `text` (`text`) -) -COLLATE='utf8_bin' -ENGINE=InnoDB; - -INSERT IGNORE INTO bases (text) -SELECT base FROM tokens_tags GROUP BY HEX(base); - -ALTER TABLE `tokens_tags` - ADD COLUMN `base_id` BIGINT(20) NOT NULL AFTER `token_id`; - -SET @count = 0; -UPDATE `bases` SET `bases`.`id` = @count:= @count + 1; -ALTER TABLE bases AUTO_INCREMENT = 1; -UPDATE tokens_tags SET base_id = (SELECT id FROM bases WHERE text=tokens_tags.base COLLATE utf8_bin) WHERE base_id = 0; - -RENAME TABLE `tokens_tags` TO `tokens_tags_optimized`; -ALTER TABLE `tokens_tags_optimized` - ADD CONSTRAINT `FK_tokens_tags_optimized_bases` FOREIGN KEY (`base_id`) REFERENCES `bases` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT; - -ALTER TABLE `tokens_tags_optimized` - DROP COLUMN `base`; - -CREATE ALGORITHM = UNDEFINED VIEW `tokens_tags` AS - SELECT token_tag_id,token_id,b.text as base,base_id,ctag,disamb - FROM tokens_tags_optimized AS tt - LEFT JOIN bases AS b ON b.id=tt.base_id; - -DELIMITER $$ -CREATE PROCEDURE `bases_delete_unused_bases`() - LANGUAGE SQL - NOT DETERMINISTIC - MODIFIES SQL DATA - SQL SECURITY INVOKER - COMMENT '' -BEGIN - DROP TABLE IF EXISTS bases_temp; - - CREATE TEMPORARY TABLE bases_temp ( `base_id` BIGINT NOT NULL, - PRIMARY KEY (`base_id`)) ENGINE=MEMORY; - - INSERT INTO bases_temp (base_id) - SELECT base_id - FROM tokens_tags_optimized - GROUP BY base_id; - - DELETE - FROM bases - WHERE id NOT IN (SELECT * FROM bases_temp); - DROP TABLE bases_temp; -END$$ -DELIMITER $$ diff --git a/database/update/update_030_2_reports_annotations.sql b/database/update/update_030_2_reports_annotations.sql deleted file mode 100644 index 0d65f561..00000000 --- a/database/update/update_030_2_reports_annotations.sql +++ /dev/null @@ -1,26 +0,0 @@ -ALTER TABLE `annotation_types` - ADD COLUMN `annotation_type_id` INT NOT NULL AUTO_INCREMENT FIRST, - ADD PRIMARY KEY (`annotation_type_id`); - -ALTER TABLE `reports_annotations` - ADD COLUMN `type_id` INT(11) NULL DEFAULT NULL AFTER `type`; - -ALTER TABLE `reports_annotations` - DROP FOREIGN KEY `reports_annotations_ibfk_1`; - -UPDATE reports_annotations -SET type_id = (SELECT annotation_type_id FROM annotation_types WHERE annotation_types.name=reports_annotations.type COLLATE utf8_bin); - -ALTER TABLE `reports_annotations` - DROP COLUMN `type`; - -ALTER TABLE `reports_annotations` - ADD CONSTRAINT `FK_annotations_types` FOREIGN KEY (`type_id`) REFERENCES `annotation_types` (`annotation_type_id`) ON UPDATE CASCADE ON DELETE CASCADE; - -RENAME TABLE `reports_annotations` TO `reports_annotations_optimized`; - -CREATE ALGORITHM = UNDEFINED VIEW `reports_annotations` AS - SELECT ra.id, report_id, type_id, at.name AS type, `from`, `to`, text, user_id, creation_time, stage, source - FROM reports_annotations_optimized AS ra - LEFT JOIN annotation_types AS at ON at.annotation_type_id=ra.type_id - \ No newline at end of file diff --git a/database/update/update_030_reports_annotation_lemma.sql b/database/update/update_030_reports_annotation_lemma.sql deleted file mode 100644 index 33fb52a6..00000000 --- a/database/update/update_030_reports_annotation_lemma.sql +++ /dev/null @@ -1,40 +0,0 @@ -INSERT INTO `report_perspectives` (`id`, `title`, `description`, `order`) VALUES ('annotation_lemma', 'Annotation Lemmas', '', '15'); - --- phpMyAdmin SQL Dump --- version 4.0.5deb1 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generation Time: Sep 06, 2013 at 02:36 PM --- Server version: 5.5.32-0ubuntu3 --- PHP Version: 5.5.3-1ubuntu1 - -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - --- --- Database: `inforex` --- - --- -------------------------------------------------------- - --- --- Table structure for table `reports_annotations_lemma` --- - -CREATE TABLE IF NOT EXISTS `reports_annotations_lemma` ( - `report_annotation_id` bigint(20) NOT NULL, - `lemma` mediumtext COLLATE utf8_polish_ci NOT NULL, - UNIQUE KEY `report_annotation_id` (`report_annotation_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci; - --- --- Constraints for dumped tables --- - --- --- Constraints for table `reports_annotations_lemma` --- -ALTER TABLE `reports_annotations_lemma` - ADD CONSTRAINT `reports_annotations_lemma_ibfk_1` FOREIGN KEY (`report_annotation_id`) REFERENCES `reports_annotations_optimized` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; - diff --git a/database/update/update_031_tokens_tags_ctags_pos.sql b/database/update/update_031_tokens_tags_ctags_pos.sql deleted file mode 100644 index ed9b66ae..00000000 --- a/database/update/update_031_tokens_tags_ctags_pos.sql +++ /dev/null @@ -1,11 +0,0 @@ -ALTER TABLE `tokens_tags_optimized` ADD FOREIGN KEY ( `ctag_id` ) REFERENCES `tokens_tags_ctags` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT; - -INSERT INTO `tokens_tags_ctags`(`ctag`) SELECT DISTINCT ctag FROM `tokens_tags_optimized`; -UPDATE `tokens_tags_optimized` tto JOIN `tokens_tags_ctags` ttc USING(ctag) SET tto.ctag_id = ttc.id; - -ALTER TABLE `tokens_tags_optimized` ADD `pos` VARCHAR( 20 ) NOT NULL ; - -UPDATE `tokens_tags_optimized` SET pos = SUBSTRING_INDEX( SUBSTRING_INDEX(ctag, ':', 1 ) , ':', -1 ); - -ALTER TABLE `tokens_tags_optimized` DROP `ctag`; -ALTER TABLE `tokens_tags_optimized` CHANGE `ctag_id` `ctag_id` INT( 11 ) NOT NULL ; diff --git a/database/update/update_033_tokens_tags_reload.sql b/database/update/update_033_tokens_tags_reload.sql deleted file mode 100644 index 58fa55e0..00000000 --- a/database/update/update_033_tokens_tags_reload.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE ALGORITHM = UNDEFINED VIEW `tokens_tags` AS -SELECT token_tag_id,token_id,b.text as base,base_id,ctag,disamb -FROM tokens_tags_optimized AS tt -LEFT JOIN bases AS b ON b.id=tt.base_id -LEFT JOIN tokens_tags_ctags ON(tt.ctag_id = tokens_tags_ctags.id); \ No newline at end of file diff --git a/database/update/update_034_ctag_unique.sql b/database/update/update_034_ctag_unique.sql deleted file mode 100644 index 9e65aa10..00000000 --- a/database/update/update_034_ctag_unique.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `tokens_tags_ctags` ADD UNIQUE INDEX `ctag_UNIQUE` (`ctag` ASC) ; \ No newline at end of file diff --git a/database/update/update_035_no_cascade_delete_for_types.sql b/database/update/update_035_no_cascade_delete_for_types.sql deleted file mode 100644 index 38f81d80..00000000 --- a/database/update/update_035_no_cascade_delete_for_types.sql +++ /dev/null @@ -1,20 +0,0 @@ -ALTER TABLE `reports_annotations_optimized` DROP FOREIGN KEY `FK_reports_annotations_annotation_types` , -ADD FOREIGN KEY ( `type_id` ) REFERENCES `gpw`.`annotation_types` ( -`annotation_type_id` -) ON DELETE RESTRICT ON UPDATE CASCADE ; - -ALTER TABLE `relations` DROP FOREIGN KEY `relations_ibfk_5` , -ADD FOREIGN KEY ( `relation_type_id` ) REFERENCES `gpw`.`relation_types` ( -`id` -) ON DELETE RESTRICT ON UPDATE CASCADE ; - -ALTER TABLE `relations` DROP FOREIGN KEY `relations_ibfk_7` , -ADD FOREIGN KEY ( `source_id` ) REFERENCES `gpw`.`reports_annotations_optimized` ( -`id` -) ON DELETE RESTRICT ON UPDATE CASCADE ; - -ALTER TABLE `relations` DROP FOREIGN KEY `relations_ibfk_8` , -ADD FOREIGN KEY ( `target_id` ) REFERENCES `gpw`.`reports_annotations_optimized` ( -`id` -) ON DELETE RESTRICT ON UPDATE CASCADE ; - diff --git a/database/update/update_036_report_content_size.sql b/database/update/update_036_report_content_size.sql deleted file mode 100644 index 462f2098..00000000 --- a/database/update/update_036_report_content_size.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `reports` CHANGE `content` `content` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; diff --git a/database/update/update_037_shared_attributes.sql b/database/update/update_037_shared_attributes.sql deleted file mode 100644 index e9090960..00000000 --- a/database/update/update_037_shared_attributes.sql +++ /dev/null @@ -1,39 +0,0 @@ --- phpMyAdmin SQL Dump --- version 4.0.10deb1 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generation Time: Feb 05, 2015 at 01:55 PM --- Server version: 5.5.41-0ubuntu0.14.04.1 --- PHP Version: 5.5.9-1ubuntu4.5 - -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - --- --- Database: `inforex` --- - --- -------------------------------------------------------- - --- --- Table structure for table `shared_attributes` --- - -CREATE TABLE IF NOT EXISTS `shared_attributes` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(45) CHARACTER SET utf8 DEFAULT NULL, - `type` enum('enum','string') CHARACTER SET utf8 DEFAULT NULL, - `description` varchar(45) CHARACTER SET utf8 DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/database/update/update_038_shared_attributes_enum.sql b/database/update/update_038_shared_attributes_enum.sql deleted file mode 100644 index 0d8f5ac7..00000000 --- a/database/update/update_038_shared_attributes_enum.sql +++ /dev/null @@ -1,48 +0,0 @@ --- phpMyAdmin SQL Dump --- version 4.0.10deb1 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generation Time: Feb 05, 2015 at 01:55 PM --- Server version: 5.5.41-0ubuntu0.14.04.1 --- PHP Version: 5.5.9-1ubuntu4.5 - -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - --- --- Database: `inforex` --- - --- -------------------------------------------------------- - --- --- Table structure for table `shared_attributes_enum` --- - -CREATE TABLE IF NOT EXISTS `shared_attributes_enum` ( - `shared_attribute_id` int(11) NOT NULL AUTO_INCREMENT, - `value` varchar(45) CHARACTER SET utf8 NOT NULL, - `description` varchar(45) CHARACTER SET utf8 NOT NULL, - KEY `shared_attribute_id` (`shared_attribute_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; - --- --- Constraints for dumped tables --- - --- --- Constraints for table `shared_attributes_enum` --- -ALTER TABLE `shared_attributes_enum` - ADD CONSTRAINT `shared_attributes_enum_ibfk_1` FOREIGN KEY (`shared_attribute_id`) REFERENCES `shared_attributes` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/database/update/update_039_reports_annotations_shared_attributes.sql b/database/update/update_039_reports_annotations_shared_attributes.sql deleted file mode 100644 index 335f765a..00000000 --- a/database/update/update_039_reports_annotations_shared_attributes.sql +++ /dev/null @@ -1,54 +0,0 @@ --- phpMyAdmin SQL Dump --- version 4.0.10deb1 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generation Time: Feb 05, 2015 at 12:56 PM --- Server version: 5.5.41-0ubuntu0.14.04.1 --- PHP Version: 5.5.9-1ubuntu4.5 - -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - --- --- Database: `inforex` --- - --- -------------------------------------------------------- - --- --- Table structure for table `reports_annotations_shared_attributes` --- - -CREATE TABLE IF NOT EXISTS `reports_annotations_shared_attributes` ( - `annotation_id` bigint(20) NOT NULL, - `shared_attribute_id` int(11) NOT NULL, - `value` varchar(45) CHARACTER SET utf8 NOT NULL, - `user_id` int(11) NOT NULL, - UNIQUE KEY `unique_annotations_shared_attributes_values` (`annotation_id`,`shared_attribute_id`), - KEY `annotation_id` (`annotation_id`), - KEY `shared_attribute_id` (`shared_attribute_id`), - KEY `user_id` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Constraints for dumped tables --- - --- --- Constraints for table `reports_annotations_shared_attributes` --- -ALTER TABLE `reports_annotations_shared_attributes` - ADD CONSTRAINT `reports_annotations_shared_attributes_ibfk_1` FOREIGN KEY (`annotation_id`) REFERENCES `reports_annotations_optimized` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, - ADD CONSTRAINT `reports_annotations_shared_attributes_ibfk_2` FOREIGN KEY (`shared_attribute_id`) REFERENCES `shared_attributes` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, - ADD CONSTRAINT `reports_annotations_shared_attributes_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE NO ACTION; - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/database/update/update_040_annotation_types_shared_attributes.sql b/database/update/update_040_annotation_types_shared_attributes.sql deleted file mode 100644 index a6dbbdaa..00000000 --- a/database/update/update_040_annotation_types_shared_attributes.sql +++ /dev/null @@ -1,49 +0,0 @@ --- phpMyAdmin SQL Dump --- version 4.0.10deb1 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generation Time: Feb 03, 2015 at 06:22 PM --- Server version: 5.5.41-0ubuntu0.14.04.1 --- PHP Version: 5.5.9-1ubuntu4.5 - -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - --- --- Database: `inforex` --- - --- -------------------------------------------------------- - --- --- Table structure for table `annotation_types_shared_attributes` --- - -CREATE TABLE IF NOT EXISTS `annotation_types_shared_attributes` ( - `annotation_type_id` int(11) NOT NULL, - `shared_attribute_id` int(11) NOT NULL, - KEY `annotation_type_id` (`annotation_type_id`), - KEY `shared_attribute_id` (`shared_attribute_id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - --- --- Constraints for dumped tables --- - --- --- Constraints for table `annotation_types_shared_attributes` --- -ALTER TABLE `annotation_types_shared_attributes` - ADD CONSTRAINT `annotation_types_shared_attributes_ibfk_2` FOREIGN KEY (`annotation_type_id`) REFERENCES `annotation_types` (`annotation_type_id`) ON DELETE CASCADE ON UPDATE NO ACTION, - ADD CONSTRAINT `annotation_types_shared_attributes_ibfk_1` FOREIGN KEY (`shared_attribute_id`) REFERENCES `shared_attributes` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION; - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/database/update/update_041_agreement.sql b/database/update/update_041_agreement.sql deleted file mode 100644 index 354fe5e5..00000000 --- a/database/update/update_041_agreement.sql +++ /dev/null @@ -1,3 +0,0 @@ -UPDATE `corpus_roles` SET `description` = 'Edycja anotacji publicznych' WHERE `corpus_roles`.`role` = 'annotate'; - -INSERT INTO `corpus_roles` (`role`, `description`) VALUES ('', ''), ('annotate_agreement', 'Edycja anotacji prywatnych na potrzeby badania zgodności.'); diff --git a/database/update/update_042_create_corpus.sql b/database/update/update_042_create_corpus.sql deleted file mode 100644 index 3a01f034..00000000 --- a/database/update/update_042_create_corpus.sql +++ /dev/null @@ -1,3 +0,0 @@ -INSERT INTO `roles` (`role`, `description`) VALUES ('create_corpus', 'Prawo do tworzenia nowych korpusów.'); - -ALTER TABLE `corpora` CHANGE `ext` `ext` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_polish_ci NULL; diff --git a/database/update/update_043_email.sql b/database/update/update_043_email.sql deleted file mode 100644 index 7f44d9fd..00000000 --- a/database/update/update_043_email.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `users` CHANGE `email` `email` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_polish_ci NOT NULL DEFAULT 'unknown'; diff --git a/database/update/update_044_tasks.sql b/database/update/update_044_tasks.sql deleted file mode 100644 index eb3ebfc8..00000000 --- a/database/update/update_044_tasks.sql +++ /dev/null @@ -1,46 +0,0 @@ --- --- Struktura tabeli dla tabeli `tasks` --- - -CREATE TABLE IF NOT EXISTS `tasks` ( - `task_id` int(11) NOT NULL AUTO_INCREMENT, - `datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Data i czas utworzenia zadania.', - `type` varchar(32) COLLATE utf8_polish_ci NOT NULL COMMENT 'Identyfikator zadania.', - `parameters` text COLLATE utf8_polish_ci NOT NULL, - `corpus_id` int(11) NOT NULL, - `user_id` int(11) DEFAULT NULL, - `max_steps` int(11) NOT NULL, - `current_step` int(11) NOT NULL, - `status` enum('new','process','done','error') COLLATE utf8_polish_ci NOT NULL DEFAULT 'new', - PRIMARY KEY (`task_id`), - KEY `corpus_id` (`corpus_id`), - KEY `user_id` (`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci AUTO_INCREMENT=44 ; - --- --- Ograniczenia dla zrzutów tabel --- - --- --- Ograniczenia dla tabeli `tasks` --- -ALTER TABLE `tasks` - ADD CONSTRAINT `tasks_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE SET NULL ON UPDATE CASCADE, - ADD CONSTRAINT `tasks_ibfk_1` FOREIGN KEY (`corpus_id`) REFERENCES `corpora` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; - -CREATE TABLE IF NOT EXISTS `tasks_reports` ( - `task_id` int(11) NOT NULL, - `report_id` bigint(11) NOT NULL, - `status` enum('new','process','done','error') COLLATE utf8_polish_ci NOT NULL, - `message` TEXT, - KEY `document_id` (`report_id`), - KEY `task_id` (`task_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci; - - -ALTER TABLE `tasks_reports` - ADD CONSTRAINT `tasks_reports_ibfk_2` FOREIGN KEY (`report_id`) REFERENCES `reports` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `tasks_reports_ibfk_1` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`task_id`) ON DELETE CASCADE ON UPDATE CASCADE; - - -INSERT INTO `corpus_roles` (`role`, `description`) VALUES ('tasks', 'Wykonywanie masowych zadań na dokumentach'); diff --git a/database/update/update_045_tasks_update.sql b/database/update/update_045_tasks_update.sql deleted file mode 100644 index 383fa6a9..00000000 --- a/database/update/update_045_tasks_update.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `tasks` ADD `description` TEXT NULL AFTER `type`; -ALTER TABLE `tasks` ADD `message` TEXT NULL ; diff --git a/database/update/update_046_wccl_rules.sql b/database/update/update_046_wccl_rules.sql deleted file mode 100644 index 1d6dd216..00000000 --- a/database/update/update_046_wccl_rules.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE TABLE IF NOT EXISTS `wccl_rules` ( - `wccl_rule_id` int(11) NOT NULL AUTO_INCREMENT, - `user_id` int(11) NOT NULL, - `corpus_id` int(11) NOT NULL, - `rules` text COLLATE utf8_polish_ci, - PRIMARY KEY (`wccl_rule_id`), - UNIQUE KEY `user_id` (`user_id`,`corpus_id`), - KEY `user_id_2` (`user_id`), - KEY `corpus_id` (`corpus_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci AUTO_INCREMENT=1 ; - -ALTER TABLE `wccl_rules` - ADD CONSTRAINT `wccl_rules_ibfk_2` FOREIGN KEY (`corpus_id`) REFERENCES `corpora` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - ADD CONSTRAINT `wccl_rules_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/database/update/update_047_user_login_max_size.sql b/database/update/update_047_user_login_max_size.sql deleted file mode 100644 index 00706c2d..00000000 --- a/database/update/update_047_user_login_max_size.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `users` CHANGE `login` `login` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; \ No newline at end of file diff --git a/database/update/update_048_tasks_datetime_start.sql b/database/update/update_048_tasks_datetime_start.sql deleted file mode 100644 index 77a29972..00000000 --- a/database/update/update_048_tasks_datetime_start.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `tasks` -ADD COLUMN `datetime_start` TIMESTAMP NULL DEFAULT NULL AFTER `datetime`; diff --git a/database/update/update_048_wccl_match_annotations.sql b/database/update/update_048_wccl_match_annotations.sql deleted file mode 100644 index ec726933..00000000 --- a/database/update/update_048_wccl_match_annotations.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `wccl_rules` ADD `annotations` TEXT NULL ; \ No newline at end of file diff --git a/database/update/update_050_no_cascade.sql b/database/update/update_050_no_cascade.sql deleted file mode 100644 index 80c928eb..00000000 --- a/database/update/update_050_no_cascade.sql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE `reports` DROP FOREIGN KEY `reports_ibfk_7` , -ADD FOREIGN KEY ( `subcorpus_id` ) REFERENCES `inforex`.`corpus_subcorpora` ( -`subcorpus_id` -) ON DELETE SET NULL ON UPDATE CASCADE ; - -ALTER TABLE `reports` DROP FOREIGN KEY `reports_ibfk_8` , -ADD FOREIGN KEY ( `type` ) REFERENCES `inforex`.`reports_types` ( -`id` -) ON DELETE SET NULL ON UPDATE CASCADE ; diff --git a/database/update/update_051_agreement.sql b/database/update/update_051_agreement.sql deleted file mode 100644 index cb3c0b14..00000000 --- a/database/update/update_051_agreement.sql +++ /dev/null @@ -1,14 +0,0 @@ -UPDATE `corpus_roles` SET description='Edycja anotacji prywatnych' WHERE role='annotate_agreement'; - -ALTER TABLE `reports_annotations_optimized` CHANGE `stage` `stage` ENUM( 'new', 'final', 'discarded', 'agreement' ) CHARACTER SET utf8 COLLATE utf8_polish_ci NOT NULL DEFAULT 'final'; - -ALTER TABLE `corpus_roles` ADD `description_long` TEXT NOT NULL ; - -INSERT INTO `corpus_roles` ( -`role` , -`description` , -`description_long` -) -VALUES ( -'agreement_check', 'Sprawdzanie zgodności anotatorów', 'Dostęp do strony z wynikami zgodności anotatorów. ' -); diff --git a/database/update/update_052_flag_description.sql b/database/update/update_052_flag_description.sql deleted file mode 100644 index 70b3bb26..00000000 --- a/database/update/update_052_flag_description.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `corpora_flags` ADD `description` TEXT NOT NULL ; \ No newline at end of file diff --git a/database/update/update_053_role_delete_annotations.sql b/database/update/update_053_role_delete_annotations.sql deleted file mode 100644 index 6ecb3d9a..00000000 --- a/database/update/update_053_role_delete_annotations.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO `corpus_roles` (`role`, `description`, `description_long`) VALUES ('delete_annotations', 'Prawo do usuwania anotacji', 'Użytkownik może usuwać anotacje (dotyczy anotacji publicznych i prywatnych)'); \ No newline at end of file diff --git a/database/update/update_054_exports.sql b/database/update/update_054_exports.sql deleted file mode 100644 index 085563b8..00000000 --- a/database/update/update_054_exports.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE IF NOT EXISTS `exports` ( - `export_id` bigint(20) NOT NULL AUTO_INCREMENT, - `corpus_id` int(20) NOT NULL, - `datetime_submit` datetime NOT NULL, - `datetime_start` datetime DEFAULT NULL, - `datetime_finish` datetime DEFAULT NULL, - `status` enum('new','process','done','error') COLLATE utf8_polish_ci NOT NULL DEFAULT 'new', - `description` text COLLATE utf8_polish_ci NOT NULL, - `selectors` text COLLATE utf8_polish_ci NOT NULL, - `extractors` text COLLATE utf8_polish_ci NOT NULL, - `indices` text COLLATE utf8_polish_ci NOT NULL, - `message` text COLLATE utf8_polish_ci NOT NULL, - PRIMARY KEY (`export_id`), - KEY `corpus_id` (`corpus_id`), - KEY `status` (`status`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci COMMENT='Tabela z historią zadań eksportu korpusów' AUTO_INCREMENT=1 ; - -ALTER TABLE `exports` - ADD CONSTRAINT `exports_ibfk_1` FOREIGN KEY (`corpus_id`) REFERENCES `corpora` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; - -INSERT INTO `corpus_roles` ( -`role` , -`description` , -`description_long` -) -VALUES ( -'export', 'Eksport korpusu', 'Umożliwia wyeksportowanie określonych dokumentów i danych do postaci plików.' -); \ No newline at end of file diff --git a/database/update/update_055_checkboxes.sql b/database/update/update_055_checkboxes.sql deleted file mode 100644 index fd5b22f1..00000000 --- a/database/update/update_055_checkboxes.sql +++ /dev/null @@ -1,36 +0,0 @@ --- phpMyAdmin SQL Dump --- version 4.0.10deb1 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generation Time: Feb 28, 2017 at 10:15 AM --- Server version: 5.5.54-0ubuntu0.14.04.1 --- PHP Version: 5.5.9-1ubuntu4.21 - -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; - --- --- Database: `inforex` --- - --- -------------------------------------------------------- - --- --- Table structure for table `users_checkboxes` --- - -CREATE TABLE IF NOT EXISTS `users_checkboxes` ( - `user_id` int(11) NOT NULL, - `report_id` bigint(20) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; \ No newline at end of file diff --git a/database/update/update_055_missing_field.sql b/database/update/update_055_missing_field.sql deleted file mode 100644 index 18438967..00000000 --- a/database/update/update_055_missing_field.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `tasks` ADD `datetime_start` TIMESTAMP NOT NULL AFTER `datetime`; \ No newline at end of file diff --git a/database/update/update_056_report_lang.sql b/database/update/update_056_report_lang.sql deleted file mode 100644 index abf6971a..00000000 --- a/database/update/update_056_report_lang.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `reports` ADD `lang` VARCHAR( 3 ) NULL , -ADD INDEX ( `lang` ); \ No newline at end of file diff --git a/database/update/update_057_report_user_selection.sql b/database/update/update_057_report_user_selection.sql deleted file mode 100644 index 439288ef..00000000 --- a/database/update/update_057_report_user_selection.sql +++ /dev/null @@ -1 +0,0 @@ -RENAME TABLE `users_checkboxes` TO `reports_users_selection`; \ No newline at end of file diff --git a/database/update/update_058_annotation_types.sql b/database/update/update_058_annotation_types.sql deleted file mode 100644 index f06d2720..00000000 --- a/database/update/update_058_annotation_types.sql +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE IF NOT EXISTS `annotation_types_shortlist` ( - `annotation_type_id` int(11) NOT NULL, - `user_id` int(11) NOT NULL, - `shortlist` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -ALTER TABLE `annotation_types` -ADD `shortlist` int(11) DEFAULT 0; - -UPDATE `annotation_types` SET `shortlist`= 0 WHERE 1; - -DROP TABLE `annotation_types_common`; diff --git a/database/update/update_059_annotation_access.sql b/database/update/update_059_annotation_access.sql deleted file mode 100644 index 36ac316b..00000000 --- a/database/update/update_059_annotation_access.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `annotation_sets` ADD `public` INT NOT NULL DEFAULT '1'; -ALTER TABLE `annotation_sets` ADD `user_id` INT( 11 ) NOT NULL DEFAULT '1'; \ No newline at end of file diff --git a/database/update/update_059_users_acitivities.sql b/database/update/update_059_users_acitivities.sql deleted file mode 100644 index 1c81c062..00000000 --- a/database/update/update_059_users_acitivities.sql +++ /dev/null @@ -1,33 +0,0 @@ -CREATE TABLE IF NOT EXISTS `ips` ( - `ip_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `ip` char(39) COLLATE utf8_bin NOT NULL, - PRIMARY KEY (`ip_id`), - UNIQUE KEY `ip` (`ip`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin ; - -CREATE TABLE IF NOT EXISTS `activity_types` ( - `activity_type_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `category` varchar(16) COLLATE utf8_bin NOT NULL, - `name` varchar(32) COLLATE utf8_bin DEFAULT NULL, - KEY `activity_type_id` (`activity_type_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; - -CREATE TABLE IF NOT EXISTS `activities` ( - `activity_page_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `datetime` datetime NOT NULL, - `ip_id` int(10) unsigned NOT NULL, - `user_id` int(11) DEFAULT NULL, - `corpus_id` int(11) DEFAULT NULL, - `report_id` int(11) DEFAULT NULL, - `activity_type_id` int(11) NOT NULL, - `execution_time` smallint(5) unsigned DEFAULT NULL, - PRIMARY KEY (`activity_page_id`), - KEY `ip_id` (`ip_id`), - KEY `user_id` (`user_id`), - KEY `corpus_id` (`corpus_id`), - KEY `report_id` (`report_id`), - KEY `activity_type_id` (`activity_type_id`), - KEY `datetime` (`datetime`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; - -CREATE VIEW `activities_view_users` AS select `u`.`screename` AS `screename`,count(0) AS `COUNT(*)`,max(`a`.`datetime`) AS `last_datetime`,`a`.`activity_page_id` AS `activity_page_id`,`a`.`datetime` AS `datetime`,`a`.`ip_id` AS `ip_id`,`a`.`user_id` AS `user_id`,`a`.`corpus_id` AS `corpus_id`,`a`.`report_id` AS `report_id`,`a`.`activity_type_id` AS `activity_type_id`,`a`.`execution_time` AS `execution_time` from (`activities` `a` join `users` `u` on((`a`.`user_id` = `u`.`user_id`))) group by `a`.`user_id`; diff --git a/database/update/update_060_annotation_sets.sql b/database/update/update_060_annotation_sets.sql deleted file mode 100644 index 2ee62cb4..00000000 --- a/database/update/update_060_annotation_sets.sql +++ /dev/null @@ -1,11 +0,0 @@ -ALTER TABLE `annotation_sets` CHANGE `nested` `nested` TINYINT(1) NOT NULL DEFAULT '0'; -ALTER TABLE `annotation_types` CHANGE `cross_sentence` `cross_sentence` TINYINT(1) NOT NULL DEFAULT '0'; - -ALTER TABLE `annotation_sets` CHANGE `description` `name` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; -ALTER TABLE `annotation_sets` ADD `description` TEXT NOT NULL AFTER `name`; - -ALTER TABLE `annotation_subsets` CHANGE `description` `name` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; -ALTER TABLE `annotation_subsets` ADD `description` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `name`; - -ALTER TABLE `activity_types` CHANGE `name` `name` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL; -ALTER TABLE `annotation_types` CHANGE `level` `level` INT(11) NOT NULL DEFAULT '0'; \ No newline at end of file diff --git a/database/update/update_061_relation_edit.sql b/database/update/update_061_relation_edit.sql deleted file mode 100644 index 9b90c0bb..00000000 --- a/database/update/update_061_relation_edit.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `relations_groups` ADD `annotation_type_id` INT( 11 ) NULL DEFAULT NULL AFTER `annotation_subset_id` ; diff --git a/database/update/update_062_relation_sets.sql b/database/update/update_062_relation_sets.sql deleted file mode 100644 index daac1fc1..00000000 --- a/database/update/update_062_relation_sets.sql +++ /dev/null @@ -1,6 +0,0 @@ -ALTER TABLE `relation_sets` ADD `description` TEXT NOT NULL ; - -CREATE TABLE IF NOT EXISTS `corpora_relations` ( - `corpus_id` int(11) NOT NULL, - `relation_set_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1; \ No newline at end of file diff --git a/database/update/update_063_shared_annotation_sets.sql b/database/update/update_063_shared_annotation_sets.sql deleted file mode 100644 index cbddccad..00000000 --- a/database/update/update_063_shared_annotation_sets.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE IF NOT EXISTS `users_annotation_sets` ( - `user_id` int(11) NOT NULL, - `annotation_set_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1; \ No newline at end of file diff --git a/database/update/update_064_private_relation_sets.sql b/database/update/update_064_private_relation_sets.sql deleted file mode 100644 index 14bd4b05..00000000 --- a/database/update/update_064_private_relation_sets.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `relation_sets` ADD `public` INT( 1 ) NOT NULL DEFAULT '0', - ADD `user_id` INT( 11 ) NOT NULL DEFAULT '1'; \ No newline at end of file diff --git a/database/update/update_065_annotation_sets_corpora.sql b/database/update/update_065_annotation_sets_corpora.sql deleted file mode 100644 index b5115318..00000000 --- a/database/update/update_065_annotation_sets_corpora.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE TABLE IF NOT EXISTS `annotation_sets_corpora` ( - `annotation_set_id` int(11) NOT NULL, - `corpus_id` int(11) NOT NULL, - PRIMARY KEY (`annotation_set_id`,`corpus_id`), - KEY `annotation_set_id` (`annotation_set_id`), - KEY `corpus_id` (`corpus_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci; \ No newline at end of file diff --git a/database/update/update_066_morpho_disamb.sql b/database/update/update_066_morpho_disamb.sql deleted file mode 100644 index aceee914..00000000 --- a/database/update/update_066_morpho_disamb.sql +++ /dev/null @@ -1,53 +0,0 @@ --- create table tagsets - -CREATE TABLE IF NOT EXISTS `tagsets` ( - `tagset_id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(30) NOT NULL, - PRIMARY KEY (`tagset_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci; - - --- add fields to tokens_tags_optimized --- user default NULL - -ALTER TABLE `tokens_tags_optimized` ADD `user_id` INT NULL DEFAULT NULL; - --- adding foreign key constraints -ALTER TABLE `tokens_tags_optimized` -ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`user_id`); - --- adding tagset_id to tags -ALTER TABLE `tokens_tags_ctags` -ADD COLUMN tagset_id INT DEFAULT NULL , -ADD FOREIGN KEY `fk_tagset` ( tagset_id ) REFERENCES tagsets( tagset_id ) ; - --- delete unique on ctag -ALTER TABLE `tokens_tags_ctags` DROP INDEX `ctag_UNIQUE` ; - --- add uniqe on ctag and tagset -ALTER TABLE `tokens_tags_ctags` ADD CONSTRAINT `ctag_tagset_UNIQUE` UNIQUE ( -`ctag` , -`tagset_id` -); - --- adding new role into corpus_roles -INSERT INTO `corpus_roles` ( -`role` , -`description` , -`description_long` -) -VALUES ( -'agreement_morpho', 'Sprawdzanie zgodności dezambiguacji morfologicznych i wybór ostatecznej wersji.', 'Użytkownik widzi decyzje anotatorów i wybiera ostateczną wersję.' -); - --- inserting NKJP tagset into `tagsets` -INSERT INTO `tagsets` (`name`) VALUES ("nkjp"); - --- setting tagset_id of all tokens_tags_ctags to that of "nkjp" -UPDATE `tokens_tags_ctags` dest, -( -SELECT * -FROM `tagsets` -WHERE `name` LIKE "nkjp" -)src -SET dest.`tagset_id` = src.`tagset_id`; \ No newline at end of file diff --git a/database/update/update_066_relations.sql b/database/update/update_066_relations.sql deleted file mode 100644 index 611b41b3..00000000 --- a/database/update/update_066_relations.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `relations` ADD `stage` ENUM( 'final', 'discarded', 'agreement' ) NOT NULL DEFAULT 'final'; \ No newline at end of file diff --git a/database/update/update_067_federation_login_clarin.sql b/database/update/update_067_federation_login_clarin.sql deleted file mode 100644 index 3616fd50..00000000 --- a/database/update/update_067_federation_login_clarin.sql +++ /dev/null @@ -1,3 +0,0 @@ --- alter table - -ALTER TABLE `users` ADD `clarin_login` VARCHAR( 256 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ; diff --git a/database/update/update_068_morphodisamb_agreement.sql b/database/update/update_068_morphodisamb_agreement.sql deleted file mode 100644 index 2d3500c8..00000000 --- a/database/update/update_068_morphodisamb_agreement.sql +++ /dev/null @@ -1,6 +0,0 @@ --- add stage field to tokens_tags_optimized - -ALTER TABLE `tokens_tags_optimized` -ADD `stage` ENUM( 'tagger', 'agreement', 'final' ) -CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'tagger' -COMMENT 'Describes stage of chosen tag, tagger- generated by tagger, agreement- set by user, final- set by final user with agreement check'; \ No newline at end of file diff --git a/database/update/update_069_adding_report_prespectives_for_morpho.sql b/database/update/update_069_adding_report_prespectives_for_morpho.sql deleted file mode 100644 index d431a3a3..00000000 --- a/database/update/update_069_adding_report_prespectives_for_morpho.sql +++ /dev/null @@ -1,5 +0,0 @@ --- inserting pages morphodisamb and morphodisambagreement - -INSERT INTO `report_perspectives` (`id`, `title`, `description`, `order`) VALUES -("morphodisamb","Morphological Disambiguation","Show and edit user morphological disamgibuations",300), -("morphodisambagreement","Morphological Disambiguation Agreement","Show and edit final morphological disambiguations",310); \ No newline at end of file diff --git a/database/update/update_070_relation_agreement.sql b/database/update/update_070_relation_agreement.sql deleted file mode 100644 index e36ed911..00000000 --- a/database/update/update_070_relation_agreement.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `relations` ADD INDEX ( `stage` ) ; -INSERT INTO `report_perspectives` (`id`, `title`, `description`, `order`) VALUES ('relation_agreement', 'Relation agreement', '', '11'); \ No newline at end of file diff --git a/database/update/update_071_annotation_agreement.sql b/database/update/update_071_annotation_agreement.sql deleted file mode 100644 index 3985adb6..00000000 --- a/database/update/update_071_annotation_agreement.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE `report_perspectives` SET `title` = 'Annotation agreement' WHERE `report_perspectives`.`id` = 'agreement'; \ No newline at end of file diff --git a/database/update/update_071_default_nulls.sql b/database/update/update_071_default_nulls.sql deleted file mode 100644 index 436ab4c5..00000000 --- a/database/update/update_071_default_nulls.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `exports` CHANGE `description` `description` TEXT CHARACTER SET utf8 COLLATE utf8_polish_ci NULL, CHANGE `selectors` `selectors` TEXT CHARACTER SET utf8 COLLATE utf8_polish_ci NULL, CHANGE `extractors` `extractors` TEXT CHARACTER SET utf8 COLLATE utf8_polish_ci NULL, CHANGE `indices` `indices` TEXT CHARACTER SET utf8 COLLATE utf8_polish_ci NULL, CHANGE `message` `message` TEXT CHARACTER SET utf8 COLLATE utf8_polish_ci NULL; \ No newline at end of file diff --git a/database/update/update_072_tonekization_null.sql b/database/update/update_072_tonekization_null.sql deleted file mode 100644 index ca687160..00000000 --- a/database/update/update_072_tonekization_null.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `reports` CHANGE `tokenization` `tokenization` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_polish_ci NULL DEFAULT NULL; \ No newline at end of file diff --git a/database/update/update_073_reports_nulls.sql b/database/update/update_073_reports_nulls.sql deleted file mode 100644 index 67cfb663..00000000 --- a/database/update/update_073_reports_nulls.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE `reports` CHANGE `date` `date` DATE NULL DEFAULT NULL , -CHANGE `title` `title` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL , -CHANGE `source` `source` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL , -CHANGE `author` `author` VARCHAR( 128 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL , -CHANGE `content` `content` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL \ No newline at end of file diff --git a/database/update/update_074_exports.sql b/database/update/update_074_exports.sql deleted file mode 100644 index d30cf5b0..00000000 --- a/database/update/update_074_exports.sql +++ /dev/null @@ -1,19 +0,0 @@ -ALTER TABLE `exports` ADD `progress` INT NOT NULL DEFAULT '0'; -ALTER TABLE `exports` ADD `statistics` TEXT NULL DEFAULT NULL AFTER `progress`; - -CREATE TABLE `export_errors` ( - `id` int(11) NOT NULL, - `export_id` int(11) NOT NULL, - `message` text NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -ALTER TABLE `export_errors` - ADD PRIMARY KEY (`id`); - -ALTER TABLE `export_errors` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `export_errors` ADD `error_details` TEXT NOT NULL AFTER `message`; -ALTER TABLE `export_errors` ADD `count` INT NOT NULL AFTER `error_details`; -ALTER TABLE `export_errors` CHANGE `message` `message` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; -ALTER TABLE `export_errors` CHANGE `error_details` `error_details` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; \ No newline at end of file diff --git a/database/update/update_075_add_tagger_field_to_exports.sql b/database/update/update_075_add_tagger_field_to_exports.sql deleted file mode 100644 index 9671a0ed..00000000 --- a/database/update/update_075_add_tagger_field_to_exports.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `exports` ADD `tagging` VARCHAR( 16 ) DEFAULT "tagger" NOT NULL AFTER `indices`; \ No newline at end of file diff --git a/database/update/update_075_corpora_date.sql b/database/update/update_075_corpora_date.sql deleted file mode 100644 index 2cc4305b..00000000 --- a/database/update/update_075_corpora_date.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `corpora` ADD `date_created` DATETIME NULL DEFAULT NULL AFTER `ext`; \ No newline at end of file diff --git a/database/update/update_075_upload.sql b/database/update/update_075_upload.sql deleted file mode 100644 index a03ecd8e..00000000 --- a/database/update/update_075_upload.sql +++ /dev/null @@ -1,8 +0,0 @@ -ALTER TABLE `reports` ADD `filename` TEXT NULL AFTER `lang`; -ALTER TABLE `reports` CHANGE `tokenization` `tokenization` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_polish_ci NULL; - -ALTER TABLE `reports` CHANGE `date` `date` DATE NULL, -CHANGE `title` `title` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL, -CHANGE `source` `source` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL, -CHANGE `author` `author` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NULL, -CHANGE `content` `content` MEDIUMTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL; \ No newline at end of file diff --git a/database/update/update_076_flags.sql b/database/update/update_076_flags.sql deleted file mode 100644 index 99617908..00000000 --- a/database/update/update_076_flags.sql +++ /dev/null @@ -1,59 +0,0 @@ --- Flag status history table. -CREATE TABLE `flag_status_history` ( - `report_id` bigint(20) NOT NULL, - `flag_id` int(11) NOT NULL, - `user_id` int(11) NOT NULL, - `new_status` int(11) NOT NULL, - `old_status` int(11) NOT NULL, - `date` DATETIME NOT NULL -) ENGINE=InnoDB; - -ALTER TABLE `flag_status_history` - ADD KEY `report_id` (`report_id`), - ADD KEY `flag_id` (`flag_id`), - ADD KEY `user_id` (`user_id`), - ADD KEY `new_status` (`new_status`), - ADD KEY `old_status` (`old_status`); - -ALTER TABLE `flag_status_history` - ADD CONSTRAINT `flag_status_history_ibfk_1` FOREIGN KEY (`report_id`) REFERENCES `reports` (`id`), - ADD CONSTRAINT `flag_status_history_ibfk_2` FOREIGN KEY (`flag_id`) REFERENCES `corpora_flags` (`corpora_flag_id`), - ADD CONSTRAINT `flag_status_history_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`), - ADD CONSTRAINT `flag_status_history_ibfk_4` FOREIGN KEY (`new_status`) REFERENCES `flags` (`flag_id`), - ADD CONSTRAINT `flag_status_history_ibfk_5` FOREIGN KEY (`old_status`) REFERENCES `flags` (`flag_id`); - -ALTER TABLE `flag_status_history` ADD `id` BIGINT(22) NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY (`id`); - --- Stored procedure -DROP procedure IF EXISTS `changeFlagStatus`; - -DELIMITER $$ -CREATE PROCEDURE `changeFlagStatus`( - IN flag_id INT(11), - IN flag_status INT(11), - IN report_id INT(11), - IN user_id INT(11)) - BEGIN - -- Previous flag status. - DECLARE old_status INT(11); - - -- Store the previous flag status into old_status variable. - SELECT rf.flag_id INTO old_status FROM reports_flags rf - WHERE (rf.report_id = report_id AND rf.corpora_flag_id = flag_id); - - -- Update the document's flag status. - REPLACE INTO reports_flags(corpora_flag_id, report_id, flag_id) - VALUES(flag_id, report_id, flag_status); - - -- Store the change in the flag status history table. - INSERT INTO flag_status_history (date, report_id, flag_id, user_id, new_status, old_status) - VALUES (CURRENT_TIMESTAMP, report_id, flag_id, user_id, flag_status, IFNULL(old_status,-1)); - END$$ - -DELIMITER ; - --- Adding perspective -INSERT INTO `report_perspectives` (`id`, `title`, `description`, `order`) VALUES ('flag_history', 'Flag history', 'Show the history of flag changes.', '320'); - --- Adding corpus role -INSERT INTO `corpus_roles` (`role`, `description`, `description_long`) VALUES ('flag_history', 'Sprawdzanie historii flag', ''); diff --git a/database/update/update_076_roles.sql b/database/update/update_076_roles.sql deleted file mode 100644 index 5178f202..00000000 --- a/database/update/update_076_roles.sql +++ /dev/null @@ -1,24 +0,0 @@ -/* -Changing the length of the role column in roles and users_roles tables. - */ -LOCK TABLES -roles WRITE, -users_roles WRITE; - -ALTER TABLE users_roles -DROP FOREIGN KEY users_roles_ibfk_2; - -ALTER TABLE users_roles MODIFY role varchar(32); - -ALTER TABLE roles MODIFY role varchar(32); -ALTER TABLE users_roles -ADD CONSTRAINT users_roles_ibfk_2 FOREIGN KEY (role) -REFERENCES roles (role); - -UNLOCK TABLES; - -/* -Adding new roles - */ -INSERT INTO `roles` (`role`, `description`) VALUES ('editor_schema_events', 'Edit schema events.'); -INSERT INTO `roles` (`role`, `description`) VALUES ('editor_schema_relations', 'Edit schema relations.'); \ No newline at end of file diff --git a/database/update/update_077_tagsets.sql b/database/update/update_077_tagsets.sql deleted file mode 100644 index 3696b7b1..00000000 --- a/database/update/update_077_tagsets.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO `tagsets` (`tagset_id`, `name`) VALUES ('2', 'English'), ('3', 'German'); -ALTER TABLE `reports` CHANGE `tokenization` `tokenization` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_polish_ci NULL DEFAULT NULL; \ No newline at end of file diff --git a/database/update/update_078_annotation_types_attributes.sql b/database/update/update_078_annotation_types_attributes.sql deleted file mode 100644 index e4c747c8..00000000 --- a/database/update/update_078_annotation_types_attributes.sql +++ /dev/null @@ -1,32 +0,0 @@ -START TRANSACTION; - -DROP TABLE IF EXISTS `annotation_types_attributes_temp`; - -CREATE TABLE `annotation_types_attributes_temp` ( `id` INT(11) NOT NULL , `annotation_type_id` INT(11) NOT NULL , `name` VARCHAR(32) NOT NULL , `type` ENUM('radio', 'string') NOT NULL ) ENGINE = InnoDB; - -INSERT INTO annotation_types_attributes_temp (id, annotation_type_id, name, type) - SELECT ata.id, at.annotation_type_id, ata.name, ata.type FROM `annotation_types_attributes` ata - JOIN annotation_types at ON at.name = ata.annotation_type; - -SET FOREIGN_KEY_CHECKS = 0; - -DROP TABLE IF EXISTS `annotation_types_attributes`; - -SET FOREIGN_KEY_CHECKS = 1; - -CREATE TABLE `annotation_types_attributes` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `annotation_type_id` INT(11) NOT NULL, - `name` varchar(32) CHARACTER SET utf8 NOT NULL, - `type` enum('radio','string') CHARACTER SET utf8 NOT NULL, - PRIMARY KEY (`id`), - KEY `annotation_type_id` (`annotation_type_id`), - CONSTRAINT `annotation_types_attributes_ibfk_1` FOREIGN KEY (`annotation_type_id`) REFERENCES `annotation_types` (`annotation_type_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=147 DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci; - -INSERT INTO annotation_types_attributes (id, annotation_type_id, name, type) - SELECT * FROM `annotation_types_attributes_temp`; - -DROP TABLE `annotation_types_attributes_temp`; - -COMMIT; \ No newline at end of file diff --git a/database/update/update_078_message_null.sql b/database/update/update_078_message_null.sql deleted file mode 100644 index 2632d78d..00000000 --- a/database/update/update_078_message_null.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `tasks_reports` CHANGE `message` `message` TEXT CHARACTER SET utf8 COLLATE utf8_polish_ci NULL; \ No newline at end of file diff --git a/database/update/update_079_import_annotations.sql b/database/update/update_079_import_annotations.sql deleted file mode 100644 index d1c67818..00000000 --- a/database/update/update_079_import_annotations.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO `report_perspectives` (`id`, `title`, `description`, `order`) VALUES ('importannotations', 'Import annotations', 'Import annotations from a .CCL file.', '150'); diff --git a/database/update/update_080_report_translations.sql b/database/update/update_080_report_translations.sql deleted file mode 100644 index 818ba2f9..00000000 --- a/database/update/update_080_report_translations.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE `reports` ADD `parent_report_id` BIGINT(20) NULL DEFAULT NULL AFTER `filename`; -ALTER TABLE reports ADD CONSTRAINT fk_parent_report_id FOREIGN KEY (parent_report_id) REFERENCES reports(id); -INSERT INTO `report_perspectives` (`id`, `title`, `description`, `order`) VALUES ('edittranslation', 'Edit translation', 'Edit document translation', '320'); -INSERT INTO `report_perspectives` (`id`, `title`, `description`, `order`) VALUES ('extendedmetadata', 'Extended metadata', 'Metadata including translations, images and document content.', '325'); \ No newline at end of file diff --git a/database/update/update_081_import_languages.sql b/database/update/update_081_import_languages.sql deleted file mode 100644 index f9727b96..00000000 --- a/database/update/update_081_import_languages.sql +++ /dev/null @@ -1,21 +0,0 @@ -CREATE TABLE `lang` ( - `code` varchar(3), - `language` varchar(255) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -ALTER TABLE `lang` ADD PRIMARY KEY(`code`); - -INSERT INTO lang (code, language) VALUES ("aar", "Afar"),("abk", "Abkhazian"),("ace", "Achinese"),("ach", "Acoli"),("ada", "Adangme"),("ady", "Adyghe; Adygei"),("afa", "Afro-Asiatic languages"),("afh", "Afrihili"),("afr", "Afrikaans"),("ain", "Ainu"),("aka", "Akan"),("akk", "Akkadian"),("alb", "Albanian"),("ale", "Aleut"),("alg", "Algonquian languages"),("alt", "Southern Altai"),("amh", "Amharic"),("ang", "English, Old (ca.450-1100)"),("anp", "Angika"),("apa", "Apache languages"),("ara", "Arabic"),("arc", "Official Aramaic (700-300 BCE); Imperial Aramaic (700-300 BCE)"),("arg", "Aragonese"),("arm", "Armenian"),("arn", "Mapudungun; Mapuche"),("arp", "Arapaho"),("art", "Artificial languages"),("arw", "Arawak"),("asm", "Assamese"),("ast", "Asturian; Bable; Leonese; Asturleonese"),("ath", "Athapascan languages"),("aus", "Australian languages"),("ava", "Avaric"),("ave", "Avestan"),("awa", "Awadhi"),("aym", "Aymara"),("aze", "Azerbaijani"),("bad", "Banda languages"),("bai", "Bamileke languages"),("bak", "Bashkir"),("bal", "Baluchi"),("bam", "Bambara"),("ban", "Balinese"),("baq", "Basque"),("bas", "Basa"),("bat", "Baltic languages"),("bej", "Beja; Bedawiyet"),("bel", "Belarusian"),("bem", "Bemba"),("ben", "Bengali"),("ber", "Berber languages"),("bho", "Bhojpuri"),("bih", "Bihari languages"),("bik", "Bikol"),("bin", "Bini; Edo"),("bis", "Bislama"),("bla", "Siksika"),("bnt", "Bantu (Other)"),("bos", "Bosnian"),("bra", "Braj"),("bre", "Breton"),("btk", "Batak languages"),("bua", "Buriat"),("bug", "Buginese"),("bul", "Bulgarian"),("bur", "Burmese"),("byn", "Blin; Bilin"),("cad", "Caddo"),("cai", "Central American Indian languages"),("car", "Galibi Carib"),("cat", "Catalan; Valencian"),("cau", "Caucasian languages"),("ceb", "Cebuano"),("cel", "Celtic languages"),("cha", "Chamorro"),("chb", "Chibcha"),("che", "Chechen"),("chg", "Chagatai"),("chi", "Chinese"),("chk", "Chuukese"),("chm", "Mari"),("chn", "Chinook jargon"),("cho", "Choctaw"),("chp", "Chipewyan; Dene Suline"),("chr", "Cherokee"),("chu", "Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic"),("chv", "Chuvash"),("chy", "Cheyenne"),("cmc", "Chamic languages"),("cop", "Coptic"),("cor", "Cornish"),("cos", "Corsican"),("cpe", "Creoles and pidgins, English based"),("cpf", "Creoles and pidgins, French-based "),("cpp", "Creoles and pidgins, Portuguese-based "),("cre", "Cree"),("crh", "Crimean Tatar; Crimean Turkish"),("crp", "Creoles and pidgins "),("csb", "Kashubian"),("cus", "Cushitic languages"),("cze", "Czech"),("dak", "Dakota"),("dan", "Danish"),("dar", "Dargwa"),("day", "Land Dayak languages"),("del", "Delaware"),("den", "Slave (Athapascan)"),("dgr", "Dogrib"),("din", "Dinka"),("div", "Divehi; Dhivehi; Maldivian"),("doi", "Dogri"),("dra", "Dravidian languages"),("dsb", "Lower Sorbian"),("dua", "Duala"),("dum", "Dutch, Middle (ca.1050-1350)"),("dut", "Dutch; Flemish"),("dyu", "Dyula"),("dzo", "Dzongkha"),("efi", "Efik"),("egy", "Egyptian (Ancient)"),("eka", "Ekajuk"),("elx", "Elamite"),("eng", "English"),("enm", "English, Middle (1100-1500)"),("epo", "Esperanto"),("est", "Estonian"),("ewe", "Ewe"),("ewo", "Ewondo"),("fan", "Fang"),("fao", "Faroese"),("fat", "Fanti"),("fij", "Fijian"),("fil", "Filipino; Pilipino"),("fin", "Finnish"),("fiu", "Finno-Ugrian languages"),("fon", "Fon"),("fre", "French"),("frm", "French, Middle (ca.1400-1600)"),("fro", "French, Old (842-ca.1400)"),("frr", "Northern Frisian"),("frs", "Eastern Frisian"),("fry", "Western Frisian"),("ful", "Fulah"),("fur", "Friulian"),("gaa", "Ga"),("gay", "Gayo"),("gba", "Gbaya"),("gem", "Germanic languages"),("geo", "Georgian"),("ger", "German"),("gez", "Geez"),("gil", "Gilbertese"),("gla", "Gaelic; Scottish Gaelic"),("gle", "Irish"),("glg", "Galician"),("glv", "Manx"),("gmh", "German, Middle High (ca.1050-1500)"),("goh", "German, Old High (ca.750-1050)"),("gon", "Gondi"),("gor", "Gorontalo"),("got", "Gothic"),("grb", "Grebo"),("grc", "Greek, Ancient (to 1453)"),("gre", "Greek, Modern (1453-)"),("grn", "Guarani"),("gsw", "Swiss German; Alemannic; Alsatian"),("guj", "Gujarati"),("gwi", "Gwich'in"),("hai", "Haida"),("hat", "Haitian; Haitian Creole"),("hau", "Hausa"),("haw", "Hawaiian"),("heb", "Hebrew"),("her", "Herero"),("hil", "Hiligaynon"),("him", "Himachali languages; Western Pahari languages"),("hin", "Hindi"),("hit", "Hittite"),("hmn", "Hmong; Mong"),("hmo", "Hiri Motu"),("hrv", "Croatian"),("hsb", "Upper Sorbian"),("hun", "Hungarian"),("hup", "Hupa"),("iba", "Iban"),("ibo", "Igbo"),("ice", "Icelandic"),("ido", "Ido"),("iii", "Sichuan Yi; Nuosu"),("ijo", "Ijo languages"),("iku", "Inuktitut"),("ile", "Interlingue; Occidental"),("ilo", "Iloko"),("ina", "Interlingua (International Auxiliary Language Association)"),("inc", "Indic languages"),("ind", "Indonesian"),("ine", "Indo-European languages"),("inh", "Ingush"),("ipk", "Inupiaq"),("ira", "Iranian languages"),("iro", "Iroquoian languages"),("ita", "Italian"),("jav", "Javanese"),("jbo", "Lojban"),("jpn", "Japanese"),("jpr", "Judeo-Persian"),("jrb", "Judeo-Arabic"),("kaa", "Kara-Kalpak"),("kab", "Kabyle"),("kac", "Kachin; Jingpho"),("kal", "Kalaallisut; Greenlandic"),("kam", "Kamba"),("kan", "Kannada"),("kar", "Karen languages"),("kas", "Kashmiri"),("kau", "Kanuri"),("kaw", "Kawi"),("kaz", "Kazakh"),("kbd", "Kabardian"),("kha", "Khasi"),("khi", "Khoisan languages"),("khm", "Central Khmer"),("kho", "Khotanese; Sakan"),("kik", "Kikuyu; Gikuyu"),("kin", "Kinyarwanda"),("kir", "Kirghiz; Kyrgyz"),("kmb", "Kimbundu"),("kok", "Konkani"),("kom", "Komi"),("kon", "Kongo"),("kor", "Korean"),("kos", "Kosraean"),("kpe", "Kpelle"),("krc", "Karachay-Balkar"),("krl", "Karelian"),("kro", "Kru languages"),("kru", "Kurukh"),("kua", "Kuanyama; Kwanyama"),("kum", "Kumyk"),("kur", "Kurdish"),("kut", "Kutenai"),("lad", "Ladino"),("lah", "Lahnda"),("lam", "Lamba"),("lao", "Lao"),("lat", "Latin"),("lav", "Latvian"),("lez", "Lezghian"),("lim", "Limburgan; Limburger; Limburgish"),("lin", "Lingala"),("lit", "Lithuanian"),("lol", "Mongo"),("loz", "Lozi"),("ltz", "Luxembourgish; Letzeburgesch"),("lua", "Luba-Lulua"),("lub", "Luba-Katanga"),("lug", "Ganda"),("lui", "Luiseno"),("lun", "Lunda"),("luo", "Luo (Kenya and Tanzania)"),("lus", "Lushai"),("mac", "Macedonian"),("mad", "Madurese"),("mag", "Magahi"),("mah", "Marshallese"),("mai", "Maithili"),("mak", "Makasar"),("mal", "Malayalam"),("man", "Mandingo"),("mao", "Maori"),("map", "Austronesian languages"),("mar", "Marathi"),("mas", "Masai"),("may", "Malay"),("mdf", "Moksha"),("mdr", "Mandar"),("men", "Mende"),("mga", "Irish, Middle (900-1200)"),("mic", "Mi'kmaq; Micmac"),("min", "Minangkabau"),("mis", "Uncoded languages"),("mkh", "Mon-Khmer languages"),("mlg", "Malagasy"),("mlt", "Maltese"),("mnc", "Manchu"),("mni", "Manipuri"),("mno", "Manobo languages"),("moh", "Mohawk"),("mon", "Mongolian"),("mos", "Mossi"),("mul", "Multiple languages"),("mun", "Munda languages"),("mus", "Creek"),("mwl", "Mirandese"),("mwr", "Marwari"),("myn", "Mayan languages"),("myv", "Erzya"),("nah", "Nahuatl languages"),("nai", "North American Indian languages"),("nap", "Neapolitan"),("nau", "Nauru"),("nav", "Navajo; Navaho"),("nbl", "Ndebele, South; South Ndebele"),("nde", "Ndebele, North; North Ndebele"),("ndo", "Ndonga"),("nds", "Low German; Low Saxon; German, Low; Saxon, Low"),("nep", "Nepali"),("new", "Nepal Bhasa; Newari"),("nia", "Nias"),("nic", "Niger-Kordofanian languages"),("niu", "Niuean"),("nno", "Norwegian Nynorsk; Nynorsk, Norwegian"),("nob", "Bokmål, Norwegian; Norwegian Bokmål"),("nog", "Nogai"),("non", "Norse, Old"),("nor", "Norwegian"),("nqo", "N'Ko"),("nso", "Pedi; Sepedi; Northern Sotho"),("nub", "Nubian languages"),("nwc", "Classical Newari; Old Newari; Classical Nepal Bhasa"),("nya", "Chichewa; Chewa; Nyanja"),("nym", "Nyamwezi"),("nyn", "Nyankole"),("nyo", "Nyoro"),("nzi", "Nzima"),("oci", "Occitan (post 1500); Provençal"),("oji", "Ojibwa"),("ori", "Oriya"),("orm", "Oromo"),("osa", "Osage"),("oss", "Ossetian; Ossetic"),("ota", "Turkish, Ottoman (1500-1928)"),("oto", "Otomian languages"),("paa", "Papuan languages"),("pag", "Pangasinan"),("pal", "Pahlavi"),("pam", "Pampanga; Kapampangan"),("pan", "Panjabi; Punjabi"),("pap", "Papiamento"),("pau", "Palauan"),("peo", "Persian, Old (ca.600-400 B.C.)"),("per", "Persian"),("phi", "Philippine languages"),("phn", "Phoenician"),("pli", "Pali"),("pol", "Polish"),("pon", "Pohnpeian"),("por", "Portuguese"),("pra", "Prakrit languages"),("pro", "Provençal, Old (to 1500)"),("pus", "Pushto; Pashto"),("que", "Quechua"),("raj", "Rajasthani"),("rap", "Rapanui"),("rar", "Rarotongan; Cook Islands Maori"),("roa", "Romance languages"),("roh", "Romansh"),("rom", "Romany"),("rum", "Romanian; Moldavian; Moldovan"),("run", "Rundi"),("rup", "Aromanian; Arumanian; Macedo-Romanian"),("rus", "Russian"),("sad", "Sandawe"),("sag", "Sango"),("sah", "Yakut"),("sai", "South American Indian (Other)"),("sal", "Salishan languages"),("sam", "Samaritan Aramaic"),("san", "Sanskrit"),("sas", "Sasak"),("sat", "Santali"),("scn", "Sicilian"),("sco", "Scots"),("sel", "Selkup"),("sem", "Semitic languages"),("sga", "Irish, Old (to 900)"),("sgn", "Sign Languages"),("shn", "Shan"),("sid", "Sidamo"),("sin", "Sinhala; Sinhalese"),("sio", "Siouan languages"),("sit", "Sino-Tibetan languages"),("sla", "Slavic languages"),("slo", "Slovak"),("slv", "Slovenian"),("sma", "Southern Sami"),("sme", "Northern Sami"),("smi", "Sami languages"),("smj", "Lule Sami"),("smn", "Inari Sami"),("smo", "Samoan"),("sms", "Skolt Sami"),("sna", "Shona"),("snd", "Sindhi"),("snk", "Soninke"),("sog", "Sogdian"),("som", "Somali"),("son", "Songhai languages"),("sot", "Sotho, Southern"),("spa", "Spanish; Castilian"),("srd", "Sardinian"),("srn", "Sranan Tongo"),("srp", "Serbian"),("srr", "Serer"),("ssa", "Nilo-Saharan languages"),("ssw", "Swati"),("suk", "Sukuma"),("sun", "Sundanese"),("sus", "Susu"),("sux", "Sumerian"),("swa", "Swahili"),("swe", "Swedish"),("syc", "Classical Syriac"),("syr", "Syriac"),("tah", "Tahitian"),("tai", "Tai languages"),("tam", "Tamil"),("tat", "Tatar"),("tel", "Telugu"),("tem", "Timne"),("ter", "Tereno"),("tet", "Tetum"),("tgk", "Tajik"),("tgl", "Tagalog"),("tha", "Thai"),("tib", "Tibetan"),("tig", "Tigre"),("tir", "Tigrinya"),("tiv", "Tiv"),("tkl", "Tokelau"),("tlh", "Klingon; tlhIngan-Hol"),("tli", "Tlingit"),("tmh", "Tamashek"),("tog", "Tonga (Nyasa)"),("ton", "Tonga (Tonga Islands)"),("tpi", "Tok Pisin"),("tsi", "Tsimshian"),("tsn", "Tswana"),("tso", "Tsonga"),("tuk", "Turkmen"),("tum", "Tumbuka"),("tup", "Tupi languages"),("tur", "Turkish"),("tut", "Altaic languages"),("tvl", "Tuvalu"),("twi", "Twi"),("tyv", "Tuvinian"),("udm", "Udmurt"),("uga", "Ugaritic"),("uig", "Uighur; Uyghur"),("ukr", "Ukrainian"),("umb", "Umbundu"),("und", "Undetermined"),("urd", "Urdu"),("uzb", "Uzbek"),("vai", "Vai"),("ven", "Venda"),("vie", "Vietnamese"),("vol", "Volapük"),("vot", "Votic"),("wak", "Wakashan languages"),("wal", "Walamo"),("war", "Waray"),("was", "Washo"),("wel", "Welsh"),("wen", "Sorbian languages"),("wln", "Walloon"),("wol", "Wolof"),("xal", "Kalmyk; Oirat"),("xho", "Xhosa"),("yao", "Yao"),("yap", "Yapese"),("yid", "Yiddish"),("yor", "Yoruba"),("ypk", "Yupik languages"),("zap", "Zapotec"),("zbl", "Blissymbols; Blissymbolics; Bliss"),("zen", "Zenaga"),("zha", "Zhuang; Chuang"),("znd", "Zande languages"),("zul", "Zulu"),("zun", "Zuni"),("zxx", "No linguistic content; Not applicable"),("zza", "Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki"); - -ALTER TABLE reports MODIFY lang VARCHAR(3); - -CREATE INDEX reports_lang_index ON reports (lang); - -UPDATE reports SET lang = CASE WHEN lang = 'cz' THEN 'cze' WHEN lang = 'hr' THEN 'hun' WHEN lang = 'pl' THEN 'pol' WHEN lang = 'ru' THEN 'rus' WHEN lang = 'sk' THEN 'slo' WHEN lang = 'sl' THEN 'slv' WHEN lang = 'uk' THEN 'ukr' ELSE NULL END; - -ALTER TABLE reports MODIFY lang CHAR(3); -ALTER TABLE `reports` CHANGE `lang` `lang` CHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; - -ALTER TABLE `lang` CHANGE `code` `code` CHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; - -ALTER TABLE reports ADD FOREIGN KEY (lang) REFERENCES lang(code); diff --git a/database/update/update_082_cascade_flag_history.sql b/database/update/update_082_cascade_flag_history.sql deleted file mode 100644 index 1989ad89..00000000 --- a/database/update/update_082_cascade_flag_history.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE `flag_status_history` DROP FOREIGN KEY `flag_status_history_ibfk_1` , -ADD FOREIGN KEY ( `report_id` ) REFERENCES `reports` ( -`id` -) ON DELETE CASCADE ON UPDATE RESTRICT ; \ No newline at end of file diff --git a/database/update/update_083_reports_uesrs_selection_indices.sql b/database/update/update_083_reports_uesrs_selection_indices.sql deleted file mode 100644 index 6005de4b..00000000 --- a/database/update/update_083_reports_uesrs_selection_indices.sql +++ /dev/null @@ -1,9 +0,0 @@ -ALTER TABLE `reports_users_selection` ADD INDEX(`user_id`); - -ALTER TABLE `reports_users_selection` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE; - -ALTER TABLE `reports_users_selection` ADD INDEX(`report_id`); - -ALTER TABLE `reports_users_selection` ADD FOREIGN KEY (`report_id`) REFERENCES `reports`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; - -ALTER TABLE `reports_users_selection` ADD UNIQUE( `user_id`, `report_id`); \ No newline at end of file diff --git a/database/update/update_084_report_annotation_table.sql b/database/update/update_084_report_annotation_table.sql deleted file mode 100644 index 2f5ba03d..00000000 --- a/database/update/update_084_report_annotation_table.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO `report_perspectives` (`id`, `title`, `description`, `order`) VALUES ('annotation_table', 'Annotation table', 'Display a summary of annotations', '100'); \ No newline at end of file diff --git a/database/update/update_085_tagsets.sql b/database/update/update_085_tagsets.sql deleted file mode 100644 index c5864c80..00000000 --- a/database/update/update_085_tagsets.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO `tagsets` (`tagset_id`, `name`) VALUES ('4', 'Hebrew UDPipe'), ('5', 'Russian UDPipe'); -INSERT INTO `tagsets` (`tagset_id`, `name`) VALUES ('6', 'Czech UDPipe'), ('7', 'Bulgarian UDPipe'); \ No newline at end of file diff --git a/database/update/update_086_orths.sql b/database/update/update_086_orths.sql deleted file mode 100644 index e102e8cc..00000000 --- a/database/update/update_086_orths.sql +++ /dev/null @@ -1,34 +0,0 @@ --- --- Struktura tabeli dla tabeli `orths` --- - -CREATE TABLE `orths` ( - `orth_id` bigint(20) NOT NULL, - `orth` varchar(190) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4_bin; - --- --- Indeksy dla zrzutów tabel --- - --- --- Indexes for table `orths` --- -ALTER TABLE `orths` - ADD PRIMARY KEY (`orth_id`), - ADD KEY `orth` (`orth`); - --- --- AUTO_INCREMENT for dumped tables --- - --- --- AUTO_INCREMENT dla tabeli `orths` --- -ALTER TABLE `orths` - MODIFY `orth_id` bigint(20) NOT NULL AUTO_INCREMENT; - -ALTER TABLE `orths` ADD UNIQUE(`orth`); - -ALTER TABLE `tokens` ADD `orth_id` BIGINT NULL AFTER `eos`; - diff --git a/database/update/update_087_attribute_value_length.sql b/database/update/update_087_attribute_value_length.sql deleted file mode 100644 index 50a4c880..00000000 --- a/database/update/update_087_attribute_value_length.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE `reports_annotations_shared_attributes` CHANGE `value` `value` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; - -ALTER TABLE `shared_attributes_enum` CHANGE `value` `value` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; - -ALTER TABLE `shared_attributes_enum` CHANGE `description` `description` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; \ No newline at end of file diff --git a/database/update/update_088_perspective_annotation_attributes.sql b/database/update/update_088_perspective_annotation_attributes.sql deleted file mode 100644 index 0e639a26..00000000 --- a/database/update/update_088_perspective_annotation_attributes.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO `report_perspectives` (`id`, `title`, `description`, `order`) VALUES ('annotation_attributes', 'Annotation attributes', 'Batch editor of annotation attributes', '110'); \ No newline at end of file diff --git a/database/update/update_089_fix_perspective_id.sql b/database/update/update_089_fix_perspective_id.sql deleted file mode 100644 index 3212fe70..00000000 --- a/database/update/update_089_fix_perspective_id.sql +++ /dev/null @@ -1 +0,0 @@ -UPDATE `report_perspectives` SET `id` = 'importAnnotations' WHERE `report_perspectives`.`id` = 'importannotations'; \ No newline at end of file diff --git a/database/update/update_091_corpus_css.sql b/database/update/update_091_corpus_css.sql deleted file mode 100644 index 0583aecd..00000000 --- a/database/update/update_091_corpus_css.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `corpora` ADD `css` TEXT NULL AFTER `date_created`; \ No newline at end of file diff --git a/database/update/update_092_report_deleted.sql b/database/update/update_092_report_deleted.sql deleted file mode 100644 index e07ef980..00000000 --- a/database/update/update_092_report_deleted.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE `reports` ADD `deleted` BOOLEAN NOT NULL DEFAULT FALSE AFTER `parent_report_id`, ADD INDEX `reports_deleted_idx` (`deleted`); \ No newline at end of file From e4f459eacdf4648abed9b6e544212bd5726f373d Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Tue, 2 Mar 2021 11:08:31 +0100 Subject: [PATCH 012/154] another unused query files removed and moved to documentations --- database/queries/annotations_delete_by_corpus_id_and_stage.sql | 3 --- .../direct.query.examples}/statistics_activity.sql | 0 2 files changed, 3 deletions(-) delete mode 100644 database/queries/annotations_delete_by_corpus_id_and_stage.sql rename {database/queries => documentations/direct.query.examples}/statistics_activity.sql (100%) diff --git a/database/queries/annotations_delete_by_corpus_id_and_stage.sql b/database/queries/annotations_delete_by_corpus_id_and_stage.sql deleted file mode 100644 index a005f269..00000000 --- a/database/queries/annotations_delete_by_corpus_id_and_stage.sql +++ /dev/null @@ -1,3 +0,0 @@ -SET @corpus_id=51; -SET @stage='new'; -DELETE an FROM `reports_annotations_optimized` an JOIN reports r ON (an.report_id=r.id) WHERE r.corpora=@corpus_id AND an.stage=@stage; \ No newline at end of file diff --git a/database/queries/statistics_activity.sql b/documentations/direct.query.examples/statistics_activity.sql similarity index 100% rename from database/queries/statistics_activity.sql rename to documentations/direct.query.examples/statistics_activity.sql From 7ce8c850abd2a18fce92b990482db42ff53dac09 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 6 Mar 2021 14:11:46 +0100 Subject: [PATCH 013/154] actualize files in TARITIFEXISTS --- packages/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/Makefile b/packages/Makefile index f1f55a88..5de35af8 100644 --- a/packages/Makefile +++ b/packages/Makefile @@ -14,7 +14,7 @@ RELEASE = $(shell if [ ! -z '$(GITHASH)' ]; then echo -n "$(RELNO)v.$(GITHASH)"; RELSPECTAG = RELEASE_TAG # glob cannot work here -TARITIFEXISTS = tests phpunit.xml data +TARITIFEXISTS = FILES2TAR = composer.json apps LICENCE.md local sonar-project.properties config/README.md documentations phpunit engine gfx public_html database INSTALL.md README.md $(foreach wrd,$(TARITIFEXISTS),$(wrd)) $(RPM_SOURCES_DIR)/$(PACKAGE).tgz: ../.git/index From 48b19763532c2fece23d6cae0eb22a994291ae44 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 6 Mar 2021 19:46:56 +0100 Subject: [PATCH 014/154] rw rights to templetes_c dir in rpm package --- packages/rpm/SPECS/inforex.spec | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/rpm/SPECS/inforex.spec b/packages/rpm/SPECS/inforex.spec index 5cf469a1..ded62c7a 100644 --- a/packages/rpm/SPECS/inforex.spec +++ b/packages/rpm/SPECS/inforex.spec @@ -42,6 +42,9 @@ to test all phases of building rpm process # remove several scripts not used in the package #rm -rf vendor/ezyang/htmlpurifier/maintenance/ +# remove precompiled templtates from devel dir +rm -rf engine/templates_c/* + %build %install @@ -84,6 +87,8 @@ if [ -x %{_sbindir}/semanage ] ; then fi %{_sbindir}/semanage fcontext -a -t httpd_var_lib_t %{_localstatedir}/lib/%{name} %{_sbindir}/restorecon %{_localstatedir}/lib/%{name} + %{_sbindir}/semanage fcontext -a -t httpd_sys_rw_content_t %{inforexdir}/engine/templates_c + %{_sbindir}/restorecon %{inforexdir}/engine/templates_c fi %files @@ -92,6 +97,8 @@ fi %dir %{inforexdir} %{inforexdir}/* +%attr(775,-,%{httpdgroup}) %{inforexdir}/engine/templates_c + %dir %{_localstatedir}/lib/%{name} %{_localstatedir}/lib/%{name}/config.ini.php From 075a43e556a0653f5559dceee43d1f12b62ac2c8 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 6 Mar 2021 20:56:24 +0100 Subject: [PATCH 015/154] deprecated preg_replace in Smarty class --- .../Smarty-2.6.22/libs/Smarty_Compiler.class.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/engine/external/Smarty-2.6.22/libs/Smarty_Compiler.class.php b/engine/external/Smarty-2.6.22/libs/Smarty_Compiler.class.php index 374ba3d0..c4ac6cbe 100644 --- a/engine/external/Smarty-2.6.22/libs/Smarty_Compiler.class.php +++ b/engine/external/Smarty-2.6.22/libs/Smarty_Compiler.class.php @@ -271,13 +271,12 @@ function _compile_file($resource_name, $source_content, &$compiled_content) reset($this->_folded_blocks); /* replace special blocks by "{php}" */ - $source_content = preg_replace($search.'e', "'" - . $this->_quote_replace($this->left_delimiter) . 'php' - . "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'" - . $this->_quote_replace($this->right_delimiter) - . "'" - , $source_content); - + $source_content = preg_replace_callback($search, + function($matches) { + return $this->_quote_replace($this->left_delimiter) . 'php' . str_repeat($this->_quote_replace("\n"),substr_count($matches[0], $this->_quote_replace("\n"))).$this->_quote_replace($this->right_delimiter); + }, + $source_content + ); /* Gather all template tags. */ preg_match_all("~{$ldq}\s*(.*?)\s*{$rdq}~s", $source_content, $_match); $template_tags = $_match[1]; From c4b5765bfeefc6eaead84a650cb97ff695acb5b0 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 6 Mar 2021 21:06:16 +0100 Subject: [PATCH 016/154] quota missing in string constant --- engine/templates/inc_header2.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/templates/inc_header2.tpl b/engine/templates/inc_header2.tpl index 40a360fa..db18073a 100644 --- a/engine/templates/inc_header2.tpl +++ b/engine/templates/inc_header2.tpl @@ -66,7 +66,7 @@ - {if $page==wccl_match_tester || $page==corpus_wccl_match} + {if $page=="wccl_match_tester" || $page=="corpus_wccl_match"} From 5f34e95d03e88db97625a21a95bae03d316b4cd1 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Mon, 8 Mar 2021 11:19:20 +0100 Subject: [PATCH 017/154] nonexistent index in templates generate warnings --- engine/settings.php | 10 +++++++++- engine/templates/inc_header2.tpl | 6 +++--- engine/templates/inc_menu2.tpl | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/engine/settings.php b/engine/settings.php index b4e8608c..d4cfc4ca 100644 --- a/engine/settings.php +++ b/engine/settings.php @@ -16,5 +16,13 @@ ini_set("short_open_tag",1); setlocale(LC_CTYPE, "en_US.UTF-8"); - +error_reporting(E_ALL); + +function inforexCentralErrorHandler($level, $message, $file = ’’, $line = 0) { + print("[".$level."] ".$message." in ".$file.":".$line."
\n"); + //throw new ErrorException($message, 0, $level, $file, $line); +} + +set_error_handler(inforexCentralErrorHandler); + ?> diff --git a/engine/templates/inc_header2.tpl b/engine/templates/inc_header2.tpl index db18073a..65b0c1b5 100644 --- a/engine/templates/inc_header2.tpl +++ b/engine/templates/inc_header2.tpl @@ -105,7 +105,7 @@ Status: Tutaj będzie wyświetlany status. - {if $exception} + {if isset($exception)}

Exception:

{$exception}
{/if} @@ -114,14 +114,14 @@
- {if $error} + {if isset($error)}

Error {$error}

{/if} - {if $info} + {if isset($info)}

Info {$info}

diff --git a/engine/templates/inc_menu2.tpl b/engine/templates/inc_menu2.tpl index 89eb9e6e..88b9395a 100644 --- a/engine/templates/inc_menu2.tpl +++ b/engine/templates/inc_menu2.tpl @@ -15,7 +15,7 @@
  • Corpora
  • - {if $corpus.id} + {if isset($corpus.id)} {/if} - {if $corpus.id && ( "read"|has_corpus_role_or_owner || "admin"|has_role || $corpus.public ) } + {if isset($corpus.id) && ( "read"|has_corpus_role_or_owner || "admin"|has_role || $corpus.public ) }
    -{include file="inc_footer.tpl"} \ No newline at end of file +{include file="inc_footer.tpl"} diff --git a/engine/templates/page_ccl_viewer.tpl b/engine/templates/page_ccl_viewer.tpl index 6150a543..ffca0bad 100644 --- a/engine/templates/page_ccl_viewer.tpl +++ b/engine/templates/page_ccl_viewer.tpl @@ -15,7 +15,7 @@
    -
    {$content_inline|format_annotations}
    +
    {if isset($content_inline)}{$content_inline|format_annotations}{/if}
    {$content_inline2|format_annotations}
    @@ -37,4 +37,4 @@
    -{include file="inc_footer.tpl"} \ No newline at end of file +{include file="inc_footer.tpl"} From 48ed9db4f051ae072e7a971cddd48adc8654bd15 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 20 Mar 2021 10:25:59 +0100 Subject: [PATCH 038/154] all errors are catchable by handlers --- engine/settings.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/engine/settings.php b/engine/settings.php index 3e317e31..16db97ac 100644 --- a/engine/settings.php +++ b/engine/settings.php @@ -39,4 +39,40 @@ function inforexCentralErrorHandler($level, $message, $file = ’’, $line = 0) set_error_handler("inforexCentralErrorHandler"); +function inforexInitialExceptionHandler ($e) { + + // common handler for all exceptiom before CInforexWebPage was + // constructed. + + // reports to http server logs anyway + error_log($e); + http_response_code(500); + // if set display_errors write information on screen + if (ini_get(’display_errors’)) { + echo $e; + } else { + // dummy message for user + echo "

    500 Internal Server Error

    + An internal server error has been occurred.
    + Please try again later."; + } + +} // inforexInitialExceptionHandler() + +set_exception_handler("inforexInitialExceptionHandler"); + +function inforexShutdownFunction() { + + $error = error_get_last(); + if ($error !== null) { + $e = new ErrorException( + $error[’message’], 0, $error[’type’], $error[’file’], $error[’line’] + ); + nforexInitialExceptionHandler($e); + } + +} // inforexShutdownFunction() + +register_shutdown_function("inforexShutdownFunction"); + ?> From 410a27d9d9f8fe9ad67a6de00989dc03afab73c4 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 20 Mar 2021 13:42:07 +0100 Subject: [PATCH 039/154] tunning of redirection in error handlers --- engine/settings.php | 57 ++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/engine/settings.php b/engine/settings.php index 16db97ac..0ab75220 100644 --- a/engine/settings.php +++ b/engine/settings.php @@ -16,22 +16,28 @@ ini_set("short_open_tag",1); setlocale(LC_CTYPE, "en_US.UTF-8"); -// We need all messages for developer usage -error_reporting(E_ALL); -// our handler isn't depends from above setting - function inforexCentralErrorHandler($level, $message, $file = ’’, $line = 0) { - //print("[".$level."] ".$message." in ".$file.":".$line."
    \n"); - + //print("inforexCentralErrorHandler \n"); + // mask errors on error_reporting() settings + // here we have them all + $systemErrorReporting = error_reporting(); + if( ($systemErrorReporting & $level) == 0 ) { + // this error level is masked by system settings + error_clear_last(); + return; + } + // silently drop ugly strict double constructor report in PHP < 7 if(version_compare(phpversion(),'7.0.0','<')) { if(preg_match("/^Redefining already defined constructor for class Config/",$message)) { + error_clear_last(); return; } } // ver < 7.0 - // converts all errors to exceptions + // converts all not masked errors to exceptions + // there are no return from exception to code continue... $extended_message = "[".$level."] ".$message." in ".$file.":".$line; throw new ErrorException($extended_message, 0, $level, $file, $line); @@ -43,19 +49,28 @@ function inforexInitialExceptionHandler ($e) { // common handler for all exceptiom before CInforexWebPage was // constructed. + //print("inforexInitialExceptionHandler \n"); + // Uncaught exception reporting main code // reports to http server logs anyway error_log($e); - http_response_code(500); - // if set display_errors write information on screen - if (ini_get(’display_errors’)) { - echo $e; - } else { - // dummy message for user - echo "

    500 Internal Server Error

    - An internal server error has been occurred.
    - Please try again later."; - } + // on CLI console all was done, do nothing more + if (php_sapi_name() !== "cli") { + // there actions for browser environment + http_response_code(500); + // if set display_errors write information on screen + if (ini_get("display_errors")) { + echo $e; + } else { + // dummy message for user + echo "

    500 Internal Server Error

    + An internal server error has been occurred.
    + Please try again later."; + } // display_errors + } // ! CLI + + // serviced errors shouldn't be processed again + error_clear_last(); } // inforexInitialExceptionHandler() @@ -63,12 +78,16 @@ function inforexInitialExceptionHandler ($e) { function inforexShutdownFunction() { + //print("inforexShutdownFunction \n"); + // returns null or array( "type"=>, "message"=>, "file"=>, "line"=> ) + // if earlier inforexInitialExceptionHandler was called, there not + // will be reported twice $error = error_get_last(); if ($error !== null) { $e = new ErrorException( - $error[’message’], 0, $error[’type’], $error[’file’], $error[’line’] + $error["message"], 0, $error["type"], $error["file"], $error["line"] ); - nforexInitialExceptionHandler($e); + inforexInitialExceptionHandler($e); } } // inforexShutdownFunction() From 9dea7c536a235a04fddd48555eb27de096bf7614 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 20 Mar 2021 19:51:56 +0100 Subject: [PATCH 040/154] all w/o last_errors() on PHP5 --- engine/include/CPage.php | 12 ++++++++++-- engine/include/functions/func_roles.php | 12 +++++++++++- engine/templates/inc_menu2.tpl | 10 +++++----- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/engine/include/CPage.php b/engine/include/CPage.php index 7fa227af..646ed01d 100644 --- a/engine/include/CPage.php +++ b/engine/include/CPage.php @@ -149,7 +149,11 @@ function hasAccess($user=null, $corpus=null){ if (hasUserCorpusRole($user, $corpus, $this->anyCorpusRole)) { return true; } else { - $userCorpusRoles = is_array($corpus['role'][$user['user_id']]) ? array_keys($corpus['role'][$user['user_id']]) : array(ROLE_SYSTEM_USER_PUBLIC); + if(isset($corpus['role'][$user['user_id']])) { + $userCorpusRoles = is_array($corpus['role'][$user['user_id']]) ? array_keys($corpus['role'][$user['user_id']]) : array(ROLE_SYSTEM_USER_PUBLIC); + } else { + $userCorpusRoles = array(ROLE_SYSTEM_USER_PUBLIC); + } $rolesRequired = array_merge($rolesRequired, $this->anyCorpusRole); $rolesUser = array_merge($rolesUser, $userCorpusRoles); } @@ -158,7 +162,11 @@ function hasAccess($user=null, $corpus=null){ if ( hasUserSystemRole($user, $this->anySystemRole) ){ return true; } else { - $userSystemRoles = is_array($user['role']) ? array_keys($user['role']) : array(ROLE_SYSTEM_USER_PUBLIC=>""); + if(isset($user['role'])) { + $userSystemRoles = is_array($user['role']) ? array_keys($user['role']) : array(ROLE_SYSTEM_USER_PUBLIC=>""); + } else { + $userSystemRoles = array(ROLE_SYSTEM_USER_PUBLIC=>""); + } $rolesRequired = array_merge($rolesRequired, $this->anySystemRole); $rolesUser = array_merge($rolesUser, $userSystemRoles); } diff --git a/engine/include/functions/func_roles.php b/engine/include/functions/func_roles.php index e30369ba..9a4adee6 100644 --- a/engine/include/functions/func_roles.php +++ b/engine/include/functions/func_roles.php @@ -11,7 +11,11 @@ function hasUserSystemRole($user, $anyRole){ if (in_array(ROLE_SYSTEM_USER_PUBLIC, $anyRole)){ return true; } else { - $userRoles = array_keys(is_array($user['role']) ? $user['role'] : array(ROLE_SYSTEM_USER_PUBLIC=>"")); + if(isset($user['role'])) { + $userRoles = array_keys(is_array($user['role']) ? $user['role'] : array(ROLE_SYSTEM_USER_PUBLIC=>"")); + } else { + $userRoles = array(ROLE_SYSTEM_USER_PUBLIC=>""); + } return count(array_intersect($userRoles, $anyRole)) > 0; } } @@ -56,6 +60,12 @@ function hasCorpusRole($role){ */ function isCorpusOwner(){ global $corpus, $user; + if( !isset($user['user_id']) ) { + return False; + } + if( !isset($corpus['user_id']) ) { + return False; // maybe True ? + } return $user['user_id'] == $corpus['user_id']; } diff --git a/engine/templates/inc_menu2.tpl b/engine/templates/inc_menu2.tpl index 88b9395a..36c02c58 100644 --- a/engine/templates/inc_menu2.tpl +++ b/engine/templates/inc_menu2.tpl @@ -18,7 +18,7 @@ {if isset($corpus.id)}
    {/if} - {if isset($corpus.id) && ( "read"|has_corpus_role_or_owner || "admin"|has_role || $corpus.public ) } + {if isset($corpus.id) && ( "read"|has_corpus_role_or_owner || "admin"|has_role || !empty($corpus.public) ) }
    -{literal} -{/literal} \ No newline at end of file diff --git a/engine/templates/inc_report_morphodisamb.tpl b/engine/templates/inc_report_morphodisamb.tpl index cd2e3ffd..871b0981 100644 --- a/engine/templates/inc_report_morphodisamb.tpl +++ b/engine/templates/inc_report_morphodisamb.tpl @@ -149,11 +149,9 @@
    -{literal} -{/literal} diff --git a/engine/templates/inc_report_morphodisambagreement.tpl b/engine/templates/inc_report_morphodisambagreement.tpl index 66639777..b266a46d 100644 --- a/engine/templates/inc_report_morphodisambagreement.tpl +++ b/engine/templates/inc_report_morphodisambagreement.tpl @@ -136,21 +136,18 @@ diff --git a/engine/templates/page_corpus_agreement_morphology.tpl b/engine/templates/page_corpus_agreement_morphology.tpl index cb3674ed..6ae171fa 100644 --- a/engine/templates/page_corpus_agreement_morphology.tpl +++ b/engine/templates/page_corpus_agreement_morphology.tpl @@ -149,37 +149,36 @@ -{literal} -{/literal} -{include file="inc_footer.tpl"} \ No newline at end of file +{include file="inc_footer.tpl"} From d3bbaac9113a0416c3aae07212f523bbb3d7f5d3 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 19 Jun 2021 19:20:52 +0200 Subject: [PATCH 051/154] unquoting literal in template of corpus settings --- engine/templates/page_corpus_settings.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/templates/page_corpus_settings.tpl b/engine/templates/page_corpus_settings.tpl index 39870501..e67ac34c 100644 --- a/engine/templates/page_corpus_settings.tpl +++ b/engine/templates/page_corpus_settings.tpl @@ -19,7 +19,7 @@ {/foreach} {if isCorpusOwner() || "admin"|has_role} -
  • +
  • Delete corpus
  • {/if} @@ -54,4 +54,4 @@ -{include file="inc_footer.tpl"} \ No newline at end of file +{include file="inc_footer.tpl"} From dcceafc24db072b6d3e323ce45e5e5f7f90a2ed2 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Tue, 22 Jun 2021 18:00:36 +0200 Subject: [PATCH 052/154] bad screename error in page header solved --- engine/templates/inc_menu2.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/templates/inc_menu2.tpl b/engine/templates/inc_menu2.tpl index 36c02c58..33f04593 100644 --- a/engine/templates/inc_menu2.tpl +++ b/engine/templates/inc_menu2.tpl @@ -185,7 +185,7 @@
    - + {if $rev!="no_git_rev"}Code revision : {$rev}
    {/if} Suggested browser: Chrome
    @@ -211,4 +211,4 @@
    --> -{include file="inc_footer.tpl"} \ No newline at end of file +{include file="inc_footer.tpl"} From 8b8cb5c06a20dd69c5e71825a01b960b90a63c42 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 7 May 2022 13:50:58 +0200 Subject: [PATCH 097/154] agreement changes from template_types and type_limit branches --- .../inc_widget_annotation_type_tree.tpl | 52 +++---------------- public_html/js/page_report_preview.js | 11 +++- 2 files changed, 16 insertions(+), 47 deletions(-) diff --git a/engine/templates/inc_widget_annotation_type_tree.tpl b/engine/templates/inc_widget_annotation_type_tree.tpl index 693d34a5..65d1f068 100644 --- a/engine/templates/inc_widget_annotation_type_tree.tpl +++ b/engine/templates/inc_widget_annotation_type_tree.tpl @@ -4,6 +4,7 @@ * Wrocław University of Technology * See LICENCE *} +
    @@ -13,55 +14,14 @@ - - {foreach from=$annotation_types item=set key=k name=groups} - - - - - {foreach from=$set item=subset key=sk name=subsets} - {if $sk != "name"} - - - - - {foreach from=$subset item=type key=tk name=types} - {if $tk != "name"} - - - - - {/if} - {/foreach} - {/if} - {/foreach} - {/foreach} - {if (!is_array($annotation_types)) || $annotation_types|@count==0} +
    Display
    - - - {$set.name} - - -
    No layers, subsets nor types to display
    -
    +
    +{include file="inc_widget_annotation_type_tree_set_template.tpl"} +{include file="inc_widget_annotation_type_tree_subset_template.tpl"} +{include file="inc_widget_annotation_type_tree_types_template.tpl"} diff --git a/public_html/js/page_report_preview.js b/public_html/js/page_report_preview.js index 0fd22190..6fd32fe0 100644 --- a/public_html/js/page_report_preview.js +++ b/public_html/js/page_report_preview.js @@ -70,12 +70,21 @@ function createTypeRowFromTemplate(container,typeId,typeName) { * and place it on the end of container element */ const typeRowTemplateId = "typeRowTpl"; + const MAX_TYPES_NAME_LABEL = "..."; let typeRow = null; const template = document.querySelector("#"+typeRowTemplateId); if(template) { typeRow = template.content.cloneNode(true); if(typeRow){ - typeRow.querySelector("input").setAttribute("name","typeId-"+typeId); + if(typeName==MAX_TYPES_NAME_LABEL) { + /* remove checkbox for limit threshold */ + elem = typeRow.querySelector("input"); + if(elem) { + elem.parentElement.removeChild(elem); + } + } else { /* type under limit */ + typeRow.querySelector("input").setAttribute("name","typeId-"+typeId); + } typeRow.querySelector("tr").setAttribute("typeid",typeId); typeRow.querySelector(".layerName").innerText = typeName; if(container) { From 69d7607de2de2b016153f03346cc2ce08ab8f822 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Mon, 9 May 2022 19:38:03 +0200 Subject: [PATCH 098/154] bad namespaces in Config class and proper changes agreed --- composer.json | 2 +- engine/Config/Config.php | 199 ++++++++++++++++++++++++ engine/{config => Config}/Singleton.php | 0 engine/config/Config.php | 192 ----------------------- 4 files changed, 200 insertions(+), 193 deletions(-) create mode 100644 engine/Config/Config.php rename engine/{config => Config}/Singleton.php (100%) delete mode 100644 engine/config/Config.php diff --git a/composer.json b/composer.json index 7d68e006..b4466c8d 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "classmap": [ "engine/external/pear/", "engine/include/", - "engine/config/", + "engine/Config/", "engine/page/", "engine/external/ChromePhp.php" ], diff --git a/engine/Config/Config.php b/engine/Config/Config.php new file mode 100644 index 00000000..2a5c7c7d --- /dev/null +++ b/engine/Config/Config.php @@ -0,0 +1,199 @@ + "gpw", + "session_time" => 0, + "offline" => false, + "db_charset" => "utf8mb4", + + /* Inforex basic configuration */ + "path_engine" => 'ABSOLUTE_PATH_TO:inforex/engine', + "path_www" => 'ABSOLUTE_PATH_TO:inforex/public_html', + "path_secured_data" => 'ABSOLUTE_PATH_TO:inforex/data', + //static private $path_exports = 'ABSOLUTE_PATH_TO:inforex/data/exports'; + + /* set $federationLoginUrl to null if regular login is to be used */ + "federationLoginUrl" => null, + "federationValidateTokenUrl" => null, + + "url" => 'http://localhost/inforex', + "dsn" => array( + 'phptype' => 'mysqli', + 'username' => 'inforex', + 'password' => 'password', + 'hostspec' => 'localhost', + 'database' => 'inforex', + ), + + "wccl_match_enable" => false, + //"wccl_match_tester_script" => "ABSOLUTE_PATH_TO:inforex/apps/wccl/wccl-gateway.py"; + //static private $wccl_match_script = "ABSOLUTE_PATH_TO:inforex/apps/wccl/wccl-gateway-run.py"; + + "wccl_match_tester_corpora" => array( + array("name"=>"KPWr 1.2.2 TimeML train – all (1–551)", + "path"=>"/nlp/corpora/pwr/kpwr-release/kpwr-1.2.2-time-disamb/index_time_train.txt"), + array("name"=>"KPWr 1.2.2 TimeML train – A (1–100)", "path"=>"/index_time_a.txt"), + array("name"=>"KPWr 1.2.2 TimeML train – B (101–200)", "path"=>"/index_time_b.txt"), + array("name"=>"KPWr 1.2.2 TimeML train – C (201–300)", "path"=>"/index_time_c.txt"), + array("name"=>"KPWr 1.2.2 TimeML train – D (301–551)", "path"=>"/index_time_d.txt"), + array("name"=>"KPWr 1.2.2 TimeML tune","path"=>"/index_time_tune.txt"), + array("name"=>"KPWr 1.2.7 TimeML train– all", "path"=>"/index_time_train.txt") + ), + + "wccl_match_daemon" => null, + // default settings for wccl import + "insertSentenceTags" => true, + + /* Advanced parameters */ + "path_python" => 'python', + "path_liner" => null, + "path_liner2" => null, + "path_nerd" => null, + "path_wcrft" => null, + "path_semql" => null, + "file_with_rules" => null, + "takipi_wsdl" => null, + "liner_wsdl" => null, + "serel_liner_wsdl" => null, + "path_wcrft_model" => "", + "wcrft_config" => "nkjp_s2.ini", + "wcrft2_config" => "nkjp_e2", + "log_sql" => false, + "log_output" => "fb", + "path_grabber" => null, + + "max_types_limit_threshold" => MAX_TYPES_LIMIT_THRESHOLD, + + // path for local config file - if exists + "localConfigFilename" => "" + ); + + // for more friendly call only... + final public static function Config(){ + + return self::getInstance(); + + } // Config() + + // constructor - default values of some parameters + final protected function __construct(){ + + parent::__construct(); + + $this->put_session_time(60 * 60 * 24 * 356 * 2); + + // Setup default paths + $path_engine = realpath(__DIR__ . DIRECTORY_SEPARATOR . ".."); + $path_inforex = realpath($path_engine . DIRECTORY_SEPARATOR . '..'); + + $this->put_path_engine($path_engine); + $this->put_path_www($path_inforex . DIRECTORY_SEPARATOR . 'public_html'); + $this->put_path_secured_data($path_inforex . DIRECTORY_SEPARATOR . 'secured_data'); + + $this->put_path_exports($this->get_path_secured_data() . DIRECTORY_SEPARATOR . 'exports'); + + $this->put_wccl_match_tester_script($path_engine . "/../apps/wccl/wccl-gateway.py"); + $this->put_wccl_match_script($path_engine . "/../apps/wccl/wccl-gateway-run.py"); + + } + + function __call($method,$arguments){ + // for crazy or lazy developers may be set_ too + if ( substr($method, 0, 4) == "set_" ){ + // change set_ to put_ + $method=preg_replace("/^se/","pu",$method); + } + if ( substr($method, 0, 4) == "get_" ){ + $parameter_name = substr($method, 4); + if ( array_key_exists($parameter_name,self::$confVariables) ) { + return self::$confVariables[$parameter_name]; + } + if ( property_exists($this,$parameter_name) ) { + if ( isset($this->$parameter_name ) ) { + return $this->$parameter_name; + } elseif ( isset(self::${$parameter_name})) { + return self::${$parameter_name}; + } else + // last case - null is not catch by isset() + return null; + } else { + throw new ConfigException("Parameter '$parameter_name' not defined in the configuration file."); + } + } else if ( substr($method, 0, 4) == "put_" ){ + // implementation of put_($value) method + $parameter_name = substr($method, 4); + $value = $arguments[0]; + self::$confVariables[$parameter_name]=$value; + if($parameter_name=="localConfigFilename"){ + $this->loadConfigFromFile(self::get_localConfigFilename()); + } + } + else + call_user_func_array(array($this,"_".$method),$arguments); + } + + private function loadOldLocalConfig($pathname) { + + $config = new Phantom(); + include($pathname); + $classVars=get_object_vars($config); + foreach($classVars as $name => $value) { + $this->{"put_".$name}($config->{$name}); + } + + } // loadOldLocalConfig() + + public function loadConfigFromFile($pathname) { + + if ( file_exists($pathname) ) { + try { + + $this->loadOldLocalConfig($pathname); + + } catch(Exception $e) { + + // Ładowanie wg. nowego configa + $config = $this; + try { + include($pathname); + } catch( Exception $e ) { + throw new ConfigException("Error loading configuration file '$pathname'."); + } // try..catch() new syntax + } // try...catch() old syntax + } // if file_exists() + + } // loadConfigFromFile() + + public function dumpConfigSets() { + + return get_class_vars(get_class($this)); + + } // dumpConfigSets() + + +} // Config class + + +?> diff --git a/engine/config/Singleton.php b/engine/Config/Singleton.php similarity index 100% rename from engine/config/Singleton.php rename to engine/Config/Singleton.php diff --git a/engine/config/Config.php b/engine/config/Config.php deleted file mode 100644 index f852f110..00000000 --- a/engine/config/Config.php +++ /dev/null @@ -1,192 +0,0 @@ - 'mysqli', - 'username' => 'inforex', - 'password' => 'password', - 'hostspec' => 'localhost', - 'database' => 'inforex', - ); - - static private $wccl_match_enable = false; - - static private $wccl_match_tester_corpora = array( - array("name" => "KPWr 1.2.2 TimeML train – all (1–551)", - "path" => "/nlp/corpora/pwr/kpwr-release/kpwr-1.2.2-time-disamb/index_time_train.txt"), - array("name" => "KPWr 1.2.2 TimeML train – A (1–100)", "path" => "/index_time_a.txt"), - array("name" => "KPWr 1.2.2 TimeML train – B (101–200)", "path" => "/index_time_b.txt"), - array("name" => "KPWr 1.2.2 TimeML train – C (201–300)", "path" => "/index_time_c.txt"), - array("name" => "KPWr 1.2.2 TimeML train – D (301–551)", "path" => "/index_time_d.txt"), - array("name" => "KPWr 1.2.2 TimeML tune", "path" => "/index_time_tune.txt"), - array("name" => "KPWr 1.2.7 TimeML train– all", "path" => "/index_time_train.txt") - ); - - static private $wccl_match_daemon = null; - - /* Advanced parameters */ - static private $path_python = 'python'; - static private $path_liner = null; - static private $path_liner2 = null; - static private $path_nerd = null; - static private $path_wcrft = null; - static private $path_semql = null; - static private $file_with_rules = null; - static private $takipi_wsdl = null; - static private $liner_wsdl = null; - static private $serel_liner_wsdl = null; - static private $path_wcrft_model = ""; - static private $wcrft_config = "nkjp_s2.ini"; - static private $wcrft2_config = "nkjp_e2"; - static private $log_sql = false; - static private $log_output = "fb"; - static private $path_grabber = null; - - static private $max_types_limit_threshold = MAX_TYPES_LIMIT_THRESHOLD; - - // path for local config file - if exists - static private $localConfigFilename = ""; - - // for more friendly call only... - final public static function Config() - { - - return self::getInstance(); - - } - - // constructor - default values of some parameters - final protected function __construct() - { - - parent::__construct(); - - $this->session_time = 60 * 60 * 24 * 356 * 2; - - // Setup default paths - $path_engine = realpath(__DIR__ . DIRECTORY_SEPARATOR . ".."); - $path_inforex = realpath($path_engine . DIRECTORY_SEPARATOR . '..'); - - $this->path_engine = $path_engine; - $this->path_www = $path_inforex . DIRECTORY_SEPARATOR . 'public_html'; - $this->path_secured_data = $path_inforex . DIRECTORY_SEPARATOR . 'secured_data'; - - $this->path_exports = $this->path_secured_data.DIRECTORY_SEPARATOR.'exports'; - - $this->wccl_match_tester_script = $path_engine . "/../apps/wccl/wccl-gateway.py"; - $this->wccl_match_script = $path_engine . "/../apps/wccl/wccl-gateway-run.py"; - - } - - function __call($method, $arguments) - { - // for crazy or lazy developers may be set_ too - if (substr($method, 0, 4) == "set_") { - // change set_ to put_ - $method = preg_replace("/^se/", "pu", $method); - } - if (substr($method, 0, 4) == "get_") { - $parameter_name = substr($method, 4); - if (property_exists($this, $parameter_name)) { - if (isset($this->$parameter_name)) { - return $this->$parameter_name; - } elseif (isset(self::${$parameter_name})) { - return self::${$parameter_name}; - } else - // last case - null is not catch by isset() - return null; - } else { - throw new Exception("Parameter '$parameter_name' not defined in the configuration file."); - } - } else if (substr($method, 0, 4) == "put_") { - // implementation of put_($value) method - $parameter_name = substr($method, 4); - $value = $arguments[0]; - $this->{$parameter_name} = $value; - if ($parameter_name == "localConfigFilename") { - $this->loadConfigFromFile($this->localConfigFilename); - } - } else - call_user_func_array(array($this, "_" . $method), $arguments); - } - - private function loadOldLocalConfig($pathname) - { - - $config = new Phantom(); - include($pathname); - $classVars = get_object_vars($config); - foreach ($classVars as $name => $value) { - $this->{"put_" . $name}($config->{$name}); - } - - } - - public function loadConfigFromFile($pathname) - { - - if (file_exists($pathname)) { - try { - - $this->loadOldLocalConfig($pathname); - - } catch (Exception $e) { - - // loading new config - $config = $this; - try { - include($pathname); - } catch (Exception $e) { - throw new Exception("Error loading configuration file '$pathname'."); - } - } - } - - } - - public function dumpConfigSets() - { - return get_class_vars(get_class($this)); - } -} - -?> From 2023938e37f9e6d3178527f98a2f3b2213b90988 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Wed, 11 May 2022 19:29:40 +0200 Subject: [PATCH 099/154] some database interface improvements --- engine/include/database/Database.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/engine/include/database/Database.php b/engine/include/database/Database.php index 20e37f89..35890d1f 100644 --- a/engine/include/database/Database.php +++ b/engine/include/database/Database.php @@ -6,9 +6,6 @@ * See LICENCE */ -// dla dostępności MDB2::MDB2_PORTABILITY_NONE przy inicjowaniu $db tylko -require_once(__DIR__."/../../../engine/external/pear/MDB2.php"); - /** * Database gateway. */ @@ -118,7 +115,6 @@ private function log_sql($sql, $args){ */ function execute($sql, $args=null){ $time_start = microtime(TRUE); - //$sth = null; $result = null; try{ $this->log_sql($sql, $args); @@ -154,7 +150,7 @@ function fetch_rows($sql, $args = null){ } /** - * Return one-dimensional array of values for given column for each row + * Return one-dimensional array of values from given column for each row * returned by the query. * @param $sql {String} SQL query. * @param $column {String} Column name. @@ -501,7 +497,11 @@ function fetch_assoc_array($sql, $key_column_name, $value_column_name, $args = n $rows = $this->fetch_rows($sql, $args); $result = array(); foreach ($rows as $row){ - $result[$row[$key_column_name]] = $row[$value_column_name]; + if( array_key_exists($key_column_name,$row) && array_key_exists($value_column_name,$row) ) { + $result[$row[$key_column_name]] = $row[$value_column_name]; + } else { + throw new DatabaseException("Columns $key_column_name or $value_column_name doesn't exists in result of query: $sql in fetch_assoc_array() database method."); + } } return $result; } // fetch_assoc_array() @@ -520,4 +520,4 @@ public function get_collate() { } // of Database class -?> \ No newline at end of file +?> From 81cf35c8be44543378a19b3cee42890167b11c8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Naskr=C4=99t?= Date: Fri, 13 May 2022 08:12:31 +0200 Subject: [PATCH 100/154] fix: remove PHPUnit from settings --- engine/settings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engine/settings.php b/engine/settings.php index c0d70137..f7d0c38e 100644 --- a/engine/settings.php +++ b/engine/settings.php @@ -22,8 +22,8 @@ define('MAX_TYPES_NAME_LABEL','...'); set_error_handler("ErrorService::errorHandler"); -if(! PHPUnitTools::isPHPUnitRunning()) { +/*if(! PHPUnitTools::isPHPUnitRunning()) { // under PHPUnit this one not works register_shutdown_function("ErrorService::shutdownFunction"); -} +}*/ ?> From 0d6aa8cd303fab7f6b87dfd8a0ca7e75201407d8 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Tue, 17 May 2022 18:39:55 +0200 Subject: [PATCH 101/154] missing opt parse added --- local/daemon-tasks.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/local/daemon-tasks.php b/local/daemon-tasks.php index 3021f83f..650a4a79 100644 --- a/local/daemon-tasks.php +++ b/local/daemon-tasks.php @@ -34,6 +34,7 @@ try{ ini_set('memory_limit', '1024M'); + $opt->parseCli(isset($argv) ? $argv : null); $dbHost = "localhost"; $dbUser = "root"; @@ -289,7 +290,7 @@ function processNlprest2Tagger($report_id, $params){ $orth_sql = $index_orths[$orth]; } else { $new_orths[$orth] = 1; - $orth_sql = "(SELECT orth_id FROM orths WHERE orth='" . $orth . "')"; + $orth_sql = "(SELECT orth_id FROM orths WHERE orth='" . $this->db->escape($orth) . "')"; } $args = array($report_id, $from, $to, $lastToken, $orth_sql); @@ -357,7 +358,7 @@ function processNlprest2Tagger($report_id, $params){ if ( count ($new_orths) > 0 ){ $new_orths = array_keys($new_orths); for($i=0;$idb->escape($new_orths[$i]); } $sql_new_orths = 'INSERT IGNORE INTO `orths` (`orth`) VALUES ("' . implode('"),("', $new_orths) . '");'; $this->db->execute($sql_new_orths); From bef82d5d631f7077806d34ea15d8abda5dea6098 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Tue, 17 May 2022 19:24:00 +0200 Subject: [PATCH 102/154] change order of include and settings --- engine/settings.php | 2 ++ local/daemon-tasks.php | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/settings.php b/engine/settings.php index c0d70137..e0163ca0 100644 --- a/engine/settings.php +++ b/engine/settings.php @@ -21,6 +21,8 @@ define('MAX_TYPES_LABEL_INDEX',999999999999); // over autoincrement id define('MAX_TYPES_NAME_LABEL','...'); +require_once(__DIR__ . DIRECTORY_SEPARATOR . 'include.php'); + set_error_handler("ErrorService::errorHandler"); if(! PHPUnitTools::isPHPUnitRunning()) { // under PHPUnit this one not works diff --git a/local/daemon-tasks.php b/local/daemon-tasks.php index 650a4a79..c38870d0 100644 --- a/local/daemon-tasks.php +++ b/local/daemon-tasks.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); From d37d9b73f5028adf99346f4fafca3f42d514e8b4 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Tue, 17 May 2022 21:07:56 +0200 Subject: [PATCH 103/154] local scripts corrections --- engine/cliopt.php | 2 +- local/agreement.php | 1 - local/ccl2iob.php | 1 - local/cli-liner2-nlprest2.php | 1 - local/cli-restore-corpus.php | 1 - local/cli-upload-txt.php | 1 - local/daemon-cleanup.php | 1 - local/daemon-export.php | 3 +-- local/daemon-grab.php | 1 - local/daemon-upload.php | 1 - local/export-corpus.php | 1 - local/flags.php | 1 - local/import-corpus-cli.php | 1 - local/import-sherlock.php | 1 - local/import-wsd-annotations.php | 1 - local/liner2.php | 1 - local/slavicner2019-annotate.php | 1 - local/slavicner2019.php | 1 - local/tokenize-update.php | 1 - local/tokenize.php | 1 - local/upload.php | 1 - local/wsd-annotate.php | 1 - 22 files changed, 2 insertions(+), 23 deletions(-) diff --git a/engine/cliopt.php b/engine/cliopt.php index 1663d3e2..7c4d0366 100644 --- a/engine/cliopt.php +++ b/engine/cliopt.php @@ -230,7 +230,7 @@ function printHelp(){ } print " [parameters]\n\n"; - if (count($this->executes)){ + if (is_array($this->executes) && count($this->executes)){ print " Sample execute:\n"; foreach ($this->executes as $e){ echo " ".sprintf(" # %s\n", $e[1]); diff --git a/local/agreement.php b/local/agreement.php index 2e576962..655a6087 100644 --- a/local/agreement.php +++ b/local/agreement.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/ccl2iob.php b/local/ccl2iob.php index f2b608ba..40573c66 100644 --- a/local/ccl2iob.php +++ b/local/ccl2iob.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/cli-liner2-nlprest2.php b/local/cli-liner2-nlprest2.php index 4d910ace..1343d77f 100644 --- a/local/cli-liner2-nlprest2.php +++ b/local/cli-liner2-nlprest2.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/cli-restore-corpus.php b/local/cli-restore-corpus.php index a9e6f80c..65788193 100644 --- a/local/cli-restore-corpus.php +++ b/local/cli-restore-corpus.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/cli-upload-txt.php b/local/cli-upload-txt.php index e8b61aa0..bd879f2e 100644 --- a/local/cli-upload-txt.php +++ b/local/cli-upload-txt.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/daemon-cleanup.php b/local/daemon-cleanup.php index 762f68d5..874a3f27 100644 --- a/local/daemon-cleanup.php +++ b/local/daemon-cleanup.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/daemon-export.php b/local/daemon-export.php index 07b7d2df..29e6f09d 100644 --- a/local/daemon-export.php +++ b/local/daemon-export.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); @@ -35,7 +34,7 @@ try{ ini_set('memory_limit', '1024M'); - $opt->parseCli($argv); + $opt->parseCli(isset($argv) ? $argv : null); if ( $opt->exists("db-uri")){ $dbHost = "localhost"; $dbUser = "root"; diff --git a/local/daemon-grab.php b/local/daemon-grab.php index dffcde4f..ed17eb6b 100644 --- a/local/daemon-grab.php +++ b/local/daemon-grab.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/daemon-upload.php b/local/daemon-upload.php index 34b2cc81..2b91b2ad 100644 --- a/local/daemon-upload.php +++ b/local/daemon-upload.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/export-corpus.php b/local/export-corpus.php index 6dfd066e..e64e84fb 100644 --- a/local/export-corpus.php +++ b/local/export-corpus.php @@ -33,7 +33,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/flags.php b/local/flags.php index 754f6030..18cec00a 100644 --- a/local/flags.php +++ b/local/flags.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath. DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "config" ). DIRECTORY_SEPARATOR ."config.local.php"); diff --git a/local/import-corpus-cli.php b/local/import-corpus-cli.php index 64979aea..d37faf1d 100644 --- a/local/import-corpus-cli.php +++ b/local/import-corpus-cli.php @@ -2,7 +2,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/import-sherlock.php b/local/import-sherlock.php index 2d9a8566..d0e335c3 100644 --- a/local/import-sherlock.php +++ b/local/import-sherlock.php @@ -2,7 +2,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/import-wsd-annotations.php b/local/import-wsd-annotations.php index 1c111242..9e50e004 100644 --- a/local/import-wsd-annotations.php +++ b/local/import-wsd-annotations.php @@ -2,7 +2,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/liner2.php b/local/liner2.php index 961439ac..c0d3a25e 100644 --- a/local/liner2.php +++ b/local/liner2.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath. DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "config") . DIRECTORY_SEPARATOR ."config.local.php"); diff --git a/local/slavicner2019-annotate.php b/local/slavicner2019-annotate.php index ff6e4c78..2081ec00 100644 --- a/local/slavicner2019-annotate.php +++ b/local/slavicner2019-annotate.php @@ -2,7 +2,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/slavicner2019.php b/local/slavicner2019.php index 2e3f4145..468c3503 100644 --- a/local/slavicner2019.php +++ b/local/slavicner2019.php @@ -1,7 +1,6 @@ put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/tokenize-update.php b/local/tokenize-update.php index 7234a619..02a4b36c 100644 --- a/local/tokenize-update.php +++ b/local/tokenize-update.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/tokenize.php b/local/tokenize.php index 7d390fef..fdb2b16d 100644 --- a/local/tokenize.php +++ b/local/tokenize.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/upload.php b/local/upload.php index d5597097..03e2e21f 100644 --- a/local/upload.php +++ b/local/upload.php @@ -8,7 +8,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/local/wsd-annotate.php b/local/wsd-annotate.php index 7221536d..3dd3cd1a 100644 --- a/local/wsd-annotate.php +++ b/local/wsd-annotate.php @@ -6,7 +6,6 @@ $enginePath = realpath(implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), "..", "engine"))); require_once($enginePath. DIRECTORY_SEPARATOR . "settings.php"); -require_once($enginePath. DIRECTORY_SEPARATOR . 'include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); From 5a3f7a1421759e90df70a0637ef3bf767bc10c4f Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Tue, 17 May 2022 21:19:32 +0200 Subject: [PATCH 104/154] double LoadRequest loader removed --- public_html/css.php | 1 - public_html/image.php | 1 - public_html/index.php | 2 -- 3 files changed, 4 deletions(-) diff --git a/public_html/css.php b/public_html/css.php index 6686445f..bf5626c0 100644 --- a/public_html/css.php +++ b/public_html/css.php @@ -8,7 +8,6 @@ $enginePath = realpath(__DIR__ . "/../engine/"); require_once($enginePath . "/settings.php"); -require_once($enginePath . '/include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/public_html/image.php b/public_html/image.php index fdf19d4c..e6b83a13 100644 --- a/public_html/image.php +++ b/public_html/image.php @@ -8,7 +8,6 @@ $enginePath = realpath(__DIR__ . "/../engine/"); require_once($enginePath."/settings.php"); -require_once($enginePath.'/include.php'); Config::Config()->put_path_engine($enginePath); Config::Config()->put_localConfigFilename(realpath($enginePath . "/../config/").DIRECTORY_SEPARATOR."config.local.php"); diff --git a/public_html/index.php b/public_html/index.php index e618f043..8821173b 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -8,7 +8,6 @@ ob_start(); $enginePath = realpath(__DIR__ . "/../engine/"); -require_once($enginePath.'/include.php'); require_once($enginePath."/settings.php"); try{ @@ -37,7 +36,6 @@ $auth = new UserAuthorize(Config::Config()->get_dsn()); $auth->authorize(isset($_POST['logout']) && ($_POST['logout']=="1")); $user = $auth->getUserData(); - $corpus = RequestLoader::loadCorpus(); // federation login is enabled if(Config::Config()->get_federationLoginUrl()){ From fbc4c499bbd4862a363a75f4bd5e57dddb82d19a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Naskr=C4=99t?= Date: Thu, 19 May 2022 07:22:49 +0200 Subject: [PATCH 105/154] fix: removed left closing tag --- engine/templates/inc_widget_annotation_type_tree.tpl | 1 - 1 file changed, 1 deletion(-) diff --git a/engine/templates/inc_widget_annotation_type_tree.tpl b/engine/templates/inc_widget_annotation_type_tree.tpl index 697069a8..65d1f068 100644 --- a/engine/templates/inc_widget_annotation_type_tree.tpl +++ b/engine/templates/inc_widget_annotation_type_tree.tpl @@ -18,7 +18,6 @@ No layers, subsets nor types to display - {/if} From 10fd22442a54310dfe4915f7f6b609cfe094f5c2 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Mon, 27 Jun 2022 14:27:03 +0200 Subject: [PATCH 106/154] missing quotas in callback function name intval --- engine/include/database/CDbAnnotation.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/include/database/CDbAnnotation.php b/engine/include/database/CDbAnnotation.php index 67260933..70a58563 100755 --- a/engine/include/database/CDbAnnotation.php +++ b/engine/include/database/CDbAnnotation.php @@ -1022,7 +1022,7 @@ static function getUserAnnotations($user_id=null, $corpus_id=null, $subcorpus_id } if ( $annotation_type_ids !== null ){ - $annotation_type_ids = array_map(intval, $annotation_type_ids); + $annotation_type_ids = array_map('intval', $annotation_type_ids); if ( count($annotation_type_ids) > 0 ){ $params_where = array_merge($params_where, $annotation_type_ids); $sql_where[] = "a.type_id IN (" . implode(",", array_fill(0, count($annotation_type_ids), "?")) .")"; @@ -1099,7 +1099,7 @@ static function getAnnotationCount($user_id=null, $corpus_id=null, $subcorpus_id } if ( $annotation_type_ids !== null ){ - $annotation_type_ids = array_map(intval, $annotation_type_ids); + $annotation_type_ids = array_map('intval', $annotation_type_ids); if ( count($annotation_type_ids) > 0 ){ $params_where = array_merge($params_where, $annotation_type_ids); $sql_where[] = "a.type_id IN (" . implode(",", array_fill(0, count($annotation_type_ids), "?")) .")"; @@ -1232,7 +1232,7 @@ static function getAnnotationDocCount($user_id=null, $corpus_id=null, $subcorpus } if ( $annotation_type_ids !== null ){ - $annotation_type_ids = array_map(intval, $annotation_type_ids); + $annotation_type_ids = array_map('intval', $annotation_type_ids); if ( count($annotation_type_ids) > 0 ){ $params_where = array_merge($params_where, $annotation_type_ids); $sql_where[] = "a.type_id IN (" . implode(",", array_fill(0, count($annotation_type_ids), "?")) .")"; From 96f56d98ebff2e19e507542b13c5be0654cd6cb0 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Tue, 28 Jun 2022 10:52:10 +0200 Subject: [PATCH 107/154] extracting annotation loader to external multiusing script --- .../PerspectiveAgreement.php | 1 + .../PerspectiveAnnotation_attributes.php | 3 +- .../PerspectiveAnnotation_lemma.php | 3 +- .../PerspectiveAnnotator.php | 1 + .../PerspectivePreview.php | 1 + .../PerspectiveRelation_agreement.php | 1 + public_html/js/page_report_agreement.js | 3 + .../js/page_report_annotation_attributes.js | 5 +- .../js/page_report_annotation_lemma.js | 5 +- .../js/page_report_annotation_tree_loader.js | 145 ++++++++++++++++++ public_html/js/page_report_annotator.js | 3 + public_html/js/page_report_preview.js | 138 +---------------- .../js/page_report_relation_agreement.js | 1 + 13 files changed, 169 insertions(+), 141 deletions(-) create mode 100644 public_html/js/page_report_annotation_tree_loader.js diff --git a/engine/page/report_perspectives/PerspectiveAgreement.php b/engine/page/report_perspectives/PerspectiveAgreement.php index c526dc66..fa0bc601 100644 --- a/engine/page/report_perspectives/PerspectiveAgreement.php +++ b/engine/page/report_perspectives/PerspectiveAgreement.php @@ -13,6 +13,7 @@ function __construct(CPage $page, $document) parent::__construct($page, $document); $this->page->includeJs("js/c_widget_annotation_type_tree.js"); $this->page->includeJs("js/c_widget_user_selection_a_b.js"); + $this->page->includeJs("js/page_report_annotation_tree_loader.js"); } function execute(){ diff --git a/engine/page/report_perspectives/PerspectiveAnnotation_attributes.php b/engine/page/report_perspectives/PerspectiveAnnotation_attributes.php index b8e4dd0b..0444b2f7 100644 --- a/engine/page/report_perspectives/PerspectiveAnnotation_attributes.php +++ b/engine/page/report_perspectives/PerspectiveAnnotation_attributes.php @@ -18,6 +18,7 @@ function __construct(CPage $page, $document){ $this->page->includeJs("js/c_widget_annotation_type_tree.js"); $this->page->includeJs("js/c_widget_annotation_details.js"); + $this->page->includeJs("js/page_report_annotation_tree_loader.js"); } function execute(){ @@ -89,4 +90,4 @@ function getAnnotationMode(){ } return $annotation_mode; } -} \ No newline at end of file +} diff --git a/engine/page/report_perspectives/PerspectiveAnnotation_lemma.php b/engine/page/report_perspectives/PerspectiveAnnotation_lemma.php index 2c7be84f..1fb10b79 100644 --- a/engine/page/report_perspectives/PerspectiveAnnotation_lemma.php +++ b/engine/page/report_perspectives/PerspectiveAnnotation_lemma.php @@ -13,6 +13,7 @@ function __construct(CPage $page, $document){ parent::__construct($page, $document); $this->page->includeJs("js/c_annotation_mode.js"); $this->page->includeJs("js/c_widget_annotation_type_tree.js"); + $this->page->includeJs("js/page_report_annotation_tree_loader.js"); } function execute(){ @@ -75,4 +76,4 @@ function getAnnotationMode(){ } return $annotation_mode; } -} \ No newline at end of file +} diff --git a/engine/page/report_perspectives/PerspectiveAnnotator.php b/engine/page/report_perspectives/PerspectiveAnnotator.php index b3e9f14c..0fa248e5 100644 --- a/engine/page/report_perspectives/PerspectiveAnnotator.php +++ b/engine/page/report_perspectives/PerspectiveAnnotator.php @@ -25,6 +25,7 @@ function __construct(CPage $page, $document){ $this->page->includeJs("js/c_autoaccordionview.js"); $this->page->includeJs("js/page_report_preview.js"); $this->page->includeJs("libs/bootstrap-confirmation.min.js"); + $this->page->includeJs("js/page_report_annotation_tree_loader.js"); } function execute(){ diff --git a/engine/page/report_perspectives/PerspectivePreview.php b/engine/page/report_perspectives/PerspectivePreview.php index 7b599d1e..6aa7291f 100644 --- a/engine/page/report_perspectives/PerspectivePreview.php +++ b/engine/page/report_perspectives/PerspectivePreview.php @@ -14,6 +14,7 @@ function __construct(CPage $page, $document) $this->page->includeJs("js/c_widget_annotation_type_tree.js"); $this->page->includeJs("js/c_widget_relation_sets.js"); $this->page->includeJs("js/c_autoaccordionview.js"); + $this->page->includeJs("js/page_report_annotation_tree_loader.js"); } function execute() diff --git a/engine/page/report_perspectives/PerspectiveRelation_agreement.php b/engine/page/report_perspectives/PerspectiveRelation_agreement.php index a469668b..c885fffe 100644 --- a/engine/page/report_perspectives/PerspectiveRelation_agreement.php +++ b/engine/page/report_perspectives/PerspectiveRelation_agreement.php @@ -13,6 +13,7 @@ function __construct(CPage $page, $document){ $this->page->includeJs("js/c_widget_relation_type_tree.js"); $this->page->includeJs("js/c_widget_annotation_type_tree.js"); $this->page->includeJs("js/c_widget_user_selection_a_b.js"); + $this->page->includeJs("js/page_report_annotation_tree_loader.js"); } function execute(){ diff --git a/public_html/js/page_report_agreement.js b/public_html/js/page_report_agreement.js index bde1a63c..d7018391 100644 --- a/public_html/js/page_report_agreement.js +++ b/public_html/js/page_report_agreement.js @@ -8,6 +8,9 @@ * Przypisanie akcji po wczytaniu się strony. */ $(document).ready(function(){ + var url = $.url(window.location.href); + var corpus_id = url.param('corpus'); + loadAnnotationTypesFromTemplates(corpus_id); assign_click_legend(); assign_annotation_triggers(); assign_more_less(); diff --git a/public_html/js/page_report_annotation_attributes.js b/public_html/js/page_report_annotation_attributes.js index 8b8e9e37..bfb1e35a 100644 --- a/public_html/js/page_report_annotation_attributes.js +++ b/public_html/js/page_report_annotation_attributes.js @@ -6,6 +6,9 @@ $(document).ready(function(){ + var url = $.url(window.location.href); + var corpus_id = url.param('corpus'); + loadAnnotationTypesFromTemplates(corpus_id); setupAnnotationTypeTree(); setupAnnotationMode(); @@ -229,4 +232,4 @@ function updateSaveButtonStatus(){ button.addClass("btn-default"); button.removeClass("btn-danger"); } -} \ No newline at end of file +} diff --git a/public_html/js/page_report_annotation_lemma.js b/public_html/js/page_report_annotation_lemma.js index 54706485..784d7033 100644 --- a/public_html/js/page_report_annotation_lemma.js +++ b/public_html/js/page_report_annotation_lemma.js @@ -5,6 +5,9 @@ */ $(document).ready(function(){ + var url = $.url(window.location.href); + var corpus_id = url.param('corpus'); + loadAnnotationTypesFromTemplates(corpus_id); assignButtonAutofillClick(); assignButtonSaveAllClick(); @@ -246,4 +249,4 @@ function updateSaveButtonStatus(){ button.addClass("btn-default"); button.removeClass("btn-danger"); } -} \ No newline at end of file +} diff --git a/public_html/js/page_report_annotation_tree_loader.js b/public_html/js/page_report_annotation_tree_loader.js new file mode 100644 index 00000000..1b749a31 --- /dev/null +++ b/public_html/js/page_report_annotation_tree_loader.js @@ -0,0 +1,145 @@ +/** + * Part of the Inforex project + * Copyright (C) 2013 Michał Marcińczuk, Jan Kocoń, Marcin Ptak + * Wrocław University of Technology + */ + +var url = $.url(window.location.href); +var corpus_id = url.param("corpus"); + +function createSetRowFromTemplate(container,setId,setName) { + + /* from HTML template in DOM named id='setRowTpl' + * creates code of set row for parametres setId,setName + * and place it on the end of container element + */ + const setRowTemplateId = "setRowTpl"; + let setRow = null; + const template = document.querySelector("#"+setRowTemplateId); + if(template) { + setRow = template.content.cloneNode(true); + if(setRow){ + setRow.querySelector("input").setAttribute("name","layerId-"+setId); + setRow.querySelector(".layerName").innerText = setName; + if(container) { + container.append(setRow); + } + } else { + console.log("Cannot clone DOM element for template with id="+setRowTemplateId); + } + } else { + console.log("Cannot create DOM element from template with id="+setRowTemplateId); + } + +} // createSetRowfromTemplate() + +function createSubsetRowFromTemplate(container,subsetId,subsetName) { + + /* from HTML template in DOM named id='subsetRowTpl' + * creates code of subset row for parametres subsetId, subsetName + * and place it on the end of container element + */ + const subsetRowTemplateId = "subsetRowTpl"; + let subsetRow = null; + const template = document.querySelector("#"+subsetRowTemplateId); + if(template) { + subsetRow = template.content.cloneNode(true); + if(subsetRow){ + subsetRow.querySelector("input").setAttribute("name","subsetId-"+subsetId); + subsetRow.querySelector("tr").setAttribute("subsetid",subsetId); + subsetRow.querySelector(".layerName").innerText = subsetName; + if(container) { + container.append(subsetRow); + } + } else { + console.log("Cannot clone DOM element for template with id="+subsetRowTemplateId); + } + } else { + console.log("Cannot create DOM element from template with id="+subsetRowTemplateId); + } + +} // createSubsetRowfromTemplate() + +function createTypeRowFromTemplate(container,typeId,typeName) { + + /* from HTML template in DOM named id='typeRowTpl' + * creates code of type row for parametres typeId, typeName + * and place it on the end of container element + */ + const typeRowTemplateId = "typeRowTpl"; + const MAX_TYPES_NAME_LABEL = "..."; + let typeRow = null; + const template = document.querySelector("#"+typeRowTemplateId); + if(template) { + typeRow = template.content.cloneNode(true); + if(typeRow){ + if(typeName==MAX_TYPES_NAME_LABEL) { + /* remove checkbox for limit threshold */ + elem = typeRow.querySelector("input"); + if(elem) { + elem.parentElement.removeChild(elem); + } + } else { /* type under limit */ + typeRow.querySelector("input").setAttribute("name","typeId-"+typeId); + } + typeRow.querySelector("tr").setAttribute("typeid",typeId); + typeRow.querySelector(".layerName").innerText = typeName; + if(container) { + container.append(typeRow); + } + } else { + console.log("Cannot clone DOM element for template with id="+typeRowTemplateId); + } + } else { + console.log("Cannot create DOM element from template with id="+typeRowTemplateId); + } + +} // createTypeRowFromTemplate() + +/** + * loads rows with sets, subsets & types of annotations from templates + * and pure JSON data from ajax request + */ +function loadAnnotationTypesFromTemplates(corpus_id) { + + // loading all data from ajax service + const serviceName = "annotation_type_tree"; + const getTypesSuccess = function(data) { + + // create rows for sets, subsets and types + if(!data){ return; } + if(data.length==0){ return; } + // element, which holds all rows + const container = $(".annotationTypesTree"); + // remove default content for empty set + $(container).find("tr").remove(); + // array of setId => set_array, + $.each(data,function(setId,setArray){ + const setName = setArray.name; + createSetRowFromTemplate(container,setId,setName); + $.each(setArray,function(subsetId,subsetArray){ + if(subsetId!='name'){ + const subsetName = subsetArray.name; + createSubsetRowFromTemplate(container,subsetId,subsetName); + $.each(subsetArray,function(typeId,typeName){ + if(typeId!='name'){ + createTypeRowFromTemplate(container,typeId,typeName); + }; // typeId<>'name' + }); // each subsetArray + }; // subsetId <> 'name' + }); // each setArray + }); // each data + + }; + const getTypesError = function() { + console.log("Error on ajax request for "+serviceName); + }; + doAjaxSync( serviceName , + { 'corpusId' : corpus_id }, + getTypesSuccess, + getTypesError, + null // getTypesComplete + ); + +} // loadAnnotationTypesFromTemplates() + diff --git a/public_html/js/page_report_annotator.js b/public_html/js/page_report_annotator.js index 8125a4af..f890ff53 100644 --- a/public_html/js/page_report_annotator.js +++ b/public_html/js/page_report_annotator.js @@ -12,6 +12,9 @@ var globalSelection = null; $(function(){ + var url = $.url(window.location.href); + var corpus_id = url.param('corpus'); + loadAnnotationTypesFromTemplates(corpus_id); setupAnnotationMode(); wAnnotationDetails = new WidgetAnnotation("#annotation-details", function(){ diff --git a/public_html/js/page_report_preview.js b/public_html/js/page_report_preview.js index 6fd32fe0..69f8f2fa 100644 --- a/public_html/js/page_report_preview.js +++ b/public_html/js/page_report_preview.js @@ -10,147 +10,11 @@ var url = $.url(window.location.href); var corpus_id = url.param("corpus"); var report_id = url.param("id"); -function createSetRowFromTemplate(container,setId,setName) { - - /* from HTML template in DOM named id='setRowTpl' - * creates code of set row for parametres setId,setName - * and place it on the end of container element - */ - const setRowTemplateId = "setRowTpl"; - let setRow = null; - const template = document.querySelector("#"+setRowTemplateId); - if(template) { - setRow = template.content.cloneNode(true); - if(setRow){ - setRow.querySelector("input").setAttribute("name","layerId-"+setId); - setRow.querySelector(".layerName").innerText = setName; - if(container) { - container.append(setRow); - } - } else { - console.log("Cannot clone DOM element for template with id="+setRowTemplateId); - } - } else { - console.log("Cannot create DOM element from template with id="+setRowTemplateId); - } - -} // createSetRowfromTemplate() - -function createSubsetRowFromTemplate(container,subsetId,subsetName) { - - /* from HTML template in DOM named id='subsetRowTpl' - * creates code of subset row for parametres subsetId, subsetName - * and place it on the end of container element - */ - const subsetRowTemplateId = "subsetRowTpl"; - let subsetRow = null; - const template = document.querySelector("#"+subsetRowTemplateId); - if(template) { - subsetRow = template.content.cloneNode(true); - if(subsetRow){ - subsetRow.querySelector("input").setAttribute("name","subsetId-"+subsetId); - subsetRow.querySelector("tr").setAttribute("subsetid",subsetId); - subsetRow.querySelector(".layerName").innerText = subsetName; - if(container) { - container.append(subsetRow); - } - } else { - console.log("Cannot clone DOM element for template with id="+subsetRowTemplateId); - } - } else { - console.log("Cannot create DOM element from template with id="+subsetRowTemplateId); - } - -} // createSubsetRowfromTemplate() - -function createTypeRowFromTemplate(container,typeId,typeName) { - - /* from HTML template in DOM named id='typeRowTpl' - * creates code of type row for parametres typeId, typeName - * and place it on the end of container element - */ - const typeRowTemplateId = "typeRowTpl"; - const MAX_TYPES_NAME_LABEL = "..."; - let typeRow = null; - const template = document.querySelector("#"+typeRowTemplateId); - if(template) { - typeRow = template.content.cloneNode(true); - if(typeRow){ - if(typeName==MAX_TYPES_NAME_LABEL) { - /* remove checkbox for limit threshold */ - elem = typeRow.querySelector("input"); - if(elem) { - elem.parentElement.removeChild(elem); - } - } else { /* type under limit */ - typeRow.querySelector("input").setAttribute("name","typeId-"+typeId); - } - typeRow.querySelector("tr").setAttribute("typeid",typeId); - typeRow.querySelector(".layerName").innerText = typeName; - if(container) { - container.append(typeRow); - } - } else { - console.log("Cannot clone DOM element for template with id="+typeRowTemplateId); - } - } else { - console.log("Cannot create DOM element from template with id="+typeRowTemplateId); - } - -} // createTypeRowFromTemplate() - -/** - * loads rows with sets, subsets & types of annotations from templates - * and pure JSON data from ajax request - */ -function loadAnnotationTypesFromTemplates() { - - // loading all data from ajax service - const serviceName = "annotation_type_tree"; - const getTypesSuccess = function(data) { - - // create rows for sets, subsets and types - if(!data){ return; } - if(data.length==0){ return; } - // element, which holds all rows - const container = $(".annotationTypesTree"); - // remove default content for empty set - $(container).find("tr").remove(); - // array of setId => set_array, - $.each(data,function(setId,setArray){ - const setName = setArray.name; - createSetRowFromTemplate(container,setId,setName); - $.each(setArray,function(subsetId,subsetArray){ - if(subsetId!='name'){ - const subsetName = subsetArray.name; - createSubsetRowFromTemplate(container,subsetId,subsetName); - $.each(subsetArray,function(typeId,typeName){ - if(typeId!='name'){ - createTypeRowFromTemplate(container,typeId,typeName); - }; // typeId<>'name' - }); // each subsetArray - }; // subsetId <> 'name' - }); // each setArray - }); // each data - - }; - const getTypesError = function() { - console.log("Error on ajax request for "+serviceName); - }; - doAjaxSync( serviceName , - { 'corpusId' : corpus_id }, - getTypesSuccess, - getTypesError, - null // getTypesComplete - ); - -} // loadAnnotationTypesFromTemplates() - /** * Przypisanie akcji po wczytaniu się strony. */ $(document).ready(function(){ - loadAnnotationTypesFromTemplates(); + loadAnnotationTypesFromTemplates(corpus_id); wRelationSets = new WidgetRelationSetSelector("#relation-sets", corpus_id); wRelationSets.load(); diff --git a/public_html/js/page_report_relation_agreement.js b/public_html/js/page_report_relation_agreement.js index 8bddba10..1796db88 100644 --- a/public_html/js/page_report_relation_agreement.js +++ b/public_html/js/page_report_relation_agreement.js @@ -9,6 +9,7 @@ var corpus_id = url.param('corpus'); * Przypisanie akcji po wczytaniu się strony. */ $(function(){ + loadAnnotationTypesFromTemplates(corpus_id); assign_click_legend(); assign_annotation_triggers(); assign_more_less(); From c6711df9432275d9464dad5cfb70d55be28e5ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Naskr=C4=99t?= Date: Wed, 13 Jul 2022 13:34:46 +0200 Subject: [PATCH 108/154] fix: service adress http->https --- engine/include/utils/CNlpRest2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/include/utils/CNlpRest2.php b/engine/include/utils/CNlpRest2.php index 9914dcd0..15d785d7 100644 --- a/engine/include/utils/CNlpRest2.php +++ b/engine/include/utils/CNlpRest2.php @@ -6,7 +6,7 @@ class NlpRest2{ var $user; var $verbose=true; - function __construct($task, $url="http://ws.clarin-pl.eu/nlprest2/base", $user="Inforex"){ + function __construct($task, $url="https://ws.clarin-pl.eu/nlprest2/base", $user="Inforex"){ $this->url = $url; $this->task = $task; $this->user = $user; From 2602007dd5393839dee5b466444099400644e0a9 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Tue, 19 Sep 2023 19:36:09 +0200 Subject: [PATCH 109/154] move vendor dir outside classmap dirs --- .gitignore | 2 +- composer.json | 3 +-- docker-compose.yml | 1 + docker-dev-up.sh | 4 ++-- engine/external/pear/HTML/Select.php | 2 +- engine/include.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index d9734d08..108b66b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ engine/templates_c/* -engine/include/vendor +vendor config/config.local.php docker/www/config/config.local.php secured_data/ccls diff --git a/composer.json b/composer.json index c3f6e3c9..500edcf7 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,6 @@ { "config": { - "platform": {"php":"5.6"}, - "vendor-dir": "engine/include/vendor" + "platform": {"php":"5.6"} }, "autoload": { diff --git a/docker-compose.yml b/docker-compose.yml index bdcc6585..de4fb4eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,7 @@ services: - ./docker/www/config:/home/inforex/config - ./secured_data:/home/inforex/secured_data - ./phpunit:/home/inforex/phpunit + - ./vendor:/home/inforex/vendor depends_on: - db restart: always diff --git a/docker-dev-up.sh b/docker-dev-up.sh index 7ce37345..9f940b24 100755 --- a/docker-dev-up.sh +++ b/docker-dev-up.sh @@ -2,7 +2,7 @@ composer update -AUTOLOAD=engine/include/vendor/autoload.php +AUTOLOAD=vendor/autoload.php if [ -f $AUTOLOAD ]; then docker-compose build @@ -10,4 +10,4 @@ if [ -f $AUTOLOAD ]; then else echo -e "[\e[31mERROR\e[0m] $AUTOLOAD not found" echo -e "Make sure that '\e[32mcomposer\e[0m' is installed in order to run '\e[32mcomposer update\e[0m' and generate $AUTOLOAD" -fi \ No newline at end of file +fi diff --git a/engine/external/pear/HTML/Select.php b/engine/external/pear/HTML/Select.php index 47f4bd88..54dce9f1 100644 --- a/engine/external/pear/HTML/Select.php +++ b/engine/external/pear/HTML/Select.php @@ -13,7 +13,7 @@ * @link http://pear.php.net/package/HTML_Select */ -require_once __DIR__ . '/../../../include/vendor/autoload.php'; +require_once __DIR__ . '/../../../../vendor/autoload.php'; /** * Class to dynamically create an HTML SELECT diff --git a/engine/include.php b/engine/include.php index 2c43a4fa..189eba19 100644 --- a/engine/include.php +++ b/engine/include.php @@ -5,4 +5,4 @@ $include_paths[] = get_include_path(); set_include_path( implode(PATH_SEPARATOR, $include_paths) ); -require_once __DIR__ . '/include/vendor/autoload.php'; \ No newline at end of file +require_once __DIR__ . '/../vendor/autoload.php'; From f28b62646952847407111731e8a57d92e286c34d Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Thu, 21 Sep 2023 20:16:12 +0200 Subject: [PATCH 110/154] extract FileWriter class for export --- engine/include/export/ConllAndJsonFactory.php | 26 ++++++----- engine/include/export/FileWriter.php | 27 ++++++++++++ .../engine/include/export/FileWriterTest.php | 44 +++++++++++++++++++ 3 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 engine/include/export/FileWriter.php create mode 100644 phpunit/tests/engine/include/export/FileWriterTest.php diff --git a/engine/include/export/ConllAndJsonFactory.php b/engine/include/export/ConllAndJsonFactory.php index 68c9a4cf..fbd0778d 100644 --- a/engine/include/export/ConllAndJsonFactory.php +++ b/engine/include/export/ConllAndJsonFactory.php @@ -1,10 +1,9 @@ makeConllAndJsonExportData($ccl, $tokens, $relations, $annotations, $tokens_ids, $annotations_by_id); + $fw = new FileWriter(); + $fw->writeTextToFile($file_path_without_ext . ".conll",$conll); + $fw->writeJSONToFile($file_path_without_ext . ".json",$json_builder); - $handle = fopen($file_path_without_ext . ".json", "w"); - fwrite($handle, json_encode($json_builder, JSON_PRETTY_PRINT + JSON_UNESCAPED_UNICODE)); - fclose($handle); - } + } // exportToConllAndJson() -} \ No newline at end of file +} // ConllAndJsonFactory class diff --git a/engine/include/export/FileWriter.php b/engine/include/export/FileWriter.php new file mode 100644 index 00000000..44c6cda0 --- /dev/null +++ b/engine/include/export/FileWriter.php @@ -0,0 +1,27 @@ +writeTextToFile($fileName,$textContent); + + } // writeJSONToFile() + +} // FileWriter class diff --git a/phpunit/tests/engine/include/export/FileWriterTest.php b/phpunit/tests/engine/include/export/FileWriterTest.php new file mode 100644 index 00000000..30a4748b --- /dev/null +++ b/phpunit/tests/engine/include/export/FileWriterTest.php @@ -0,0 +1,44 @@ +virtualDir = org\bovigo\vfs\vfsStream::setup('root',null,[]); + + } // setUp() + + public function test_writeTextToFile() { + + $fileName = $this->virtualDir->url()."/test.txt"; + $text = "jnduie773nd n"; + $fw = new FileWriter(); + $fw->writeTextToFile($fileName,$text); + $result = file_get_contents($fileName); + $this->assertEquals($text,$result); + + } // test_writeTextToFile() + + public function test_writeJSONToFile() { + + $fileName = $this->virtualDir->url()."/test.txt"; + $jsonArray = array('a' => 1); + $fw = new FileWriter(); + $fw->writeJSONToFile($fileName,$jsonArray); + $result = file_get_contents($fileName); + $expected = +'{ + "a": 1 +}'; + $this->assertEquals($expected,$result); + + } // test_writeJSONToFile + +} // FileWriterTest class + +?> From 0ad37de351c6ad31fb36ac0e190e5ed04372b323 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 23 Sep 2023 15:14:47 +0200 Subject: [PATCH 111/154] fix static call of nonstatic method - trouble in testing --- engine/include/export/CorpusExporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/include/export/CorpusExporter.php b/engine/include/export/CorpusExporter.php index 4bcd64a4..d465e18e 100644 --- a/engine/include/export/CorpusExporter.php +++ b/engine/include/export/CorpusExporter.php @@ -568,7 +568,7 @@ protected function export_document($report_id, $extractors, $disamb_only, &$extr $file_path_without_ext = $output_folder . "/" . $ccl->getFileName(); /* Wygeneruj CONLL i JSON */ - ConllAndJsonFactory::exportToConllAndJson($file_path_without_ext, $ccl, $tokens, $relations, $annotations, $tokens_ids, $annotations_by_id); + (new ConllAndJsonFactory())->exportToConllAndJson($file_path_without_ext, $ccl, $tokens, $relations, $annotations, $tokens_ids, $annotations_by_id); /* Wygeneruj xml i rel.xml */ CclFactory::setAnnotationsAndRelations($ccl, $annotations, $relations); From 439281b1894a9a2f5f227ede29e195fb1ee5872d Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Tue, 26 Sep 2023 17:53:04 +0200 Subject: [PATCH 112/154] unit tests for conll i json export --- engine/include/export/ConllAndJsonFactory.php | 3 +- .../export/ConllAndJsonFactoryTest.php | 227 ++++++++++++++++++ 2 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php diff --git a/engine/include/export/ConllAndJsonFactory.php b/engine/include/export/ConllAndJsonFactory.php index fbd0778d..dd516bec 100644 --- a/engine/include/export/ConllAndJsonFactory.php +++ b/engine/include/export/ConllAndJsonFactory.php @@ -2,7 +2,7 @@ class ConllAndJsonFactory { - private function makeConllAndJsonExportData($ccl, $tokens, $relations, $annotations, $tokens_ids, $annotations_by_id) { + protected function makeConllAndJsonExportData($ccl, $tokens, $relations, $annotations, $tokens_ids, $annotations_by_id) { /** * Create a cache for 'token from' to boost processing @@ -154,7 +154,6 @@ private function makeConllAndJsonExportData($ccl, $tokens, $relations, $annotati public function exportToConllAndJson($file_path_without_ext, $ccl, $tokens, $relations, $annotations, $tokens_ids, $annotations_by_id) { - list($conll,$json_builder) = $this->makeConllAndJsonExportData($ccl, $tokens, $relations, $annotations, $tokens_ids, $annotations_by_id); $fw = new FileWriter(); $fw->writeTextToFile($file_path_without_ext . ".conll",$conll); diff --git a/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php b/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php new file mode 100644 index 00000000..3e333577 --- /dev/null +++ b/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php @@ -0,0 +1,227 @@ +virtualDir = org\bovigo\vfs\vfsStream::setup('root',null,[]); + $this->generateFullTestData(); + + } // setUp() + + private function generateReportTestData() { + + // $report = DbReport::getReportById($report_id); + // "SELECT * FROM reports WHERE id = $report_id" + // id,corpora,date,title,source,author,content,type, + // status,user_id,subcorpus_id,tokenization,format_id, + // lang,filename,parent_report_id,deleted + $report = array( "id"=>$this->report_id, "corpora"=>12, + "date"=>'1970-01-01', "title"=>'tytuł', "source"=>'źródło', + "author"=>'Autor', + "content"=>'To jest duże okno. Bardzo duże.', "type"=>1, + "status"=>2, "user_id"=>1, "subcorpus_id"=>null, + "tokenization"=>null, "format_id"=>2, "lang"=>'pol', + "filename"=>'plik.txt', "parent_report_id"=>null, + "deleted"=>0 + ); + return $report; + + } // generateReportTestData() + + private function generateTokensTestData() { + + $report_id = $this->report_id; + // $tokens = DbToken::getTokenByReportId($report_id, null, true); + // "SELECT * FROM tokens LEFT JOIN orths USING (orth_id) WHERE report_id = ? ORDER BY `from`" + // token_id, report_id, from, to, eos, orth_id, orth + $tokens = array( + ["token_id"=>1, "report_id"=>$report_id, "from"=>0, "to"=>1, "eos"=>0, "orth_id"=>1, "orth"=>'To'], + ["token_id"=>2, "report_id"=>$report_id, "from"=>2, "to"=>5, "eos"=>0, "orth_id"=>2, "orth"=>'jest'], + ["token_id"=>3, "report_id"=>$report_id, "from"=>6, "to"=>9, "eos"=>0, "orth_id"=>3, "orth"=>'duże'], + ["token_id"=>4, "report_id"=>$report_id, "from"=>10, "to"=>13, "eos"=>0, "orth_id"=>4, "orth"=>'okno'], + ["token_id"=>5, "report_id"=>$report_id, "from"=>14, "to"=>14, "eos"=>1, "orth_id"=>5, "orth"=>'.'], + ["token_id"=>6, "report_id"=>$report_id, "from"=>15, "to"=>20, "eos"=>0, "orth_id"=>6, "orth"=>'Bardzo'], + ["token_id"=>7, "report_id"=>$report_id, "from"=>21, "to"=>24, "eos"=>0, "orth_id"=>3, "orth"=>'duże'], + ["token_id"=>8, "report_id"=>$report_id, "from"=>25, "to"=>25, "eos"=>1, "orth_id"=>5, "orth"=>'.'] + ); + + return $tokens; + + } // generateTokensTestData() + + private function generateCclTestData() { + + // $report parameter + $report = $this->generateReportTestData(); + // $tokens parameter + $tokens = $this->generateTokensTestData(); + // $tags_by_tokens parameter + $tags_by_tokens = array(); + + $ccl = CclFactory::createFromReportAndTokens($report, $tokens, $tags_by_tokens); + return $ccl; + + } // generateCclTestData() + + private function generateFullTestData() { + + $this->report_id = 1234; + + // $file_path_without_ext parameter + $this->file_path_without_ext = $this->virtualDir->url()."/test"; + + // $ccl parameter + $this->ccl = $this->generateCclTestData(); + + + } // generateFullTestData() + +// tests + + public function testEmptyReportMakesEmptyDataToWrite() { + + // args for call + $report = array(); + $tokens = array(); + $tags_by_tokens = array(); + $ccl = CclFactory::createFromReportAndTokens($report, $tokens, $tags_by_tokens); + $tokens = array(); + $relations = array(); + $annotations = array(); + $tokens_ids = array(); + $annotations_by_id = array(); + + // invoke protected method + $protectedMethod = new ReflectionMethod('ConllAndJsonFactory','makeConllAndJsonExportData'); + $protectedMethod->setAccessible(True); + list($conll,$json_builder) = $protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + + // check results + $expectedConll = "ORDER_ID\tTOKEN_ID\tORTH\tCTAG\tFROM\tTO\tANN_TAGS\tANN_IDS\tREL_IDS\tREL_TARGET_ANN_IDS\n"; + $this->assertEquals($expectedConll,$conll); + + $expectedJson = array( + "chunks" => array( + array() + ), + "relations" => array(), + "annotations" => array() + ); + $this->assertEquals($expectedJson,$json_builder); + + } // testEmptyReportMakesEmptyDataToWrite() + + public function testAllDataPlacesToDataConllAndJsonStructures() { + + // args for call + $tokens = array(); + + // DbToken::getTokenByReportId($report_id, null, true); + $relations = array(); + $annotations = array(); + $tokens_ids = array(); + $annotations_by_id = array(); + + // invoke protected method + $protectedMethod = new ReflectionMethod('ConllAndJsonFactory','makeConllAndJsonExportData'); + $protectedMethod->setAccessible(True); + list($conll,$json_builder) = $protectedMethod->invoke(new ConllAndJsonFactory(),$this->ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + + // check results + $expectedConll = "ORDER_ID\tTOKEN_ID\tORTH\tCTAG\tFROM\tTO\tANN_TAGS\tANN_IDS\tREL_IDS\tREL_TARGET_ANN_IDS\n"; + $expectedConll .= "0\t0\tTo\t\t0\t1\tO\t_\t_\t_\n". + "1\t1\tjest\t\t2\t5\tO\t_\t_\t_\n". + "2\t2\tduże\t\t6\t9\tO\t_\t_\t_\n". + "3\t3\tokno\t\t10\t13\tO\t_\t_\t_\n". + "4\t4\t.\t\t14\t14\tO\t_\t_\t_\n". + "\n". + "5\t0\tBardzo\t\t15\t20\tO\t_\t_\t_\n". + "6\t1\tduże\t\t21\t24\tO\t_\t_\t_\n". + "7\t2\t.\t\t25\t25\tO\t_\t_\t_\n". + "\n"; + $this->assertEquals($expectedConll,$conll); + + $expectedJson = array( + "chunks" => array( + array( + array( + array('order_id' => 0,'token_id' => 0,'orth' => 'To','ctag' => null,'from' => 0,'to' => 1,'annotations' => array(),'relations' => array()), + array('order_id' => 1,'token_id' => 1,'orth' => 'jest','ctag' => null,'from' => 2,'to' => 5,'annotations' => array(),'relations' => array()), + array('order_id' => 2,'token_id' => 2,'orth' => 'duże','ctag' => null,'from' => 6,'to' => 9,'annotations' => array(),'relations' => array()), + array('order_id' => 3,'token_id' => 3,'orth' => 'okno','ctag' => null,'from' => 10,'to' => 13,'annotations' => array(),'relations' => array()), + array('order_id' => 4,'token_id' => 4,'orth' => '.','ctag' => null,'from' => 14,'to' => 14,'annotations' => array(),'relations' => array()) + ), + array( + array('order_id' => 5,'token_id' => 0,'orth' => 'Bardzo','ctag' => null,'from' => 15,'to' => 20,'annotations' => array(),'relations' => array()), + array('order_id' => 6,'token_id' => 1,'orth' => 'duże','ctag' => null,'from' => 21,'to' => 24,'annotations' => array(),'relations' => array()), + array('order_id' => 7,'token_id' => 2,'orth' => '.','ctag' => null,'from' => 25,'to' => 25,'annotations' => array(),'relations' => array()) + ) + ) + ), + "relations" => array(), + "annotations" => array() + ); + $this->assertEquals($expectedJson,$json_builder); + + } // testAllDataPlacesToDataConllAndJsonStructures() + +/* class ConllAndJsonFactory has only 1 function + function exportToConllAndJson($file_path_without_ext, $ccl, $tokens, $relations, $annotations, $tokens_ids, $annotations_by_id) +*/ + + public function testDeliveredDataAreWrittenToFiles() { + + $conll = "jakiś text"; + $json_builder = array("a"=>1); + + // this values doesn't matter + $report = array(); + $tokens = array(); + $tags_by_tokens = array(); + $ccl = CclFactory::createFromReportAndTokens($report, $tokens, $tags_by_tokens); + $tokens = array(); + $relations = array(); + $annotations = array(); + $tokens_ids = array(); + $annotations_by_id = array(); + + // self-mocking another method + $mockedMethodNamesList = array('makeConllAndJsonExportData'); + $mockedResult = array($conll,$json_builder); + $mock = $this->getMockBuilder(ConllAndJsonFactory::class) + -> setMethods($mockedMethodNamesList) // ustawia je na null + -> getMock(); + $mock // i mockuje na zwracanie określonego rezultatu + -> method('makeConllAndJsonExportData') + -> will($this->returnValue($mockedResult)); + + // metoda exportToConllAndJson() powinna zachować obsługę oryginalną + $mock->exportToConllAndJson($this->file_path_without_ext,$this->ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + + $expectedConll = $conll; + $conllFileName = $this->file_path_without_ext.".conll"; + $resultConll = file_get_contents($conllFileName); + $this->assertEquals($expectedConll,$resultConll); + $expectedJson = +'{ + "a": 1 +}'; + $jsonFileName = $this->file_path_without_ext.".json"; + $resultJson = file_get_contents($jsonFileName); + $this->assertEquals($expectedJson,$resultJson); + + } // testDeliveredDataAreWrittenToFiles + +} // ConllAndJsonFactoryTest class + +?> From e49806ff8f82fd1a4c95625dd486daf1a1e8b40c Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Wed, 4 Oct 2023 12:57:06 +0200 Subject: [PATCH 113/154] unit tests with tokens, annotations, relations, lemmas and attributes --- .../export/ConllAndJsonFactoryTest.php | 310 ++++++++++++++---- 1 file changed, 254 insertions(+), 56 deletions(-) diff --git a/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php b/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php index 3e333577..d312a7aa 100644 --- a/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php +++ b/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php @@ -8,18 +8,29 @@ class ConllAndJsonFactoryTest extends PHPUnit_Framework_TestCase { private $virtualDir = null; // data for test private $report_id = null; + private $ccl = null; + private $tokens = null; + private $tokens_ids = null; // data for class method private $file_path_without_ext = null; + // reflection to protected method in tested class + private $protectedMethod = null; protected function setUp() { $this->virtualDir = org\bovigo\vfs\vfsStream::setup('root',null,[]); $this->generateFullTestData(); + // protected method to invoke in all tests + $this->protectedMethod = new ReflectionMethod('ConllAndJsonFactory','makeConllAndJsonExportData'); + $this->protectedMethod->setAccessible(True); } // setUp() - private function generateReportTestData() { + private function generateReportTestData($report_id=1234) { + if(!$this->report_id) { + $this->report_id = $report_id; + } // $report = DbReport::getReportById($report_id); // "SELECT * FROM reports WHERE id = $report_id" // id,corpora,date,title,source,author,content,type, @@ -38,8 +49,12 @@ private function generateReportTestData() { } // generateReportTestData() - private function generateTokensTestData() { + private function generateTokensTestData($report_id=1234) { + if(!$this->report_id) { + $this->report_id = $report_id; + } + $report_id = $this->report_id; // $tokens = DbToken::getTokenByReportId($report_id, null, true); // "SELECT * FROM tokens LEFT JOIN orths USING (orth_id) WHERE report_id = ? ORDER BY `from`" @@ -59,12 +74,127 @@ private function generateTokensTestData() { } // generateTokensTestData() - private function generateCclTestData() { + private function getExpectedConllHeader() { + // static header for all CONLL files + return "ORDER_ID\tTOKEN_ID\tORTH\tCTAG\tFROM\tTO\tANN_TAGS\tANN_IDS\tREL_IDS\tREL_TARGET_ANN_IDS\n"; + } // + + private function getExpectedConll() { + // expected Conll pattern for our data and not annotations + $expectedConll = $this->getExpectedConllHeader(); + $expectedConll .= "0\t0\tTo\t\t0\t1\tO\t_\t_\t_\n". + "1\t1\tjest\t\t2\t5\tO\t_\t_\t_\n". + "2\t2\tduże\t\t6\t9\tO\t_\t_\t_\n". + //"2\t2\tduże\t\t6\t9\tB-\t1\t_\t_\n". + //"2\t2\tduże\t\t6\t9\tB-nam_adj\t1\t_\t_\n". + "3\t3\tokno\t\t10\t13\tO\t_\t_\t_\n". + "4\t4\t.\t\t14\t14\tO\t_\t_\t_\n". + "\n". + "5\t0\tBardzo\t\t15\t20\tO\t_\t_\t_\n". + "6\t1\tduże\t\t21\t24\tO\t_\t_\t_\n". + "7\t2\t.\t\t25\t25\tO\t_\t_\t_\n". + "\n"; + return $expectedConll; + } // getExpectedConll() + + private function getExpectedEmptyJson() { + + return array( + "chunks" => array( + array() + ), + "relations" => array(), + "annotations" => array() + ); + + } // getExpectedEmptyJson() + + private function getExpectedChunks() { + // returns "chunks" section in expected table for JSON + // for our data without annotations + $chunks = array( + array( + array( + array('order_id' => 0,'token_id' => 0,'orth' => 'To','ctag' => null,'from' => 0,'to' => 1,'annotations' => array(),'relations' => array()), + array('order_id' => 1,'token_id' => 1,'orth' => 'jest','ctag' => null,'from' => 2,'to' => 5,'annotations' => array(),'relations' => array()), + array('order_id' => 2,'token_id' => 2,'orth' => 'duże','ctag' => null,'from' => 6,'to' => 9,'annotations' => array(),'relations' => array()), + array('order_id' => 3,'token_id' => 3,'orth' => 'okno','ctag' => null,'from' => 10,'to' => 13,'annotations' => array(),'relations' => array()), + array('order_id' => 4,'token_id' => 4,'orth' => '.','ctag' => null,'from' => 14,'to' => 14,'annotations' => array(),'relations' => array()) + ), + array( + array('order_id' => 5,'token_id' => 0,'orth' => 'Bardzo','ctag' => null,'from' => 15,'to' => 20,'annotations' => array(),'relations' => array()), + array('order_id' => 6,'token_id' => 1,'orth' => 'duże','ctag' => null,'from' => 21,'to' => 24,'annotations' => array(),'relations' => array()), + array('order_id' => 7,'token_id' => 2,'orth' => '.','ctag' => null,'from' => 25,'to' => 25,'annotations' => array(),'relations' => array()) + ) + ) + ); + return $chunks; + } // getExpectedChunks + + private function generateAnnotation_By_IdTestData( + $annotationExtractorFields=true, + $annotationsWithLemmaField=true, + $annotationsWithTypeAttributte=true + ) { + + $annotation_id = 1; + // index must match 'id' field + $annotations_by_id = array( + $annotation_id => array( 'id'=>$annotation_id, + // fields, that always exists + // only 'to' changes business logic + 'report_id'=>1,'type_id'=>360,'from'=>6,'to'=>9,'text'=>'duże','user_id'=>1,'creation_time'=>'2022-10-03 08:07:37','stage'=>'final','source'=>'user','annotation_subset_id'=>'52', + // this are always, but from different tables + 'type'=>'nam_adj','group_id'=>1, + ) + + ); + if($annotationExtractorFields) { + // fields, that exists for extractor 'annotation' only + $annotations_by_id[$annotation_id]['login']='admin'; + $annotations_by_id[$annotation_id]['screename']='Inforex Admin'; + if($annotationsWithLemmaField){ + $annotations_by_id[$annotation_id]['lemma']='lemat dodany do duże'; + } else { + $annotations_by_id[$annotation_id]['lemma']=null; + } + } else { + // fields, that exists for extractors 'annotation_id' + // and 'annotation_subset_id' only + $annotations_by_id[$annotation_id]['group']=1; + $annotations_by_id[$annotation_id]['name']='nam_adj'; + $annotations_by_id[$annotation_id]['description']='Przymiotnik utworzony od nazwy własnej'; + $annotations_by_id[$annotation_id]['css']='background: lightgreen;'; + $annotations_by_id[$annotation_id]['cross_sentence']='0'; + $annotations_by_id[$annotation_id]['shortlist']='0'; + // this section only for simple extractor with attribute in DB + if($annotationsWithTypeAttributte) { + $annotations_by_id[$annotation_id]['annotation_id']=$annotation_id; + $annotations_by_id[$annotation_id]['annotation_attribute_id']=1; + $annotations_by_id[$annotation_id]['value']='valueAtrTypu'; + $annotations_by_id[$annotation_id]['prop']='valueAtrTypu'; + } + } + + return $annotations_by_id; + + } // generateAnnotation_By_IdTestData() + + private function generateAnnotationsFromAnnotations_By_Id(array $annotations_by_id) { + return array_values($annotations_by_id); + + } // generateAnnotationsFromAnnotations_By_Id + + private function generateCclTestData($report=null,$tokens=null) { // $report parameter - $report = $this->generateReportTestData(); + if($report==null){ + $report = $this->generateReportTestData(); + } // $tokens parameter - $tokens = $this->generateTokensTestData(); + if($tokens==null){ + $tokens = $this->generateTokensTestData(); + } // $tags_by_tokens parameter $tags_by_tokens = array(); @@ -80,8 +210,16 @@ private function generateFullTestData() { // $file_path_without_ext parameter $this->file_path_without_ext = $this->virtualDir->url()."/test"; + // $report parameter, local for CCL only + $report = $this->generateReportTestData(); + + // $tokens parameter + $this->tokens = $this->generateTokensTestData($this->report_id); + // tak jest ustawiane zawsze w CorpusExporter + $this->tokens_ids = array_column($this->tokens, 'token_id'); + // $ccl parameter - $this->ccl = $this->generateCclTestData(); + $this->ccl = $this->generateCclTestData($report,$this->tokens); } // generateFullTestData() @@ -90,6 +228,7 @@ private function generateFullTestData() { public function testEmptyReportMakesEmptyDataToWrite() { + // all empty input data generates minimal export output // args for call $report = array(); $tokens = array(); @@ -101,80 +240,139 @@ public function testEmptyReportMakesEmptyDataToWrite() { $tokens_ids = array(); $annotations_by_id = array(); - // invoke protected method - $protectedMethod = new ReflectionMethod('ConllAndJsonFactory','makeConllAndJsonExportData'); - $protectedMethod->setAccessible(True); - list($conll,$json_builder) = $protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + // invoke tested method + list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); // check results - $expectedConll = "ORDER_ID\tTOKEN_ID\tORTH\tCTAG\tFROM\tTO\tANN_TAGS\tANN_IDS\tREL_IDS\tREL_TARGET_ANN_IDS\n"; - $this->assertEquals($expectedConll,$conll); - - $expectedJson = array( - "chunks" => array( - array() - ), - "relations" => array(), - "annotations" => array() - ); - $this->assertEquals($expectedJson,$json_builder); + $this->assertEquals($this->getExpectedConllHeader(),$conll); + $this->assertEquals($this->getExpectedEmptyJson(),$json_builder); } // testEmptyReportMakesEmptyDataToWrite() - public function testAllDataPlacesToDataConllAndJsonStructures() { + public function testReportArrayFieldsMakesEmptyDataToWrite() { + + // any content of $report array doesn't generate nonempty output // args for call $tokens = array(); - - // DbToken::getTokenByReportId($report_id, null, true); + $tags_by_tokens = array(); $relations = array(); $annotations = array(); $tokens_ids = array(); $annotations_by_id = array(); - // invoke protected method - $protectedMethod = new ReflectionMethod('ConllAndJsonFactory','makeConllAndJsonExportData'); - $protectedMethod->setAccessible(True); - list($conll,$json_builder) = $protectedMethod->invoke(new ConllAndJsonFactory(),$this->ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + // test only 'id' field + $report = array('id'=>1234); + $ccl = CclFactory::createFromReportAndTokens($report, $tokens, $tags_by_tokens); + list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + $this->assertEquals($this->getExpectedConllHeader(),$conll); + $this->assertEquals($this->getExpectedEmptyJson(),$json_builder); + + // test only 'content' field + $report = array('content'=>'jakiś tekst'); + $ccl = CclFactory::createFromReportAndTokens($report, $tokens, $tags_by_tokens); + + list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + $this->assertEquals($this->getExpectedConllHeader(),$conll); + $this->assertEquals($this->getExpectedEmptyJson(),$json_builder); + + // test any other field in $report + $report = array('id'=>1234, + 'content'=>'jakiś tekst', + 'other_report_field'=>'other field text'); + $ccl = CclFactory::createFromReportAndTokens($report, $tokens, $tags_by_tokens); + list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + $this->assertEquals($this->getExpectedConllHeader(),$conll); + $this->assertEquals($this->getExpectedEmptyJson(),$json_builder); + + } // testReportArrayFieldsMakesEmptyDataToWrite() + + public function testAllDataPlacesToDataConllAndJsonStructures() { + + // args for call + $relations = array(); + $annotations_by_id = $this->generateAnnotation_By_IdTestData(False,True); + $annotations = $this->generateAnnotationsFromAnnotations_By_Id($annotations_by_id); + + // invoke tested method + list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$this->ccl,$this->tokens,$relations,$annotations,$this->tokens_ids,$annotations_by_id); // check results - $expectedConll = "ORDER_ID\tTOKEN_ID\tORTH\tCTAG\tFROM\tTO\tANN_TAGS\tANN_IDS\tREL_IDS\tREL_TARGET_ANN_IDS\n"; - $expectedConll .= "0\t0\tTo\t\t0\t1\tO\t_\t_\t_\n". - "1\t1\tjest\t\t2\t5\tO\t_\t_\t_\n". - "2\t2\tduże\t\t6\t9\tO\t_\t_\t_\n". - "3\t3\tokno\t\t10\t13\tO\t_\t_\t_\n". - "4\t4\t.\t\t14\t14\tO\t_\t_\t_\n". - "\n". - "5\t0\tBardzo\t\t15\t20\tO\t_\t_\t_\n". - "6\t1\tduże\t\t21\t24\tO\t_\t_\t_\n". - "7\t2\t.\t\t25\t25\tO\t_\t_\t_\n". - "\n"; + $expectedConll = $this->getExpectedConll(); + $expectedConll = str_replace( + "2\t2\tduże\t\t6\t9\tO\t_\t_\t_\n", + "2\t2\tduże\t\t6\t9\tB-nam_adj\t1\t_\t_\n", + $expectedConll); $this->assertEquals($expectedConll,$conll); + $expectedChunks = $this->getExpectedChunks(); + // annotation_id to 'annotations' list in 3-rd chunk + $expectedChunks[0][0][2]['annotations'][] = 1; $expectedJson = array( - "chunks" => array( - array( - array( - array('order_id' => 0,'token_id' => 0,'orth' => 'To','ctag' => null,'from' => 0,'to' => 1,'annotations' => array(),'relations' => array()), - array('order_id' => 1,'token_id' => 1,'orth' => 'jest','ctag' => null,'from' => 2,'to' => 5,'annotations' => array(),'relations' => array()), - array('order_id' => 2,'token_id' => 2,'orth' => 'duże','ctag' => null,'from' => 6,'to' => 9,'annotations' => array(),'relations' => array()), - array('order_id' => 3,'token_id' => 3,'orth' => 'okno','ctag' => null,'from' => 10,'to' => 13,'annotations' => array(),'relations' => array()), - array('order_id' => 4,'token_id' => 4,'orth' => '.','ctag' => null,'from' => 14,'to' => 14,'annotations' => array(),'relations' => array()) - ), - array( - array('order_id' => 5,'token_id' => 0,'orth' => 'Bardzo','ctag' => null,'from' => 15,'to' => 20,'annotations' => array(),'relations' => array()), - array('order_id' => 6,'token_id' => 1,'orth' => 'duże','ctag' => null,'from' => 21,'to' => 24,'annotations' => array(),'relations' => array()), - array('order_id' => 7,'token_id' => 2,'orth' => '.','ctag' => null,'from' => 25,'to' => 25,'annotations' => array(),'relations' => array()) - ) - ) - ), + "chunks" => $expectedChunks, "relations" => array(), - "annotations" => array() + "annotations" => array( + array('id'=>1,'report_id'=>1,'type_id'=>360,'from'=>6,'to'=>9, + 'text' => 'duże','user_id' => 1, + 'creation_time' => '2022-10-03 08:07:37','stage' => 'final', + 'source' => 'user','annotation_subset_id' => '52', + 'type'=>'nam_adj','group_id'=>1, +/* + 'login' => 'admin','screename' => 'Inforex Admin', + 'lemma' => 'lemat dodany do duże', +*/ + 'group' => 1,'description' => 'Przymiotnik utworzony od nazwy własnej','css' => 'background: lightgreen;','cross_sentence' => '0','shortlist' => '0', + 'name'=>'nam_adj', + // tylko jeśli istnieje atrybut + 'annotation_id' => 1,'annotation_attribute_id' => 1,'value' => 'valueAtrTypu','prop' => 'valueAtrTypu' + ), + ) ); $this->assertEquals($expectedJson,$json_builder); } // testAllDataPlacesToDataConllAndJsonStructures() + public function testDocumentWithoutTokenizationPlaceDataToJsonAndConllArray() { + // CCL is self-tokenized by constructor + // args for call + $tokens = array(); + // tak jest ustawiane zawsze w CorpusExporter + $tokens_ids = array_column($tokens, 'token_id'); + $ccl = $this->generateCclTestData( + $this->generateReportTestData(),$tokens); + $relations = array(); + $annotations = array(); + $annotations_by_id = array(); + + // invoke tested method + list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + + // check results + $this->assertEquals($this->getExpectedConll(),$conll); + + $expectedJson = $this->getExpectedEmptyJson(); + $expectedJson["chunks"] = $this->getExpectedChunks(); + $this->assertEquals($expectedJson,$json_builder); + + // with tokens without annotations there are all the same as above + + // invoke tested method + list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$this->ccl,$this->tokens,$relations,$annotations,$this->tokens_ids,$annotations_by_id); + + $this->assertEquals($this->getExpectedConll(),$conll); + $this->assertEquals($expectedJson,$json_builder); + + } // testDocumentWithoutTokenizationPlaceDataToJsonAndConllArray() + + public function testGeneralAnnotationFieldsPlacedToJsonAndConllArray() { + + // are all fields which always should be present in annotation + // record placed correctly to JSON and CONLL structures + + $this->assertTrue(True); + + } // testGeneralAnnotationFieldsPlacedToJsonAndConllArray + /* class ConllAndJsonFactory has only 1 function function exportToConllAndJson($file_path_without_ext, $ccl, $tokens, $relations, $annotations, $tokens_ids, $annotations_by_id) */ From 15a5e7149fdaf957e0b4d760b71106044aeb7427 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Sat, 7 Oct 2023 18:54:46 +0200 Subject: [PATCH 114/154] mocked all Ccl input clases for tests --- .../export/ConllAndJsonFactoryTest.php | 111 +++++++----------- 1 file changed, 43 insertions(+), 68 deletions(-) diff --git a/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php b/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php index d312a7aa..61cc6240 100644 --- a/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php +++ b/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php @@ -185,24 +185,6 @@ private function generateAnnotationsFromAnnotations_By_Id(array $annotations_by_ } // generateAnnotationsFromAnnotations_By_Id - private function generateCclTestData($report=null,$tokens=null) { - - // $report parameter - if($report==null){ - $report = $this->generateReportTestData(); - } - // $tokens parameter - if($tokens==null){ - $tokens = $this->generateTokensTestData(); - } - // $tags_by_tokens parameter - $tags_by_tokens = array(); - - $ccl = CclFactory::createFromReportAndTokens($report, $tokens, $tags_by_tokens); - return $ccl; - - } // generateCclTestData() - private function generateFullTestData() { $this->report_id = 1234; @@ -210,35 +192,68 @@ private function generateFullTestData() { // $file_path_without_ext parameter $this->file_path_without_ext = $this->virtualDir->url()."/test"; - // $report parameter, local for CCL only - $report = $this->generateReportTestData(); - // $tokens parameter $this->tokens = $this->generateTokensTestData($this->report_id); // tak jest ustawiane zawsze w CorpusExporter $this->tokens_ids = array_column($this->tokens, 'token_id'); // $ccl parameter - $this->ccl = $this->generateCclTestData($report,$this->tokens); - + $this->ccl = $this->generateFullCclData(); } // generateFullTestData() + private function makeMockToken($id,$orth,$lexemes,$from,$to) { + + $mockToken = $this->getMockBuilder(CclToken::class)->getMock(); + $mockToken->id = $id; + $mockToken->orth = $orth; + $mockToken->lexemes = $lexemes; + $mockToken->from = $from; + $mockToken->to = $to; + return $mockToken; + + } // makeMockToken + + private function generateFullCclData() { + + // mocked $ccl argument for empty report + $mockToken11 = $this->makeMockToken(0,"To",array(),0,1); + $mockToken12 = $this->makeMockToken(1,"jest",array(),2,5); + $mockToken13 = $this->makeMockToken(2,"duże",array(),6,9); + $mockToken14 = $this->makeMockToken(3,"okno",array(),10,13); + $mockToken15 = $this->makeMockToken(4,".",array(),14,14); + $mockSentence1 = $this->getMockBuilder(CclSentence::class)->getMock(); + $mockSentence1->tokens = array($mockToken11,$mockToken12,$mockToken13,$mockToken14,$mockToken15); + $mockToken21 = $this->makeMockToken(5,"Bardzo",array(),15,20); + $mockToken22 = $this->makeMockToken(6,"duże",array(),21,24); + $mockToken23 = $this->makeMockToken(7,".",array(),25,25); + $mockSentence2 = $this->getMockBuilder(CclSentence::class)->getMock(); + $mockSentence2->tokens = array($mockToken21,$mockToken22,$mockToken23); + $mockChunk = $this->getMockBuilder(CclChunk::class)->getMock(); + $mockChunk->sentences = array($mockSentence1,$mockSentence2); + $mockCclDocument = $this->getMockBuilder(CclDocument::class)->getMock(); + $mockCclDocument->chunks = array($mockChunk); + return $mockCclDocument; + + } // generateFullCclData() + // tests public function testEmptyReportMakesEmptyDataToWrite() { // all empty input data generates minimal export output // args for call - $report = array(); - $tokens = array(); - $tags_by_tokens = array(); - $ccl = CclFactory::createFromReportAndTokens($report, $tokens, $tags_by_tokens); $tokens = array(); $relations = array(); $annotations = array(); $tokens_ids = array(); $annotations_by_id = array(); + // mocked $ccl argument for empty report + $mockChunk = $this->getMockBuilder(CclChunk::class)->getMock(); + $mockChunk->sentences = array(); + $mockCclDocument = $this->getMockBuilder(CclDocument::class)->getMock(); + $mockCclDocument->chunks = array($mockChunk); + $ccl = $mockCclDocument; // invoke tested method list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); @@ -249,44 +264,6 @@ public function testEmptyReportMakesEmptyDataToWrite() { } // testEmptyReportMakesEmptyDataToWrite() - public function testReportArrayFieldsMakesEmptyDataToWrite() { - - // any content of $report array doesn't generate nonempty output - - // args for call - $tokens = array(); - $tags_by_tokens = array(); - $relations = array(); - $annotations = array(); - $tokens_ids = array(); - $annotations_by_id = array(); - - // test only 'id' field - $report = array('id'=>1234); - $ccl = CclFactory::createFromReportAndTokens($report, $tokens, $tags_by_tokens); - list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); - $this->assertEquals($this->getExpectedConllHeader(),$conll); - $this->assertEquals($this->getExpectedEmptyJson(),$json_builder); - - // test only 'content' field - $report = array('content'=>'jakiś tekst'); - $ccl = CclFactory::createFromReportAndTokens($report, $tokens, $tags_by_tokens); - - list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); - $this->assertEquals($this->getExpectedConllHeader(),$conll); - $this->assertEquals($this->getExpectedEmptyJson(),$json_builder); - - // test any other field in $report - $report = array('id'=>1234, - 'content'=>'jakiś tekst', - 'other_report_field'=>'other field text'); - $ccl = CclFactory::createFromReportAndTokens($report, $tokens, $tags_by_tokens); - list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); - $this->assertEquals($this->getExpectedConllHeader(),$conll); - $this->assertEquals($this->getExpectedEmptyJson(),$json_builder); - - } // testReportArrayFieldsMakesEmptyDataToWrite() - public function testAllDataPlacesToDataConllAndJsonStructures() { // args for call @@ -338,14 +315,12 @@ public function testDocumentWithoutTokenizationPlaceDataToJsonAndConllArray() { $tokens = array(); // tak jest ustawiane zawsze w CorpusExporter $tokens_ids = array_column($tokens, 'token_id'); - $ccl = $this->generateCclTestData( - $this->generateReportTestData(),$tokens); $relations = array(); $annotations = array(); $annotations_by_id = array(); // invoke tested method - list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$this->ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); // check results $this->assertEquals($this->getExpectedConll(),$conll); From 0f56fd7e69f217ef5b653ae1a0337292c264a825 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Mon, 9 Oct 2023 19:01:59 +0200 Subject: [PATCH 115/154] export unit tests for elementary Ccl elements --- .../export/ConllAndJsonFactoryTest.php | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php b/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php index 61cc6240..2af10178 100644 --- a/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php +++ b/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php @@ -264,6 +264,116 @@ public function testEmptyReportMakesEmptyDataToWrite() { } // testEmptyReportMakesEmptyDataToWrite() + public function testOneEmptySentenceCclReportMakesLinesWithNoData() { + + // only 1 empty sentence in 1 chunk in Ccl + // args for call + $tokens = array(); + $relations = array(); + $annotations = array(); + $tokens_ids = array(); + $annotations_by_id = array(); + // mocked $ccl argument for empty report + $mockSentence = $this->getMockBuilder(CclSentence::class)->getMock(); + $mockSentence->tokens = array(); + $mockChunk = $this->getMockBuilder(CclChunk::class)->getMock(); + $mockChunk->sentences = array($mockSentence); + $mockCclDocument = $this->getMockBuilder(CclDocument::class)->getMock(); + $mockCclDocument->chunks = array($mockChunk); + $ccl = $mockCclDocument; + + // invoke tested method + list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + + // check results + // empty sentence generates one empty line in export CONLL + $expectedConll = $this->getExpectedConllHeader()."\n"; + $this->assertEquals($expectedConll,$conll); + $expectedJson = $this->getExpectedEmptyJson(); + // empty sentence generates one empty array in export JSON + $expectedJson['chunks'][0][] = array(); + $this->assertEquals($expectedJson,$json_builder); + + } // testOneEmptySentenceCclReportMakesLinesWithNoData() + + public function testOneEmptyTokenCclReportMakesTokenWithEmptyData() { + + // only 1 sentence with 1 empty token in 1 chunk in Ccl + // args for call + $tokens = array(); + $relations = array(); + $annotations = array(); + $tokens_ids = array(); + $annotations_by_id = array(); + // mocked $ccl argument for empty report + $mockToken = $this->getMockBuilder(CclToken::class)->getMock(); + $mockSentence = $this->getMockBuilder(CclSentence::class)->getMock(); + $mockSentence->tokens = array($mockToken); + $mockChunk = $this->getMockBuilder(CclChunk::class)->getMock(); + $mockChunk->sentences = array($mockSentence); + $mockCclDocument = $this->getMockBuilder(CclDocument::class)->getMock(); + $mockCclDocument->chunks = array($mockChunk); + $ccl = $mockCclDocument; + + // invoke tested method + list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + + // check results + // empty token generates row with empty data in export CONLL + $expectedConll = $this->getExpectedConllHeader() + ."\t0\t\t\t\t\tO\t_\t_\t_\n" + ."\n"; + $this->assertEquals($expectedConll,$conll); + // empty token generates one token array in sentence with export + // dummy data in JSON & also creates annotations and relations arrays + $emptyTokenData = array('order_id' => null,'token_id' => 0,'orth' => null,'ctag' => null,'from' => null,'to' => null,'annotations' => Array (),'relations' => Array ()); + $expectedJson['chunks'][0][] = array($emptyTokenData); + // if any token exist, must be annotations & relations tables in JSON + $expectedJson["annotations"] = array(); + $expectedJson["relations"] = array(); + $this->assertEquals($expectedJson,$json_builder); + + } // testOneEmptyTokenCclReportMakesTokenWithEmptyData() + + public function testOneTokenCclMakesNonemptyDataToWrite() { + + // minimal set - 1 sentence with 1 normal token in 1 chunk in Ccl + // args for call + $tokens = array(); + $relations = array(); + $annotations = array(); + $tokens_ids = array(); + $annotations_by_id = array(); + // mocked $ccl argument for empty report + $mockToken = $this->makeMockToken(0,"To",array(),0,1); + $mockSentence = $this->getMockBuilder(CclSentence::class)->getMock(); + $mockSentence->tokens = array($mockToken); + $mockChunk = $this->getMockBuilder(CclChunk::class)->getMock(); + $mockChunk->sentences = array($mockSentence); + $mockCclDocument = $this->getMockBuilder(CclDocument::class)->getMock(); + $mockCclDocument->chunks = array($mockChunk); + $ccl = $mockCclDocument; + + // invoke tested method + list($conll,$json_builder) = $this->protectedMethod->invoke(new ConllAndJsonFactory(),$ccl,$tokens,$relations,$annotations,$tokens_ids,$annotations_by_id); + + // check results + // simple token generates row with its data in export CONLL + $expectedConll = $this->getExpectedConllHeader() + ."0\t0\tTo\t\t0\t1\tO\t_\t_\t_\n" + ."\n"; + $this->assertEquals($expectedConll,$conll); + // one token generates token array with data in sentence array + // & also creates annotations and relations arrays in export JSON + $emptyTokenData = array('order_id' => 0,'token_id' => 0,'orth' => 'To','ctag' => null,'from' => 0,'to' => 1,'annotations' => Array (),'relations' => Array ()); + $expectedJson['chunks'][0][] = array($emptyTokenData); + // if any token exist, must be annotations & relations tables in JSON + $expectedJson["annotations"] = array(); + $expectedJson["relations"] = array(); + $this->assertEquals($expectedJson,$json_builder); + + } // testOneTokenCclMakesNonemptyDataToWrite + public function testAllDataPlacesToDataConllAndJsonStructures() { // args for call From 6da0801786ea251f3e681aa8bb4e46857b0424d7 Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Thu, 12 Oct 2023 08:17:19 +0200 Subject: [PATCH 116/154] unit test for export with relation --- .../export/ConllAndJsonFactoryTest.php | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php b/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php index 2af10178..b0460fef 100644 --- a/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php +++ b/phpunit/tests/engine/include/export/ConllAndJsonFactoryTest.php @@ -372,12 +372,23 @@ public function testOneTokenCclMakesNonemptyDataToWrite() { $expectedJson["relations"] = array(); $this->assertEquals($expectedJson,$json_builder); - } // testOneTokenCclMakesNonemptyDataToWrite + } // testOneTokenCclMakesNonemptyDataToWrite() public function testAllDataPlacesToDataConllAndJsonStructures() { // args for call $relations = array(); + $relationData = array( + 'report_id' => '1', + 'id' => '1', + 'relation_type_id' => '1', + 'source_id' => '1', + 'target_id' => '2', + 'relation_set_id' => '1', + 'name' => 'test', + 'rsname' => 'test', + ); + $relations = array( $relationData ); $annotations_by_id = $this->generateAnnotation_By_IdTestData(False,True); $annotations = $this->generateAnnotationsFromAnnotations_By_Id($annotations_by_id); @@ -388,16 +399,19 @@ public function testAllDataPlacesToDataConllAndJsonStructures() { $expectedConll = $this->getExpectedConll(); $expectedConll = str_replace( "2\t2\tduże\t\t6\t9\tO\t_\t_\t_\n", - "2\t2\tduże\t\t6\t9\tB-nam_adj\t1\t_\t_\n", + "2\t2\tduże\t\t6\t9\tB-nam_adj\t1\t1\t2\n", $expectedConll); $this->assertEquals($expectedConll,$conll); $expectedChunks = $this->getExpectedChunks(); // annotation_id to 'annotations' list in 3-rd chunk $expectedChunks[0][0][2]['annotations'][] = 1; + $expectedChunks[0][0][2]['relations'][0] = 1; $expectedJson = array( "chunks" => $expectedChunks, - "relations" => array(), + "relations" => array( + $relationData + ), "annotations" => array( array('id'=>1,'report_id'=>1,'type_id'=>360,'from'=>6,'to'=>9, 'text' => 'duże','user_id' => 1, @@ -468,10 +482,6 @@ public function testDeliveredDataAreWrittenToFiles() { $json_builder = array("a"=>1); // this values doesn't matter - $report = array(); - $tokens = array(); - $tags_by_tokens = array(); - $ccl = CclFactory::createFromReportAndTokens($report, $tokens, $tags_by_tokens); $tokens = array(); $relations = array(); $annotations = array(); From 88eddcf78c681974b3a9a201b4c799122e53579d Mon Sep 17 00:00:00 2001 From: Seweryn Walentynowicz Date: Fri, 20 Oct 2023 17:51:18 +0200 Subject: [PATCH 117/154] synchro with relation export startegy change --- engine/include/database/CDbCorpusRelation.php | 36 ++++++++----------- engine/include/export/CorpusExporter.php | 16 +++++++-- engine/include/export/ExportManager.php | 2 +- engine/templates/page_corpus_export.tpl | 1 + .../export/CorpusExporter_part0_Test.php | 4 +-- public_html/js/c_widget_annotation_panel.js | 4 +-- 6 files changed, 34 insertions(+), 29 deletions(-) diff --git a/engine/include/database/CDbCorpusRelation.php b/engine/include/database/CDbCorpusRelation.php index 8f281e8c..28f99854 100644 --- a/engine/include/database/CDbCorpusRelation.php +++ b/engine/include/database/CDbCorpusRelation.php @@ -163,28 +163,20 @@ static function getRelationsByRelationSetIds($relation_set_ids){ return $db->fetch_rows($sql); } - //TODO to delete - static function getRelationsBySets($report_ids, $relation_type_ids){ - global $db; - $sql = "SELECT reports_annotations.report_id as report_id, rel.id, rel.relation_type_id, rel.source_id, rel.target_id, relation_types.name " . - "FROM " . - "(SELECT * " . - "FROM relations " . - "WHERE source_id IN " . - "(SELECT id " . - "FROM reports_annotations " . - "WHERE report_id IN('" . implode("','",$report_ids) . "')) " . - "AND relation_type_id " . - "IN (".implode(",",$relation_type_ids).")) rel " . - "LEFT JOIN relation_types " . - "ON rel.relation_type_id=relation_types.id " . - "LEFT JOIN reports_annotations " . - "ON rel.source_id=reports_annotations.id "; - return $db->fetch_rows($sql); - } - - static function getRelationsBySets2($report_ids=null, $relation_set_ids=null, $relation_type_ids=null, $stage_ids=null, $user_ids=null){ + static function getRelationsBySets($report_ids=null, $relation_set_ids=null, $relation_type_ids=null, $stage_ids=null, $user_ids=null, $relation_stages=array()){ global $db; + + // if $relation_stages not set is equal $stage_ids - stages of + // relation are identical as stages of annotations + if( is_array($relation_stages) && (count($relation_stages)==0)) { + $relation_stages = $stage_ids; + } // if not set + + if (is_array($relation_stages) && (count($relation_stages)>0)) { + $relationStages = "stage IN('".implode("','",$relation_stages)."') AND"; + } else { // if $relation_stages==null default is 'final' + $relationStages = "stage = 'final' AND"; + } $sql = "SELECT reports_annotations.report_id as report_id, " . " rel.id, " . " rel.relation_type_id, " . @@ -196,7 +188,7 @@ static function getRelationsBySets2($report_ids=null, $relation_set_ids=null, $r "FROM " . "(SELECT * " . "FROM relations " . - "WHERE stage = 'final' AND source_id IN " . + "WHERE ".$relationStages." source_id IN " . "(SELECT id " . "FROM reports_annotations " . "WHERE report_id IN('0','" . implode("','",$report_ids) . "')) " . diff --git a/engine/include/export/CorpusExporter.php b/engine/include/export/CorpusExporter.php index d465e18e..92fdf8fd 100644 --- a/engine/include/export/CorpusExporter.php +++ b/engine/include/export/CorpusExporter.php @@ -109,6 +109,7 @@ protected function parse_extractor($description){ $params['attributes_annotation_subset_ids'] = null; $params['relation_set_ids'] = null; $params['stages'] = null; + $params['relation_stages'] = array(); // internally expanded foreach ( explode(";", $parts[1]) as $part ){ $name_value = explode("#", $part); @@ -126,6 +127,17 @@ protected function parse_extractor($description){ } } + // hint for selecting annotation in stage final and relation + // in stage agreement + if( is_array($params["stages"])) { + foreach($params["stages"] as &$stage) { + if($stage=='relationagreement') { + $stage = 'final'; // for annotations + $params["relation_stages"] = array('agreement'); // for relations + } // if 'relationagreement' + } // foreach "stages" + } // is_array('stages') + $extractor["params"] = $params; $extractor["extractor"] = function($report_id, $params, &$elements){ // $params -- annotations_set_ids, $stages @@ -163,7 +175,7 @@ protected function parse_extractor($description){ } if(is_array($params['relation_set_ids']) && count($params['relation_set_ids'])>0) { // add custom relation - $relations = DbCorpusRelation::getRelationsBySets2(array($report_id), $params['relation_set_ids'], null, $params["stages"],$params["user_ids"]); + $relations = DbCorpusRelation::getRelationsBySets(array($report_id), $params['relation_set_ids'], null, $params["stages"],$params["user_ids"],$params["relation_stages"]); if ( is_array($relations) ) { $elements['relations'] = array_merge($elements['relations'], $relations); } @@ -188,7 +200,7 @@ protected function parse_extractor($description){ $extractor["params"] = explode(",", $parts[1]); $extractor["extractor"] = function($report_id, $params, &$elements){ // $params -- set of annotation_set_id - $relations = DbCorpusRelation::getRelationsBySets2(array($report_id), $params); + $relations = DbCorpusRelation::getRelationsBySets(array($report_id), $params); if ( is_array($relations) ) { $elements['relations'] = array_merge($elements['relations'], $relations); } diff --git a/engine/include/export/ExportManager.php b/engine/include/export/ExportManager.php index 80a27532..8960f190 100644 --- a/engine/include/export/ExportManager.php +++ b/engine/include/export/ExportManager.php @@ -298,7 +298,7 @@ function readContent(){ } $this->log(" e) reading relations ..."); - $relations = DbCorpusRelation::getRelationsBySets2($this->report_ids, + $relations = DbCorpusRelation::getRelationsBySets($this->report_ids, $this->relation_set_ids, $this->relation_type_ids); foreach ($relations as &$relation){ $report_id = $relation['report_id']; diff --git a/engine/templates/page_corpus_export.tpl b/engine/templates/page_corpus_export.tpl index 2c3fb395..a928d070 100644 --- a/engine/templates/page_corpus_export.tpl +++ b/engine/templates/page_corpus_export.tpl @@ -109,6 +109,7 @@