添加元数据错误检查功能

This commit is contained in:
wlx 2012-12-03 03:38:08 +00:00
parent 64504bb861
commit 7e87fc1768
1 changed files with 52 additions and 12 deletions

View File

@ -1814,7 +1814,14 @@ class AuthorController extends Zend_Controller_Action
{ {
//导入元数据 //导入元数据
$iso=new ISO19115(); $iso=new ISO19115();
@$iso->saveDB($this->db,$row['xml']); @$iso->loadXML($row['xml']);
if ($iso->validate())
{
$data=array("error"=>"元数据导入过程中发现错误。<br />".implode("<br />",$iso->error));
$this->jsonexit($data);
return true;
}
@$iso->saveDB($this->db);
//进入评审库 //进入评审库
$sql="insert into mdstatus (uuid,status,userid) select uuid,0,? from mdversion where id=?"; $sql="insert into mdstatus (uuid,status,userid) select uuid,0,? from mdversion where id=?";
$this->db->query($sql,array($u_id,$id)); $this->db->query($sql,array($u_id,$id));
@ -1868,7 +1875,15 @@ class AuthorController extends Zend_Controller_Action
} else { //说明是已发布的数据且数据不存在评审信息 } else { //说明是已发布的数据且数据不存在评审信息
//同步元数据 //同步元数据
$iso=new ISO19115(); $iso=new ISO19115();
@$iso->saveDB($this->db,$row['xml']); @$iso->loadXML($row['xml']);
if ($iso->validate())
{
$data=array("error"=>"元数据导入过程中发现错误。<br />".implode("<br />",$iso->error));
$this->jsonexit($data);
return true;
}
@$iso->saveDB($this->db);
//移除中间版本 //移除中间版本
$sql="delete from mdversion where uuid in (select uuid from mdversion where id=?) and changelog is null"; $sql="delete from mdversion where uuid in (select uuid from mdversion where id=?) and changelog is null";
$this->db->query($sql,array($id)); $this->db->query($sql,array($id));
@ -1906,8 +1921,16 @@ class AuthorController extends Zend_Controller_Action
else if ($row['status']==-1 || $row['status']==0 || $row['status']==1) //取消发布的数据,初始状态,已接收 else if ($row['status']==-1 || $row['status']==0 || $row['status']==1) //取消发布的数据,初始状态,已接收
{ {
//同步元数据 //同步元数据
$iso=new ISO19115(); $iso=new ISO19115();
@$iso->saveDB($this->db,$row['xml']); @$iso->loadXML($row['xml']);
if ($iso->validate())
{
$data=array("error"=>"元数据导入过程中发现错误。<br />".implode("<br />",$iso->error));
$this->jsonexit($data);
return true;
}
@$iso->saveDB($this->db);
//email to admin //email to admin
$mail=new WestdcMailer($this->view->config->smtp); $mail=new WestdcMailer($this->view->config->smtp);
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组'); $mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
@ -2035,8 +2058,16 @@ class AuthorController extends Zend_Controller_Action
else if ($row['status']>=5)//数据已经发布,再次修改后将只通知管理员,保留发布状态 else if ($row['status']>=5)//数据已经发布,再次修改后将只通知管理员,保留发布状态
{ {
//同步元数据 //同步元数据
$iso=new ISO19115(); $iso=new ISO19115();
@$iso->saveDB($this->db,$row['xml']); @$iso->loadXML($row['xml']);
if ($iso->validate())
{
$data=array("error"=>"元数据导入过程中发现错误。<br />".implode("<br />",$iso->error));
$this->jsonexit($data);
return true;
}
@$iso->saveDB($this->db);
//移除中间版本 //移除中间版本
$sql="delete from mdversion where uuid in (select uuid from mdversion where id=?) and changelog is null"; $sql="delete from mdversion where uuid in (select uuid from mdversion where id=?) and changelog is null";
$this->db->query($sql,array($id)); $this->db->query($sql,array($id));
@ -2266,6 +2297,16 @@ class AuthorController extends Zend_Controller_Action
$this->jsonexit($data); $this->jsonexit($data);
return true; return true;
} }
//首先检查元数据错误
$iso=new ISO19115();
@$iso->loadXML($row['data']);
if ($iso->validate())
{
$data=array("error"=>"元数据导入过程中发现错误。<br />".implode("<br />",$iso->error));
$this->jsonexit($data);
return true;
}
// 保存数据作者信息 // 保存数据作者信息
$sql="insert into mdauthor (uuid,userid,ts_activated,status) values(?,?,now(),1)"; $sql="insert into mdauthor (uuid,userid,ts_activated,status) values(?,?,now(),1)";
$this->db->query($sql,array($row['uuid'],$u_id)); $this->db->query($sql,array($row['uuid'],$u_id));
@ -2276,8 +2317,7 @@ class AuthorController extends Zend_Controller_Action
file_get_contents("http://ftp1.westgis.ac.cn/proftp_upload.php?uuid='".$row['uuid']."'&filelist=1"); file_get_contents("http://ftp1.westgis.ac.cn/proftp_upload.php?uuid='".$row['uuid']."'&filelist=1");
// 3. 保存数据评审状态 // 3. 保存数据评审状态
//导入元数据 //导入元数据
$iso=new ISO19115(); @$iso->saveDB($this->db);
@$iso->saveDB($this->db,$row['data']);
//进入评审库 //进入评审库
$sql="insert into mdstatus (uuid,status,userid) select uuid,0,? from geonetworkmetadata where id=?"; $sql="insert into mdstatus (uuid,status,userid) select uuid,0,? from geonetworkmetadata where id=?";
$this->db->query($sql,array($u_id,$id)); $this->db->query($sql,array($u_id,$id));