Blame view

php/RemoteDataCenter/ImpexParamManager.php 16.9 KB
bf74fc2d   Elena.Budnik   IMPEX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
/** 
*   @class ImpexParamManager.php
*   @brief  Simations parameters Manager (Simulations db client) 
* 
*/
  
class ImpexParamManager  
{
	// input parameters
	protected $extraParam, $sampling;
	protected $dataProducer, $argStartTime, $argStopTime;
	protected $parameterID, $resourceID, $parameterKey, $parameterSize;
	protected $vectorList = null, $isSpectra = false;
	
   protected $orbitTempFolder = null;
   protected $center = null;
   
	protected $requestManager = null;
	protected $baseManager = null;
	protected $votManager = null;
	protected $impex_pairs = array("/" => "_", ":" => "_");
63f83396   Elena.Budnik   orbit in km for i...
23
	protected $webAlias;
bf74fc2d   Elena.Budnik   IMPEX
24
25
26
27
28
	
	public $startTime, $stopTime;
	
	private $impexParamInfo = null;
	
63f83396   Elena.Budnik   orbit in km for i...
29
30
// 	private $scale = array("km" => 1, "Rme" => 2438, "Rv" => 6052, "Re" => 6371, "Rma" => 3396, "Rm" => 3396,
// 									"Rj" => 71492, "Rs" => 60268, "Ru" => 25559, "Rn" => 24764);
bf74fc2d   Elena.Budnik   IMPEX
31
32
33
34
35
36
37

	function __construct() 
	{		
		$this->baseManager= new BaseManager();
		
		date_default_timezone_set('UTC');
		ini_set("soap.wsdl_cache_enabled", "0");
63f83396   Elena.Budnik   orbit in km for i...
38
	
710dc325   Elena.Budnik   typo
39
		$this->webAlias = webAlias.IHMConfigClass::getRelativeResultPath(); 
bf74fc2d   Elena.Budnik   IMPEX
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
	}
 
	public function getImpexFullParamId($param_id, $templateArgs = NULL) {
	
		if (!$templateArgs)
			return $param_id;
		
		$fullParamId = $param_id;
		foreach ($templateArgs as $key => $value)	
			$fullParamId .= "_".$value;
			
		return $fullParamId;
	}
	
	private function initParam($param, $templateArgs = NULL)
	{		
		$this->impexParamInfo = new IHMImpexParamClass();
		
		$this->parameterID = $this->getImpexFullParamId($param, $templateArgs);
		$this->dataProducer = $this->impexParamInfo->getDataProducer($param);
		$this->resourceID = $this->impexParamInfo->getResourceID($param);
		$this->parameterSize = $this->impexParamInfo->getParameterSize($param);
		$this->vectorList = $this->impexParamInfo->getVectorList($this->resourceID);
		$this->isSpectra = $this->impexParamInfo->isSpectra($param);
	}
	
