testlink1.9.6 /install/migration/Migrator.php

Language PHP Lines 592
MD5 Hash 8953890174d393986b78952f3d5a5bdf Estimated Cost $12,255 (why?)
Repository https://bitbucket.org/pfernandez/testlink1.9.6 View Raw File
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
<?php
/*
 * TestLink Open Source Project - http://testlink.sourceforge.net/
 * $Id: Migrator.php,v 1.5 2008/01/25 14:49:53 franciscom Exp $
 *
 * BUGID 1328 - LEFT without AS
 */

require_once("migrate_16_to_17_functions.php");

class Migrator
{
	// tmp table for test cases
	private $tmp_table_count = 0;
	private $tmp_table_name = "tc_tmp_table";
	// tmp table for test plans
	private $tp_tmp_table_name = "tp_tmp_table";
	private $tp_tmp_table_count = 0;
	// tmp table for results
	private $results_tmp_table_name = "results_tmp_table";
	private $results_tmp_table_count = 0;

	private $source_db;
	private $target_db;
	private $users = null;
	private $old_new = array();
	private $msg_click_to_show=" [Click to show details] ";
	private $products;
	private $map_tc_tcversion;
	private $builds;

	function __construct($source_db, $target_db)
	{
		$this->source_db = $source_db;
		$this->target_db = $target_db;
		$this->get_users();
		$this->get_old_new();
	}
	
	// Migrate everything in the correct order
	public function migrate_all()
	{
		$this->select_testcases();
		$this->select_testplans();
		$this->select_results();
		$this->testcases_migration();
		$this->users_migration();
		$this->products_components_categories_migration();
		$this->keywords_migration();
		$this->builds_migration();
		$this->testplan_migration();
		$this->results_migration();
		$this->bugs_migration();
		$this->users_test_plan_assignments_migration();
		$this->milestones_migration();
		$this->risk_migration();
		$this->requirements_specification_migration();
		$this->requirements_migration();
		$this->requirements_coverage_migration();
	}

	// get the value of the users var from the db
	function get_users()
	{
		// only do a query if the variable hasn't already been set
		if ($this->users == null)
		{
			// Get list of 1.6 users
			$sql="SELECT * FROM user";
			$this->users=$this->source_db->fetchRowsIntoMap($sql,'login');			
		}
		return $this->users;
	}

	function get_old_new()
	{
		if (count($this->old_new) == 0)
		{
			$this->old_new['product']=array();
			$this->old_new['tplan']=array();
			$this->old_new['mgtcomp']=array();
			$this->old_new['mgtcat']=array();
			$this->old_new['mgttc']=array();
			$this->old_new['build']=array();
			$this->old_new['bug']=array();
			$this->old_new['result']=array();
		}
		return $this->old_new;
	}

	// determine the number of test cases we are dealing with in the tmp table
	function get_tmp_table_count($table_name=null)
	{	
		if(null==$table_name)
		{
			echo "<br>getting normal tmp_table count<br>";
			if ($this->tmp_table_count == 0)
			{
				$sql = "SELECT COUNT(*) as count FROM " . $this->tmp_table_name;
				$this->tmp_table_count = $this->source_db->fetchFirstRowSingleColumn($sql, 'count');
			}
			return $this->tmp_table_count;
		}
		else if("tp"==$table_name)
		{
			echo "<br>getting count for tp_tmp_table<br>";
			if ($this->tp_tmp_table_count == 0)
			{
				$sql = "SELECT COUNT(*) as count FROM " . $this->tp_tmp_table_name;
				$this->tp_tmp_table_count = $this->source_db->fetchFirstRowSingleColumn($sql, 'count');
			}
			return $this->tp_tmp_table_count;
		}
		else if("results"==$table_name)
		{
			echo "<br>getting count for results_tmp_table<br>";
			if ($this->results_tmp_table_count == 0)
			{
				$sql = "SELECT COUNT(*) as count FROM " . $this->results_tmp_table_name;
				$this->results_tmp_table_count = $this->source_db->fetchFirstRowSingleColumn($sql, 'count');
			}
			return $this->results_tmp_table_count;
		}
	}

