From d77b70f7df6920004e9556984cb89b7c0f10c0d7 Mon Sep 17 00:00:00 2001 From: ryans Date: Mon, 5 May 2025 09:20:06 -0400 Subject: [PATCH 1/4] Highlight changed auth rows Fixes #63 --- container/oracle/initdb.d/02_ddl.sql | 8 ++++-- .../ReducedBeamAuthorizationBuilder.java | 2 ++ .../ReducedRFAuthorizationBuilder.java | 2 ++ .../entity/BeamDestinationAuthorization.java | 27 ++++++++++--------- .../entity/RFSegmentAuthorization.java | 13 +++++++++ .../WEB-INF/tags/beam-operations-panel.tag | 2 +- .../WEB-INF/tags/rf-operations-panel.tag | 2 +- .../destinations-history.jsp | 6 +++++ .../segments-history.jsp | 6 +++++ 9 files changed, 52 insertions(+), 16 deletions(-) diff --git a/container/oracle/initdb.d/02_ddl.sql b/container/oracle/initdb.d/02_ddl.sql index f07c5a60..0429dde7 100644 --- a/container/oracle/initdb.d/02_ddl.sql +++ b/container/oracle/initdb.d/02_ddl.sql @@ -189,10 +189,12 @@ CREATE TABLE JAM_OWNER.BEAM_DESTINATION_AUTHORIZATION CW_LIMIT NUMBER(24,12) NULL, COMMENTS VARCHAR2(256 CHAR) NULL, EXPIRATION_DATE DATE NULL, + CHANGED_YN VARCHAR2(1 CHAR) DEFAULT 'N' NOT NULL, CONSTRAINT BEAM_DESTINATION_AUTHORIZATION_PK PRIMARY KEY (BEAM_DESTINATION_ID,BEAM_AUTHORIZATION_ID), CONSTRAINT BEAM_DESTINATION_AUTHORIZATION_FK1 FOREIGN KEY (BEAM_DESTINATION_ID, FACILITY_ID) REFERENCES JAM_OWNER.BEAM_DESTINATION (BEAM_DESTINATION_ID, FACILITY_ID), CONSTRAINT BEAM_DESTINATION_AUTHORIZATION_FK2 FOREIGN KEY (BEAM_AUTHORIZATION_ID, FACILITY_ID) REFERENCES JAM_OWNER.BEAM_AUTHORIZATION (BEAM_AUTHORIZATION_ID, FACILITY_ID), - CONSTRAINT BEAM_DESTINATION_AUTHORIZATION_CK1 CHECK (BEAM_MODE IN ('None', 'Tune', 'CW', 'Ceramic Viewer', 'Viewer Limited', 'High Duty Cycle', 'BLM Checkout', 'RF Only')) + CONSTRAINT BEAM_DESTINATION_AUTHORIZATION_CK1 CHECK (BEAM_MODE IN ('None', 'Tune', 'CW', 'Ceramic Viewer', 'Viewer Limited', 'High Duty Cycle', 'BLM Checkout', 'RF Only')), + CONSTRAINT BEAM_DESTINATION_AUTHORIZATION_CK2 CHECK (CHANGED_YN IN ('Y', 'N')) ); CREATE TABLE JAM_OWNER.RF_SEGMENT_AUTHORIZATION @@ -203,10 +205,12 @@ CREATE TABLE JAM_OWNER.RF_SEGMENT_AUTHORIZATION HIGH_POWER_RF_YN VARCHAR2(1 CHAR) DEFAULT 'N' NOT NULL, COMMENTS VARCHAR2(256 CHAR) NULL, EXPIRATION_DATE DATE NULL, + CHANGED_YN VARCHAR2(1 CHAR) DEFAULT 'N' NOT NULL, CONSTRAINT RF_SEGMENT_AUTHORIZATION_PK PRIMARY KEY (RF_SEGMENT_ID,RF_AUTHORIZATION_ID), CONSTRAINT RF_SEGMENT_AUTHORIZATION_FK1 FOREIGN KEY (RF_SEGMENT_ID, FACILITY_ID) REFERENCES JAM_OWNER.RF_SEGMENT (RF_SEGMENT_ID, FACILITY_ID), CONSTRAINT RF_SEGMENT_AUTHORIZATION_FK2 FOREIGN KEY (RF_AUTHORIZATION_ID, FACILITY_ID) REFERENCES JAM_OWNER.RF_AUTHORIZATION (RF_AUTHORIZATION_ID, FACILITY_ID), - CONSTRAINT RF_SEGMENT_AUTHORIZATION_CK1 CHECK (HIGH_POWER_RF_YN IN ('Y', 'N')) + CONSTRAINT RF_SEGMENT_AUTHORIZATION_CK1 CHECK (HIGH_POWER_RF_YN IN ('Y', 'N')), + CONSTRAINT RF_SEGMENT_AUTHORIZATION_CK2 CHECK (CHANGED_YN IN ('Y', 'N')) ); CREATE TABLE JAM_OWNER.CREDITED_CONTROL diff --git a/src/main/java/org/jlab/jam/business/session/ReducedBeamAuthorizationBuilder.java b/src/main/java/org/jlab/jam/business/session/ReducedBeamAuthorizationBuilder.java index 19feb5ff..8ddfc589 100644 --- a/src/main/java/org/jlab/jam/business/session/ReducedBeamAuthorizationBuilder.java +++ b/src/main/java/org/jlab/jam/business/session/ReducedBeamAuthorizationBuilder.java @@ -52,6 +52,7 @@ private boolean populateReducedPermissionsDueToVerification( operationAuth.setBeamMode("None"); operationAuth.setCwLimit(null); operationAuth.setExpirationDate(null); + operationAuth.setChanged(true); operationAuth.setComments( "Permission automatically revoked due to credited control " + verification.getCreditedControl().getName() @@ -107,6 +108,7 @@ private boolean populateReducedPermissionDueToAuthorizationExpiration( operationAuth.setBeamMode("None"); operationAuth.setCwLimit(null); operationAuth.setExpirationDate(null); + operationAuth.setChanged(true); operationAuth.setComments( "Permission automatically revoked due to director's authorization expiration"); atLeastOne = true; diff --git a/src/main/java/org/jlab/jam/business/session/ReducedRFAuthorizationBuilder.java b/src/main/java/org/jlab/jam/business/session/ReducedRFAuthorizationBuilder.java index 6e07f8ac..55bb635f 100644 --- a/src/main/java/org/jlab/jam/business/session/ReducedRFAuthorizationBuilder.java +++ b/src/main/java/org/jlab/jam/business/session/ReducedRFAuthorizationBuilder.java @@ -52,6 +52,7 @@ private boolean populateReducedPermissionsDueToVerification( if (segmentId.equals(verification.getRFSegment().getRFSegmentId())) { operationAuth.setHighPowerRf(false); operationAuth.setExpirationDate(null); + operationAuth.setChanged(true); operationAuth.setComments( "Permission automatically revoked due to credited control " + verification.getCreditedControl().getName() @@ -104,6 +105,7 @@ private boolean populateReducedPermissionDueToAuthorizationExpiration( if (containsName(segmentList, operationAuth)) { operationAuth.setHighPowerRf(false); operationAuth.setExpirationDate(null); + operationAuth.setChanged(true); operationAuth.setComments( "Permission automatically revoked due to director's authorization expiration"); atLeastOne = true; diff --git a/src/main/java/org/jlab/jam/persistence/entity/BeamDestinationAuthorization.java b/src/main/java/org/jlab/jam/persistence/entity/BeamDestinationAuthorization.java index a70a8d49..14873950 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/BeamDestinationAuthorization.java +++ b/src/main/java/org/jlab/jam/persistence/entity/BeamDestinationAuthorization.java @@ -4,20 +4,10 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; -import javax.persistence.Basic; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import javax.persistence.*; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; +import org.jlab.smoothness.persistence.util.YnStringToBoolean; /** * @author ryans @@ -75,6 +65,11 @@ public class BeamDestinationAuthorization implements Serializable { @ManyToOne(optional = false, fetch = FetchType.LAZY) private BeamAuthorization beamAuthorization; + @Basic + @Column(name = "CHANGED_YN", nullable = false, length = 1) + @Convert(converter = YnStringToBoolean.class) + private boolean changed; + public BeamDestinationAuthorization() {} public BeamDestinationAuthorization(DestinationAuthorizationPK destinationAuthorizationPK) { @@ -152,6 +147,14 @@ public void setAuthorization(BeamAuthorization beamAuthorization) { this.beamAuthorization = beamAuthorization; } + public boolean isChanged() { + return changed; + } + + public void setChanged(boolean changed) { + this.changed = changed; + } + @Override public int hashCode() { int hash = 0; diff --git a/src/main/java/org/jlab/jam/persistence/entity/RFSegmentAuthorization.java b/src/main/java/org/jlab/jam/persistence/entity/RFSegmentAuthorization.java index ea661a70..d9264b95 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/RFSegmentAuthorization.java +++ b/src/main/java/org/jlab/jam/persistence/entity/RFSegmentAuthorization.java @@ -60,6 +60,11 @@ public class RFSegmentAuthorization implements Serializable { @ManyToOne(optional = false, fetch = FetchType.LAZY) private RFAuthorization rfAuthorization; + @Basic + @Column(name = "CHANGED_YN", nullable = false, length = 1) + @Convert(converter = YnStringToBoolean.class) + private boolean changed; + public RFSegmentAuthorization() {} public RFSegmentAuthorization(SegmentAuthorizationPK segmentAuthorizationPK) { @@ -122,6 +127,14 @@ public void setRFAuthorization(RFAuthorization rfAuthorization) { this.rfAuthorization = rfAuthorization; } + public boolean isChanged() { + return changed; + } + + public void setChanged(boolean changed) { + this.changed = changed; + } + @Override public int hashCode() { int hash = 0; diff --git a/src/main/webapp/WEB-INF/tags/beam-operations-panel.tag b/src/main/webapp/WEB-INF/tags/beam-operations-panel.tag index 542c7711..ff4f4b14 100644 --- a/src/main/webapp/WEB-INF/tags/beam-operations-panel.tag +++ b/src/main/webapp/WEB-INF/tags/beam-operations-panel.tag @@ -30,7 +30,7 @@ - + diff --git a/src/main/webapp/WEB-INF/tags/rf-operations-panel.tag b/src/main/webapp/WEB-INF/tags/rf-operations-panel.tag index 0a211233..5e5b96a2 100644 --- a/src/main/webapp/WEB-INF/tags/rf-operations-panel.tag +++ b/src/main/webapp/WEB-INF/tags/rf-operations-panel.tag @@ -28,7 +28,7 @@ - + diff --git a/src/main/webapp/WEB-INF/views/authorization-history/destinations-history.jsp b/src/main/webapp/WEB-INF/views/authorization-history/destinations-history.jsp index 5a0ffc22..6b11c21c 100644 --- a/src/main/webapp/WEB-INF/views/authorization-history/destinations-history.jsp +++ b/src/main/webapp/WEB-INF/views/authorization-history/destinations-history.jsp @@ -15,6 +15,12 @@ box-shadow: 8px 8px 8px #979797; border-radius: 0 0 8px 8px; } + .changed { + background-color: #fafab4; + } + .message-box { + text-align: center; + } diff --git a/src/main/webapp/WEB-INF/views/authorization-history/segments-history.jsp b/src/main/webapp/WEB-INF/views/authorization-history/segments-history.jsp index f79efd6f..221eaf4e 100644 --- a/src/main/webapp/WEB-INF/views/authorization-history/segments-history.jsp +++ b/src/main/webapp/WEB-INF/views/authorization-history/segments-history.jsp @@ -15,6 +15,12 @@ box-shadow: 8px 8px 8px #979797; border-radius: 0 0 8px 8px; } + .changed { + background-color: #fafab4; + } + .message-box { + text-align: center; + } From a9139c77f21eb81ef2492a65a005830aa9d66f33 Mon Sep 17 00:00:00 2001 From: ryans Date: Mon, 5 May 2025 11:10:30 -0400 Subject: [PATCH 2/4] Emphasis on reduction in auth --- .../ReducedBeamAuthorizationBuilder.java | 14 ++----- .../ReducedRFAuthorizationBuilder.java | 14 ++----- .../persistence/entity/BeamAuthorization.java | 4 ++ .../persistence/entity/RFAuthorization.java | 4 ++ .../WEB-INF/tags/beam-operations-panel.tag | 11 ++++-- .../WEB-INF/tags/rf-operations-panel.tag | 15 ++++++-- .../authorization-history/beam-history.jsp | 37 +++++++++++++++++-- .../destinations-history.jsp | 4 +- .../authorization-history/rf-history.jsp | 37 +++++++++++++++++-- .../segments-history.jsp | 4 +- .../webapp/resources/css/authorizations.css | 8 ++++ 11 files changed, 113 insertions(+), 39 deletions(-) diff --git a/src/main/java/org/jlab/jam/business/session/ReducedBeamAuthorizationBuilder.java b/src/main/java/org/jlab/jam/business/session/ReducedBeamAuthorizationBuilder.java index 8ddfc589..d9bd42eb 100644 --- a/src/main/java/org/jlab/jam/business/session/ReducedBeamAuthorizationBuilder.java +++ b/src/main/java/org/jlab/jam/business/session/ReducedBeamAuthorizationBuilder.java @@ -67,12 +67,9 @@ private boolean populateReducedPermissionsDueToVerification( } if (atLeastOne) { - String comments = clone.getComments(); - if (comments == null) { - comments = ""; - } + String comments = ""; // We replace Change Notes completely with changes String csv = IOUtil.toCsv(revokedDestinationList.toArray()); - comments = comments + "\nCHANGE: Destination control verification revoked: " + csv; + comments = comments + "\nDestination control verification revoked: " + csv; clone.setComments(comments); } @@ -118,12 +115,9 @@ private boolean populateReducedPermissionDueToAuthorizationExpiration( } if (atLeastOne) { - String comments = clone.getComments(); - if (comments == null) { - comments = ""; - } + String comments = ""; // We replace Change Notes completely with changes String csv = IOUtil.toCsv(revokedDestinationList.toArray()); - comments = comments + "\nCHANGE: Destination authorization revoked: " + csv; + comments = comments + "\nDestination authorization revoked: " + csv; clone.setComments(comments); } diff --git a/src/main/java/org/jlab/jam/business/session/ReducedRFAuthorizationBuilder.java b/src/main/java/org/jlab/jam/business/session/ReducedRFAuthorizationBuilder.java index 55bb635f..6c97676b 100644 --- a/src/main/java/org/jlab/jam/business/session/ReducedRFAuthorizationBuilder.java +++ b/src/main/java/org/jlab/jam/business/session/ReducedRFAuthorizationBuilder.java @@ -67,12 +67,9 @@ private boolean populateReducedPermissionsDueToVerification( } if (atLeastOne) { - String comments = clone.getComments(); - if (comments == null) { - comments = ""; - } + String comments = ""; // We replace Change Notes completely with changes String csv = IOUtil.toCsv(revokedSegmentList.toArray()); - comments = comments + "\nCHANGE: Segment control verification revoked: " + csv; + comments = comments + "\nSegment control verification revoked: " + csv; clone.setComments(comments); } @@ -115,12 +112,9 @@ private boolean populateReducedPermissionDueToAuthorizationExpiration( } if (atLeastOne) { - String comments = clone.getComments(); - if (comments == null) { - comments = ""; - } + String comments = ""; // We replace Change Notes completely with changes String csv = IOUtil.toCsv(revokedSegmentList.toArray()); - comments = comments + "\nCHANGE: Segment authorization revoked: " + csv; + comments = comments + "\nSegment authorization revoked: " + csv; clone.setComments(comments); } diff --git a/src/main/java/org/jlab/jam/persistence/entity/BeamAuthorization.java b/src/main/java/org/jlab/jam/persistence/entity/BeamAuthorization.java index 44847e87..9874bf1c 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/BeamAuthorization.java +++ b/src/main/java/org/jlab/jam/persistence/entity/BeamAuthorization.java @@ -67,6 +67,10 @@ public class BeamAuthorization implements Serializable { @OneToMany(cascade = CascadeType.ALL, mappedBy = "beamAuthorization", fetch = FetchType.EAGER) private List beamDestinationAuthorizationList; + public boolean isAutomatedReduction() { + return !modifiedBy.equals(authorizedBy); + } + public BeamAuthorization() {} public BigInteger getBeamAuthorizationId() { diff --git a/src/main/java/org/jlab/jam/persistence/entity/RFAuthorization.java b/src/main/java/org/jlab/jam/persistence/entity/RFAuthorization.java index 5c4d4bed..f8d8c16b 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/RFAuthorization.java +++ b/src/main/java/org/jlab/jam/persistence/entity/RFAuthorization.java @@ -64,6 +64,10 @@ public class RFAuthorization implements Serializable { @Column(name = "LOGENTRY_URL", length = 2048) private String logentryUrl; + public boolean isAutomatedReduction() { + return !modifiedBy.equals(authorizedBy); + } + @OneToMany(cascade = CascadeType.ALL, mappedBy = "rfAuthorization", fetch = FetchType.EAGER) private List rfSegmentAuthorizationList; diff --git a/src/main/webapp/WEB-INF/tags/beam-operations-panel.tag b/src/main/webapp/WEB-INF/tags/beam-operations-panel.tag index ff4f4b14..85b74399 100644 --- a/src/main/webapp/WEB-INF/tags/beam-operations-panel.tag +++ b/src/main/webapp/WEB-INF/tags/beam-operations-panel.tag @@ -122,12 +122,12 @@ -

Notes

+

Change Notes

- - + +

Digital Signature