F3.1: limitar cambio de Asset a familia técnica
This commit is contained in:
@@ -1,25 +1,43 @@
|
|||||||
import {
|
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
||||||
Column,
|
|
||||||
Entity,
|
|
||||||
Index,
|
|
||||||
PrimaryGeneratedColumn,
|
|
||||||
} from 'typeorm';
|
|
||||||
import { TimestampedEntity } from './timestamped.entity';
|
import { TimestampedEntity } from './timestamped.entity';
|
||||||
import {
|
|
||||||
AssetDataOrigin,
|
export enum AssetInformationStatus {
|
||||||
AssetInformationStatus,
|
DRAFT = 'DRAFT',
|
||||||
AssetOperationalStatus,
|
PENDING_SURVEY = 'PENDING_SURVEY',
|
||||||
} from './enums';
|
SURVEYED = 'SURVEYED',
|
||||||
|
VALIDATED = 'VALIDATED',
|
||||||
|
OBSERVED = 'OBSERVED',
|
||||||
|
OUTDATED = 'OUTDATED',
|
||||||
|
INACTIVE = 'INACTIVE',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum AssetOperationalStatus {
|
||||||
|
UNKNOWN = 'UNKNOWN',
|
||||||
|
IN_SERVICE = 'IN_SERVICE',
|
||||||
|
TEMPORARILY_OUT_OF_SERVICE = 'TEMPORARILY_OUT_OF_SERVICE',
|
||||||
|
OUT_OF_SERVICE = 'OUT_OF_SERVICE',
|
||||||
|
DECOMMISSIONED = 'DECOMMISSIONED',
|
||||||
|
ABANDONED = 'ABANDONED',
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum AssetDataOrigin {
|
||||||
|
MANUAL = 'MANUAL',
|
||||||
|
FIELD_SURVEY = 'FIELD_SURVEY',
|
||||||
|
PROVIDED_DOCUMENT = 'PROVIDED_DOCUMENT',
|
||||||
|
IMPORT = 'IMPORT',
|
||||||
|
SYSTEM = 'SYSTEM',
|
||||||
|
}
|
||||||
|
|
||||||
@Entity({ name: 'assets' })
|
@Entity({ name: 'assets' })
|
||||||
@Index('uq_assets_code', ['code'], { unique: true })
|
@Index('idx_assets_type_id', ['assetTypeId'])
|
||||||
@Index('idx_assets_parent', ['parentId'])
|
@Index('idx_assets_parent_id', ['parentId'])
|
||||||
@Index('idx_assets_type', ['assetTypeId'])
|
@Index('idx_assets_operational_area_id', ['operationalAreaId'])
|
||||||
@Index('idx_assets_status', ['informationStatus'])
|
@Index('idx_assets_operator_company_id', ['operatorCompanyId'])
|
||||||
|
@Index('idx_assets_inventory_family_id', ['inventoryFamilyId'])
|
||||||
|
@Index('idx_assets_information_status', ['informationStatus'])
|
||||||
@Index('idx_assets_operational_status', ['operationalStatus'])
|
@Index('idx_assets_operational_status', ['operationalStatus'])
|
||||||
@Index('idx_assets_operational_area', ['operationalAreaId'])
|
@Index('idx_assets_data_origin', ['dataOrigin'])
|
||||||
@Index('idx_assets_operator_company', ['operatorCompanyId'])
|
@Index('idx_assets_provenance_verified_at', ['provenanceVerifiedAt'])
|
||||||
@Index('idx_assets_inventory_family', ['inventoryFamilyId'])
|
|
||||||
export class Asset extends TimestampedEntity {
|
export class Asset extends TimestampedEntity {
|
||||||
@PrimaryGeneratedColumn('uuid')
|
@PrimaryGeneratedColumn('uuid')
|
||||||
id!: string;
|
id!: string;
|
||||||
@@ -42,10 +60,10 @@ export class Asset extends TimestampedEntity {
|
|||||||
@Column({ type: 'varchar', length: 120 })
|
@Column({ type: 'varchar', length: 120 })
|
||||||
code!: string;
|
code!: string;
|
||||||
|
|
||||||
@Column({ type: 'varchar', length: 240 })
|
@Column({ type: 'varchar', length: 200 })
|
||||||
name!: string;
|
name!: string;
|
||||||
|
|
||||||
@Column({ name: 'common_name', type: 'varchar', length: 240, nullable: true })
|
@Column({ name: 'common_name', type: 'varchar', length: 200, nullable: true })
|
||||||
commonName!: string | null;
|
commonName!: string | null;
|
||||||
|
|
||||||
@Column({ type: 'text', nullable: true })
|
@Column({ type: 'text', nullable: true })
|
||||||
@@ -53,18 +71,14 @@ export class Asset extends TimestampedEntity {
|
|||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
name: 'information_status',
|
name: 'information_status',
|
||||||
type: 'varchar',
|
type: 'enum',
|
||||||
length: 20,
|
enum: AssetInformationStatus,
|
||||||
|
enumName: 'asset_information_status',
|
||||||
default: AssetInformationStatus.DRAFT,
|
default: AssetInformationStatus.DRAFT,
|
||||||
})
|
})
|
||||||
informationStatus!: AssetInformationStatus;
|
informationStatus!: AssetInformationStatus;
|
||||||
|
|
||||||
@Column({
|
@Column({ name: 'operational_status', type: 'enum', enum: AssetOperationalStatus, enumName: 'asset_operational_status', default: AssetOperationalStatus.UNKNOWN })
|
||||||
name: 'operational_status',
|
|
||||||
type: 'varchar',
|
|
||||||
length: 24,
|
|
||||||
default: AssetOperationalStatus.IN_SERVICE,
|
|
||||||
})
|
|
||||||
operationalStatus!: AssetOperationalStatus;
|
operationalStatus!: AssetOperationalStatus;
|
||||||
|
|
||||||
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
||||||
@@ -73,18 +87,16 @@ export class Asset extends TimestampedEntity {
|
|||||||
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
||||||
updatedBy!: string | null;
|
updatedBy!: string | null;
|
||||||
|
|
||||||
@Column({
|
@Column({ name: 'current_version', type: 'integer', default: 0 })
|
||||||
name: 'data_origin',
|
currentVersion!: number;
|
||||||
type: 'varchar',
|
|
||||||
length: 20,
|
@Column({ name: 'data_origin', type: 'varchar', length: 32, default: AssetDataOrigin.MANUAL })
|
||||||
default: AssetDataOrigin.MANUAL,
|
|
||||||
})
|
|
||||||
dataOrigin!: AssetDataOrigin;
|
dataOrigin!: AssetDataOrigin;
|
||||||
|
|
||||||
@Column({ name: 'source_name', type: 'varchar', length: 240, nullable: true })
|
@Column({ name: 'source_name', type: 'varchar', length: 160, nullable: true })
|
||||||
sourceName!: string | null;
|
sourceName!: string | null;
|
||||||
|
|
||||||
@Column({ name: 'source_reference', type: 'varchar', length: 500, nullable: true })
|
@Column({ name: 'source_reference', type: 'varchar', length: 255, nullable: true })
|
||||||
sourceReference!: string | null;
|
sourceReference!: string | null;
|
||||||
|
|
||||||
@Column({ name: 'source_observed_at', type: 'timestamptz', nullable: true })
|
@Column({ name: 'source_observed_at', type: 'timestamptz', nullable: true })
|
||||||
@@ -99,9 +111,9 @@ export class Asset extends TimestampedEntity {
|
|||||||
@Column({ name: 'provenance_verified_by', type: 'uuid', nullable: true })
|
@Column({ name: 'provenance_verified_by', type: 'uuid', nullable: true })
|
||||||
provenanceVerifiedBy!: string | null;
|
provenanceVerifiedBy!: string | null;
|
||||||
|
|
||||||
|
@Column({ name: 'provenance_updated_at', type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
|
||||||
|
provenanceUpdatedAt!: Date;
|
||||||
|
|
||||||
@Column({ name: 'provenance_updated_by', type: 'uuid', nullable: true })
|
@Column({ name: 'provenance_updated_by', type: 'uuid', nullable: true })
|
||||||
provenanceUpdatedBy!: string | null;
|
provenanceUpdatedBy!: string | null;
|
||||||
|
|
||||||
@Column({ name: 'current_version', type: 'integer', default: 0 })
|
|
||||||
currentVersion!: number;
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user