FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
dbmigrate_copyright-author.php
Go to the documentation of this file.
1 <?php
2 /***********************************************************
3  Copyright (C) 2017 Siemens AG
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ***********************************************************/
18 
19 
28 $countAuthorColumns = $dbManager->getSingleRow("SELECT count(*) FROM copyright WHERE type <> 'statement' AND content IS NOT NULL;",array(),'getCountAuthorColumns');
29 
30 if($countAuthorColumns['count'] > 0){
31 
32  echo "Insert email/url/author data from copyright to author table... \nIt takes some time depending number of columns... \n";
33 
34  $dbManager->queryOnce("INSERT INTO author (agent_fk, pfile_fk, content, hash, type, copy_startbyte, copy_endbyte, is_enabled)
35  SELECT agent_fk, pfile_fk, content, hash, type, copy_startbyte, copy_endbyte, is_enabled
36  FROM copyright WHERE type <> 'statement' AND content IS NOT NULL;");
37  $countInsertedAuthorColumns = $dbManager->getSingleRow("SELECT count(*) FROM author au INNER JOIN copyright co
38  ON au.pfile_fk = co.pfile_fk WHERE au.author_pk = co.copyright_pk AND au.content = co.content;",array(),'getCountInsertedAuthorColumns');
39  if($countAuthorColumns['count'] == $countInsertedAuthorColumns['count']){
40  echo "Deleting the email/url/author data from copyright table...\n";
41  $dbManager->queryOnce("DELETE FROM copyright WHERE type <> 'statement' AND content IS NOT NULL;");
42  } else {
43  echo "Something went wrong please execute the postinstall again...\n";
44  }
45 }