Ejemplo n.º 1
0
    def get_links_generator(self,
                            with_view_properties='none',
                            with_view_filters=False):
        is_single_value = with_view_properties == 'single'
        use_properties = bool(with_view_properties != 'none'
                              and self._view.properties_per_collection)

        with db_conn() as conn, conn.cursor(
                name=uuid4().hex, cursor_factory=extras.RealDictCursor) as cur:
            cur.execute(
                self.get_links_generator_sql(with_view_properties,
                                             with_view_filters))

            for link in fetch_many(cur):
                yield {
                    'source':
                    link['source_uri'],
                    'target':
                    link['target_uri'],
                    'link_order':
                    link['link_order'],
                    'source_collections':
                    link['source_collections'],
                    'target_collections':
                    link['target_collections'],
                    'source_intermediates':
                    flatten(list(link['source_intermediates'].values()))
                    if link['source_intermediates'] else None,
                    'target_intermediates':
                    flatten(list(link['target_intermediates'].values()))
                    if link['source_intermediates'] else None,
                    'source_values':
                    self._get_values(link,
                                     check_key='source_uri',
                                     is_single_value=is_single_value)
                    if use_properties else None,
                    'target_values':
                    self._get_values(link,
                                     check_key='target_uri',
                                     is_single_value=is_single_value)
                    if use_properties else None,
                    'cluster_id':
                    link['cluster_id'],
                    'cluster_hash_id':
                    link['cluster_hash_id'],
                    'valid':
                    link['valid'],
                    'similarity':
                    link['similarity'],
                    'motivation':
                    link['motivation']
                }
Ejemplo n.º 2
0
 def intermediates(self):
     return set(
         self.with_matching_methods_recursive(
             lambda condition: flatten(condition['children']), lambda mm: [
                 self._job.get_entity_type_selection_by_id(ets_id)
                 for ets_id in mm['matching_method'].intermediates.keys()
             ]))
Ejemplo n.º 3
0
 def filters_per_collection(self):
     return self._with_filters_per_collection(lambda c, type: flatten(c))
Ejemplo n.º 4
0
 def matching_methods(self):
     return self.with_matching_methods_recursive(
         lambda condition: flatten(condition['children']))
Ejemplo n.º 5
0
 def source_intermediates_props(self):
     return set(flatten([x['source'] for x in self.intermediates.values()]))
Ejemplo n.º 6
0
 def target_intermediates_props(self):
     return set(flatten([x['target'] for x in self.intermediates.values()]))
Ejemplo n.º 7
0
 def targets_props(self):
     return set(flatten(list(self.targets.values())))
Ejemplo n.º 8
0
 def sources_props(self):
     return set(flatten(list(self.sources.values())))
Ejemplo n.º 9
0
 def lenses(self):
     return set(
         self.with_lenses_recursive(
             lambda elem: flatten([elem['left'], elem['right']]),
             lambda spec: [spec['spec']] + list(spec['spec'].lenses)
             if spec['type'] == 'lens' else None))
Ejemplo n.º 10
0
 def linksets(self):
     return set(
         self.with_lenses_recursive(
             lambda elem: flatten([elem['left'], elem['right']]),
             lambda spec: spec['spec']
             if spec['type'] == 'linkset' else list(spec['spec'].linksets)))
 def filters(self):
     return self.with_filters_recursive(
         lambda condition: flatten(condition['children']), default=[])