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

ORV2 2299 LOA #1486

Closed
wants to merge 75 commits into from
Closed
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
8e683c6
Initial commit LoA
gchauhan-aot Jul 4, 2024
ba240d8
Merge branch 'main' into ORV2-2299-loa-db-setup
zgong-gov Jul 4, 2024
13efc5e
optimizing
gchauhan-aot Jul 4, 2024
73cf742
Merge branch 'ORV2-2299-loa-db-setup' of https://github.com/bcgov/onr…
gchauhan-aot Jul 4, 2024
34ffda3
optimizing
gchauhan-aot Jul 4, 2024
74f0c63
Adding delete operation
gchauhan-aot Jul 5, 2024
e679aa8
changes for dops
gchauhan-aot Jul 8, 2024
0d8b96b
Merge remote-tracking branch 'origin/main' into ORV2-2299-loa-db-setup
gchauhan-aot Jul 8, 2024
b66a891
db changes
gchauhan-aot Jul 8, 2024
4030bd6
changes for loa
gchauhan-aot Jul 8, 2024
cfe4fe7
formatting
gchauhan-aot Jul 8, 2024
5bc8c31
updating loa sequence number
gchauhan-aot Jul 8, 2024
d6024fc
updates for loa
gchauhan-aot Jul 9, 2024
bf0f6e1
changes for expired loa
gchauhan-aot Jul 9, 2024
c31febe
updates for loa
gchauhan-aot Jul 9, 2024
5c9449c
formatting and optimizing
gchauhan-aot Jul 9, 2024
188a19d
setting correlation id
gchauhan-aot Jul 9, 2024
12852eb
updating validations
gchauhan-aot Jul 9, 2024
fd1c6bf
formating and adding delete loa document endpoint
gchauhan-aot Jul 9, 2024
85ced97
fix: Setting Correlation Id Response Header before sending the respon…
praju-aot Jul 9, 2024
d8c6d2c
Merge remote-tracking branch 'origin/fix-dops-file-download-url-mode'…
gchauhan-aot Jul 9, 2024
6129d06
updating delete operation
gchauhan-aot Jul 10, 2024
5e55dff
updating error handling
gchauhan-aot Jul 10, 2024
fb1f70e
updating sql
gchauhan-aot Jul 10, 2024
b917af5
bit to boolean transformation and setting header
gchauhan-aot Jul 11, 2024
f0334e4
update loa changes
gchauhan-aot Jul 11, 2024
8eb0387
fix for deletion
gchauhan-aot Jul 11, 2024
ff20d60
updates for loa deletion
gchauhan-aot Jul 11, 2024
87761a4
fixing loa mapping
gchauhan-aot Jul 11, 2024
7955be4
Adding validation or vehicle
gchauhan-aot Jul 12, 2024
5609297
fixing update loa, delete vehicles mapping issue
gchauhan-aot Jul 15, 2024
f412e66
Merge remote-tracking branch 'origin/main' into ORV2-2299-loa-db-setup
gchauhan-aot Jul 15, 2024
a49483d
Merge remote-tracking branch 'origin/main' into ORV2-2299-loa-db-setup
gchauhan-aot Jul 15, 2024
0658f96
Updating review comments
gchauhan-aot Jul 16, 2024
2d47b45
review comment changes
gchauhan-aot Jul 16, 2024
2b26a93
changes for ddl version
gchauhan-aot Jul 17, 2024
a42ac51
Merge remote-tracking branch 'origin/main' into ORV2-2299-loa-db-setup
gchauhan-aot Jul 17, 2024
7c6a93d
changes for isActive flag
gchauhan-aot Jul 17, 2024
e478f6a
changing to int
gchauhan-aot Jul 17, 2024
457b5ce
sql version change
gchauhan-aot Jul 17, 2024
c5c252e
Merge remote-tracking branch 'origin/main' into ORV2-2299-loa-db-setup
gchauhan-aot Jul 17, 2024
d171ca3
LoA changes
gchauhan-aot Jul 18, 2024
396e2db
changes for update LOA
gchauhan-aot Jul 18, 2024
a681cd3
validation for start and end date
gchauhan-aot Jul 18, 2024
6d345e1
Fix profile mapping
praju-aot Jul 18, 2024
560706a
Merge branch 'ORV2-2299-loa-db-setup' of https://github.com/bcgov/onr…
gchauhan-aot Jul 18, 2024
241ac6b
fix mapping
praju-aot Jul 18, 2024
e582e71
Merge branch 'ORV2-2299-loa-db-setup' of https://github.com/bcgov/onr…
praju-aot Jul 18, 2024
17839c2
changes for update LoA
gchauhan-aot Jul 18, 2024
e81f7f0
Change Create LOA to use interceptor
praju-aot Jul 18, 2024
451fdd2
changes for update Loa
gchauhan-aot Jul 19, 2024
c125a54
formatting
gchauhan-aot Jul 19, 2024
343d794
Json interceptor update changes
gchauhan-aot Jul 19, 2024
5012daf
Refactor the code
praju-aot Jul 19, 2024
f886a7b
Apply Date Range Validation
praju-aot Jul 19, 2024
85a6eff
Refactor update loa method and resolve code review comments
praju-aot Jul 19, 2024
fda4c54
Loa Code review changes on GET Loa Document endpoint
praju-aot Jul 19, 2024
b1ab4ea
Change Get LoaByID to asynchronous
praju-aot Jul 19, 2024
29e0a31
Code review fixes and refactoring
praju-aot Jul 19, 2024
23f0102
Remove unused method from Loa Service
praju-aot Jul 19, 2024
5e78a61
Resolve Code review and validations
praju-aot Jul 19, 2024
16d5068
Merge branch 'main' into ORV2-2299-loa-db-setup
praju-aot Jul 19, 2024
eea9c40
Update GetLoaByID documentation
praju-aot Jul 19, 2024
3b3d6ae
Merge branch 'ORV2-2299-loa-db-setup' of https://github.com/bcgov/onr…
praju-aot Jul 19, 2024
72d617d
Remove unused file
praju-aot Jul 19, 2024
1b81873
Code review comments and Feature flag
praju-aot Jul 19, 2024
f3b64b7
Code Review fixes
praju-aot Jul 19, 2024
33480c8
Resolve Code review comments
praju-aot Jul 19, 2024
5899dc5
Code review changes
praju-aot Jul 19, 2024
5f13164
Code Review changes
praju-aot Jul 19, 2024
cbb53b2
Documentation changes
praju-aot Jul 19, 2024
f226f21
Code review changes
praju-aot Jul 19, 2024
91e63ab
Code review changes to use URL
praju-aot Jul 19, 2024
767857b
File upload url fix
praju-aot Jul 19, 2024
ad26eb8
Code review changes for Delete method
praju-aot Jul 19, 2024
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
28 changes: 28 additions & 0 deletions database/mssql/scripts/versions/revert/v_32_ddl_revert.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET NOCOUNT ON
GO

