Beispiel #1
0
class IsochroneCalculation(SQLModel, table=True):
    __tablename__ = "isochrone_calculation"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    calculation_type: str = Field(sa_column=Column(Text, nullable=False))
    starting_point: str = Field(sa_column=Column(Text, nullable=False))
    routing_profile: str = Field(sa_column=Column(Text, nullable=False))
    speed: float = Field(sa_column=Column(Float(53), nullable=False))
    modus: str = Field(sa_column=Column(Text, nullable=False))
    creation_date: Optional[datetime] = Field(
        sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP")))
    parent_id: Optional[int] = Field(sa_column=Column(
        Integer,
        ForeignKey("customer.isochrone_calculation.id", ondelete="CASCADE")))
    scenario_id: Optional[int] = Field(sa_column=Column(
        Integer, ForeignKey("customer.scenario.id", ondelete="CASCADE")))
    user_id: int = Field(
        sa_column=Column(Integer,
                         ForeignKey("customer.user.id", ondelete="CASCADE"),
                         nullable=False))

    scenario: Optional["Scenario"] = Relationship(
        back_populates="isochrone_calculations")
    user: "******" = Relationship(back_populates="isochrone_calculations")
    isochrone_features: "IsochroneFeature" = Relationship(
        back_populates="isochrone_calculation")
Beispiel #2
0
class Block(SQLModel, table=True):
    id: int = Field(primary_key=True)
    chain_id: int
    height: int
    timestamp: datetime = Field(sa_column=Column(DateTime(timezone=True)))
    snapshot: Optional[datetime] = Field(sa_column=Column(DateTime(timezone=True)))

    snapshots: List["Snapshot"] = Relationship(back_populates="block")
Beispiel #3
0
class Role(SQLModel, table=True):
    __tablename__ = "role"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True))
    name: str = Field(sa_column=Column(Text, nullable=False))

    customizations: List["Customization"] = Relationship(back_populates="role")
    users: List["User"] = Relationship(back_populates="roles", link_model=UserRole)
Beispiel #4
0
class StyleLibrary(SQLModel, table=True):
    __tablename__ = "style_library"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True))
    name: str = Field(sa_column=Column(Text(), nullable=False, index=True))
    style: dict = Field(sa_column=Column(JSONB))
    translation: dict = Field(sa_column=Column(JSONB))
    layer_libraries: "LayerLibrary" = Relationship(back_populates="style_library")
Beispiel #5
0
class Population(PopulationBase, table=True):
    __tablename__ = "population"
    __table_args__ = {"schema": "basic"}

    demography: Optional[dict] = Field(sa_column=Column(JSONB))
    building_id: Optional[int] = Field(sa_column=Column(
        Integer,
        ForeignKey("basic.building.id", ondelete="CASCADE"),
        index=True), )
    building: Optional["Building"] = Relationship(back_populates="populations")
Beispiel #6
0
class CourseBase(SQLModel):
    name: str
    code: str
    description: Optional[str]
    primary_resource: Optional[str]
    status: str
    due: datetime.date
    cover: Dict = Field(sa_column=Column(JSON), default={"color": "#222222"})
    syllabus: List[Dict] = Field(sa_column=Column(JSON))
    user_id: Optional[int] = Field(default=None, foreign_key="user.id")
Beispiel #7
0
class UserRole(SQLModel, table=True):
    __tablename__ = "user_role"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    user_id: Optional[int] = Field(sa_column=Column(
        Integer, ForeignKey("customer.user.id"), nullable=False, index=True))
    role_id: Optional[int] = Field(sa_column=Column(
        Integer, ForeignKey("customer.role.id"), nullable=False, index=True))
Beispiel #8
0
class Organization(SQLModel, table=True):
    __tablename__ = "organization"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True))
    name: Optional[str] = Field(sa_column=Column(Text, nullable=False))
    creation_date: Optional[datetime] = Field(
        sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
    )

    users: List["User"] = Relationship(back_populates="organization")