	// TODO: create a separate function to print the section header that is copied and 
	// used in most of the functions
	function print_section_header()
	{
	}

	function select_testcases()
	{
		// -----------------------------------------------------------------------------------
		// To preserve test case ID, I will create first all test cases.
		// Using all these joins we will considered only well formed tc =>
		// no dangling records.
		//
		// 20070103 - franciscom - added prodid column in results record set.
		// 
		// 20070807 - asielb - store results in temporary table to avoid requiring 
		// 		excessive amounts of memory for php
		// 20071212 - asielb = select only first 100 chars of title fixing bug 1125
		$tmp_table_name = "tmp_good_testcases";
		$sql="CREATE TEMPORARY TABLE " . $this->tmp_table_name . " " .
			 "SELECT mtc.id, " .
			 "LEFT(mtc.title,100) AS title," .
			 "mtc.steps," .
			 "mtc.exresult," .
			 "mtc.keywords," .
			 "mtc.catid," .
			 "mtc.version," .
			 "mtc.summary," .
			 "mtc.author," .
			 "mtc.create_date," .
			 "mtc.reviewer," .
			 "mtc.modified_date," .
			 "mtc.TCorder," .
			 "mc.prodid " .
		     " FROM mgtproduct mp, mgtcomponent mc, mgtcategory mk, mgttestcase mtc " .
		     " WHERE mc.prodid=mp.id " .
		     " AND   mk.compid=mc.id " .
		     " AND   mtc.catid=mk.id " .
		     " ORDER BY mtc.id";
		
		echo "<br />creating temporary table for good testcases<br />";
		//echo "<br />using sql: $sql";
		$this->source_db->exec_query($sql);
		
		return $this->get_tmp_table_count();
	}

	function select_testplans()
	{
		// use a temporary table to avoid requiring excessive amounts of memory for php
		$sql="CREATE TEMPORARY TABLE " . $this->tp_tmp_table_name . " SELECT tplan.name " .
			 "AS tplan_name,tplan.id AS projid,k.compid,tc.mgttcid AS mgttcid " .
		     "FROM component c,category k,testcase tc," .
		     "     mgtcomponent mc, mgtcategory mk,mgttestcase mtc,project tplan " .
		     "where c.id=k.compid " .
		     "AND   k.id=tc.catid " .
		     "AND k.mgtcatid = mk.id " .
		     "AND c.mgtcompid = mc.id " .
		     "AND tc.mgttcid=mtc.id " .
		     "AND c.projid = tplan.id " .
		     "ORDER BY projid ";
		   
		echo "<br />creating temporary table for test plans<br />";
		//echo "testplan sql is $sql";
		
		$this->source_db->exec_query($sql);
		
		return $this->get_tmp_table_count("tp");
	}

	function select_results()
	{
		// 20070120 - franciscom
		// added join with build, to filter out results records that belong to deleted builds
		//
		// 20070113 - franciscom
		// added filter on status, because executions with NOT RUN will not be migrated
		// 
		$sql="CREATE TEMPORARY TABLE " . $this->results_tmp_table_name .
			 " SELECT MGT.id as mgttcid, R.tcid, R.build_id,R.daterun," .
		     " R.runby,R.notes,R.status " .
		     " FROM mgttestcase MGT,testcase TC,results R, build B " .
		     " WHERE TC.mgttcid=MGT.id " .
		     " AND   TC.id=R.tcid  AND R.status <> 'n'" .
		     " AND   B.id=R.build_id " .
		     " ORDER BY tcid,build_id";
		
		echo "<br />creating temporary table for results";    
		$this->source_db->exec_query($sql);
		
		return $this->get_tmp_table_count("results");
	}
	