SET XACT_ABORT ON

BEGIN TRY
BEGIN TRANSACTION
DROP TABLE [permit].[ORBC_LOA_PERMIT_TYPE_DETAILS]
DROP TABLE [permit].[ORBC_LOA_VEHICLES]
DROP TABLE [permit].[ORBC_LOA_DETAILS]
DROP SEQUENCE [permit].[ORBC_LOA_NUMBER_SEQ]
COMMIT
END TRY

BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK;
THROW
END CATCH

DECLARE @VersionDescription VARCHAR(255)
SET @VersionDescription = 'Reverting initial creation of LOA tables.'

INSERT [dbo].[ORBC_SYS_VERSION] ([VERSION_ID], [DESCRIPTION], [RELEASE_DATE]) VALUES (31, @VersionDescription, getutcdate())
213 changes: 213 additions & 0 deletions database/mssql/scripts/versions/v_32_ddl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
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
CREATE SEQUENCE permit.ORBC_LOA_NUMBER_SEQ
START WITH 100000
INCREMENT BY 1 ;
GO

CREATE TABLE [permit].[ORBC_LOA_DETAILS] (
LOA_ID [bigint] IDENTITY(1,1) NOT NULL,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be an int instead of bigint. Please confirm with @john-fletcher-aot

LOA_NUMBER [bigint] NOT NULL DEFAULT (NEXT VALUE FOR permit.ORBC_LOA_NUMBER_SEQ),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How many digits would a LOA_NUMBER be? If its a small number, please change to int

[COMPANY_ID] [int] NULL,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add FK on company Id

START_DATE [varchar](10) NOT NULL,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type should be Date instead of varchar

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LOA start and expiry date should be string instead of datetime, since we are not accounting for time (same as permit)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be of type DATE instead of DATETIMESTAMP.

EXPIRY_DATE [varchar](10),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type should be Date instead of varchar

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@praju-aot The LOA start and expiry date should be string instead of datetime, since we are not accounting for time (same as permit)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be of type DATE instead of DATETIMESTAMP

DOCUMENT_ID [bigint],
praju-aot marked this conversation as resolved.
Show resolved Hide resolved
COMMENTS [nvarchar](4000),
[IS_ACTIVE] [bit] NOT NULL DEFAULT(1),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to Y or N to be consistent with other IS_ACTIVE/IS_SUSPEND flags is in the system

[APP_CREATE_TIMESTAMP] [datetime2](7) DEFAULT(getutcdate()),
[APP_CREATE_USERID] [nvarchar](30) DEFAULT(user_name()),
[APP_CREATE_USER_GUID] [char](32) NULL,
[APP_CREATE_USER_DIRECTORY] [nvarchar](30) DEFAULT(user_name()),
[APP_LAST_UPDATE_TIMESTAMP] [datetime2](7) DEFAULT(getutcdate()),
[APP_LAST_UPDATE_USERID] [nvarchar](30) DEFAULT(user_name()),
[APP_LAST_UPDATE_USER_GUID] [char](32) NULL,
[APP_LAST_UPDATE_USER_DIRECTORY] [nvarchar](30) DEFAULT(user_name()),
[CONCURRENCY_CONTROL_NUMBER] [int] NULL,
[DB_CREATE_USERID] [varchar](63) NOT NULL,
[DB_CREATE_TIMESTAMP] [datetime2](7) NOT NULL,
[DB_LAST_UPDATE_USERID] [varchar](63) NOT NULL,
[DB_LAST_UPDATE_TIMESTAMP] [datetime2](7) NOT NULL,
CONSTRAINT [PK_ORBC_LOA_DETAILS] PRIMARY KEY CLUSTERED ([LOA_ID] ASC) WITH (
PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON
) ON [PRIMARY]
) ON [PRIMARY];

