实现数据目录信息处理功能

This commit is contained in:
wlx 2011-03-02 13:16:05 +00:00
parent d5d6f3fd86
commit 89849648d7
3 changed files with 84 additions and 0 deletions

View File

@ -645,6 +645,57 @@ class Admin_DataController extends Zend_Controller_Action
$this->_redirect('/data');
}
}
function datafileimportAction()
{
if ($this->_request->isPost()) {
$dir = $this->_request->getPost('directory');
if (file_exists($dir.'/dataset.txt'))
{
$fp=fopen($dir.'/dataset.txt','rb');
$ds=fread($fp,filesize($dir.'/dataset.txt'));
fclose($fp);
$ds1=explode("\n",$ds);
for($i=0;$i<floor(count($ds1)/2);$i++)
{
$dpath=trim($ds1[$i*2]);
$duuid=trim($ds1[$i*2+1]);
if (file_exists($dir.'/'.$duuid.'.txt'))
{
$sql="delete from dataset where uuid='".$duuid."'";
//datafile table will auto-delete
$this->db->query($sql);
$sql="insert into dataset (path,uuid) values('".$dpath."','".$duuid."')";
$this->db->query($sql);
$sql="select id from dataset where uuid='".$duuid."'";
$rs=$this->db->fetchRow($sql);
$dsid=$rs["id"];
$fp=fopen($dir.'/'.$duuid.'.txt','rb');
$filep=fread($fp,filesize($dir.'/'.$duuid.'.txt'));
fclose($fp);
$filep1=explode("\n",$filep);
//print $duuid."<br/>";
//print $dpath." ".count($dpatch)."<br/>";
for($j=0;$j<floor(count($filep1)/2);$j++)
{
$fpath1=explode("\t",$filep1[$j*2]);
$fsize=$fpath1[0];
$fpath=mb_substr($fpath1[1],mb_strlen($dpath));
$fdir=($filep1[$j*2+1]=="directory")?1:0;
if ($fdir==1) $fsize=0;
if ($fpath!="")
{
$fdepth=substr_count($fpath,"/")+1;
//print $fsize." ".$fpath." ".$fdir."<br/>";
$sql="insert into datafile (dsid,filename,filesize,isdir,depth) values(".$dsid.",'".$fpath."',".$fsize.",".$fdir.",".$fdepth.")";
$this->db->query($sql);
}
}
}
}
}
$this->view->msg='已成功处理数据目录信息!';
}
}
/*
* 保存XML数据到数据库
*/

View File

@ -0,0 +1,32 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->headLink()->appendStylesheet('/css/admin.css');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('<a href="/admin/data">数据管理</a>');
$this->breadcrumb('导入数据目录文件</a>');
$this->breadcrumb()->setSeparator(' > ');
?>
<div id="leftPanel">
<?= $this->partial('data/left.phtml'); ?>
</div>
<div id="rightPanel">
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<form method="POST">
<p>数据目录文件通过在数据服务器所在目录进行信息提取后生成的一系列文本文件上传到本服务器上再进行处理。具体包括dataset和以UUID为名称的文本文件。</p>
<p>数据目录文件: <input type="text" name="directory"></p>
<input type="submit" value="导入数据目录" />
</form>
</div>

View File

@ -4,6 +4,7 @@
<li><a href="/admin/data/reference">数据文献关联管理</a></li>
<li><a href="/admin/data/import">上传元数据文件</a></li>
<li><a href="/admin/data/batchimport">导入服务器元数据目录</a></li>
<li><a href="/admin/data/datafileimport">导入数据目录</a></li>
<li><a href="/admin/data/sync">同步GeoNetwork元数据</a></li>
<li><a href="/admin/data/datasetcd">特色数据集管理</a></li>
<li><a href="/admin/data/newsletter">数据中心通讯管理</a></li>