	function users_migration()
	{
		$msg='Users: ';
		$hhmmss=date("H:i:s");
		
		if(!is_null($this->get_users())) 
		{
			$users_qty=count($this->get_users());  
			$msg .= " (Found " . $users_qty . " users to migrate) ";
		}
		else
		{
			$msg .= " Ooops! no users to migrate !!!! ";
		}
		
		echo "<a onclick=\"return DetailController.toggle('details-users')\" href=\"users/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>{$msg} {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-users" style="display: none;">';
		if(!is_null($this->get_users())) 
		{
			migrate_users($this->target_db,$this->get_users());
		}
		echo "</div><p>";
	}

	function testcases_migration()
	{
		$tcspecs_msg="Test Case Specifications: (Found " . $this->get_tmp_table_count() . 
				" test cases to migrate)";

		$msg=$tcspecs_msg;
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-tcspecs')\" href=\"tcspecs/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>{$msg} {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-tcspecs" style="display: none;">';
		if(!$this->get_tmp_table_count() > 0) 
		{
			echo "<span class='notok'>There are no test cases to be migrated!</span></b>";
		}
		else
		{
		  $this->map_tc_tcversion=migrate_tc_specs($this->source_db,$this->target_db,$this->tmp_table_name,$this->users,$this);
		}
		echo "</div><p>";
	}

	function products_components_categories_migration()
	{
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-pcc')\" href=\"pcc/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>
		Products, Components & Categories migration: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-pcc" style="display: none;">';

		// Get list of 1.6 Products
		$sql="SELECT * FROM mgtproduct";
		
		$this->products=$this->source_db->fetchRowsIntoMap($sql,'id');
		if(is_null($this->products)) 
		{
			echo "<span class='notok'>Failed!</span></b> - Getting products:" .
				$source_db->error_msg() ."<br>";
		}
		migrate_cc_specs($this->source_db,$this->target_db,$this->products,$this->old_new);
		echo "</div><p>";
	}

	function keywords_migration()
	{
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-kw')\" href=\"kw/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>Keywords migration: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-kw" style="display: none;">';
		
		$prod_keyword_tc=extract_kw_tc_links($this->source_db,$this->target_db,$this->tmp_table_name,$this);
		migrate_keywords($this->source_db,$this->target_db,$this->products,$prod_keyword_tc,$this->old_new);
		echo "</div><p>";
		
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-tcpu')\" href=\"tcpu/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>Test case parent update: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-tcpu" style="display: none;">';
		// asielb - modified to use the tmp_table
		update_tc_specs_parents($this->source_db,$this->target_db,$this->tmp_table_name,$this->old_new, $this);
		echo "</div><p>";
		
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-tplan')\" href=\"tplan/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>Test plans: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-tplan" style="display: none;">';
		$sql="SELECT * FROM project ORDER BY ID";
		$tplans=$this->source_db->fetchRowsIntoMap($sql,'id');
		if(is_null($tplans)) 
		{
			echo "<span class='notok'>There are no test plans to be migrated!</span></b>";
		}
		else
		{
		  migrate_test_plans($this->source_db,$this->target_db,$tplans,$this->old_new);
		}
		echo "</div><p>";
	}

	function builds_migration()
	{
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-builds')\" href=\"tplan/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>Builds: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-builds" style="display: none;">';
		
		// find the number of duplicate build names that will get blown away
		$sql = "SELECT COUNT(*) - COUNT(DISTINCT build.name, build.projid) AS duplicate_names FROM build";

		$duplicate_builds = $this->source_db->fetchFirstRowSingleColumn($sql, "duplicate_names");
		
		echo "will be deleting $duplicate_builds duplicate builds"; 

		// select everything but the duplicates that will violate the unique constraint in 1.7
		$sql="SELECT build.*, project.name AS TPLAN_NAME FROM build,project WHERE build.projid=project.id" .
				" GROUP BY build.name, build.projid HAVING COUNT(*)=1 ORDER BY project.id";

		$this->builds=$this->source_db->fetchRowsIntoMap($sql,'id');

		if(is_null($this->builds)) 
		{
			echo "<span class='notok'>There are no builds to be migrated!</span></b>";
		}
		else
		{
		  migrate_builds($this->source_db,$this->target_db,$this->builds,$this->old_new);
		}
		echo "</div><p>";
	}