CREATE TABLE [permit].[ORBC_LOA_PERMIT_TYPE_DETAILS] (
LOA_PERMIT_TYPE_ID [bigint] IDENTITY(1,1) NOT NULL,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use an int instead of bigint? Please confirm with @john-fletcher-aot

LOA_ID [bigint] NOT NULL,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use an int instead of bigint? Please confirm with @john-fletcher-aot

PERMIT_TYPE_ID [varchar](10) NOT NULL,
[APP_CREATE_TIMESTAMP] [datetime2](7) DEFAULT(getutcdate()),
[APP_CREATE_USERID] [nvarchar](30) DEFAULT(user_name()),
[APP_CREATE_USER_GUID] [char](32) NULL,
[APP_CREATE_USER_DIRECTORY] [nvarchar](30) DEFAULT(user_name()),
[APP_LAST_UPDATE_TIMESTAMP] [datetime2](7) DEFAULT(getutcdate()),
[APP_LAST_UPDATE_USERID] [nvarchar](30) DEFAULT(user_name()),
[APP_LAST_UPDATE_USER_GUID] [char](32) NULL,
[APP_LAST_UPDATE_USER_DIRECTORY] [nvarchar](30) DEFAULT(user_name()),
[CONCURRENCY_CONTROL_NUMBER] [int] NULL,
[DB_CREATE_USERID] [varchar](63) NOT NULL,
[DB_CREATE_TIMESTAMP] [datetime2](7) NOT NULL,
[DB_LAST_UPDATE_USERID] [varchar](63) NOT NULL,
[DB_LAST_UPDATE_TIMESTAMP] [datetime2](7) NOT NULL,
CONSTRAINT [PK_ORBC_LOA_PERMIT_TYPE_DETAILS] PRIMARY KEY CLUSTERED ([LOA_PERMIT_TYPE_ID] ASC) WITH (
PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON
) ON [PRIMARY]
) ON [PRIMARY];