Beispiel #9
0
class AoiModified(AoiBase, table=True):
    __tablename__ = "aoi_modified"
    __table_args__ = {"schema": "customer"}

    creation_date: Optional[datetime] = Field(
        sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP")))
    scenario_id: Optional[int] = Field(sa_column=Column(
        Integer,
        ForeignKey("customer.scenario.id", ondelete="CASCADE"),
        index=True))

    scenario: Optional["Scenario"] = Relationship(
        back_populates="aois_modified")
class OpportunityStudyAreaConfig(OpportunityConfigBase, table=True):
    __tablename__ = "opportunity_study_area_config"
    __table_args__ = {"schema": "basic"}

    opportunity_group_id: Optional[int] = Field(sa_column=Column(
        Integer, ForeignKey("basic.opportunity_group.id"), nullable=False))
    study_area_id: int = Field(sa_column=Column(
        Integer, ForeignKey("basic.study_area.id"), nullable=False))
    is_active: bool = Field(sa_column=Column(Boolean, nullable=False))
    study_area: "StudyArea" = Relationship(
        back_populates="opportunity_study_area_configs")

    opportunity_group: "OpportunityGroup" = Relationship(
        back_populates="opportunity_study_area_configs")
Beispiel #11
0
class User(UserBase, table=True):
    __tablename__ = "user"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    hashed_password: Optional[str] = Field(
        sa_column=Column(Text, nullable=False))
    is_active: Optional[bool] = Field(default=False)
    newsletter: Optional[bool] = Field(default=False)
    occupation: Optional[str] = Field(sa_column=Column(Text, nullable=True))
    domain: Optional[str] = Field(sa_column=Column(Text, nullable=True))
    creation_date: Optional[datetime] = Field(
        sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP")))
    organization_id: int = Field(sa_column=Column(
        Integer,
        ForeignKey("customer.organization.id", ondelete="CASCADE"),
        nullable=False))
    active_study_area_id: int = Field(sa_column=Column(
        Integer, ForeignKey("basic.study_area.id"), nullable=False))
    language_preference: str = Field(sa_column=Column(Text, nullable=False))

    organization: "Organization" = Relationship(back_populates="users")
    roles: List["Role"] = Relationship(back_populates="users",
                                       link_model=UserRole)
    scenarios: List["Scenario"] = Relationship(back_populates="user")
    study_areas: List["StudyArea"] = Relationship(back_populates="users",
                                                  link_model=UserStudyArea)
    data_uploads: List["DataUpload"] = Relationship(back_populates="user")
    isochrone_calculations: List["IsochroneCalculation"] = Relationship(
        back_populates="user")
    user_customizations: List["UserCustomization"] = Relationship(
        back_populates="users")
    opportunity_user_configs: List["OpportunityUserConfig"] = Relationship(
        back_populates="user")
Beispiel #12
0
class PopulationBase(SQLModel):
    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    sub_study_area_id: int = Field(sa_column=Column(
        Integer,
        ForeignKey("basic.sub_study_area.id", ondelete="CASCADE"),
        index=True))
    population: Optional[float] = Field(sa_column=Column(Float(53)))
    geom: str = Field(sa_column=Column(
        Geometry(geometry_type="Point", srid="4326", spatial_index=False),
        nullable=False,
    ))
    sub_study_area: Optional["SubStudyArea"] = Relationship(
        back_populates="populations")
Beispiel #13
0
class StudyAreaGridVisualization(SQLModel, table=True):
    __tablename__ = "study_area_grid_visualization"
    __table_args__ = {"schema": "basic"}

    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    study_area_id: int = Field(sa_column=Column(
        Integer, ForeignKey(
            "basic.study_area.id"), nullable=False, index=True))
    grid_visualization_id: int = Field(sa_column=Column(
        BigInteger,
        ForeignKey("basic.grid_visualization.id"),
        nullable=False,
    ))
Beispiel #14
0
class AoiUser(AoiBase, table=True):
    __tablename__ = "aoi_user"
    __table_args__ = {"schema": "customer"}

    creation_date: Optional[datetime] = Field(
        sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP")))
    data_upload_id: int = Field(sa_column=Column(
        Integer,
        ForeignKey("customer.data_upload.id", ondelete="CASCADE"),
        index=True,
        nullable=False,
    ))

    data_upload: Optional["DataUpload"] = Relationship(
        back_populates="aois_user")
Beispiel #15
0
class PoiBase(SQLModel):
    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    category: str = Field(sa_column=Column(Text(), nullable=False, index=True))
    name: Optional[str] = Field(sa_column=Column(Text))
    street: Optional[str] = Field(sa_column=Column(Text))
    housenumber: Optional[str] = Field(sa_column=Column(Text))
    zipcode: Optional[str] = Field(sa_column=Column(Text))
    opening_hours: Optional[str] = Field(sa_column=Column(Text))
    wheelchair: Optional[str] = Field(sa_column=Column(Text))
    tags: Optional[dict] = Field(sa_column=Column(JSONB))
    geom: str = Field(sa_column=Column(
        Geometry(geometry_type="Point", srid="4326", spatial_index=False),
        nullable=False,
    ))
Beispiel #16
0
class Customization(SQLModel, table=True):
    __tablename__ = "customization"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True))
    type: str = Field(sa_column=Column(Text, nullable=False))
    setting: dict = Field(sa_column=Column(JSONB, nullable=False))
    role_id: int = Field(
        sa_column=Column(
            Integer, ForeignKey("customer.role.id", ondelete="CASCADE"), nullable=False
        )
    )

    role: "Role" = Relationship(back_populates="customizations")
    user_customizations: Optional[List["UserCustomization"]] = Relationship(back_populates="customizations")
Beispiel #17
0
class UserStudyArea(SQLModel, table=True):
    __tablename__ = "user_study_area"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    creation_date: Optional[datetime] = Field(
        sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP")))
    user_id: int = Field(sa_column=Column(Integer,
                                          ForeignKey("customer.user.id",
                                                     ondelete="CASCADE"),
                                          nullable=False), )
    study_area_id: int = Field(
        sa_column=Column(Integer,
                         ForeignKey("basic.study_area.id", ondelete="CASCADE"),
                         nullable=False))
Beispiel #18
0
class ReachedEdgeFullHeatmap(SQLModel, table=True):
    __tablename__ = "reached_edge_full_heatmap"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    geom: str = Field(sa_column=Column(
        Geometry(geometry_type="Linestring", srid="4326", spatial_index=False),
        nullable=False,
    ))
    edge_id: int = Field(sa_column=Column(Integer, index=True,
                                          nullable=False), )
    scenario_id: Optional[int] = Field(sa_column=Column(
        Integer,
        ForeignKey("customer.scenario.id", ondelete="CASCADE"),
        index=True), )
class OpportunityDefaultConfig(OpportunityConfigBase, table=True):
    __tablename__ = "opportunity_default_config"
    __table_args__ = {"schema": "basic"}

    opportunity_group_id: Optional[int] = Field(sa_column=Column(
        Integer, ForeignKey("basic.opportunity_group.id"), nullable=False))
    opportunity_group: "OpportunityGroup" = Relationship(
        back_populates="opportunity_default_configs")
Beispiel #20
0
class DataUpload(SQLModel, table=True):

    __tablename__ = "data_upload"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True))
    data_type: str = Field(sa_column=Column(Text, nullable=False))
    upload_type: str = Field(sa_column=Column(Text, nullable=False))
    upload_grid_ids: Optional[List[str]] = Field(
        sa_column=Column(ARRAY(Text()), nullable=False, server_default=text("'{}'::text[]"))
    )
    upload_size: int = Field(nullable=False)
    creation_date: Optional[datetime] = Field(
        sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
    )
    user_id: int = Field(
        sa_column=Column(
            Integer, ForeignKey("customer.user.id", ondelete="CASCADE"), nullable=False
        )
    )
    study_area_id: int = Field(
        sa_column=Column(
            Integer, ForeignKey("basic.study_area.id"), nullable=False
        )
    )
    reached_poi_heatmap_computed: Optional[bool]

    user: "******" = Relationship(back_populates="data_uploads")
    study_area: "StudyArea" = Relationship(back_populates="data_uploads")
    pois_user: List["PoiUser"] = Relationship(back_populates="data_upload")
    aois_user: List["AoiUser"] = Relationship(back_populates="data_upload")