	function testplan_migration()
	{
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-tctpa')\" href=\"tplan/\">		
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>Test case -> test plan assignments: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-tctpa" style="display: none;">';

		$count=$this->get_tmp_table_count("tp");
		if (0==$count) 
		{
			echo "<br>somehow count was 0 for tp_tmp_table<br>";
			$count=$this->select_testplans();
		}

		// check if the count still is 0
		if (0==$count)
		{
			echo "<span class='notok'>All test plans are empty!</span></b>";
		}
		else
		{
			//migrate_tplan_contents(&$source_db,&$target_db,&$tmp_table_name,&$tc_tcversion,&$old_new,&$migrator)
			migrate_tplan_contents($this->source_db,$this->target_db,$this->tp_tmp_table_name,
					$this->map_tc_tcversion,$this->old_new,$this);
		}
		echo "</div><p>";
	}

	function results_migration()
	{
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-results')\" href=\"tplan/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>Executions results: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-results" style="display: none;">';

		$count=$this->get_tmp_table_count("results");
		if (0==$count)
		{
			$count=$this->select_results();
		}

		// if count is still 0 we have a problem
		if (0==$count)
		{
			echo "<span class='notok'>There are no results to migrate!</span></b>";
		}
		else
		{
			migrate_results($this->source_db,$this->target_db,$this->results_tmp_table_name,
					$this->builds,$this->get_users(),$this->map_tc_tcversion,$this->old_new, $this);			
		}

		echo "<br />Finished migrating execution results";
		echo "</div><p>";
	}

	function bugs_migration()
	{
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-bugs')\" href=\"tplan/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>Executions bugs: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-bugs" style="display: none;">';
		$sql="SELECT bugs.tcid,bugs.build_id,bugs.bug,mgt.id AS mgttcid " .
			"FROM bugs,mgttestcase mgt,testcase t " .
			"WHERE bugs.tcid=t.id " .
			"AND   t.mgttcid=mgt.id";

		$bugs=$this->source_db->get_recordset($sql);
		if(is_null($bugs)) 
		{
			echo "<span class='notok'>There are no bugs to be migrated!</span></b>";
		}
		else
		{
			migrate_bugs($this->source_db,$this->target_db,$bugs,$this->builds,$this->map_tc_tcversion,$this->old_new);
		}
		echo "</div><p>";
	}

	function users_test_plan_assignments_migration()
	{
		//---USERS TEST PLAN ASSIGNMENTS MIGRATION---
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-user_tpa')\" href=\"tplan/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>Users - Test plan assignments: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-user_tpa" style="display: none;">';

		// 20070317 - BUGID 738
		migrate_tesplan_assignments($this->source_db,$this->target_db,$this->old_new);
		echo "</div><p>";

		//---PRIORITY RULES MIGRATION---
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-prior')\" href=\"tplan/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>Priority Rules: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-prior" style="display: none;">';

		$sql="SELECT * from priority";
		$prules=$this->source_db->fetchRowsIntoMap($sql,'projid');
		if(is_null($prules)) 
		{
			echo "<span class='notok'>There are no priority rules to be migrated!</span></b>";
		}
		else
		{
			migrate_prules($this->source_db,$this->target_db,$prules,$this->old_new);
		}
		echo "</div><p>";
	}

	function milestones_migration()
	{
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-Milestones')\" href=\"tplan/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>Milestones: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-Milestones" style="display: none;">';

		$sql="SELECT * from milestone";
		$ms=$this->source_db->fetchRowsIntoMap($sql,'projid');
		if(is_null($ms)) 
		{
			echo "<span class='notok'>There are no results to be migrated!</span></b>";
		}
		else
		{
			migrate_milestones($this->source_db,$this->target_db,$ms,$this->old_new);
		}
		echo "</div><p>";
	}