CREATE TABLE [permit].[ORBC_LOA_VEHICLES] (
LOA_VEHICLE_ID [bigint] IDENTITY(1,1) NOT NULL,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use an int instead of bigint? Please confirm with @john-fletcher-aot

LOA_ID [bigint] NOT NULL,
POWER_UNIT_ID [bigint],
TRAILER_ID [bigint],
[APP_CREATE_TIMESTAMP] [datetime2](7) DEFAULT(getutcdate()),
[APP_CREATE_USERID] [nvarchar](30) DEFAULT(user_name()),
[APP_CREATE_USER_GUID] [char](32) NULL,
[APP_CREATE_USER_DIRECTORY] [nvarchar](30) DEFAULT(user_name()),
[APP_LAST_UPDATE_TIMESTAMP] [datetime2](7) DEFAULT(getutcdate()),
[APP_LAST_UPDATE_USERID] [nvarchar](30) DEFAULT(user_name()),
[APP_LAST_UPDATE_USER_GUID] [char](32) NULL,
[APP_LAST_UPDATE_USER_DIRECTORY] [nvarchar](30) DEFAULT(user_name()),
[CONCURRENCY_CONTROL_NUMBER] [int] NULL,
[DB_CREATE_USERID] [varchar](63) NOT NULL,
[DB_CREATE_TIMESTAMP] [datetime2](7) NOT NULL,
[DB_LAST_UPDATE_USERID] [varchar](63) NOT NULL,
[DB_LAST_UPDATE_TIMESTAMP] [datetime2](7) NOT NULL,
CONSTRAINT [PK_ORBC_LOA_VEHICLES] PRIMARY KEY CLUSTERED ([LOA_VEHICLE_ID] ASC) WITH (
PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON
) ON [PRIMARY]
) ON [PRIMARY];

ALTER TABLE [permit].[ORBC_LOA_DETAILS] ADD CONSTRAINT [DF_ORBC_LOA_DETAILS_DB_CREATE_USERID] DEFAULT(user_name())
FOR [DB_CREATE_USERID]

ALTER TABLE [permit].[ORBC_LOA_DETAILS] ADD CONSTRAINT [DF_ORBC_LOA_DETAILS_DB_CREATE_TIMESTAMP] DEFAULT(getutcdate())
FOR [DB_CREATE_TIMESTAMP]

ALTER TABLE [permit].[ORBC_LOA_DETAILS] ADD CONSTRAINT [DF_ORBC_LOA_DETAILS_DB_LAST_UPDATE_USERID] DEFAULT(user_name())
FOR [DB_LAST_UPDATE_USERID]

ALTER TABLE [permit].[ORBC_LOA_DETAILS] ADD CONSTRAINT [DF_ORBC_LOA_DETAILS_DB_LAST_UPDATE_TIMESTAMP] DEFAULT(getutcdate())
FOR [DB_LAST_UPDATE_TIMESTAMP]

ALTER TABLE [permit].[ORBC_LOA_PERMIT_TYPE_DETAILS] ADD CONSTRAINT [DF_ORBC_LOA_PERMIT_TYPE_DETAILS_DB_CREATE_USERID] DEFAULT(user_name())
FOR [DB_CREATE_USERID]

ALTER TABLE [permit].[ORBC_LOA_PERMIT_TYPE_DETAILS] ADD CONSTRAINT [DF_ORBC_LOA_PERMIT_TYPE_DETAILS_DB_CREATE_TIMESTAMP] DEFAULT(getutcdate())
FOR [DB_CREATE_TIMESTAMP]

ALTER TABLE [permit].[ORBC_LOA_PERMIT_TYPE_DETAILS] ADD CONSTRAINT [DF_ORBC_LOA_PERMIT_TYPE_DETAILS_DB_LAST_UPDATE_USERID] DEFAULT(user_name())
FOR [DB_LAST_UPDATE_USERID]

ALTER TABLE [permit].[ORBC_LOA_PERMIT_TYPE_DETAILS] ADD CONSTRAINT [DF_ORBC_LOA_PERMIT_TYPE_DETAILS_DB_LAST_UPDATE_TIMESTAMP] DEFAULT(getutcdate())
FOR [DB_LAST_UPDATE_TIMESTAMP]

ALTER TABLE [permit].[ORBC_LOA_VEHICLES] ADD CONSTRAINT [DF_ORBC_LOA_VEHICLES_DB_CREATE_USERID] DEFAULT(user_name())
FOR [DB_CREATE_USERID]

ALTER TABLE [permit].[ORBC_LOA_VEHICLES] ADD CONSTRAINT [DF_ORBC_LOA_VEHICLES_DB_CREATE_TIMESTAMP] DEFAULT(getutcdate())
FOR [DB_CREATE_TIMESTAMP]

