#NEWLINE# def getrecordbyid( self , raw = False ) : #NEWLINE# #INDENT# ' Handle GetRecordById request ' #NEWLINE# if ( 'id' not in self . parent . kvp ) : #NEWLINE# #INDENT# return self . exceptionreport ( 'MissingParameterValue' , 'id' , 'Missing id parameter' ) #NEWLINE# #UNINDENT# if ( len ( self . parent . kvp [ 'id' ] ) < 1 ) : #NEWLINE# #INDENT# return self . exceptionreport ( 'InvalidParameterValue' , 'id' , 'Invalid id parameter' ) #NEWLINE# #UNINDENT# if ( 'outputschema' not in self . parent . kvp ) : #NEWLINE# #INDENT# self . parent . kvp [ 'outputschema' ] = self . parent . context . namespaces [ 'csw' ] #NEWLINE# #UNINDENT# if ( self . parent . requesttype == 'GET' ) : #NEWLINE# #INDENT# self . parent . kvp [ 'id' ] = self . parent . kvp [ 'id' ] . split ( ',' ) #NEWLINE# #UNINDENT# if ( ( 'outputformat' in self . parent . kvp ) and ( self . parent . kvp [ 'outputformat' ] not in self . parent . context . model [ 'operations' ] [ 'GetRecordById' ] [ 'parameters' ] [ 'outputFormat' ] [ 'values' ] ) ) : #NEWLINE# #INDENT# return self . exceptionreport ( 'InvalidParameterValue' , 'outputformat' , ( 'Invalid outputformat parameter %s' % self . parent . kvp [ 'outputformat' ] ) ) #NEWLINE# #UNINDENT# if ( ( 'outputschema' in self . parent . kvp ) and ( self . parent . kvp [ 'outputschema' ] not in self . parent . context . model [ 'operations' ] [ 'GetRecordById' ] [ 'parameters' ] [ 'outputSchema' ] [ 'values' ] ) ) : #NEWLINE# #INDENT# return self . exceptionreport ( 'InvalidParameterValue' , 'outputschema' , ( 'Invalid outputschema parameter %s' % self . parent . kvp [ 'outputschema' ] ) ) #NEWLINE# #UNINDENT# if ( 'elementsetname' not in self . parent . kvp ) : #NEWLINE# #INDENT# self . parent . kvp [ 'elementsetname' ] = 'summary' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . parent . kvp [ 'elementsetname' ] not in self . parent . context . model [ 'operations' ] [ 'GetRecordById' ] [ 'parameters' ] [ 'ElementSetName' ] [ 'values' ] ) : #NEWLINE# #INDENT# return self . exceptionreport ( 'InvalidParameterValue' , 'elementsetname' , ( 'Invalid elementsetname parameter %s' % self . parent . kvp [ 'elementsetname' ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# node = etree . Element ( util . nspath_eval ( 'csw:GetRecordByIdResponse' , self . parent . context . namespaces ) , nsmap = self . parent . context . namespaces ) #NEWLINE# node . attrib [ util . nspath_eval ( 'xsi:schemaLocation' , self . parent . context . namespaces ) ] = ( '%s %s/csw/2.0.2/CSW-discovery.xsd' % ( self . parent . context . namespaces [ 'csw' ] , self . parent . config . get ( 'server' , 'ogc_schemas_base' ) ) ) #NEWLINE# LOGGER . debug ( ( 'Querying repository with ids: %s.' % self . parent . kvp [ 'id' ] [ 0 ] ) ) #NEWLINE# results = self . parent . repository . query_ids ( self . parent . kvp [ 'id' ] ) #NEWLINE# if raw : #NEWLINE# #INDENT# LOGGER . debug ( 'GetRepositoryItem request.' ) #NEWLINE# if ( len ( results ) > 0 ) : #NEWLINE# #INDENT# return etree . fromstring ( util . getqattr ( results [ 0 ] , self . parent . context . md_core_model [ 'mappings' ] [ 'pycsw:XML' ] ) , self . parent . context . parser ) #NEWLINE# #UNINDENT# #UNINDENT# for result in results : #NEWLINE# #INDENT# if ( ( util . getqattr ( result , self . parent . context . md_core_model [ 'mappings' ] [ 'pycsw:Typename' ] ) == 'csw:Record' ) and ( self . parent . kvp [ 'outputschema' ] == 'http://www.opengis.net/cat/csw/2.0.2' ) ) : #NEWLINE# #INDENT# node . append ( self . _write_record ( result , self . parent . repository . queryables [ '_all' ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . parent . kvp [ 'outputschema' ] == 'http://www.opengis.net/cat/csw/2.0.2' ) : #NEWLINE# #INDENT# typename = None #NEWLINE# for prof in self . parent . profiles [ 'loaded' ] : #NEWLINE# #INDENT# if ( self . parent . profiles [ 'loaded' ] [ prof ] . typename in [ util . getqattr ( result , self . parent . context . md_core_model [ 'mappings' ] [ 'pycsw:Typename' ] ) ] ) : #NEWLINE# #INDENT# typename = self . parent . profiles [ 'loaded' ] [ prof ] . typename #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( typename is not None ) : #NEWLINE# #INDENT# util . transform_mappings ( self . parent . repository . queryables [ '_all' ] , self . parent . context . model [ 'typenames' ] [ typename ] [ 'mappings' ] [ 'csw:Record' ] , reverse = True ) #NEWLINE# #UNINDENT# node . append ( self . _write_record ( result , self . parent . repository . queryables [ '_all' ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . parent . kvp [ 'outputschema' ] in self . parent . outputschemas . keys ( ) ) : #NEWLINE# #INDENT# node . append ( self . parent . outputschemas [ self . parent . kvp [ 'outputschema' ] ] . write_record ( result , self . parent . kvp [ 'elementsetname' ] , self . parent . context , self . parent . config . get ( 'server' , 'url' ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# node . append ( self . parent . profiles [ 'loaded' ] [ self . parent . kvp [ 'outputschema' ] ] . write_record ( result , self . parent . kvp [ 'elementsetname' ] , self . parent . kvp [ 'outputschema' ] , self . parent . repository . queryables [ '_all' ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( raw and ( len ( results ) == 0 ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# return node