30 if($dbManager == NULL){
31 echo
"No connection object passed!\n";
35 $sql =
"SELECT rf_fk FROM obligation_map WHERE rf_fk NOT IN (" .
36 "SELECT rf_pk FROM ONLY license_ref) AND ob_fk = $1;";
37 $statement = __METHOD__ .
".getLicenseList";
38 $licenses = $dbManager->getRows($sql, array($obPk), $statement);
39 foreach ($licenses as $license) {
42 echo
"* Moving license " . $license[
'rf_fk'] .
" to candidate map of " .
43 "obligation $obPk *\n";
45 $sql =
"SELECT om_pk FROM obligation_candidate_map WHERE " .
46 "ob_fk = $1 AND rf_fk = $2;";
47 $statement = __METHOD__ .
".checkMaping";
48 $exists = $dbManager->getSingleRow($sql, array($obPk, $license[
'rf_fk']),
51 $statement = __METHOD__ .
".insertCandidateMap";
52 $dbManager->insertTableRow(
"obligation_candidate_map", array(
54 "rf_fk" => $license[
'rf_fk']
58 $sql =
"DELETE FROM obligation_map WHERE ob_fk = $1 AND rf_fk = $2;";
59 $statement = __METHOD__ .
".removeMap";
60 $dbManager->getSingleRow($sql, array($obPk, $license[
'rf_fk']), $statement);
72 if($dbManager == NULL){
73 echo
"No connection object passed!\n";
76 $requiredTables = array(
78 "obligation_candidate_map",
82 foreach ($requiredTables as $table) {
89 $sql =
"SELECT count(*) AS cnt FROM obligation_map WHERE rf_fk NOT IN (" .
90 "SELECT rf_pk FROM ONLY license_ref);";
91 $statement = __METHOD__ .
".candCount";
92 $row = $dbManager->getSingleRow($sql, array(), $statement);
94 if (array_key_exists(
"cnt", $row) && $row[
"cnt"] > 0) {
109 if($dbManager == NULL){
110 echo
"No connection object passed!\n";
113 $requiredTables = array(
118 foreach ($requiredTables as $table) {
124 $sql =
"WITH comp AS (" . LicenseMap::getMappedLicenseRefView() .
125 ") SELECT * FROM obligation_map WHERE rf_fk NOT IN " .
126 "(SELECT rf_pk FROM comp);";
127 $statement = __METHOD__ .
".conclusionMigrate";
128 return $dbManager->getRows($sql, array(LicenseMap::CONCLUSION), $statement);
138 if($dbManager == NULL){
139 echo
"No connection object passed!\n";
143 $sql =
"SELECT ob_pk FROM obligation_ref;";
144 $obligations = $dbManager->getRows($sql);
145 foreach ($obligations as $obligation) {
157 if ($dbManager === NULL) {
158 echo
"No connection object passed!\n";
165 $sql =
"SELECT exists(SELECT 1 FROM upload_reuse WHERE reuse_mode = $1 LIMIT 1)::int";
166 $row = $dbManager->getSingleRow($sql, array(8), $stmt);
168 if ($row[
'exists']) {
169 echo
"*** Changing enhance reuse with main license value to 6 from 8 ***\n";
170 $stmt = __METHOD__ .
"ReplaceValuesFrom8to6";
171 $dbManager->prepare($stmt,
173 SET reuse_mode = $1 WHERE reuse_mode = $2"
175 $dbManager->freeResult($dbManager->execute($stmt, array(6,8)));
194 $mappedLicenses = [];
196 $sql = LicenseMap::getMappedLicenseRefView();
197 $params = array(LicenseMap::CONCLUSION);
198 $statement = __METHOD__ .
".getLicenseMap";
199 $rows = $dbManager->getRows($sql, $params, $statement);
200 foreach ($rows as $row) {
201 $mappedLicenses[$row[
"rf_origin"]] = $row;
204 foreach ($migrationData as $row) {
206 $obligationId = $row[
"ob_fk"];
207 $licenseId = $row[
"rf_fk"];
208 $parentId = $mappedLicenses[$licenseId][
"rf_pk"];
210 $licenseName = $obligationMap->getShortnameFromId($row[
"rf_fk"]);
211 $obligationTopic = $obligationMap->getTopicNameFromId($row[
"ob_fk"]);
212 echo
" Removed '$licenseName' license from '$obligationTopic' obligation";
213 if (! $obligationMap->isLicenseAssociated($obligationId, $parentId)) {
214 $obligationMap->associateLicenseWithObligation($obligationId, $parentId);
215 echo
" replacing with parent license '" .
216 $obligationMap->getShortnameFromId($parentId) .
"'";
219 $obligationMap->unassociateLicenseFromObligation($obligationId, $licenseId);
220 $dbManager->commit();
234 if (! ($candidateMigration || (count($concLicenseMigration) > 0))) {
239 if ($candidateMigration) {
240 echo
"*** Moving candidate licenses from obligation map ***\n";
243 if (count($concLicenseMigration) > 0) {
244 echo
"*** Removed following obligation map (" .
245 count($concLicenseMigration) .
") ***\n";
248 }
catch (Exception $e) {
249 echo
"Something went wrong. Try running postinstall again!\n";
250 $dbManager->rollback();
Wrapper class for license map.
Wrapper class for obligation map.
DB_TableExists($tableName)
Check if table exists.
Migrate_36_37($dbManager, $verbose)
moveCandidateLicenseMap($dbManager, $obPk, $verbose)
Move licenses from obligation map to obligation candidate map.
removeNonConcLicensesFromObligation($dbManager, $migrationData)
Remove identified licenses from obligations.
moveObligation($dbManager, $verbose)
Get all obligations and move licenses.
checkMigrate3637Required($dbManager)
migrateReuseValueForEnhanceWithMainLicense($dbManager)
getLicConObligationMigrate($dbManager)