ALTER TABLE [permit].[ORBC_LOA_VEHICLES] ADD CONSTRAINT [DF_ORBC_LOA_VEHICLES_DB_LAST_UPDATE_USERID] DEFAULT(user_name())
FOR [DB_LAST_UPDATE_USERID]

ALTER TABLE [permit].[ORBC_LOA_VEHICLES] ADD CONSTRAINT [DF_ORBC_LOA_VEHICLES_DB_LAST_UPDATE_TIMESTAMP] DEFAULT(getutcdate())
FOR [DB_LAST_UPDATE_TIMESTAMP]

ALTER TABLE [permit].[ORBC_LOA_VEHICLES]
WITH CHECK ADD CONSTRAINT [ORBC_LOA_VEHICLES_LOA_ID_FK] FOREIGN KEY ([LOA_ID]) REFERENCES [permit].[ORBC_LOA_DETAILS]([LOA_ID]) ON DELETE CASCADE

ALTER TABLE [permit].[ORBC_LOA_VEHICLES]
WITH CHECK ADD CONSTRAINT [ORBC_LOA_VEHICLES_POWER_UNIT_ID_FK] FOREIGN KEY ([POWER_UNIT_ID]) REFERENCES [dbo].[ORBC_POWER_UNIT]([POWER_UNIT_ID])

ALTER TABLE [permit].[ORBC_LOA_VEHICLES]
WITH CHECK ADD CONSTRAINT [ORBC_LOA_VEHICLES_TRAILER_ID_FK] FOREIGN KEY ([TRAILER_ID]) REFERENCES [dbo].[ORBC_TRAILER]([TRAILER_ID])

ALTER TABLE [permit].[ORBC_LOA_PERMIT_TYPE_DETAILS]
WITH CHECK ADD CONSTRAINT [ORBC_LOA_PERMIT_TYPES_PERMIT_TYPE_ID_FK] FOREIGN KEY ([PERMIT_TYPE_ID]) REFERENCES [permit].[ORBC_PERMIT_TYPE]([PERMIT_TYPE])

ALTER TABLE [permit].[ORBC_LOA_PERMIT_TYPE_DETAILS]
WITH CHECK ADD CONSTRAINT [ORBC_LOA_PERMIT_TYPE_LOA_ID_FK] FOREIGN KEY ([LOA_ID]) REFERENCES [permit].[ORBC_LOA_DETAILS]([LOA_ID]) ON DELETE CASCADE

ALTER TABLE [permit].[ORBC_LOA_DETAILS]
WITH CHECK ADD CONSTRAINT [ORBC_LOA_DETAILS_DOCUMENT_ID_FK] FOREIGN KEY ([DOCUMENT_ID]) REFERENCES [dops].[ORBC_DOCUMENT]([ID])

IF @@ERROR <> 0
SET NOEXEC ON
GO

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add col descriptions for the tables

DECLARE @VersionDescription VARCHAR(255)

SET @VersionDescription = '-- Add Serive Account diretory type to ORBC_DIRECTORY_TYPE'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the comment


INSERT [dbo].[ORBC_SYS_VERSION] (
[VERSION_ID],
[DESCRIPTION],
[UPDATE_SCRIPT],
[REVERT_SCRIPT],
[RELEASE_DATE]
)
VALUES (
31,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 32

@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
7 changes: 7 additions & 0 deletions database/mssql/test/versions/v_32_1_test.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SET NOCOUNT ON
IF OBJECT_ID('[$(DB_NAME)].[permit].[ORBC_LOA_PERMIT_TYPE_DETAILS]', 'U') IS NOT NULL
AND OBJECT_ID('[$(DB_NAME)].[permit].[ORBC_LOA_VEHICLES]', 'U') IS NOT NULL
AND OBJECT_ID('[$(DB_NAME)].[permit].[ORBC_LOA_DETAILS]', 'U') IS NOT NULL
SELECT 1
ELSE
SELECT 0
17 changes: 17 additions & 0 deletions database/mssql/test/versions/v_32_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/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 32 are run from this shell script.
# TESTS_DIR variable set by the calling test-runner script.

TEST_32_1_RESULT=$(/opt/mssql-tools/bin/sqlcmd -U ${USER} -P "${PASS}" -S ${SERVER} -v DB_NAME=${DATABASE} -h -1 -i ${TESTS_DIR}/v_32_1_test.sql | xargs)
if [[ $TEST_32_1_RESULT -eq 1 ]]; then
echo "Test 32.1 passed: LOA tables are created correctly"
else
echo "******** Test 32.1 failed: LOA tables are created correctly"
fi

15 changes: 15 additions & 0 deletions dops/src/helper/response-header.helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Response } from 'express';
import { ClsServiceManager } from 'nestjs-cls';

