code: def get_resource_by_urn(self, urn):
          
          search_query = """
              PREFIX frbroo: <http://erlangen-crm.org/efrbroo/>
              PREFIX crm: <http://erlangen-crm.org/current/>
              PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  
              SELECT ?resource_URI
  
              WHERE {
                  ?resource_URI crm:P1_is_identified_by ?urn .
                  ?urn a crm:E42_Identifier .
                  ?urn rdfs:label "%s"
              }
          """ % urn
          # check type of the input URN
          try:
              assert isinstance(urn, CTS_URN)
          except Exception as e:
              # convert to pyCTS.CTS_URN if it's a string
              urn = CTS_URN(urn)
              logger.debug('Converted the input urn from string to %s' % type(
                  CTS_URN
              ))
  
          if (urn.work is not None):
              Work = self._session.get_class(surf.ns.EFRBROO['F1_Work'])
              result = self._store.execute_sparql(search_query)
              if len(result['results']['bindings']) == 0:
                  raise ResourceNotFound
              else:
                  tmp = result['results']['bindings'][0]
                  resource_uri = tmp['resource_URI']['value']
                  return self._session.get_resource(resource_uri, Work)
  
          elif (urn.work is None and urn.textgroup is not None):
              Person = self._session.get_class(surf.ns.EFRBROO['F10_Person'])
              result = self._store.execute_sparql(search_query)
              if len(result['results']['bindings']) == 0:
                  raise ResourceNotFound
              else:
                  tmp = result['results']['bindings'][0]
                  resource_uri = tmp['resource_URI']['value']
                  return self._session.get_resource(resource_uri, Person)
docs: Fetch the resource corresponding to the input CTS URN.
  
          Currently supports
          only HucitAuthor and HucitWork.
  
          :param urn: the CTS URN of the resource to fetch
          :return: either an instance of `HucitAuthor` or of `HucitWork`