parameters: (ontology, workspace_pid, add_nonleafs=False, depth=0, max_depth=100)
return_statement: return features
docstring: Returns all root-leaf paths of the passed ontology. It respects
      is_a relationships. It uses an implementation stored remotely in the
      database server. It needs three database queries in total.
docstring_summary: Returns all root-leaf paths of the passed ontology. It respects
      is_a relationships. It uses an implementation stored remotely in the
      database server. It needs three database queries in total.
docstring_tokens: Returns all root - leaf paths of the passed ontology . It respects is_a relationships . It uses an implementation stored remotely in the database server . It needs three database queries in total .
function: def get_feature_paths_remote(ontology, workspace_pid, add_nonleafs=False, depth=0, max_depth=100) -> List:
      """ Returns all root-leaf paths of the passed ontology. It respects
      is_a relationships. It uses an implementation stored remotely in the
      database server. It needs three database queries in total.
      """
  
      query = "SELECT * FROM get_feature_paths(%s, %s, %s, %s, %s);" % \
          (ontology.id, workspace_pid, add_nonleafs, depth, max_depth)
  
      # Run query
      cursor = connection.cursor()
      cursor.execute(query)
  
      # Parse result
      class_ids = set()
      relation_ids = set()
      rows = cursor.fetchall()
      for r in rows:
          # We get back tuples of feature links with each consisting of the
          # IDs of class_a, class_b, relation and a super class. To create
          # FeatureLink objects out of this, we need to get the class objects
          # first. So collect all class IDs we have got.
          # The link data can be found in the first row of the result set
          if not r:
              raise Exception('Could not parse feature path data received from data base.')
          for link_data in r[0]:
              class_ids.add(link_data[0])
              class_ids.add(link_data[1])
              relation_ids.add(link_data[2])
              if link_data[3]:
                  class_ids.add(link_data[3])
  
      # Get all needed class and relation model objects
      classes = Class.objects.in_bulk(class_ids)
      relations = Relation.objects.in_bulk(relation_ids)
  
      # Create feature links
      features = []
      for r in rows:
          feature = []
          for link_data in r[0]:
              class_a = classes[link_data[0]]
              class_b = classes[link_data[1]]
              relation = relations[link_data[2]]
              super_a = classes.get(link_data[3], None)
              fl = FeatureLink(class_a, class_b, relation, super_a)
              feature.append(fl)
          features.append(feature)
  
      return features
function_tokens: def get_feature_paths_remote ( ontology , workspace_pid , add_nonleafs = False , depth = 0 , max_depth = 100 ) -> List : query = "SELECT * FROM get_feature_paths(%s, %s, %s, %s, %s);" % ( ontology . id , workspace_pid , add_nonleafs , depth , max_depth ) # Run query cursor = connection . cursor ( ) cursor . execute ( query ) # Parse result class_ids = set ( ) relation_ids = set ( ) rows = cursor . fetchall ( ) for r in rows : # We get back tuples of feature links with each consisting of the # IDs of class_a, class_b, relation and a super class. To create # FeatureLink objects out of this, we need to get the class objects # first. So collect all class IDs we have got. # The link data can be found in the first row of the result set if not r : raise Exception ( 'Could not parse feature path data received from data base.' ) for link_data in r [ 0 ] : class_ids . add ( link_data [ 0 ] ) class_ids . add ( link_data [ 1 ] ) relation_ids . add ( link_data [ 2 ] ) if link_data [ 3 ] : class_ids . add ( link_data [ 3 ] ) # Get all needed class and relation model objects classes = Class . objects . in_bulk ( class_ids ) relations = Relation . objects . in_bulk ( relation_ids ) # Create feature links features = [ ] for r in rows : feature = [ ] for link_data in r [ 0 ] : class_a = classes [ link_data [ 0 ] ] class_b = classes [ link_data [ 1 ] ] relation = relations [ link_data [ 2 ] ] super_a = classes . get ( link_data [ 3 ] , None ) fl = FeatureLink ( class_a , class_b , relation , super_a ) feature . append ( fl ) features . append ( feature ) return features