	public function createImpexParameter($param, $intervals, $templateArgs = NULL)
	{	
		$this->initParam($param, $templateArgs);
		$this->parameterKey = $this->impexParamInfo->getParameterKey($param);
		
		if (!$this->center)
			$this->center = new $this->dataProducer();

		$mask = $this->center->getMask($this->resourceID, $templateArgs);
		 
		// if VI exists (i.e. another parameter from this dataset has been already created)
		if ($this->baseManager->existsVi($mask))
		{
			$result = $this->addImpexData($param, $intervals, $templateArgs);
			$viID = $result['VIID'];

			$localFile = $this->baseManager->getFirstFileName($viID);
			
			if ($this->center->outputFormat == "VOTable")
			{
				if (!$this->votManager)
						$this->votManager = new VOTableMgr();
						
				if (!$this->votManager->load(IHMConfigClass::getLocalBasePath().$localFile))
						throw new Exception('Cannot load '.$localFile); 
			}			
		}
		else 
		{
			$start = $intervals[0]->getStart();
			$duration = $intervals[0]->getDuration();
			
			$startTime = CommonClass::DDTimeToIso($start);
			$stopTime = CommonClass::DDStartIntervalToStopIso($start,$duration);
			$this->argStartTime = $startTime;
			$this->argStopTime = $stopTime;
									
			if (is_array($templateArgs))
				$templateArgs = (object) $templateArgs;
				
			if ($templateArgs->url_XYZ)  
			{
				$url_XYZ = $this->getOrbit($startTime, $stopTime, $templateArgs->url_XYZ);	
				$params = $this->makeRequest($templateArgs, $url_XYZ);
			}
			else 
			{
				 $params = $this->makeRequest($templateArgs);
			}
	    	
			$remoteFile = $this->center->getData($params, $this->isSpectra);
			
			$localFile = $this->center->getFileName($this->resourceID, $templateArgs,$start);
				
63f83396   Elena.Budnik   orbit in km for i...
120
121
122
123
124
			if (!copy($remoteFile, IHMConfigClass::getLocalBasePath().$localFile)) {			
				if ($this->orbitTempFolder)
					CommonClass::rrmdir($this->orbitTempFolder);
					
				throw new Exception('Cannot wget '.$remoteFile); 				
bf74fc2d   Elena.Budnik   IMPEX
125
126
127
128
129
130
131
			}
			
			if ($this->center->outputFormat == "VOTable")
			{
				if (!$this->votManager)
						$this->votManager = new VOTableMgr();
						
63f83396   Elena.Budnik   orbit in km for i...
132
133
134
135
136
137
138
				if (!$this->votManager->load(IHMConfigClass::getLocalBasePath().$localFile))				
				{
					if ($this->orbitTempFolder)
						CommonClass::rrmdir($this->orbitTempFolder);
						
					throw new Exception('Cannot load '.$localFile);
				}
bf74fc2d   Elena.Budnik   IMPEX
139
140
141
142
				
				if (!$this->votManager->isData()) 
				{
					unlink(IHMConfigClass::getLocalBasePath().$localFile);
63f83396   Elena.Budnik   orbit in km for i...
143
144
145
146
					if ($this->orbitTempFolder)
						CommonClass::rrmdir($this->orbitTempFolder);
						
					throw new Exception('Empty file '.$localFile);					
bf74fc2d   Elena.Budnik   IMPEX
147
148
149
150
151
152
153
154
155
156
157
158
159
160
				}
				
				if ($this->vectorList)
				{
					//TODO if it is needed to reload xml in case of several vectors
					foreach ($this->vectorList as $vector)
					{
						$this->votManager->addVectorToVot($vector,IHMConfigClass::getLocalBasePath().$localFile);
					}
				}
				$viID = $this->addFileToDb($mask, $localFile, $startTime, $stopTime);
			}
			elseif ($this->center->outputFormat == "CDF")
			{
46ac3264   Elena.Budnik   redmine #6005 : b...
161
162
163
164
165
166
				   $status= $this->center->validateStartStop($localFile, $startTime, $stopTime);
				   
					$startTime = $status["start"];
					$stopTime = $status["stop"];
					
					$viID = $this->addFileToDb($mask, $localFile, $startTime, $stopTime, 'cdf');
bf74fc2d   Elena.Budnik   IMPEX
167
			}
46ac3264   Elena.Budnik   redmine #6005 : b...
168

bf74fc2d   Elena.Budnik   IMPEX
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
		   if ($this->orbitTempFolder)
				CommonClass::rrmdir($this->orbitTempFolder);
		}
		
		$res = $this->getInfoFromFile($localFile);	

		$res["success"] = true;		
		$res["param"]["id"] = $this->parameterID;
		$res["param"]["dateModif"] = time(); 
		$res["param"]["info"]["viId"] = $viID;
		$res["param"]["info"]["name"] = $this->parameterKey;
		$res["param"]["info"]["yTitle"] =  $this->parameterKey;
		$res["param"]["info"]["units"] = $this->impexParamInfo->getUnits($param);
		
		
		//TODO define in DataCenter Class
		// special info on EnergyRange Table for Spectra : LATMOS, FMI_HYBRID
		if ($this->isSpectra)		
		{
			$res["param"]["info"]["tableDef"] = $this->center->getTableDefinition();
			$res["param"]["info"]["yTitle"] =  $this->center->tableTitle;
			$res["param"]["info"]["yUnits"] = $this->impexParamInfo->getEnergyUnits($param);
		}
		if ($this->dataProducer == "IPIM")		
		{
			$res["param"]["info"]["tableDef"] = $this->center->getTableDefinition(); // ($viID);
			$res["param"]["info"]["yTitle"] = $this->center->energyTableName;
			$res["param"]["info"]["yUnits"] =  'km';
		}
		return $res;
	}
	
