Changeset 3544 for TI05-delivery


Ignore:
Timestamp:
28/02/08 15:24:20 (12 years ago)
Author:
cbyrom
Message:

Adjust code to allow multiple WMC docs to be selected in the selections
tab and displayed in the view tab. Also rename the display tab to 'details'
and add new exceptions to deal with URL lookup failures.

Location:
TI05-delivery/ows_framework/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_common/ows_common/exceptions.py

    r2507 r3544  
    3535        OwsError.__init__(self, 'NoApplicableCode', text, locator) 
    3636 
     37class URLUnavailable(OwsError): 
     38    def __init__(self, text, locator=None): 
     39        OwsError.__init__(self, 'URLUnavailable', text, locator) 
     40 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/retrieve.py

    r3536 r3544  
    9191                    c.xml=x.tohtml() 
    9292                    r='content' 
    93                     c.tab='Display' 
     93                    c.tab='Details' 
    9494                elif viewFormat=='DIF': 
    9595                    r='dif' 
     
    111111                    c.xml=x.tohtml() 
    112112                    r='content' 
    113                     c.tab='Display' 
     113                    c.tab='Details' 
    114114                elif self.format=='raw': 
    115115                    c.xml=x.xmls 
     
    120120            if 'lastViewed' not in session: needed=1 
    121121            session['lastViewed']=h.current_url() 
    122             if needed: c.pageTabs.append(('Display',session['lastViewed'])) 
     122            if needed: c.pageTabs.append(('Details',session['lastViewed'])) 
    123123             
    124124            session.save() 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/selectedItems.py

    r3536 r3544  
    44from ows_server.models import stubB 
    55from ows_server.lib.wmc_util import * 
     6from ows_server.controllers import viewItems 
    67import copy 
    78import urllib 
     
    4445                        wmcURLs.append(item.wmcURL) 
    4546                return getConTerraDoc(wmcURLs) 
     47         
     48        elif 'PlotSelectedInLocal' in self.inputs: 
     49            # get all selected selections 
     50            self.getSelectedItems() 
     51 
     52            # ensure selections have been made 
     53            if 'selectedItems' in session: 
     54                # the view tab uses its own selections session variable 
     55                # - this should initially match that set here 
     56                session['viewItems'] = copy.deepcopy(session['selectedItems']) 
     57                 
     58                viewController = viewItems.ViewitemsController() 
     59                return viewController.index() 
    4660         
    4761        else: 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/viewItems.py

    r3538 r3544  
    33from ows_server.models import Utilities 
    44from ows_server.lib.wmc_util import * 
     5from ows_server.models import stubB 
    56import copy 
    67 
     
    1314        if 'REQUEST' in self.inputs and self.inputs['REQUEST'] == 'GetWebMapContext': 
    1415            return GetWebMapContext(self) 
    15         # otherwise,  
    16         elif (self.inputs): 
    17             needed=0 
    18             if 'lastViewedWMC' not in session:  
    19                 needed=1 
    20             session['lastViewedWMC']=h.current_url() 
    21             if needed: 
    22                 c.pageTabs.append(('View',session['lastViewedWMC'])) 
    23             c.wmcURL = self.inputs['ENDPOINT'] 
     16        # otherwise, we can get here by two routes: 
     17        # i) either by clicking on the WMC icon in the details view - if so, get passed endpoint and add to 
     18        #    selected items; 
     19        # ii) or from the selections tab - which will already have set up the correct selected items 
     20         
     21        # firstly check if page has been visited before; if not display tab 
     22        if 'viewItems' not in session: 
     23            c.pageTabs.append(('View', h.url_for(controller='viewItems',action='index'))) 
    2424 
     25        # if ENDPOINT specified, we've reached the page via the WMC icon 
     26        if ('ENDPOINT' in self.inputs): 
     27            self.addViewItem(self.inputs['ENDPOINT']) 
     28                                     
    2529        session.save() 
    2630        return render('viewItems') 
     31 
     32 
     33    # add a selected item to the session 
     34    # - if this is the first item, then display the selections tab 
     35    def addViewItem(self,endpoint): 
     36         
     37        item = stubB.SelectedItem(None, None, None, endpoint) 
     38         
     39        selections = [item,] 
     40        # avoid duplicates 
     41        if 'viewItems' in session: 
     42            for selection in session['viewItems']: 
     43                if selection.wmcURL != endpoint: 
     44                    selections.append(selection) 
     45                     
     46        session['viewItems'] = selections 
     47        session.save() 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/base.py

    r3536 r3544  
    9090            c.pageTabs.append(('Selections',h.url_for(controller='selectedItems',action='index'))) 
    9191             
    92         if 'lastViewed' in session: c.pageTabs.append(('Display',session['lastViewed'])) 
    93         if 'lastViewedWMC' in session: c.pageTabs.append(('View',session['lastViewedWMC'])) 
     92        if 'lastViewed' in session: c.pageTabs.append(('Details',session['lastViewed'])) 
    9493         
     94        if 'viewItems' in session: c.pageTabs.append(('View', h.url_for(controller='viewItems',action='index'))) 
     95 
    9596#            c.pageTabs.append(('Visualise',h.url_for(controller='visualise', action='index'))) 
    9697#            c.pageTabs.append(('Download','Blah')) 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/lib/wmc_util.py

    r3536 r3544  
    1313from ndgUtils.ETxmlView import loadET,et2text, nsdumb 
    1414from ows_server.models.WMC import WMC 
     15from ows_common import exceptions 
    1516import urllib2 
    1617 
     
    6162    return render('conterra_aggregate', format='xml') 
    6263 
    63          
    6464 
    65 # Lookup a WMC doc and return it in the response     
     65     
    6666def GetWebMapContext(self): 
     67    """ 
     68    Lookup a WMC doc and return it in the response 
     69    """ 
    6770    # retrieve context data from the specifiled url 
    6871    endpoint = self.inputs['ENDPOINT'] 
    6972    if not endpoint: 
    70         raise ServiceException, "ENDPOINT parameter required" 
     73        raise exceptions.MissingParameterValue, "ENDPOINT parameter required" 
    7174    logger.info('Getting WebMapContext from endpoint: ' + endpoint) 
    7275 
     
    7477        filehandle = urllib2.urlopen(endpoint) 
    7578    except IOError: 
    76         raise ServiceException, "Could not access WMC endpoint: %s" % endpoint 
     79        raise exceptions.URLUnavailable, "Could not access WMC endpoint: %s" % endpoint 
    7780         
    7881    response.headers['Content-Type'] = 'text/xml' 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/Utilities.py

    r3501 r3544  
    171171    recreate it in its list form 
    172172    ''' 
     173    if not string: 
     174        return 
     175     
    173176    newList = [] 
    174177    element = [] 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/public/js/wmscControl.js

    r3538 r3544  
    3030    wmsParams: null, 
    3131 
    32     initialize: function(treeDiv, layerDiv, domainDiv, notesDiv)  
     32    initialize: function(treeDiv, layerDiv, domainDiv)  
    3333    { 
    3434                WMSC.log("Initialising Control"); 
     
    3636                this.layerDiv = layerDiv; 
    3737                this.domainDiv = domainDiv; 
    38                 this.notesDiv = notesDiv; 
    3938 
    4039                this.events = new OpenLayers.Events(this, $(this.treeDiv), 
     
    202201 
    203202                this.wmsEndpoint = node.data.endpoint; 
    204                 this._updateTreeNotes(); 
    205203 
    206204                // If this node is a leaf, display the different layers available 
     
    441439        return items; 
    442440    }, 
    443     _updateTreeNotes: function() { 
    444         var div = $(this.notesDiv); 
    445         var notes = this.getTreeNotes(); 
    446         var i, items, item; 
    447  
    448         items = []; 
    449         for (i=0; i<notes.length; i++) { 
    450             item = '<li><b>'+notes[i].title+'</b>'; 
    451             if (notes[i].abstract) { 
    452                 item += '<div>'+notes[i].abstract+'</div>'; 
    453             } 
    454             item += '</li>'; 
    455             items[items.length] = item; 
    456         } 
    457         div.innerHTML = '<ul class="WMSC_treeNotes">' + items.join('\n') + '</ul>'; 
    458     }, 
    459441 
    460442    /** A hook to change the display of Dimension items. 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/dif.kid

    r3503 r3544  
    77    <div id="entirepage"> 
    88        <div py:replace="header()"/> 
    9         <div py:replace="PageTabs('Display')"/> 
     9        <div py:replace="PageTabs('Details')"/> 
    1010        <div py:replace="searchOneLine()"/> 
    1111        <div id="contents"> 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/stubB.kid

    r3503 r3544  
    77    <body> 
    88        <div id="entirepage"> ${XML(c.tbinfo)} <div py:replace="header()"/> 
    9             <div py:replace="PageTabs('Display')"/> 
     9            <div py:replace="PageTabs('Details')"/> 
    1010            <div py:replace="searchOneLine(targets='Browse')"/> 
    1111            <div id="contents"> 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/viewItems.kid

    r3538 r3544  
    4444function init()  
    4545{ 
    46     control = new WMSC.Control('layerTree', 'layerLeaves', 'dims', 'notes'); 
    47     control.addWebMapContext('viewItems', '${c.wmcURL}'); 
     46    control = new WMSC.Control('layerTree', 'layerLeaves', 'dims'); 
     47    <for py:for="i in session['viewItems']" class="dataset" py:strip="True"> 
     48        control.addWebMapContext('viewItems', '${i.wmcURL}'); 
     49    </for> 
    4850 
    4951    app = new WMSC.VisApp('map', control); 
     
    114116<table class="controlTable"> 
    115117<tr class="controlHeadings"> 
    116 <th>Dataset</th><th>Field</th><th>Selection Notes</th> 
     118<th>Dataset</th><th>Field</th> 
    117119</tr> 
    118120<tr> 
     
    125127        </div> 
    126128</td> 
    127 <td class="controlPanel"> 
    128         <div class="controlContent" id="notes"> 
    129         </div> 
    130 </td> 
    131129</tr> 
    132130</table> 
Note: See TracChangeset for help on using the changeset viewer.