class OpportunityUserConfig(OpportunityConfigBase, table=True):
    __tablename__ = "opportunity_user_config"
    __table_args__ = {"schema": "customer"}

    opportunity_group_id: Optional[int] = Field(sa_column=Column(
        Integer, ForeignKey("basic.opportunity_group.id"), nullable=False))
    study_area_id: int = Field(
        sa_column=Column(Integer, ForeignKey("basic.study_area.id")))
    user_id: int = Field(sa_column=Column(
        Integer, ForeignKey("customer.user.id", ondelete="CASCADE")))
    data_upload_id: Optional[int] = Field(sa_column=Column(
        Integer, ForeignKey("customer.data_upload.id", ondelete="CASCADE")))

    study_area: "StudyArea" = Relationship(
        back_populates="opportunity_user_configs")
    user: "******" = Relationship(back_populates="opportunity_user_configs")

    opportunity_group: "OpportunityGroup" = Relationship(
        back_populates="opportunity_user_configs")
class OpportunityGroup(SQLModel, table=True):
    __tablename__ = "opportunity_group"
    __table_args__ = {"schema": "basic"}

    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    type: str = Field(sa_column=Column(Text, nullable=False))
    group: str = Field(sa_column=Column(Text, nullable=False))
    icon: str = Field(sa_column=Column(Text, nullable=False))
    color: List[str] = Field(sa_column=Column(ARRAY(Text()), nullable=False))

    opportunity_default_configs: Optional[
        List["OpportunityDefaultConfig"]] = Relationship(
            back_populates="opportunity_group")
    opportunity_study_area_configs: Optional[
        List["OpportunityStudyAreaConfig"]] = Relationship(
            back_populates="opportunity_group")
    opportunity_user_configs: Optional[
        List["OpportunityUserConfig"]] = Relationship(
            back_populates="opportunity_group")