	public function addImpexData($param, $intervals, $templateArgs = NULL)
	{
		$this->initParam($param, $templateArgs);
46ac3264   Elena.Budnik   redmine #6005 : b...
204
	
bf74fc2d   Elena.Budnik   IMPEX
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
		$start = $intervals[0]->getStart();
		$duration = $intervals[0]->getDuration();				 

		if (!$this->center)
			$this->center = new $this->dataProducer();
		
		$mask = $this->center->getMask($this->resourceID, $templateArgs); 
		
		$startStamp = CommonClass::DDTimeToTimeStamp($start);
		$stopStamp = $startStamp + CommonClass::DDTimeToTimeStamp($duration);
		 
		$intervalsToGet = $this->baseManager->intervalsToGet($startStamp, $stopStamp, $mask);
  
		$startT = $intervalsToGet['start'];
		$stopT = $intervalsToGet['stop']; 
		
		if ( is_array($templateArgs) )
				$templateArgs = (object) $templateArgs;
				
		if (count($startT) > 0)
		{
			for ( $i = 0; $i < count($startT); $i++ )
			{
				$startTime = date("Y-m-d\TH:i:s",$startT[$i]);
				$stopTime = date("Y-m-d\TH:i:s",$stopT[$i]);
				
				$this->argStartTime = $startTime;
				$this->argStopTime = $stopTime;
				
				if ($templateArgs->url_XYZ)  
				{
					$url_XYZ = $this->getOrbit($startTime, $stopTime, $templateArgs->url_XYZ);	
					$params = $this->makeRequest($templateArgs, $url_XYZ);
				}
				else 
				{
					$params = $this->makeRequest($templateArgs);
				}			
							
								   				
				$remoteFile = $this->center->getData($params, $this->isSpectra);				
				
				$localFile = $this->center->getFileName($this->resourceID,$templateArgs,$start);
										
				if (!copy($remoteFile, IHMConfigClass::getLocalBasePath().$localFile)) {
					throw new Exception('Cannot wget '.$remoteFile);       
				}
				
				if ($this->center->outputFormat == "VOTable")
				{
					if (!$this->votManager)
						$this->votManager = new VOTableMgr();
					
					if (!$this->votManager->load(IHMConfigClass::getLocalBasePath().$localFile))
						throw new Exception('Cannot load '.$localFile);   
				
					if (!$this->votManager->isData()) 
					{
						unlink(IHMConfigClass::getLocalBasePath().$localFile);
						throw new Exception('Empty file '.$localFile);	
					}
					
					if ($this->vectorList)
					{
						foreach ($this->vectorList as $vector)
						{
							$this->votManager->addVectorToVot($vector,IHMConfigClass::getLocalBasePath().$localFile);
						}
					}
						
					$viID = $this->addFileToDb($mask, $localFile, $startTime, $stopTime);				 	
				}
				else if ($this->center->outputFormat == "CDF")
46ac3264   Elena.Budnik   redmine #6005 : b...
278
279
280
281
282
283
284
285
286
287
288
				{
					$status= $this->center->validateStartStop($localFile, $startTime, $stopTime);
				   
				   if ($status["success"]) {
							$startTime = $status["start"];
							$stopTime = $status["stop"];
							$viID = $this->addFileToDb($mask, $localFile, $startTime, $stopTime, 'cdf');
					}
					else {
							unlink(IHMConfigClass::getLocalBasePath().$localFile);
					}
bf74fc2d   Elena.Budnik   IMPEX
289
				}
63f83396   Elena.Budnik   orbit in km for i...
290
				
bf74fc2d   Elena.Budnik   IMPEX
291
				if ($this->orbitTempFolder)
63f83396   Elena.Budnik   orbit in km for i...
292
293
					CommonClass::rrmdir($this->orbitTempFolder);					
				
bf74fc2d   Elena.Budnik   IMPEX
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
			}
		}
		// nothing to add
		else 
		{
			$viID = $this->baseManager->getVI($mask);
		}
		
		$startStop = $this->baseManager->getViDesc($viID);	
		
		$res = array('VIID' => $viID, 'StartStop' => $startStop);
		
		return $res;
	}
		
