change schema to en

This commit is contained in:
wlx 2013-11-10 10:40:56 +00:00
parent e31ccb7cc6
commit 2fa1e199bb
1 changed files with 28 additions and 28 deletions

View File

@ -170,10 +170,10 @@ class ISO19115
{
if (!empty($xml)) $this->loadXML($xml);
//先删除已有元数据,然后再插入新数据
$sql="delete from metadata where uuid=?";
$sql="delete from en.metadata where uuid=?";
$db->query($sql,array($this->uuid));
//删除所有未用到的responsible数据
$sql="delete from responsible where id not in (select distinct(resid) from role)";
$sql="delete from en.responsible where id not in (select distinct(resid) from role)";
$db->query($sql);
$this->view->config = Zend_Registry::get('config');
@ -181,8 +181,8 @@ class ISO19115
//生成空白统计数据可以转移到数据库端处理todo
try
{
$sql="insert into mdstat (uuid) values(?)";
$db->query($sql,array($this->uuid));
//$sql="insert into mdstat (uuid) values(?)";
//$db->query($sql,array($this->uuid));
} catch (Exception $e) {
//do nothing.
//说明数据库中已存在该信息
@ -193,41 +193,41 @@ class ISO19115
try {
if ($this->refDate)
{
$sql="insert into metadata (uuid,title,title_en,description,citation,suppinfo,fileformat,projection,datatype,filesize,ts_created,
$sql="insert into en.metadata (uuid,title,title_en,description,citation,suppinfo,fileformat,projection,datatype,filesize,ts_created,
timebegin,timeend,west,south,north,east,doi,ts_published) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$db->query($sql,array($this->uuid,$this->resTitle,$this->resAltTitle,$this->idAbs,$this->citation,$this->suppinfo,$this->fileformat,
$this->projection,$this->datatype,$this->filesize,$this->mdDateSt,$this->timebegin,$this->timeend,$this->geoBox['w'],
$this->geoBox['s'],$this->geoBox['n'],$this->geoBox['e'],$this->doi,$this->refDate));
} else {
$sql="insert into metadata (uuid,title,title_en,description,citation,suppinfo,fileformat,projection,datatype,filesize,ts_created,
$sql="insert into en.metadata (uuid,title,title_en,description,citation,suppinfo,fileformat,projection,datatype,filesize,ts_created,
timebegin,timeend,west,south,north,east,doi) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$db->query($sql,array($this->uuid,$this->resTitle,$this->resAltTitle,$this->idAbs,$this->citation,$this->suppinfo,$this->fileformat,
$this->projection,$this->datatype,$this->filesize,$this->mdDateSt,$this->timebegin,$this->timeend,$this->geoBox['w'],
$this->geoBox['s'],$this->geoBox['n'],$this->geoBox['e'],$this->doi));
}
$id=$db->lastInsertId('metadata','id');
$id=$db->lastInsertId('en.metadata','id');
//处理在线资源
if ($this->onlineresource) foreach($this->onlineresource as $resource)
{
$sql="insert into onlineresource (uuid,linkage,protocol,name,description) values(?,?,?,?,?)";
$sql="insert into en.onlineresource (uuid,linkage,protocol,name,description) values(?,?,?,?,?)";
$db->query($sql,array($this->uuid,$resource['linkage'],$resource['protocol'],$resource['name'],$resource['description']));
}
//处理缩略图
if (!empty($this->thumbnail)) {
$sql="insert into thumbnail (id,data,filetype) values(?,?,?)";
$sql="insert into en.thumbnail (id,data,filetype) values(?,?,?)";
$db->query($sql,array($id,$this->thumbnail,'jpg'));
} elseif ($this->graph) {
//$trow->data=$this->graph['data'];
$sql="select id as gid from geonetworkmetadata where uuid=?";
$sql="select id as gid from en.geonetworkmetadata where uuid=?";
$r=$db->fetchRow($sql,array($this->uuid));
if ($r)
{
if ($this->view->config)
$geonetwork=$this->view->config->geonetwork->url;
else
$geonetwork='http://westdc.westgis.ac.cn/geonetwork/';
$geonetwork='http://card.westgis.ac.cn/geonetwork/';
$thumb=base64_encode(file_get_contents($geonetwork.'srv/cn/resources.get?access=public&id='.$r->gid.'&fname='.urlencode($this->graph['filename'])));
$sql="insert into thumbnail (id,data,filetype,filedesc,filename) values(?,?,?,?,?)";
$sql="insert into en.thumbnail (id,data,filetype,filedesc,filename) values(?,?,?,?,?)";
$db->query($sql,array($id,$thumb,$this->graph['filetype'],$this->graph['filedesc'],$this->graph['filename']));
}
}
@ -237,7 +237,7 @@ class ISO19115
{
foreach($keys as $key)
{
$sql="insert into keyword (id,keyword,keytype) values(?,?,?)";
$sql="insert into en.keyword (id,keyword,keytype) values(?,?,?)";
try {
$db->query($sql,array($id,$key,$keytype));
} catch(Exception $e) {
@ -249,29 +249,29 @@ class ISO19115
//M:N relation
if ($this->datasetSeries) foreach($this->datasetSeries as $ds) if (!empty($ds['seriesName']))
{
$sql="select id from series where name=?";
$sql="select id from en.series where name=?";
$sth=$db->prepare($sql);
$sth->execute(array($ds['seriesName']));
$trow=$sth->fetch();
if ($trow)
$sid=$trow->id;
else {
$sql="insert into series (name) values(?)";
$sql="insert into en.series (name) values(?)";
$db->query($sql,array($ds['seriesName']));
$sid=$db->lastInsertId('series','id');
}
$sql="insert into dataseries (id,sid) values(?,?)";
$sql="insert into en.dataseries (id,sid) values(?,?)";
$db->query($sql,array($id,$sid));
}
//处理数据分类
foreach($this->tpCat as $cat){
if (is_numeric($cat)) {
$sql="insert into category (id,code) values(?,?)";
$sql="insert into en.category (id,code) values(?,?)";
$db->query($sql,array($id,(int)$cat));
} else {
//是字符串geonetwork会采用这种模式
//从categorycode表中查找其对应的code
$sql="insert into category (id,code) select ?,code from categorycode where name=?";
$sql="insert into en.category (id,code) select ?,code from categorycode where name=?";
$db->query($sql,array($id, trim($cat)));
}
}
@ -284,25 +284,25 @@ class ISO19115
$inds=explode(";",$au['individual']);
foreach($inds as $ind)
{
$sql="select id from responsible where individual=? and organisation=?";
$sql="select id from en.responsible where individual=? and organisation=?";
$row=$db->fetchRow($sql,array(trim($ind),trim($au['organisation'])));
if (!$row)
{
$sql="insert into responsible (individual,organisation,position,delivery,phone,email,city,country,administrative,postal) values(?,?,?,?,?,?,?,?,?,?)";
$sql="insert into en.responsible (individual,organisation,position,delivery,phone,email,city,country,administrative,postal) values(?,?,?,?,?,?,?,?,?,?)";
$db->query($sql,array(trim($ind),trim($au['organisation']),trim($au['position']),trim($au['delivery']),trim($au['phone']),trim($au['email']),trim($au['city']),trim($au['country']),trim($au['administrative']),trim($au['postal'])));
} elseif (count($inds)==1) {
//deal email address
if (($au['email']) && empty($row->email))
{
$sql="update responsible set email=? where id=?";
$sql="update en.responsible set email=? where id=?";
$db->query($sql,array(trim($au['email']),$row->id));
}
}
$sql="select id from responsible where individual=? and organisation=?";
$sql="select id from en.responsible where individual=? and organisation=?";
$row=$db->fetchRow($sql,array(trim($ind),trim($au['organisation'])));
if ($row->id>0)
{
$sql="insert into role (resid,uuid,role) values(?,?,?)";
$sql="insert into en.role (resid,uuid,role) values(?,?,?)";
$db->query($sql,array($row->id,$this->uuid,trim($au['role'])));
}
}
@ -310,25 +310,25 @@ class ISO19115
//处理数据限制信息
foreach($this->limits as $uselimit)
{
$sql="select id from uselimit where uselimit=?";
$sql="select id from en.uselimit where uselimit=?";
$row=$db->fetchRow($sql,array($uselimit));
if (!$row)
{
$sql="insert into uselimit (uselimit) values (?)";
$sql="insert into en.uselimit (uselimit) values (?)";
$db->query($sql,array($uselimit));
}
$sql="select id from uselimit where uselimit=?";
$sql="select id from en.uselimit where uselimit=?";
$row=$db->fetchRow($sql,array($uselimit));
if ($row)
{
$sql="insert into mdlimit (uuid,lid) values(?,?)";
$sql="insert into en.mdlimit (uuid,lid) values(?,?)";
$db->query($sql,array($this->uuid,$row->id));
}
}
$this->save("../data/import/$this->uuid.xml");
//处理XML入库
if (!empty($xml)) $this->xml=$xml;
$sql="insert into xml (id,data) values(?,?)";
$sql="insert into en.xml (id,data) values(?,?)";
$db->query($sql,array($id,$this->xml));
} catch (Exception $e) {
//数据重复插入,此处忽略所有错误