/**
* Sets the 'x-correlation-id' header in the response if it is not already set.
*
* @param {Response} response - The HTTP response object.
*/
export const setResHeaderCorrelationId = (response: Response) => {
const cls = ClsServiceManager.getClsService();
const correlationId = cls.getId();
if (!response.getHeader('x-correlation-id') && correlationId) {
response.setHeader('x-correlation-id', correlationId);
}
};
8 changes: 2 additions & 6 deletions dops/src/interceptor/correlationId.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import { Response } from 'express';
import { ClsServiceManager } from 'nestjs-cls';
import { setResHeaderCorrelationId } from '../helper/response-header.helper';

@Injectable()
export class CorrelationIdInterceptor implements NestInterceptor {
Expand All @@ -16,11 +16,7 @@ export class CorrelationIdInterceptor implements NestInterceptor {
const response = context.switchToHttp().getResponse<Response>();
return next.handle().pipe(
tap(() => {
const cls = ClsServiceManager.getClsService();
const correlationId = cls.getId();
if (!response.getHeader('x-correlation-id') && correlationId) {
response.setHeader('x-correlation-id', correlationId);
}
setResHeaderCorrelationId(response);
}),
);
}
Expand Down
3 changes: 3 additions & 0 deletions dops/src/modules/dms/dms.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { IDP } from '../../enum/idp.enum';
import { Roles } from '../../decorator/roles.decorator';
import { Role } from '../../enum/roles.enum';
import { GetDocumentQueryParamsDto } from './dto/request/queryParam/getDocument.query-params.dto';
import { setResHeaderCorrelationId } from '../../helper/response-header.helper';

@ApiTags('DMS')
@ApiBadRequestResponse({
Expand Down Expand Up @@ -193,8 +194,10 @@ export class DmsController {
s3Object.pipe(res);
} else {
if (getDocumentQueryParamsDto.download === FileDownloadModes.URL) {
setResHeaderCorrelationId(res);
res.status(201).send(file);
} else {
setResHeaderCorrelationId(res);
res.status(302).set('Location', file.preSignedS3Url).end();
}
}
Expand Down
1 change: 1 addition & 0 deletions vehicles/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vehicles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"class-validator": "^0.14.1",
"dayjs": "^1.11.11",
"dotenv": "^16.4.5",
"form-data": "^4.0.0",
"handlebars": "^4.7.8",
"helmet": "^7.1.0",
"jwks-rsa": "^3.1.0",
Expand Down
2 changes: 2 additions & 0 deletions vehicles/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { PaymentModule } from './modules/permit-application-payment/payment/paym
import { PermitReceiptDocumentModule } from './modules/permit-application-payment/permit-receipt-document/permit-receipt-document.module';
import { ShoppingCartModule } from './modules/shopping-cart/shopping-cart.module';
import { CreditAccountModule } from './modules/credit-account/credit-account.module';
import { LoaModule } from './modules/loa/loa.module';

const envPath = path.resolve(process.cwd() + '/../');

Expand Down Expand Up @@ -100,6 +101,7 @@ const envPath = path.resolve(process.cwd() + '/../');
PermitModule,
CreditAccountModule,
FeatureFlagsModule,
LoaModule,
],
controllers: [AppController],
providers: [AppService],
Expand Down
15 changes: 15 additions & 0 deletions vehicles/src/common/helper/response-header.helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Response } from 'express';
import { ClsServiceManager } from 'nestjs-cls';

/**
* Sets the 'x-correlation-id' header in the response if it is not already set.
*
* @param {Response} response - The HTTP response object.
*/
export const setResHeaderCorrelationId = (response: Response) => {
const cls = ClsServiceManager.getClsService();
const correlationId = cls.getId();
if (!response.getHeader('x-correlation-id') && correlationId) {
response.setHeader('x-correlation-id', correlationId);
}
};
Loading