	private function getInfoFromFile($localFile)
	{
		$res = array();
		$res["param"] = array();
		$res["param"]["info"] = array();
		
		if ($this->center->outputFormat == "VOTable")
		{
			if (!$this->votManager)
				$this->votManager = new VOTableMgr();
				
			// reload xml after adding vector field	
			if (!$this->votManager->load(IHMConfigClass::getLocalBasePath().$localFile))
				throw new Exception('Cannot load '.$localFile);
				
			$infos = $this->votManager->getFieldInfoByID($this->parameterKey);
			$samplings = $this->votManager->getSamplings();	  			 			 			 
			$res["param"]["info"]["realVar"] = $infos["id"];
			$res["param"]["info"]["type"] = $infos["type"];
			$res["param"]["info"]["unit"] = $infos["unit"];
			$res["param"]["info"]["ucd"] = $infos["ucd"];
			$res["param"]["info"]["size"] = $infos["size"];
			$res["param"]["info"]["minSampling"] = $samplings["minSampling"];
			$res["param"]["info"]["maxSampling"] = $samplings["maxSampling"];
			$res["param"]["info"]["plotType"] = "Time Series";
		}
		else if ($this->center->outputFormat == "CDF")
		{		
			$filesMgr = new FilesMgr();
			$filesMgr->setFileName($localFile);
			
			$varInfo = $filesMgr->getCdfVarInfo($this->parameterKey);
		   $varSampling = $filesMgr->getCdfSampling();
		   
			$res["param"]["info"]["realVar"] = $this->parameterKey;
			$res["param"]["info"]["type"] = $varInfo['type'];
			$res["param"]["info"]["minSampling"] = $varSampling[4];
			$res["param"]["info"]["maxSampling"] = $varSampling[4];
			$res["param"]["info"]["plotType"] = "Spectro";
			$res["param"]["info"]["size"] = $varInfo['size'];
		}
		return $res;
	}
      
	private function addFileToDb($maskName, $fileName, $startTime, $stopTime, $format = null)
	{			
		if (!$format)
			$format = "vot";
			
		if (!$this->baseManager->existsVi($maskName))
		{ 			
			$viID = $this->baseManager->addVI($maskName, $format);
		}
		else 
		{
			$viID = $this->baseManager->getVI($maskName);
		}
		
		$start = strtotime($startTime);
		$stop = strtotime($stopTime);
		 
		$mask = $this->baseManager->addFile($fileName, $start, $stop); 
		
		return $viID;
	}
      