	function risk_migration()
	{
		echo "<a onclick=\"return DetailController.toggle('details-risk')\" href=\"tplan/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>Risk TO BE DONE - No data wll be migrated:</a>";
		echo '<div class="detail-container" id="details-risk" style="display: none;">';
		echo "</div><p>";

		$sql="SELECT tplan.name as tplan_name,tplan.id as projid," .
		     "       k.mgtcatid,k.risk,k.importance,k.owner,tc.mgttcid " .
		     "FROM   component c,category k,testcase tc," .
		     "       mgtcomponent mc, mgtcategory mk,mgttestcase mtc,project tplan " .
		     "WHERE c.id=k.compid " .
		     "AND k.id=tc.catid " .
		     "AND k.mgtcatid = mk.id " .
		     "AND c.mgtcompid = mc.id " .
		     "AND tc.mgttcid=mtc.id " .
		     "AND c.projid = tplan.id " .
		     "ORDER BY projid ";
		$tp4risk_own=$this->source_db->get_recordset($sql);
		
		
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-own')\" href=\"tplan/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'>Ownership (becomes user assignment=test_execution): {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-own" style="display: none;">';
		
		if(is_null($tp4risk_own)) 
		{
			echo "<span class='notok'>There are no data to be migrated!</span></b>";
		}
		else
		{
			migrate_ownership($this->source_db,$this->target_db,$tp4risk_own,$this->map_tc_tcversion,$this->old_new);
		}
		echo "</div><p>";
	}

	function requirements_specification_migration()
	{
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-req_spec_table')\" href=\"tplan/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'> Requirement Specification: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-req_spec_table" style="display: none;">';
		
		$sql="SELECT * from req_spec";
		$rspec=$this->source_db->fetchRowsIntoMap($sql,'id');
		if(is_null($rspec)) 
		{
			echo "<span class='notok'>There are no req specs to be migrated!</span></b>";
		}
		else
		{
		  migrate_req_specs($this->source_db,$this->target_db,$rspec,$this->old_new);
		}
		echo "</div><p>";
	}

	function requirements_migration()
	{
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-reqtable')\" href=\"tplan/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'> Requirements: {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-reqtable" style="display: none;">';

		// 20070103 - franciscom - added filter on NULL
		// select everything but the duplicates that will violate the unique constraint in 1.7
		$sql="SELECT * from requirements " . 
		     " WHERE req_doc_id <> NULL OR req_doc_id <> '' " .
		     " GROUP BY id_srs, req_doc_id HAVING COUNT(*)=1";
		$req=$this->source_db->fetchRowsIntoMap($sql,'id');
		if(is_null($req)) 
		{
			echo "<span class='notok'>There are no requirements to be migrated!</span></b>";
		}
		else
		{
		  migrate_requirements($this->source_db,$this->target_db,$req,$this->old_new);
		}
		echo "</div><p>";
	}

function requirements_coverage_migration()
	{
		$hhmmss=date("H:i:s");
		echo "<a onclick=\"return DetailController.toggle('details-req_coverage')\" href=\"tplan/\">
		<img src='../img/icon-foldout.gif' align='top' title='show/hide'> Req. Coverage (requirement / test case relationship): {$this->msg_click_to_show} {$hhmmss}</a>";
		echo '<div class="detail-container" id="details-req_coverage" style="display: none;">';

		$sql="SELECT * from req_coverage";

		// 20061203 - franciscom - id (wrong) -> id_req
		//$req_cov=$this->source_db->fetchRowsIntoMap($sql,'id_req');   //970 items no duplicate ids
	
		// 20071213 - havlatm:   	 0001112: Requirements coverage migration from 1.6.3 to 1.7.0 final
		$result = $this->source_db->get_recordset($sql);	
		
		if(is_null($result))
		{
			echo "<span class='notok'>There are no req specs to be migrated!</span></b>";
		}
		else
		{
			// 20071213 - havlatm:   	 0001112: Requirements coverage migration from 1.6.3 to 1.7.0 final
			migrate_req_coverage($this->source_db,$this->target_db,$result,$this->old_new);
		}
		echo "</div><p>";
	}

}
?>
Back to Top