Beispiel #1
0
def search_result_detail(request):
    uuid = request.GET.get("uuid")
    csw = get_csw()
    csw.getrecordbyid([uuid])
    doc = csw._records.find(nspath('Record', namespaces['csw']))
    rec = _build_search_result(doc)
    return render_to_response('maps/search_result_snippet.html', RequestContext(request, {
        'rec': rec
    }))
Beispiel #2
0
def _inspire_validator(uuid):
    global _csw
    # Check the layer is in the GeoNetwork catalog and points back to get_absolute_url
    if(_csw is None): # Might need to re-cache, nothing equivalent to _wms.contents?
        _csw = get_csw()

    _csw.getrecordbyid([uuid], outputschema=namespaces["gmd"])
    md_metadata = _csw._exml.find('//'+util.nspath('MD_Metadata', namespaces['gmd']))
    body = etree.tostring(md_metadata)
    mp = MultipartParam('dataFile',body,filename='test.xml',filetype='text/xml',filesize=len(body))
    datagen, headers = multipart_encode([mp])
    request = urllib2.Request("http://www.inspire-geoportal.eu/INSPIREValidatorService/resources/validation/inspire", datagen, headers)
    register_openers()
    response = urllib2.urlopen(request).read()
    return response
Beispiel #3
0
def _inspire_validator(uuid):
    global _csw
    # Check the layer is in the GeoNetwork catalog and points back to get_absolute_url
    if (_csw is None
        ):  # Might need to re-cache, nothing equivalent to _wms.contents?
        _csw = get_csw()

    _csw.getrecordbyid([uuid], outputschema=namespaces["gmd"])
    md_metadata = _csw._exml.find(
        '//' + util.nspath('MD_Metadata', namespaces['gmd']))
    body = etree.tostring(md_metadata)
    mp = MultipartParam('dataFile',
                        body,
                        filename='test.xml',
                        filetype='text/xml',
                        filesize=len(body))
    datagen, headers = multipart_encode([mp])
    request = urllib2.Request(
        "http://inspire-geoportal.ec.europa.eu/INSPIREValidatorService/resources/validation/inspire",
        datagen, headers)
    register_openers()
    response = urllib2.urlopen(request).read()
    return response
Beispiel #4
0
def _metadata_search(query, start, limit, **kw):
    
    csw = get_csw()

    keywords = _split_query(query)
    
    csw.getrecords(keywords=keywords, startposition=start+1, maxrecords=limit, bbox=kw.get('bbox', None))
    
    
    # build results 
    # XXX this goes directly to the result xml doc to obtain 
    # correct ordering and a fuller view of the result record
    # than owslib currently parses.  This could be improved by
    # improving owslib.
    results = [_build_search_result(doc) for doc in 
               csw._records.findall('//'+nspath('Record', namespaces['csw']))]

    result = {'rows': results, 
              'total': csw.results['matches']}

    result['query_info'] = {
        'start': start,
        'limit': limit,
        'q': query
    }
    if start > 0: 
        prev = max(start - limit, 0)
        params = urlencode({'q': query, 'start': prev, 'limit': limit})
        result['prev'] = reverse('geonode.maps.views.metadata_search') + '?' + params

    next = csw.results.get('nextrecord', 0) 
    if next > 0:
        params = urlencode({'q': query, 'start': next - 1, 'limit': limit})
        result['next'] = reverse('geonode.maps.views.metadata_search') + '?' + params
    
    return result