	public function getOrbit($startTime, $stopTime, $paramId)
	{
	   $params = array();	   
		$params[] = (object)array("paramid" => $paramId);
	   	   
		$obj = (object)array(
				"nodeType"         => "download",
				"downloadSrc"      => "0",
				"structure"        => 2,
				"refparamSampling" => false,
				"sampling"         => 60,
				"timesrc"          => "Interval",
				"startDate"        => $startTime,
				"stopDate"         => $stopTime,
				"list"             => $params,
				"fileformat"       => "vot",  
				"timeformat"       => "YYYY-MM-DDThh:mm:ss",
				"compression"      => "gzip" ,
				"disablebatch"     => true
		);
		
		if (!isset($this->requestManager))
			$this->requestManager = new RequestManagerClass();
			
		$userID = IHMConfigClass::getUserName();
		$userHost = IHMConfigClass::getUserHost();
		 	   
		try 
		{
			$downloadResult = $this->requestManager->runIHMRequest($userID, $userHost, FunctionTypeEnumClass::PARAMS, $obj);
		} 
		catch (Exception $e) 
		{
			  throw new Exception($e->getMessage());
		} 

		$this->orbitTempFolder = IHMConfigClass::getRequestPath().$downloadResult['folder'];
63f83396   Elena.Budnik   orbit in km for i...
412
	  
bf74fc2d   Elena.Budnik   IMPEX
413
414
415
		try 
		{
		   $this->convertVot($paramId, $downloadResult['result']);
63f83396   Elena.Budnik   orbit in km for i...
416
			$orbitURL = $this->webAlias.$downloadResult['folder']."/".$downloadResult['result'].".vot";
710dc325   Elena.Budnik   typo
417
					
bf74fc2d   Elena.Budnik   IMPEX
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
			return $orbitURL;
		}
		catch (Exception $e) 
		{
			  throw new Exception($e->getMessage());
		}  		
	}
	
	public function makeRequest($templateArgs = null, $url_XYZ = null)
	{ 
		$params = array();
		
		if ($templateArgs)
		{
			$extraParams = array();
			
			foreach ($templateArgs as $key => $value)
			{
				if ($key != 'url_XYZ')
					$extraParams[$key] = $value;
			}
			
			$extraParams['OutputFileType'] = $this->center->outputFormat;
			
			if ($this->center->additionalArgs)
			{
				$args = $this->center->additionalArgs[$this->resourceID];
				foreach ($args as $key => $type)
				{
					if ($key == "StartTime") $params[$key] = $this->argStartTime;
					if ($key == "StopTime") $params[$key] = $this->argStopTime;
					if ($key == "Sampling") $params[$key] = 60;
				}
			}
			
			if ($url_XYZ)
			{
				$params['url_XYZ'] = $url_XYZ;
			}
			 
			$params['extraParams'] = $extraParams;				  
		}
		else 
		{
			$params['accessUrl'] = $this->impexParamInfo->getAccessUrl($this->resourceID);
		}
		
		$params['ResourceID'] = $this->resourceID;
		
		return $params;		 	
	}
	