Beispiel #23
0
class BuildingModified(BuildingBase, table=True):
    __tablename__ = "building_modified"
    __table_args__ = {"schema": "customer"}

    creation_date: Optional[datetime] = Field(
        sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
    )
    building_id: Optional[int] = Field(
        sa_column=Column(
            Integer, ForeignKey("basic.building.id", ondelete="CASCADE"), default=None
        ),
    )
    scenario_id: int = Field(
        sa_column=Column(
            Integer,
            ForeignKey("customer.scenario.id", ondelete="CASCADE"),
            index=True,
            nullable=False,
        ),
    )
    population: Optional[float] = Field(sa_column=Column(Float(53)))
    building: Optional["Building"] = Relationship(back_populates="buildings_modified")
    scenario: "Scenario" = Relationship(back_populates="buildings_modified")
    populations_modified: Optional[List["PopulationModified"]] = Relationship(
        back_populates="building_modified"
    )
    edit_type: str = Field(sa_column=Column(Text, nullable=False, index=True))
    outdated: Optional[bool] = Field(sa_column=Column(Boolean, default=False))
Beispiel #24
0
class Scenario(SQLModel, table=True):
    __tablename__ = "scenario"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True))
    scenario_name: str = Field(sa_column=Column(Text, nullable=False))
    routing_heatmap_computed: Optional[bool]
    creation_date: Optional[datetime] = Field(
        sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
    )
    user_id: int = Field(
        sa_column=Column(
            Integer, ForeignKey("customer.user.id", ondelete="CASCADE"), nullable=False
        ),
    )
    data_upload_ids: Optional[List[int]] = Field(
        sa_column=Column(ARRAY(Integer()), server_default=text("'{}'::int[]"))
    ) 
    study_area_id: int = Field(
        sa_column=Column(Integer, ForeignKey("basic.study_area.id"), nullable=False)
    )

    user: "******" = Relationship(back_populates="scenarios")
    isochrone_calculations: List["IsochroneCalculation"] = Relationship(back_populates="scenario")
    pois_modified: List["PoiModified"] = Relationship(back_populates="scenario")
    aois_modified: List["AoiModified"] = Relationship(back_populates="scenario")
    populations_modified: List["PopulationModified"] = Relationship(back_populates="scenario")
    buildings_modified: List["BuildingModified"] = Relationship(back_populates="scenario")
    edges: List["Edge"] = Relationship(back_populates="scenario")
    ways_modified: List["WayModified"] = Relationship(back_populates="scenario")
    nodes: List["Node"] = Relationship(back_populates="scenario")
Beispiel #25
0
class UserCustomization(SQLModel, table=True):
    __tablename__ = "user_customization"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(sa_column=Column(Integer, primary_key=True, autoincrement=True))
    setting: dict = Field(sa_column=Column(JSONB, nullable=False))
    creation_date: Optional[datetime] = Field(
        sa_column=Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
    )
    user_id: int = Field(
        sa_column=Column(
            Integer, ForeignKey("customer.user.id", ondelete="CASCADE"), nullable=False
        )
    )
    customization_id: int = Field(
        sa_column=Column(
            Integer, ForeignKey("customer.customization.id", ondelete="CASCADE"), nullable=False
        )
    )
    study_area_id: int = Field(
        sa_column=Column(
            Integer, ForeignKey("basic.study_area.id"), nullable=False
        )
    )
    customizations: "Customization" = Relationship(back_populates="user_customizations")
    users: "User" = Relationship(back_populates="user_customizations")
    study_areas: "StudyArea" = Relationship(back_populates="user_customizations")
