Skip to content

Commit

Permalink
Merge branch 'SIMSBIOHUB-383' into dataset_security_feature
Browse files Browse the repository at this point in the history
  • Loading branch information
NickPhura committed Dec 14, 2023
2 parents 68adef6 + 990d05b commit 0af3140
Show file tree
Hide file tree
Showing 27 changed files with 741 additions and 507 deletions.
121 changes: 93 additions & 28 deletions api/package-lock.json

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

2 changes: 1 addition & 1 deletion api/src/paths/administrative/submission/reviewed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function getReviewedSubmissionsForAdmins(): RequestHandler {

return res.status(200).json(response);
} catch (error) {
defaultLog.error({ label: 'getReviewedSubmissions', message: 'error', error });
defaultLog.error({ label: 'getReviewedSubmissionsForAdmins', message: 'error', error });
await connection.rollback();
throw error;
} finally {
Expand Down
2 changes: 1 addition & 1 deletion api/src/paths/administrative/submission/unreviewed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function getUnreviewedSubmissionsForAdmins(): RequestHandler {

return res.status(200).json(response);
} catch (error) {
defaultLog.error({ label: 'getUnreviewedSubmissions', message: 'error', error });
defaultLog.error({ label: 'getUnreviewedSubmissionsForAdmins', message: 'error', error });
await connection.rollback();
throw error;
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export function patchSubmissionRecord(): RequestHandler {

const submissionId = Number(req.params.submissionId);

const patch = req.body as PatchSubmissionRecord;
const patch = req.body.patch as PatchSubmissionRecord;

try {
await connection.open();
Expand Down
9 changes: 9 additions & 0 deletions api/src/paths/submission/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { RequestHandler } from 'express';
import { Operation } from 'express-openapi';
import { getAPIUserDBConnection } from '../../database/db';
import { defaultErrorResponses } from '../../openapi/schemas/http-responses';
import { SECURITY_APPLIED_STATUS } from '../../repositories/security-repository';
import { SubmissionService } from '../../services/submission-service';
import { getLogger } from '../../utils/logger';

Expand Down Expand Up @@ -81,6 +82,14 @@ GET.apiDoc = {
revision_count: {
type: 'integer',
minimum: 0
},
security: {
type: 'string',
enum: [
SECURITY_APPLIED_STATUS.SECURED,
SECURITY_APPLIED_STATUS.UNSECURED,
SECURITY_APPLIED_STATUS.PARTIALLY_SECURED
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { defaultErrorResponses } from '../../../openapi/schemas/http-responses';
import { SubmissionService } from '../../../services/submission-service';
import { getLogger } from '../../../utils/logger';

const defaultLog = getLogger('paths/submission/{submissionUUID}}');
const defaultLog = getLogger('paths/submission/{submissionId}');

export const GET: Operation = [getSubmissionInformation()];

GET.apiDoc = {
description: 'retrieves submission data from the submission table',
description: 'Retrieves a submission record from the submission table',
tags: ['eml'],
security: [
{
Expand All @@ -19,19 +19,19 @@ GET.apiDoc = {
],
parameters: [
{
description: 'submission uuid',
description: 'Submission ID.',
in: 'path',
name: 'submissionUUID',
name: 'submissionId',
schema: {
type: 'string',
format: 'uuid'
type: 'integer',
minimum: 1
},
required: true
}
],
responses: {
200: {
description: 'Dataset metadata response object.',
description: 'A submission record and all child submission feature records.',
content: {
'application/json': {
schema: {
Expand All @@ -40,26 +40,63 @@ GET.apiDoc = {
properties: {
submission: {
type: 'object',
required: ['submission_id', 'uuid', 'security_review_timestamp', 'create_date', 'create_user'],
required: [
'submission_id',
'uuid',
'security_review_timestamp',
'submitted_timestamp',
'source_system',
'name',
'description',
'create_date',
'create_user',
'update_date',
'update_user',
'revision_count'
],
properties: {
submission_id: {
type: 'number'
type: 'integer',
minimum: 1
},
uuid: {
type: 'string',
format: 'uuid'
},
security_review_timestamp: {
type: 'string',
format: 'date-time',
nullable: true
},
create_date: {
source_system: {
type: 'string'
},
name: {
type: 'string',
format: 'date-time'
maxLength: 200
},
create_user: {
description: {
type: 'string',
maxLength: 3000
},
create_date: {
type: 'string'
},
create_user: {
type: 'integer',
minimum: 1
},
update_date: {
type: 'string',
nullable: true
},
update_user: {
type: 'integer',
minimum: 1,
nullable: true
},
revision_count: {
type: 'integer',
minimum: 0
}
}
},
Expand Down Expand Up @@ -102,22 +139,22 @@ GET.apiDoc = {
};

/**
* Retrieves submission data from the submission table.
* Retrieves a submission record and all child submission feature records.
*
* @returns {RequestHandler}
*/
export function getSubmissionInformation(): RequestHandler {
return async (req, res) => {
const connection = req['keycloak_token'] ? getDBConnection(req['keycloak_token']) : getAPIUserDBConnection();

const submissionUUID = String(req.params.submissionUUID);
const submissionId = Number(req.params.submissionId);

try {
await connection.open();

const submissionService = new SubmissionService(connection);

const result = await submissionService.getSubmissionAndFeaturesBySubmissionUUID(submissionUUID);
const result = await submissionService.getSubmissionAndFeaturesBySubmissionId(submissionId);

await connection.commit();

Expand Down
Loading

0 comments on commit 0af3140

Please sign in to comment.