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'] }
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() ]))
def filters_per_collection(self): return self._with_filters_per_collection(lambda c, type: flatten(c))
def matching_methods(self): return self.with_matching_methods_recursive( lambda condition: flatten(condition['children']))
def source_intermediates_props(self): return set(flatten([x['source'] for x in self.intermediates.values()]))
def target_intermediates_props(self): return set(flatten([x['target'] for x in self.intermediates.values()]))
def targets_props(self): return set(flatten(list(self.targets.values())))
def sources_props(self): return set(flatten(list(self.sources.values())))
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))
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=[])