change schema to en
This commit is contained in:
parent
e31ccb7cc6
commit
2fa1e199bb
|
@ -170,10 +170,10 @@ class ISO19115
|
||||||
{
|
{
|
||||||
if (!empty($xml)) $this->loadXML($xml);
|
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));
|
$db->query($sql,array($this->uuid));
|
||||||
//删除所有未用到的responsible数据
|
//删除所有未用到的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);
|
$db->query($sql);
|
||||||
$this->view->config = Zend_Registry::get('config');
|
$this->view->config = Zend_Registry::get('config');
|
||||||
|
|
||||||
|
@ -181,8 +181,8 @@ class ISO19115
|
||||||
//生成空白统计数据,可以转移到数据库端处理(todo)
|
//生成空白统计数据,可以转移到数据库端处理(todo)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$sql="insert into mdstat (uuid) values(?)";
|
//$sql="insert into mdstat (uuid) values(?)";
|
||||||
$db->query($sql,array($this->uuid));
|
//$db->query($sql,array($this->uuid));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
//do nothing.
|
//do nothing.
|
||||||
//说明数据库中已存在该信息
|
//说明数据库中已存在该信息
|
||||||
|
@ -193,41 +193,41 @@ class ISO19115
|
||||||
try {
|
try {
|
||||||
if ($this->refDate)
|
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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
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,
|
$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->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));
|
$this->geoBox['s'],$this->geoBox['n'],$this->geoBox['e'],$this->doi,$this->refDate));
|
||||||
} else {
|
} 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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
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,
|
$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->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->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)
|
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']));
|
$db->query($sql,array($this->uuid,$resource['linkage'],$resource['protocol'],$resource['name'],$resource['description']));
|
||||||
}
|
}
|
||||||
//处理缩略图
|
//处理缩略图
|
||||||
if (!empty($this->thumbnail)) {
|
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'));
|
$db->query($sql,array($id,$this->thumbnail,'jpg'));
|
||||||
} elseif ($this->graph) {
|
} elseif ($this->graph) {
|
||||||
//$trow->data=$this->graph['data'];
|
//$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));
|
$r=$db->fetchRow($sql,array($this->uuid));
|
||||||
if ($r)
|
if ($r)
|
||||||
{
|
{
|
||||||
if ($this->view->config)
|
if ($this->view->config)
|
||||||
$geonetwork=$this->view->config->geonetwork->url;
|
$geonetwork=$this->view->config->geonetwork->url;
|
||||||
else
|
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'])));
|
$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']));
|
$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)
|
foreach($keys as $key)
|
||||||
{
|
{
|
||||||
$sql="insert into keyword (id,keyword,keytype) values(?,?,?)";
|
$sql="insert into en.keyword (id,keyword,keytype) values(?,?,?)";
|
||||||
try {
|
try {
|
||||||
$db->query($sql,array($id,$key,$keytype));
|
$db->query($sql,array($id,$key,$keytype));
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
|
@ -249,29 +249,29 @@ class ISO19115
|
||||||
//M:N relation
|
//M:N relation
|
||||||
if ($this->datasetSeries) foreach($this->datasetSeries as $ds) if (!empty($ds['seriesName']))
|
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=$db->prepare($sql);
|
||||||
$sth->execute(array($ds['seriesName']));
|
$sth->execute(array($ds['seriesName']));
|
||||||
$trow=$sth->fetch();
|
$trow=$sth->fetch();
|
||||||
if ($trow)
|
if ($trow)
|
||||||
$sid=$trow->id;
|
$sid=$trow->id;
|
||||||
else {
|
else {
|
||||||
$sql="insert into series (name) values(?)";
|
$sql="insert into en.series (name) values(?)";
|
||||||
$db->query($sql,array($ds['seriesName']));
|
$db->query($sql,array($ds['seriesName']));
|
||||||
$sid=$db->lastInsertId('series','id');
|
$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));
|
$db->query($sql,array($id,$sid));
|
||||||
}
|
}
|
||||||
//处理数据分类
|
//处理数据分类
|
||||||
foreach($this->tpCat as $cat){
|
foreach($this->tpCat as $cat){
|
||||||
if (is_numeric($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));
|
$db->query($sql,array($id,(int)$cat));
|
||||||
} else {
|
} else {
|
||||||
//是字符串,geonetwork会采用这种模式
|
//是字符串,geonetwork会采用这种模式
|
||||||
//从categorycode表中查找其对应的code
|
//从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)));
|
$db->query($sql,array($id, trim($cat)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,25 +284,25 @@ class ISO19115
|
||||||
$inds=explode(";",$au['individual']);
|
$inds=explode(";",$au['individual']);
|
||||||
foreach($inds as $ind)
|
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'])));
|
$row=$db->fetchRow($sql,array(trim($ind),trim($au['organisation'])));
|
||||||
if (!$row)
|
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'])));
|
$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) {
|
} elseif (count($inds)==1) {
|
||||||
//deal email address
|
//deal email address
|
||||||
if (($au['email']) && empty($row->email))
|
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));
|
$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'])));
|
$row=$db->fetchRow($sql,array(trim($ind),trim($au['organisation'])));
|
||||||
if ($row->id>0)
|
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'])));
|
$db->query($sql,array($row->id,$this->uuid,trim($au['role'])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,25 +310,25 @@ class ISO19115
|
||||||
//处理数据限制信息
|
//处理数据限制信息
|
||||||
foreach($this->limits as $uselimit)
|
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));
|
$row=$db->fetchRow($sql,array($uselimit));
|
||||||
if (!$row)
|
if (!$row)
|
||||||
{
|
{
|
||||||
$sql="insert into uselimit (uselimit) values (?)";
|
$sql="insert into en.uselimit (uselimit) values (?)";
|
||||||
$db->query($sql,array($uselimit));
|
$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));
|
$row=$db->fetchRow($sql,array($uselimit));
|
||||||
if ($row)
|
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));
|
$db->query($sql,array($this->uuid,$row->id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->save("../data/import/$this->uuid.xml");
|
$this->save("../data/import/$this->uuid.xml");
|
||||||
//处理XML入库
|
//处理XML入库
|
||||||
if (!empty($xml)) $this->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));
|
$db->query($sql,array($id,$this->xml));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
//数据重复插入,此处忽略所有错误
|
//数据重复插入,此处忽略所有错误
|
||||||
|
|
Loading…
Reference in New Issue