37 if($dbManager == NULL){
38 echo
"No connection object passed!\n";
42 $sql =
"SELECT rf_fk FROM obligation_map WHERE rf_fk NOT IN (" .
43 "SELECT rf_pk FROM ONLY license_ref) AND ob_fk = $1;";
44 $statement = __METHOD__ .
".getLicenseList";
45 $licenses = $dbManager->getRows($sql, array($obPk), $statement);
46 foreach ($licenses as $license) {
49 echo
"* Moving license " . $license[
'rf_fk'] .
" to candidate map of " .
50 "obligation $obPk *\n";
52 $sql =
"SELECT om_pk FROM obligation_candidate_map WHERE " .
53 "ob_fk = $1 AND rf_fk = $2;";
54 $statement = __METHOD__ .
".checkMaping";
55 $exists = $dbManager->getSingleRow($sql, array($obPk, $license[
'rf_fk']),
58 $statement = __METHOD__ .
".insertCandidateMap";
59 $dbManager->insertTableRow(
"obligation_candidate_map", array(
61 "rf_fk" => $license[
'rf_fk']
65 $sql =
"DELETE FROM obligation_map WHERE ob_fk = $1 AND rf_fk = $2;";
66 $statement = __METHOD__ .
".removeMap";
67 $dbManager->getSingleRow($sql, array($obPk, $license[
'rf_fk']), $statement);
79 if($dbManager == NULL){
80 echo
"No connection object passed!\n";
83 $requiredTables = array(
85 "obligation_candidate_map",
89 foreach ($requiredTables as $table) {
96 $sql =
"SELECT count(*) AS cnt FROM obligation_map WHERE rf_fk NOT IN (" .
97 "SELECT rf_pk FROM ONLY license_ref);";
98 $row = $dbManager->getSingleRow($sql);
100 if (array_key_exists(
"cnt", $row) && $row[
"cnt"] > 0) {
115 if($dbManager == NULL){
116 echo
"No connection object passed!\n";
120 $sql =
"SELECT ob_pk FROM obligation_ref;";
121 $obligations = $dbManager->getRows($sql);
122 foreach ($obligations as $obligation) {
134 if($dbManager == NULL){
135 echo
"No connection object passed!\n";
142 $sql =
"SELECT exists(SELECT 1 FROM upload_reuse WHERE reuse_mode = $1 LIMIT 1)::int";
143 $row = $dbManager->getSingleRow($sql, array(8), $stmt);
145 if ($row[
'exists']) {
146 echo
"*** Changing enhance reuse with main license value to 6 from 8 ***\n";
147 $stmt = __METHOD__.
"ReplaceValuesFrom8to6";
148 $dbManager->prepare($stmt,
150 SET reuse_mode = $1 WHERE reuse_mode = $2" 152 $dbManager->freeResult($dbManager->execute($stmt, array(6,8)));
170 echo
"*** Moving candidate licenses from obligation map ***\n";
172 }
catch (Exception $e) {
173 echo
"Something went wrong. Try running postinstall again!\n";
174 $dbManager->rollback();
migrateReuseValueForEnhanceWithMainLicense($dbManager)
Migrate_36_37($dbManager, $verbose)
moveObligation($dbManager, $verbose)
Get all obligations and move licenses.
DB_TableExists($tableName)
Check if table exists.
moveCandidateLicenseMap($dbManager, $obPk, $verbose)
Move licenses from obligation map to obligation candidate map.
checkMigrate3637Required($dbManager)