F3.1: limitar cambio de Asset a familia técnica
This commit is contained in:
@@ -1,25 +1,43 @@
|
||||
import {
|
||||
Column,
|
||||
Entity,
|
||||
Index,
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { TimestampedEntity } from './timestamped.entity';
|
||||
import {
|
||||
AssetDataOrigin,
|
||||
AssetInformationStatus,
|
||||
AssetOperationalStatus,
|
||||
} from './enums';
|
||||
|
||||
export enum AssetInformationStatus {
|
||||
DRAFT = 'DRAFT',
|
||||
PENDING_SURVEY = 'PENDING_SURVEY',
|
||||
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' })
|
||||
@Index('uq_assets_code', ['code'], { unique: true })
|
||||
@Index('idx_assets_parent', ['parentId'])
|
||||
@Index('idx_assets_type', ['assetTypeId'])
|
||||
@Index('idx_assets_status', ['informationStatus'])
|
||||
@Index('idx_assets_type_id', ['assetTypeId'])
|
||||
@Index('idx_assets_parent_id', ['parentId'])
|
||||
@Index('idx_assets_operational_area_id', ['operationalAreaId'])
|
||||
@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_area', ['operationalAreaId'])
|
||||
@Index('idx_assets_operator_company', ['operatorCompanyId'])
|
||||
@Index('idx_assets_inventory_family', ['inventoryFamilyId'])
|
||||
@Index('idx_assets_data_origin', ['dataOrigin'])
|
||||
@Index('idx_assets_provenance_verified_at', ['provenanceVerifiedAt'])
|
||||
export class Asset extends TimestampedEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
@@ -42,10 +60,10 @@ export class Asset extends TimestampedEntity {
|
||||
@Column({ type: 'varchar', length: 120 })
|
||||
code!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 240 })
|
||||
@Column({ type: 'varchar', length: 200 })
|
||||
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;
|
||||
|
||||
@Column({ type: 'text', nullable: true })
|
||||
@@ -53,18 +71,14 @@ export class Asset extends TimestampedEntity {
|
||||
|
||||
@Column({
|
||||
name: 'information_status',
|
||||
type: 'varchar',
|
||||
length: 20,
|
||||
type: 'enum',
|
||||
enum: AssetInformationStatus,
|
||||
enumName: 'asset_information_status',
|
||||
default: AssetInformationStatus.DRAFT,
|
||||
})
|
||||
informationStatus!: AssetInformationStatus;
|
||||
|
||||
@Column({
|
||||
name: 'operational_status',
|
||||
type: 'varchar',
|
||||
length: 24,
|
||||
default: AssetOperationalStatus.IN_SERVICE,
|
||||
})
|
||||
@Column({ name: 'operational_status', type: 'enum', enum: AssetOperationalStatus, enumName: 'asset_operational_status', default: AssetOperationalStatus.UNKNOWN })
|
||||
operationalStatus!: AssetOperationalStatus;
|
||||
|
||||
@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 })
|
||||
updatedBy!: string | null;
|
||||
|
||||
@Column({
|
||||
name: 'data_origin',
|
||||
type: 'varchar',
|
||||
length: 20,
|
||||
default: AssetDataOrigin.MANUAL,
|
||||
})
|
||||
@Column({ name: 'current_version', type: 'integer', default: 0 })
|
||||
currentVersion!: number;
|
||||
|
||||
@Column({ name: 'data_origin', type: 'varchar', length: 32, default: AssetDataOrigin.MANUAL })
|
||||
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;
|
||||
|
||||
@Column({ name: 'source_reference', type: 'varchar', length: 500, nullable: true })
|
||||
@Column({ name: 'source_reference', type: 'varchar', length: 255, nullable: true })
|
||||
sourceReference!: string | null;
|
||||
|
||||
@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 })
|
||||
provenanceVerifiedBy!: string | null;
|
||||
|
||||
@Column({ name: 'provenance_updated_at', type: 'timestamptz', default: () => 'CURRENT_TIMESTAMP' })
|
||||
provenanceUpdatedAt!: Date;
|
||||
|
||||
@Column({ name: 'provenance_updated_by', type: 'uuid', nullable: true })
|
||||
provenanceUpdatedBy!: string | null;
|
||||
|
||||
@Column({ name: 'current_version', type: 'integer', default: 0 })
|
||||
currentVersion!: number;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user