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

Update barrier access upload feature #752

Merged
merged 14 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion WNPRC_Compliance/module.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ License: Apache 2.0
LicenseURL: http://www.apache.org/licenses/LICENSE-2.0
ModuleClass: org.labkey.wnprc_compliance.WNPRC_ComplianceModule
Name: WNPRC_Compliance
SchemaVersion: 21.001
SchemaVersion: 25.001
SupportedDatabases: pgsql
ManageVersion: false
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,23 @@ personsList.isArchived,
card_info.first_name,
card_info.last_name,
card_info.middle_name,
card_info.department,
card_info.employee_number,
card_info.info2,
card_info.info3,
card_info.info5,

access_info.areas,
access_info.access_levels,

persons_to_cards.personid

FROM (
SELECT
report_id,
card_id,
GROUP_CONCAT(display_area, ';') as areas
GROUP_CONCAT(access_level, ';') as access_levels


FROM (
SELECT
reports.report_id,
report_data.card_id,
report_data.enabled,
report_data.area,
CASE
WHEN report_data.enabled IS FALSE THEN CAST(COALESCE(report_data.area, '') || ' (disabled)' as VARCHAR)
ELSE report_data.area
END as display_area
report_data.access_level,


FROM wnprc_compliance.access_reports reports, wnprc_compliance.access_report_data report_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ last_name,
first_name,
middle_name,
date_of_birth,
cardInfo.employee_number,
notes,
tbResults.lastClearance as lastTbClearance,
measlesResults.lastClearance as measlesClearance,
Expand Down Expand Up @@ -51,16 +50,3 @@ LEFT JOIN (

ON measlesResults.person_id = persons.personid

--Adding employee_number from card_info table. Need to select the latest uploaded record to the card_info table
--Use person_to_cards table to link the personid to the card_id.
LEFT JOIN wnprc_compliance.persons_to_cards pers_to_card ON (persons.personid = pers_to_card.personid)
LEFT JOIN
(
SELECT card_info.employee_number, card_info.card_id, MAX(card_info.created)
FROM wnprc_compliance.card_info
GROUP BY card_info.card_id, card_info.employee_number
) cardInfo
ON (pers_to_card.cardid = cardInfo.card_id)

ORDER BY last_name ASC

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ id,
first_name,
middle_name,
last_name,
display,
COALESCE(display, '') as display,
LCASE(display) as displayLcase,
notes,
COALESCE(notes, '') as notes,
"type"

FROM (
Expand All @@ -33,7 +33,7 @@ FROM (
SELECT
card_id as id,
first_name,
middle_name,
COALESCE(middle_name, ''),
last_name,
COALESCE(first_name, '') || ' ' || COALESCE(middle_name, '') || ' ' || COALESCE(last_name, '') || ' (' || card_id || ')' as display,
COALESCE(department || ';', '') || COALESCE(info2 || ';', '') || COALESCE(info3 || ';', '') as notes,
Expand All @@ -48,7 +48,7 @@ FROM (
SELECT
personid as id,
first_name,
middle_name,
COALESCE(middle_name, ''),
last_name,
COALESCE(first_name, '') || ' ' || COALESCE(middle_name, '') || ' ' || COALESCE(last_name, '') as display,
notes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ cards.card_id,
last_name,
first_name,
middle_name,
department,
employee_number,
info2,
info3,
info5
card_info.card_type,
to_char(card_info.date_issued , 'yyyy-MM-dd') AS date_issued,
to_char(card_info.date_expire, 'yyyy-MM-dd') AS date_expire,
card_info.issue_code

FROM (
SELECT
Expand All @@ -18,12 +17,16 @@ FROM (
SELECT
unknown_cards.card_id,
card_info.report_id,
card_info.report_id.date
card_info.report_id.date,
card_info.card_type,
card_info.date_issued,
card_info.date_expire,
card_info.issue_code

FROM (
SELECT
cards.card_id,
persons_to_cards.personid
persons_to_cards.personid,

FROM (
SELECT card_id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ALTER TABLE wnprc_compliance.card_info ADD COLUMN IF NOT EXISTS card_type text;
ALTER TABLE wnprc_compliance.card_info ADD COLUMN IF NOT EXISTS date_issued timestamp;
ALTER TABLE wnprc_compliance.card_info ADD COLUMN IF NOT EXISTS date_expire timestamp;
ALTER TABLE wnprc_compliance.card_info ADD COLUMN IF NOT EXISTS issue_code int;

ALTER TABLE wnprc_compliance.access_report_data RENAME TO access_report_data_old;


DROP TABLE IF EXISTS wnprc_compliance.access_report_data;
CREATE TABLE wnprc_compliance.access_report_data (
report_id TEXT,
access_level TEXT,
card_id TEXT,

container entityid NOT NULL,
createdby userid,
created TIMESTAMP,
modifiedby userid,
modified TIMESTAMP,

CONSTRAINT PK_access_report_data_new PRIMARY KEY (report_id, access_level, card_id),
CONSTRAINT FK_access_report_data_access_reports_new FOREIGN KEY (report_id) REFERENCES wnprc_compliance.access_reports (report_id)
);
16 changes: 16 additions & 0 deletions WNPRC_Compliance/resources/schemas/wnprc_compliance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@
</columns>
</table>
<table tableName="access_report_data" tableDbType="TABLE">
<columns>
<column columnName="report_id"/>
<column columnName="access_level"/>
<column columnName="card_id"/>
<column columnName="container"/>
<column columnName="createdby"/>
<column columnName="created"/>
<column columnName="modifiedby"/>
<column columnName="modified"/>
</columns>
</table>
<table tableName="access_report_data_old" tableDbType="TABLE">
<columns>
<column columnName="report_id"/>
<column columnName="area"/>
Expand All @@ -156,6 +168,10 @@
<column columnName="first_name"/>
<column columnName="last_name"/>
<column columnName="middle_name"/>
<column columnName="date_issued"/>
<column columnName="date_expire"/>
<column columnName="card_type"/>
<column columnName="issue_code"/>
<column columnName="department"/>
<column columnName="employee_number"/>
<column columnName="info2"/>
Expand Down
Loading