Beispiel #26
0
class GridCalculation(SQLModel, table=True):
    __tablename__ = "grid_calculation"
    __table_args__ = {"schema": "basic"}

    id: Optional[int] = Field(
        # TODO: Add next value to the sequence
        sa_column=Column(BigInteger(), primary_key=True, autoincrement=False)
    )
    geom: str = Field(
        sa_column=Column(
            Geometry(geometry_type="Polygon", srid="4326", spatial_index=False),
            nullable=False,
        )
    )
    grid_visualization_id: int = Field(
        sa_column=Column(
            BigInteger,
            ForeignKey("basic.grid_visualization.id", ondelete="CASCADE"),
            nullable=False,
        )
    )
    grid_visualization: "GridVisualization" = Relationship(back_populates="grid_calculations")
Beispiel #27
0
class GridVisualization(SQLModel, table=True):
    __tablename__ = "grid_visualization"
    __table_args__ = {"schema": "basic"}

    id: Optional[int] = Field(
        sa_column=Column(BigInteger(), primary_key=True, autoincrement=False),
    )
    area_isochrone: float = Field(sa_column=Column(Float(53)))
    percentile_area_isochrone: int = Field(sa_column=Column(SmallInteger, nullable=True))
    population: Optional[int]
    percentile_population: int = Field(sa_column=Column(SmallInteger, nullable=True))
    geom: str = Field(
        sa_column=Column(
            Geometry(geometry_type="Polygon", srid="4326", spatial_index=False),
            nullable=False,
        )
    )

    study_areas: List["StudyArea"] = Relationship(
        back_populates="grid_visualizations", link_model=StudyAreaGridVisualization
    )
    grid_calculations: List["GridCalculation"] = Relationship(back_populates="grid_visualization")
Beispiel #28
0
class UserBase(SQLModel):
    name: str = Field(sa_column=Column(Text, nullable=False))
    surname: str = Field(sa_column=Column(Text, nullable=False))
    email: EmailStr = Field(sa_column=Column(Text, nullable=False))

    organization_id: int = Field(sa_column=Column(
        Integer,
        ForeignKey("customer.organization.id", ondelete="CASCADE"),
        nullable=False))
    active_study_area_id: int = Field(sa_column=Column(
        Integer, ForeignKey("basic.study_area.id"), nullable=False))
    active_data_upload_ids: List[int] = Field(
        sa_column=Column(ARRAY(Integer()), server_default=text("'{}'::int[]")))
    storage: int = Field(sa_column=Column(Integer), nullable=False)
    limit_scenarios: int = Field(sa_column=Column(Integer), nullable=False)
class OpportunityConfigBase(SQLModel):
    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    category: str = Field(sa_column=Column(Text, nullable=False))
    icon: str = Field(sa_column=Column(Text, nullable=False))
    color: List[str] = Field(sa_column=Column(ARRAY(Text()), nullable=False))
    sensitivity: Optional[int] = Field(sa_column=Column(Integer))
    multiple_entrance: Optional[bool] = Field(sa_column=Column(Boolean))
Beispiel #30
0
class IsochroneFeature(SQLModel, table=True):
    __tablename__ = "isochrone_feature"
    __table_args__ = {"schema": "customer"}

    id: Optional[int] = Field(
        sa_column=Column(Integer, primary_key=True, autoincrement=True))
    step: int = Field(nullable=False)
    reached_opportunities: Optional[dict] = Field(
        sa_column=Column(JSONB, server_default=text("1::jsonb")))
    geom: str = Field(sa_column=Column(
        Geometry(
            geometry_type="MultiPolygon", srid="4326", spatial_index=False),
        nullable=False,
    ))
    isochrone_calculation_id: int = Field(sa_column=Column(
        Integer,
        ForeignKey("customer.isochrone_calculation.id", ondelete="CASCADE"),
        index=True,
        nullable=False,
    ))

    isochrone_calculation: "IsochroneCalculation" = Relationship(
        back_populates="isochrone_features")