From: <fxp...@us...> - 2008-04-08 11:13:55
|
Revision: 1266 http://geonetwork.svn.sourceforge.net/geonetwork/?rev=1266&view=rev Author: fxprunayre Date: 2008-04-08 04:14:00 -0700 (Tue, 08 Apr 2008) Log Message: ----------- Added OGC WxS GetCapabilities harvester Added Paths: ----------- trunk/web/geonetwork/scripts/harvesting/ogcwxs/ trunk/web/geonetwork/scripts/harvesting/ogcwxs/model.js trunk/web/geonetwork/scripts/harvesting/ogcwxs/ogcwxs.js trunk/web/geonetwork/scripts/harvesting/ogcwxs/view.js Added: trunk/web/geonetwork/scripts/harvesting/ogcwxs/model.js =================================================================== --- trunk/web/geonetwork/scripts/harvesting/ogcwxs/model.js (rev 0) +++ trunk/web/geonetwork/scripts/harvesting/ogcwxs/model.js 2008-04-08 11:14:00 UTC (rev 1266) @@ -0,0 +1,109 @@ +//===================================================================================== +//=== +//=== Model (type:ogcwxs) +//=== +//===================================================================================== + +ogcwxs.Model = function(xmlLoader) +{ + HarvesterModel.call(this); + + var loader = xmlLoader; + var callBackF = null; + + this.retrieveGroups = retrieveGroups; + this.retrieveCategories= retrieveCategories; + this.retrieveIcons = retrieveIcons; + this.getUpdateRequest = getUpdateRequest; + +//===================================================================================== + +function retrieveGroups(callBack) +{ + new InfoService(loader, 'groups', callBack); +} + +//===================================================================================== + +function retrieveCategories(callBack) +{ + new InfoService(loader, 'categories', callBack); +} + +//===================================================================================== + +function retrieveIcons(callBack) +{ + callBackF = callBack; + + var request = ker.createRequest('type', 'icons'); + + ker.send('xml.harvesting.info', request, ker.wrap(this, retrieveIcons_OK)); +} + +//------------------------------------------------------------------------------------- + +function retrieveIcons_OK(xmlRes) +{ + if (xmlRes.nodeName == 'error') + ker.showError(loader.getText('cannotRetrieve'), xmlRes); + else + { + var data = []; + var list = xml.children(xml.children(xmlRes)[0]); + + for (var i=0; i<list.length; i++) + data.push(xml.textContent(list[i])); + + callBackF(data); + } +} + +//===================================================================================== + +function getUpdateRequest(data) +{ + var request = str.substitute(updateTemp, data); + //alert (this.substituteCommon(data, request)); + return this.substituteCommon(data, request); +} + +//===================================================================================== + +var updateTemp = +' <node id="{ID}" type="{TYPE}">'+ +' <site>'+ +' <name>{NAME}</name>'+ +' <ogctype>{OGCTYPE}</ogctype>'+ +' <url>{CAPAB_URL}</url>'+ +' <icon>{ICON}</icon>'+ +' <account>'+ +' <use>{USE_ACCOUNT}</use>'+ +' <username>{USERNAME}</username>'+ +' <password>{PASSWORD}</password>'+ +' </account>'+ +' </site>'+ + +' <options>'+ +' <every>{EVERY}</every>'+ +' <oneRunOnly>{ONE_RUN_ONLY}</oneRunOnly>'+ +' <lang>{LANG}</lang>'+ +' <topic>{TOPIC}</topic>' + +' <createThumbnails>{CREATETHUMBNAILS}</createThumbnails>' + +' <useLayer>{USELAYER}</useLayer>' + +' <useLayerMd>{USELAYERMD}</useLayerMd>'+ +' <datasetCategory>{DATASETCATEGORY}</datasetCategory>'+ +' </options>'+ + +' <privileges>'+ +' {PRIVIL_LIST}'+ +' </privileges>'+ + +' <categories>'+ +' {CATEG_LIST}'+ +' </categories>'+ +' </node>'; + + +//===================================================================================== +} Added: trunk/web/geonetwork/scripts/harvesting/ogcwxs/ogcwxs.js =================================================================== --- trunk/web/geonetwork/scripts/harvesting/ogcwxs/ogcwxs.js (rev 0) +++ trunk/web/geonetwork/scripts/harvesting/ogcwxs/ogcwxs.js 2008-04-08 11:14:00 UTC (rev 1266) @@ -0,0 +1,97 @@ +//===================================================================================== +//=== +//=== ogcwxs controller +//=== +//===================================================================================== + +ker.include('harvesting/ogcwxs/model.js'); +ker.include('harvesting/ogcwxs/view.js'); + +var ogcwxs = new Object(); + +//===================================================================================== + +function OgcWxs(xmlLoader) +{ + //--- call super constructor + Harvester.call(this); + + var loader= xmlLoader; + + var model = new ogcwxs.Model(loader); + var view = new ogcwxs.View(loader); + + //--- public methods + this.addGroupRow = addGroupRow; + this.removeGroupRow = view.removeGroupRow; + this.getResultTip = view.getResultTip; + + this.model = model; + this.view = view; + +//===================================================================================== +//=== +//=== API methods +//=== +//===================================================================================== + +this.getType = function() { return "ogcwxs"; } +this.getLabel = function() { return loader.eval("info[@type='ogcwxs']/long"); } +this.getEditPanel = function() { return "ogcwxs.editPanel"; } + +//===================================================================================== + +this.init = function() +{ + this.view.init(); + + model.retrieveGroups (ker.wrap(this, init_groups_OK)); + model.retrieveCategories(ker.wrap(this, init_categ_OK)); + model.retrieveIcons (ker.wrap(this, init_icons_OK)); +} + +//------------------------------------------------------------------------------------- + +function init_groups_OK(data) +{ + view.clearGroups(); + + for (var i=0; i<data.length; i++) + view.addGroup(data[i].id, data[i].label[Env.lang]); +} + +//------------------------------------------------------------------------------------- + +function init_categ_OK(data) +{ + view.clearCategories(); + + for (var i=0; i<data.length; i++) { + view.addCategory(data[i].id, data[i].label[Env.lang]); + + gui.addToSelect('ogcwxs.datasetCategory', data[i].id, data[i].label[Env.lang]); + } +} + +//------------------------------------------------------------------------------------- + +function init_icons_OK(data) +{ + view.clearIcons(); + + for (var i=0; i<data.length; i++) + view.addIcon(data[i]); +} + +//===================================================================================== + +function addGroupRow() +{ + var groups = view.getSelectedGroups(); + + if (groups.length == 0) alert(loader.getText('pleaseSelectGroup')); + else view.addEmptyGroupRows(groups); +} + +//===================================================================================== +} Added: trunk/web/geonetwork/scripts/harvesting/ogcwxs/view.js =================================================================== --- trunk/web/geonetwork/scripts/harvesting/ogcwxs/view.js (rev 0) +++ trunk/web/geonetwork/scripts/harvesting/ogcwxs/view.js 2008-04-08 11:14:00 UTC (rev 1266) @@ -0,0 +1,182 @@ +//===================================================================================== +//=== +//=== View (type:ogcwxs) +//=== +//===================================================================================== + +ogcwxs.View = function(xmlLoader) +{ + HarvesterView.call(this); + + var privilTransf = new XSLTransformer('harvesting/ogcwxs/client-privil-row.xsl', xmlLoader); + var resultTransf = new XSLTransformer('harvesting/ogcwxs/client-result-tip.xsl', xmlLoader); + + var loader = xmlLoader; + var valid = new Validator(loader); + var shower = null; + + + var currSearchId = 0; + + this.setPrefix('ogcwxs'); + + this.setPrivilTransf(privilTransf); + this.setResultTransf(resultTransf); + + //--- public methods + + this.init = init; + this.setEmpty = setEmpty; + this.setData = setData; + this.getData = getData; + this.isDataValid = isDataValid; + this.clearIcons = clearIcons; + this.addIcon = addIcon; + + Event.observe('ogcwxs.icon', 'change', ker.wrap(this, updateIcon)); + +//===================================================================================== +//=== +//=== API methods +//=== +//===================================================================================== + +function init() +{ + valid.add( + [ + { id:'ogcwxs.name', type:'length', minSize :1, maxSize :200 }, + { id:'ogcwxs.capabUrl', type:'length', minSize :1, maxSize :200 }, + { id:'ogcwxs.capabUrl', type:'url' }, + { id:'ogcwxs.username', type:'length', minSize :0, maxSize :200 }, + { id:'ogcwxs.password', type:'length', minSize :0, maxSize :200 }, + { id:'ogcwxs.every.days', type:'integer', minValue:0, maxValue:99 }, + { id:'ogcwxs.every.hours', type:'integer', minValue:0, maxValue:23 }, + { id:'ogcwxs.every.mins', type:'integer', minValue:0, maxValue:59 } + ]); + shower = new Shower('ogcwxs.useAccount', 'ogcwxs.account'); + +} + +//===================================================================================== + +function setEmpty() +{ + this.setEmptyCommon(); + + $('ogcwxs.useLayer').checked = false; + $('ogcwxs.useLayerMd').checked = false; + $('ogcwxs.createThumbnails').checked = false; + $('ogcwxs.ogctype').value = 'WMS111'; + $('ogcwxs.lang').value = 'eng'; + $('ogcwxs.topic').value = ''; + $('ogcwxs.capabUrl').value = ''; + + var icons = $('ogcwxs.icon').options; + + for (var i=0; i<icons.length; i++) + if (icons[i].value == 'default.gif') + { + icons[i].selected = true; + break; + } + + shower.update(); + updateIcon(); +} + +//===================================================================================== + +function setData(node) +{ + this.setDataCommon(node); + + var site = node.getElementsByTagName('site') [0]; + var options = node.getElementsByTagName('options')[0]; + + hvutil.setOption(site, 'url', 'ogcwxs.capabUrl'); + hvutil.setOption(site, 'ogctype', 'ogcwxs.ogctype'); + hvutil.setOption(site, 'icon', 'ogcwxs.icon'); + hvutil.setOption(options, 'topic', 'ogcwxs.topic'); + hvutil.setOption(options, 'createThumbnails', 'ogcwxs.createThumbnails'); + hvutil.setOption(options, 'useLayer', 'ogcwxs.useLayer'); + hvutil.setOption(options, 'useLayerMd', 'ogcwxs.useLayerMd'); + hvutil.setOption(options, 'lang', 'ogcwxs.lang'); + hvutil.setOption(options, 'datasetCategory', 'ogcwxs.datasetCategory'); + + + //--- add privileges entries + + this.removeAllGroupRows(); + this.addGroupRows(node); + + //--- set categories + + this.unselectCategories(); + this.selectCategories(node); + + shower.update(); + updateIcon(); +} + +//===================================================================================== + +function getData() +{ + var data = this.getDataCommon(); + + data.CAPAB_URL = $F('ogcwxs.capabUrl'); + data.ICON = $F('ogcwxs.icon'); + data.OGCTYPE = $F('ogcwxs.ogctype'); + data.LANG = $F('ogcwxs.lang'); + data.TOPIC = $F('ogcwxs.topic'); + data.DATASETCATEGORY = $F('ogcwxs.datasetCategory'); + data.CREATETHUMBNAILS = $('ogcwxs.createThumbnails').checked; + data.USELAYER = $('ogcwxs.useLayer').checked; + data.USELAYERMD = $('ogcwxs.useLayerMd').checked; + + //--- retrieve privileges and categories information + + data.PRIVILEGES = this.getPrivileges(); + data.CATEGORIES = this.getSelectedCategories(); + + return data; +} + +//===================================================================================== + +function isDataValid() +{ + if (!valid.validate()) + return false; + + return this.isDataValidCommon(); +} + +//===================================================================================== + +function clearIcons() +{ + $('ogcwxs.icon').options.length = 0; +} + +//===================================================================================== + +function addIcon(file) +{ + gui.addToSelect('ogcwxs.icon', file, file); +} + +//===================================================================================== + +function updateIcon() +{ + var icon = $F('ogcwxs.icon'); + var image= $('ogcwxs.icon.image'); + + image.setAttribute('src', Env.url +'/images/harvesting/'+icon); +} + +//===================================================================================== +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |