Skip to content
Snippets Groups Projects
Select Git revision
  • b03e4ac66c26d2e9319baf631772a587f6d37e04
  • develop default protected
  • feature/webrtc
  • feature/mesh-based-reprojection
  • feature/linux-fixes
  • feature/dual-layer-reprojection
  • feature/frame-invalidation
  • feature/plot-script
  • bug/jittering
  • feature/indirect-sky
  • feature/depth-peeling-reprojection protected
  • master
12 results

Reference.md

Blame
  • into_mappings.py 2.00 KiB
    from mitm_tooling.extraction.sql.data_models import SourceDBType
    from mitm_tooling.extraction.sql.mapping import ConceptMapping, ForeignRelation
    from mitm_tooling.representation import Header, SQLRepresentationSchema
    
    
    def sql_rep_into_mappings(header: Header, sql_rep_schema: SQLRepresentationSchema) -> list[ConceptMapping]:
        mitm_def = header.mitm_def
        cms = []
        for he in header.header_entries:
            concept_properties, relations = mitm_def.get(he.concept)
            base_table = None
            if (type_t := sql_rep_schema.type_tables.get(he.concept, {}).get(he.type_name)) is not None:
                base_table = type_t
            elif (concept_t := sql_rep_schema.concept_tables.get(he.concept)) is not None:
                base_table = concept_t
            if base_table is not None:
                cms.append(
                    ConceptMapping(
                        mitm=header.mitm,
                        concept=he.concept,
                        base_table=(SourceDBType.OriginalDB, base_table.schema, base_table.name),
                        kind_col='kind' if 'kind' in base_table.columns else None,
                        type_col=concept_properties.typing_concept,
                        identity_columns=list(relations.identity.keys()),
                        inline_relations=list(relations.inline.keys()),
                        foreign_relations={
                            fk_name: ForeignRelation(
                                fk_columns=list(fk_info.fk_relations.keys()),
                                referred_table=(SourceDBType.OriginalDB,
                                                target_concept_t.schema,
                                                target_concept_t.name),
                            ) for fk_name, fk_info in relations.foreign.items() if
                            (target_concept_t := sql_rep_schema.concept_tables.get(fk_info.target_concept)) is not None
                        },
                        attributes=list(he.attributes),
                        attribute_dtypes=list(he.attribute_dtypes),
                    )
                )
    
        return cms