	private function convertVot($paramID, $fileName)
	{
		$comps = array('x', 'y', 'z');

		$xmlFile = $this->orbitTempFolder."/".$fileName.'.vot';
		
		exec("gunzip ".$xmlFile.".gz");
				
		$dom =  new DomDocument("1.0"); 
		$dom->formatOutput = false;
		$dom->preserveWhiteSpace = false;
		$dom->load($xmlFile);
		$xp = new domxpath($dom);
		
		$fields = $dom->getElementsByTagName('FIELD');
		$table = $dom->getElementsByTagName('TABLE')->item(0);
		$data = $dom->getElementsByTagName('DATA')->item(0);
		
		$i=0;
			
		foreach ($fields as $field)
		{
			if ($field->getAttribute('ID') == $paramID)
			{
				$unit = $field->getAttribute('unit');
				$ucd  = $field->getAttribute('ucd');
				$datatype  = $field->getAttribute('datatype');
				$firstTD = $i;
			}
			$i++;
		}
		//TODO unit from output VOT file
		/*----------------- temporary-----------------*/
63f83396   Elena.Budnik   orbit in km for i...
503
504
505
// 		  $temp =  new DomDocument("1.0");
// 		  $temp->load(IHMConfigClass::getLocalParamDBPath().$paramID.".xml");
// 		  $unit = $temp->getElementsByTagName('units')->item(0)->nodeValue;
bf74fc2d   Elena.Budnik   IMPEX
506
		
63f83396   Elena.Budnik   orbit in km for i...
507
		 $unit = 'km';
bf74fc2d   Elena.Budnik   IMPEX
508
509
510
		/*----------------- temporary-----------------*/
		if ($firstTD > 0)
		{			
63f83396   Elena.Budnik   orbit in km for i...
511
			/*if (array_key_exists($unit, $this->scale)) 
bf74fc2d   Elena.Budnik   IMPEX
512
513
				$unitScale = $this->scale[$unit];
			else
63f83396   Elena.Budnik   orbit in km for i...
514
				throw new Exception("Undefined unit ".$unit);*/	
bf74fc2d   Elena.Budnik   IMPEX
515
516
517
518
519
520
521
522
523
			
			$table->removeChild($fields->item($firstTD));
			
			foreach ($comps as $comp)
			{
				$new_field = $dom->createElement('FIELD');
				$new_field->appendChild(new DOMAttr('ID', $comp));
				$new_field->appendChild(new DOMAttr('name', $comp));
				$new_field->appendChild(new DOMAttr('datatype', $datatype));				 
63f83396   Elena.Budnik   orbit in km for i...
524
				$new_field->appendChild(new DOMAttr('unit',  $unit)); // $unit
bf74fc2d   Elena.Budnik   IMPEX
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
				$new_field->appendChild(new DOMAttr('ucd', 'pos.cartesian.'.$comp));
				
				$table->insertBefore($new_field,$data);
			}
			
			$trs = $dom->getElementsByTagName('TR');
			foreach($trs as $tr)
			{
				$tds = $tr->getElementsByTagName('TD');
				$values = explode(' ',$tds->item($firstTD)->nodeValue);
				$toRemote  = $tds->item($firstTD);
				$tr->removeChild($toRemote);
				
				foreach ($values as $value)
				{
63f83396   Elena.Budnik   orbit in km for i...
540
541
					//$td = $dom->createElement('TD', $value*$unitScale); //3400
					$td = $dom->createElement('TD', $value);
bf74fc2d   Elena.Budnik   IMPEX
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
593
594
595
596
597
598
					$tr->appendChild($td);
				}
			}	
				
			$dom->save($xmlFile);
		}
	}
	
	/*
	*  Delete impex params descriptions in User WS dir (and in Plot?)
	*/
	public function deleteImpexParams()
	{
		$dom = new DomDocument("1.0");
		$params = glob(IHMConfigClass::getUserWSPath().IHMImpexParamClass::$paramPrefix.'*.xml');

		$vis = array();
		foreach ($params as $param)
		{
			$dom->load($param);
			$vi = $dom->getElementsByTagName('localvi');
			if ($vi->length == 0) {
			//	throw new Exception('No localVi tag in '.$param);
				continue;
			}
			$viId = $vi->item(0)->getAttribute('id');	
			if (!in_array ($viId, $vis))
				$vis[] = $viId;
	   }
	   
	   foreach ($params as $param)
		{
			unlink($param);
		}
		
		// Delete params in Plot/params
		foreach (glob(IHMConfigClass::getRequestPath().'Plot_/params/'.IHMImpexParamClass::$paramPrefix.'*.xml') as $param)
		{
			unlink($param);
		}
		
	   return $vis;
	}
	
	/*
	*  Delete impex VIs and Files in User DATA dir
	*/
	public function deleteImpexStaff()
	{
		$vis = $this->deleteImpexParams();
		
	   foreach ($vis as $vi)
	   {	   
			$this->baseManager->deleteViTotal($vi);	   
	   }
	}
}