Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIMS-1373 ParcelBuildings Restructure Entities #2238

Merged
merged 8 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion express-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"pg": "8.11.3",
"reflect-metadata": "0.2.1",
"swagger-ui-express": "5.0.0",
"typeorm": "0.3.17",
"typeorm": "0.3.20",
"typeorm-naming-strategies": "4.1.0",
"winston": "3.12.0",
"zod": "3.22.4"
Expand Down
70 changes: 0 additions & 70 deletions express-api/src/controllers/buildings/IBuilding.ts

This file was deleted.

112 changes: 0 additions & 112 deletions express-api/src/controllers/parcels/IParcel.ts

This file was deleted.

18 changes: 0 additions & 18 deletions express-api/src/controllers/properties/IProperty.ts

This file was deleted.

44 changes: 0 additions & 44 deletions express-api/src/typeorm/Entities/AccessRequest.ts

This file was deleted.

4 changes: 2 additions & 2 deletions express-api/src/typeorm/Entities/Agency.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {
Entity,
Index,
PrimaryColumn,
Column,
ManyToOne,
JoinColumn,
OneToMany,
Relation,
PrimaryGeneratedColumn,
} from 'typeorm';
import { BaseEntity } from '@/typeorm/Entities/abstractEntities/BaseEntity';
import { User } from '@/typeorm/Entities/User';

@Entity()
@Index(['ParentId', 'IsDisabled', 'Id', 'Name', 'SortOrder']) // I'm not sure this index is needed. How often do we search by this group?
export class Agency extends BaseEntity {
@PrimaryColumn({ type: 'int' })
@PrimaryGeneratedColumn({ type: 'int' })
Id: number;

@Column({ type: 'character varying', length: 150 })
Expand Down
12 changes: 10 additions & 2 deletions express-api/src/typeorm/Entities/Building.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { BuildingConstructionType } from '@/typeorm/Entities/BuildingConstructionType';
import { BuildingOccupantType } from '@/typeorm/Entities/BuildingOccupantType';
import { BuildingPredominateUse } from '@/typeorm/Entities/BuildingPredominateUse';
import { Entity, Column, ManyToOne, Index, JoinColumn } from 'typeorm';
import { Entity, Column, ManyToOne, Index, JoinColumn, OneToMany } from 'typeorm';
import { Property } from '@/typeorm/Entities/abstractEntities/Property';
import { BuildingFiscal } from '@/typeorm/Entities/BuildingFiscal';
import { BuildingEvaluation } from '@/typeorm/Entities/BuildingEvaluation';

// Should the occupant information (OccupantTypeId, OccupantName, and BuildingTenancyUpdatedOn) be a separate table?
// This may change over time and we wouldn't be able to track previous occupants by storing it in this table.

// Can Buildings and Parcels share a base Properties entity?
@Entity()
@Index(['PID', 'PIN'], { unique: false })
export class Building extends Property {
// Construction Type Relations
@Column({ name: 'building_construction_type_id', type: 'int' })
Expand Down Expand Up @@ -67,4 +69,10 @@ export class Building extends Property {

@Column({ type: 'real' })
TotalArea: number;

@OneToMany(() => BuildingFiscal, (Fiscal) => Fiscal.BuildingId, { nullable: true })
Fiscals: BuildingFiscal[];

@OneToMany(() => BuildingEvaluation, (Evaluation) => Evaluation.BuildingId, { nullable: true })
Evaluations: BuildingEvaluation[];
}
16 changes: 9 additions & 7 deletions express-api/src/typeorm/Entities/Parcel.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { Entity, Column, Index, ManyToOne, JoinColumn } from 'typeorm';
import { Entity, Column, Index, ManyToOne, JoinColumn, OneToMany } from 'typeorm';
import { Property } from '@/typeorm/Entities/abstractEntities/Property';
import { ParcelFiscal } from '@/typeorm/Entities/ParcelFiscal';
import { ParcelEvaluation } from '@/typeorm/Entities/ParcelEvaluation';

@Entity()
@Index(['PID', 'PIN'], { unique: true })
export class Parcel extends Property {
@Column({ type: 'int' })
PID: number;

@Column({ type: 'int', nullable: true })
PIN: number;

@Column({ type: 'real', nullable: true })
LandArea: number;

Expand All @@ -31,4 +27,10 @@ export class Parcel extends Property {
@ManyToOne(() => Parcel, (Parcel) => Parcel.Id)
@JoinColumn({ name: 'parent_parcel_id' })
ParentParcel: Parcel;

@OneToMany(() => ParcelFiscal, (Fiscal) => Fiscal.ParcelId, { nullable: true })
Fiscals: ParcelFiscal[];

@OneToMany(() => ParcelEvaluation, (Evaluation) => Evaluation.ParcelId, { nullable: true })
Evaluations: ParcelEvaluation[];
}
21 changes: 0 additions & 21 deletions express-api/src/typeorm/Entities/ParcelBuilding.ts

This file was deleted.

12 changes: 10 additions & 2 deletions express-api/src/typeorm/Entities/abstractEntities/BaseEntity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import type { User } from '@/typeorm/Entities/User';
import { UUID } from 'crypto';
import { Column, CreateDateColumn, ManyToOne, JoinColumn, Index, Relation } from 'typeorm';
import {
Column,
CreateDateColumn,
ManyToOne,
JoinColumn,
Index,
Relation,
UpdateDateColumn,
} from 'typeorm';

export abstract class BaseEntity {
@Column({ name: 'created_by_id' })
Expand All @@ -22,6 +30,6 @@ export abstract class BaseEntity {
@Index()
UpdatedBy: Relation<User>;

@Column({ type: 'timestamp', nullable: true })
@UpdateDateColumn({ type: 'timestamp', nullable: true })
UpdatedOn: Date;
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export abstract class Property extends BaseEntity {
@Column({ type: 'character varying', length: 6, nullable: true })
Postal: string;

@Column({ type: 'int', nullable: true })
PID: number;

@Column({ type: 'int', nullable: true })
PIN: number;

// Including this for quick geocoder lookup.
@Column({ type: 'character varying', nullable: true })
SiteId: string;
Expand Down
Loading
Loading