generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: praju-aot <[email protected]>
- Loading branch information
1 parent
bef3f6d
commit b4be18a
Showing
28 changed files
with
563 additions
and
26 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
database/mssql/scripts/versions/revert/v_39_ddl_revert.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
SET ANSI_NULLS ON | ||
GO | ||
SET QUOTED_IDENTIFIER ON | ||
GO | ||
SET NOCOUNT ON | ||
GO | ||
|
||
SET XACT_ABORT ON | ||
|
||
BEGIN TRY | ||
BEGIN TRANSACTION | ||
ALTER TABLE [permit].[ORBC_SPECIAL_AUTH] DROP CONSTRAINT [DF_ORBC_SPECIAL_AUTH_DB_CREATE_USERID] | ||
ALTER TABLE [permit].[ORBC_SPECIAL_AUTH] DROP CONSTRAINT [DF_ORBC_SPECIAL_AUTH_DB_CREATE_TIMESTAMP] | ||
ALTER TABLE [permit].[ORBC_SPECIAL_AUTH] DROP CONSTRAINT [DF_ORBC_SPECIAL_AUTH_DB_LAST_UPDATE_USERID] | ||
ALTER TABLE [permit].[ORBC_SPECIAL_AUTH] DROP CONSTRAINT [DF_ORBC_SPECIAL_AUTH_DB_LAST_UPDATE_TIMESTAMP] | ||
ALTER TABLE [permit].[ORBC_NO_FEE_TYPE] DROP CONSTRAINT [DF_ORBC_NO_FEE_TYPE_DB_CREATE_USERID] | ||
ALTER TABLE [permit].[ORBC_NO_FEE_TYPE] DROP CONSTRAINT [DF_ORBC_NO_FEE_TYPE_DB_CREATE_TIMESTAMP] | ||
ALTER TABLE [permit].[ORBC_NO_FEE_TYPE] DROP CONSTRAINT [DF_ORBC_NO_FEE_TYPE_DB_LAST_UPDATE_USERID] | ||
ALTER TABLE [permit].[ORBC_NO_FEE_TYPE] DROP CONSTRAINT [DF_ORBC_NO_FEE_TYPE_DB_LAST_UPDATE_TIMESTAMP] | ||
ALTER TABLE [permit].[ORBC_SPECIAL_AUTH_HIST] ALTER COLUMN NO_FEE_TYPE VARCHAR(12) NOT NULL | ||
COMMIT | ||
END TRY | ||
|
||
BEGIN CATCH | ||
IF @@TRANCOUNT > 0 | ||
ROLLBACK; | ||
THROW | ||
END CATCH | ||
|
||
DECLARE @VersionDescription VARCHAR(255) | ||
SET @VersionDescription = 'Deleting constraint from DB related coulmns form special authorization and no fee tables' | ||
|
||
INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [RELEASE_DATE]) VALUES (38, @VersionDescription, getutcdate()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
SET ANSI_NULLS ON | ||
GO | ||
SET QUOTED_IDENTIFIER ON | ||
GO | ||
SET NOCOUNT ON | ||
GO | ||
|
||
SET XACT_ABORT ON | ||
GO | ||
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE | ||
GO | ||
BEGIN TRANSACTION | ||
GO | ||
IF @@ERROR <> 0 SET NOEXEC ON | ||
GO | ||
ALTER TABLE [permit].[ORBC_SPECIAL_AUTH] ADD CONSTRAINT [DF_ORBC_SPECIAL_AUTH_DB_CREATE_USERID] DEFAULT(user_name()) | ||
FOR [DB_CREATE_USERID] | ||
|
||
ALTER TABLE [permit].[ORBC_SPECIAL_AUTH] ADD CONSTRAINT [DF_ORBC_SPECIAL_AUTH_DB_CREATE_TIMESTAMP] DEFAULT(getutcdate()) | ||
FOR [DB_CREATE_TIMESTAMP] | ||
|
||
ALTER TABLE [permit].[ORBC_SPECIAL_AUTH] ADD CONSTRAINT [DF_ORBC_SPECIAL_AUTH_DB_LAST_UPDATE_USERID] DEFAULT(user_name()) | ||
FOR [DB_LAST_UPDATE_USERID] | ||
|
||
ALTER TABLE [permit].[ORBC_SPECIAL_AUTH] ADD CONSTRAINT [DF_ORBC_SPECIAL_AUTH_DB_LAST_UPDATE_TIMESTAMP] DEFAULT(getutcdate()) | ||
FOR [DB_LAST_UPDATE_TIMESTAMP] | ||
|
||
ALTER TABLE [permit].[ORBC_NO_FEE_TYPE] ADD CONSTRAINT [DF_ORBC_NO_FEE_TYPE_DB_CREATE_USERID] DEFAULT(user_name()) | ||
FOR [DB_CREATE_USERID] | ||
|
||
ALTER TABLE [permit].[ORBC_NO_FEE_TYPE] ADD CONSTRAINT [DF_ORBC_NO_FEE_TYPE_DB_CREATE_TIMESTAMP] DEFAULT(getutcdate()) | ||
FOR [DB_CREATE_TIMESTAMP] | ||
|
||
ALTER TABLE [permit].[ORBC_NO_FEE_TYPE] ADD CONSTRAINT [DF_ORBC_NO_FEE_TYPE_DB_LAST_UPDATE_USERID] DEFAULT(user_name()) | ||
FOR [DB_LAST_UPDATE_USERID] | ||
|
||
ALTER TABLE [permit].[ORBC_NO_FEE_TYPE] ADD CONSTRAINT [DF_ORBC_NO_FEE_TYPE_DB_LAST_UPDATE_TIMESTAMP] DEFAULT(getutcdate()) | ||
FOR [DB_LAST_UPDATE_TIMESTAMP] | ||
GO | ||
ALTER TABLE [permit].[ORBC_SPECIAL_AUTH_HIST] ALTER COLUMN NO_FEE_TYPE VARCHAR(12) NULL | ||
GO | ||
|
||
IF @@ERROR <> 0 SET NOEXEC ON | ||
GO | ||
|
||
DECLARE @VersionDescription VARCHAR(255) | ||
SET @VersionDescription = 'Default values for ORBC_SPECIAL_AUTH for Db related columns.' | ||
|
||
INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [UPDATE_SCRIPT], [REVERT_SCRIPT], [RELEASE_DATE]) VALUES (39, @VersionDescription, '$(UPDATE_SCRIPT)', '$(REVERT_SCRIPT)', getutcdate()) | ||
IF @@ERROR <> 0 SET NOEXEC ON | ||
GO | ||
|
||
COMMIT TRANSACTION | ||
GO | ||
IF @@ERROR <> 0 SET NOEXEC ON | ||
GO | ||
DECLARE @Success AS BIT | ||
SET @Success = 1 | ||
SET NOEXEC OFF | ||
IF (@Success = 1) PRINT 'The database update succeeded' | ||
ELSE BEGIN | ||
IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION | ||
PRINT 'The database update failed' | ||
END | ||
GO | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- Test that the role types have been inserted correctly against user auth groups | ||
SET NOCOUNT ON | ||
|
||
IF (OBJECT_ID('[$(DB_NAME)].[permit].[DF_ORBC_SPECIAL_AUTH_DB_CREATE_USERID]','D') IS NOT NULL) | ||
AND OBJECT_ID('[$(DB_NAME)].[permit].[DF_ORBC_SPECIAL_AUTH_DB_CREATE_TIMESTAMP]','D') IS NOT NULL | ||
AND (OBJECT_ID('[$(DB_NAME)].[permit].[DF_ORBC_SPECIAL_AUTH_DB_LAST_UPDATE_USERID]','D') IS NOT NULL) | ||
AND (OBJECT_ID('[$(DB_NAME)].[permit].[DF_ORBC_SPECIAL_AUTH_DB_LAST_UPDATE_TIMESTAMP]','D') IS NOT NULL) | ||
AND (OBJECT_ID('[$(DB_NAME)].[permit].[DF_ORBC_NO_FEE_TYPE_DB_CREATE_USERID]','D') IS NOT NULL) | ||
AND OBJECT_ID('[$(DB_NAME)].[permit].[DF_ORBC_NO_FEE_TYPE_DB_CREATE_TIMESTAMP]','D') IS NOT NULL | ||
AND (OBJECT_ID('[$(DB_NAME)].[permit].[DF_ORBC_NO_FEE_TYPE_DB_LAST_UPDATE_USERID]','D') IS NOT NULL) | ||
AND (OBJECT_ID('[$(DB_NAME)].[permit].[DF_ORBC_NO_FEE_TYPE_DB_LAST_UPDATE_TIMESTAMP]','D') IS NOT NULL) | ||
SELECT 1 | ||
ELSE | ||
SELECT 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# Retrieve arguments | ||
source ${SCRIPT_DIR}/utility/getopt.sh | ||
USAGE="-u USER -p PASS -s SERVER -d DATABASE" | ||
parse_options "${USAGE}" ${@} | ||
|
||
# All database tests for database version 39 are run from this shell script. | ||
# TESTS_DIR variable set by the calling test-runner script. | ||
|
||
TEST_39_1_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_39_1_test.sql | xargs) | ||
if [[ $TEST_39_1_RESULT -eq 1 ]]; then | ||
echo "Test 39.1 passed: Db column constaints for special auth and no fee table are added correctly" | ||
else | ||
echo "******** Test 39.1 failed: Db column constaints for special auth and no fee table are not added correctly" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export enum NoFeeType { | ||
CA_GOVT = 'CA_GOVT', | ||
MUNICPALITY = 'MUNICPALITY', | ||
SCHOOL = 'SCHOOL', | ||
USA_GOVT = 'USA_GOVT', | ||
ANY_USA_GOVT = 'ANY_USA_GOVT', | ||
} |
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
vehicles/src/modules/special-auth/dto/request/create-lcv.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { Transform } from 'class-transformer'; | ||
import { IsBoolean } from 'class-validator'; | ||
|
||
export class CreateLcvDto { | ||
@ApiProperty({ | ||
type: 'boolean', | ||
example: false, | ||
description: | ||
'Indicates whether the company is permitted to operate long combination vehicles', | ||
}) | ||
@Transform(({ obj, key }: { obj: Record<string, unknown>; key: string }) => { | ||
return obj[key] === 'true' ? true : obj[key] === 'false' ? false : obj[key]; | ||
}) | ||
@IsBoolean() | ||
isLcvAllowed: boolean; | ||
} |
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
vehicles/src/modules/special-auth/dto/request/create-no-fee.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsEnum, IsOptional } from 'class-validator'; | ||
import { NoFeeType } from 'src/common/enum/no-fee-type.enum'; | ||
|
||
export class CreateNoFeeDto { | ||
@ApiProperty({ | ||
enum: NoFeeType, | ||
example: NoFeeType.CA_GOVT, | ||
description: 'Detailed reason of no fee type permit.', | ||
}) | ||
@IsOptional() | ||
@IsEnum(NoFeeType) | ||
noFeeType: NoFeeType; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions
46
vehicles/src/modules/special-auth/dto/response/read-special-auth.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { AutoMap } from '@automapper/classes'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { Transform } from 'class-transformer'; | ||
import { IsOptional } from 'class-validator'; | ||
import { NoFeeType } from 'src/common/enum/no-fee-type.enum'; | ||
|
||
export class ReadSpecialAuthDto { | ||
@AutoMap() | ||
@ApiProperty({ | ||
example: 1, | ||
description: 'Unique Identifier for special authorization.', | ||
}) | ||
specialAuthId: number; | ||
|
||
@AutoMap() | ||
@ApiProperty({ | ||
description: 'Id of the company requesting the LoA.', | ||
example: 74, | ||
required: false, | ||
}) | ||
companyId: number; | ||
|
||
@AutoMap() | ||
@ApiProperty({ | ||
type: 'boolean', | ||
example: false, | ||
description: | ||
'Indicates whether the company is permitted to operate long combination vehicles', | ||
required: false, | ||
}) | ||
@Transform(({ obj, key }: { obj: Record<string, unknown>; key: string }) => { | ||
return obj[key] === 'true' ? true : obj[key] === 'false' ? false : obj[key]; | ||
}) | ||
@IsOptional() | ||
isLcvAllowed: boolean; | ||
|
||
@AutoMap() | ||
@ApiProperty({ | ||
enum: NoFeeType, | ||
example: NoFeeType.CA_GOVT, | ||
description: 'Detailed reason of no fee type permit.', | ||
required: false, | ||
}) | ||
@IsOptional() | ||
noFeeType: NoFeeType; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
54 changes: 54 additions & 0 deletions
54
vehicles/src/modules/special-auth/entities/special-auth.entity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { | ||
Entity, | ||
Column, | ||
PrimaryGeneratedColumn, | ||
ManyToOne, | ||
JoinColumn, | ||
} from 'typeorm'; | ||
import { AutoMap } from '@automapper/classes'; | ||
import { Base } from 'src/modules/common/entities/base.entity'; | ||
import { Company } from 'src/modules/company-user-management/company/entities/company.entity'; | ||
import { IsOptional } from 'class-validator'; | ||
import { NoFeeType } from 'src/common/enum/no-fee-type.enum'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
@Entity({ name: 'permit.ORBC_SPECIAL_AUTH' }) | ||
export class SpecialAuth extends Base { | ||
@AutoMap() | ||
@PrimaryGeneratedColumn({ type: 'int', name: 'ID' }) | ||
specialAuthId: number; | ||
|
||
@AutoMap() | ||
@ManyToOne(() => Company, { eager: true, cascade: false }) | ||
@JoinColumn({ name: 'COMPANY_ID' }) | ||
company: Company; | ||
|
||
@AutoMap() | ||
@Column({ | ||
type: 'char', | ||
name: 'LCV', | ||
nullable: false, | ||
default: false, | ||
transformer: { | ||
to: (value: boolean): string => (value ? 'Y' : 'N'), // Converts the boolean value to 'Y' or 'N' for storage. | ||
from: (value: string): boolean => value === 'Y', // Converts the stored string back to a boolean. | ||
}, | ||
}) | ||
isLcvAllowed: boolean; | ||
|
||
@AutoMap() | ||
@ApiProperty({ | ||
enum: NoFeeType, | ||
example: NoFeeType.CA_GOVT, | ||
description: 'No Fee Type Id', | ||
}) | ||
@IsOptional() | ||
@Column({ | ||
type: 'simple-enum', | ||
enum: NoFeeType, | ||
length: 12, | ||
name: 'NO_FEE_TYPE', | ||
nullable: true, | ||
}) | ||
noFeeType: NoFeeType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
28 changes: 28 additions & 0 deletions
28
vehicles/src/modules/special-auth/profile/special-auth.profile.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Mapper, createMap, forMember, mapFrom } from '@automapper/core'; | ||
import { AutomapperProfile, InjectMapper } from '@automapper/nestjs'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { SpecialAuth } from '../entities/special-auth.entity'; | ||
import { ReadSpecialAuthDto } from '../dto/response/read-special-auth.dto'; | ||
|
||
@Injectable() | ||
export class SpecialAuthProfile extends AutomapperProfile { | ||
constructor(@InjectMapper() mapper: Mapper) { | ||
super(mapper); | ||
} | ||
|
||
override get profile() { | ||
return (mapper: Mapper) => { | ||
createMap( | ||
mapper, | ||
SpecialAuth, | ||
ReadSpecialAuthDto, | ||
forMember( | ||
(d) => d.companyId, | ||
mapFrom((s) => { | ||
return s.company?.companyId; | ||
}), | ||
), | ||
); | ||
}; | ||
} | ||
} |
Oops, something went wrong.