From 554190a72b5a3223b1d957e9834ecb884a0a49ea Mon Sep 17 00:00:00 2001 From: Ryan Slominski Date: Mon, 27 Jan 2025 13:12:00 -0500 Subject: [PATCH 01/44] Separate Facilities Fixes #1 Separate RF Operations Fixes #15 --- container/oracle/initdb.d/02_ddl.sql | 82 ++++++++---- container/oracle/initdb.d/03_default_data.sql | 43 +++++-- .../session/BeamDestinationFacade.java | 37 +++++- .../jam/business/session/FacilityFacade.java | 60 +++++++++ .../persistence/entity/BeamDestination.java | 24 ++-- .../jlab/jam/persistence/entity/Facility.java | 117 ++++++++++++++++++ .../controller/ContextRootController.java | 32 +++++ ...ssions.java => FacilityAuthorization.java} | 45 ++++--- .../presentation/util/BeamAuthFunctions.java | 6 +- .../WEB-INF/tags/authorization-page.tag | 37 ++++++ .../tags/destination-permissions-table.tag | 7 +- src/main/webapp/WEB-INF/tags/page.tag | 2 +- .../webapp/WEB-INF/tags/permissions-page.tag | 22 ++-- ...issions.jsp => facility-authorization.jsp} | 6 +- src/main/webapp/WEB-INF/web.xml | 3 - 15 files changed, 431 insertions(+), 92 deletions(-) create mode 100644 src/main/java/org/jlab/jam/business/session/FacilityFacade.java create mode 100644 src/main/java/org/jlab/jam/persistence/entity/Facility.java create mode 100644 src/main/java/org/jlab/jam/presentation/controller/ContextRootController.java rename src/main/java/org/jlab/jam/presentation/controller/{BeamPermissions.java => FacilityAuthorization.java} (86%) create mode 100644 src/main/webapp/WEB-INF/tags/authorization-page.tag rename src/main/webapp/WEB-INF/views/{permissions.jsp => facility-authorization.jsp} (83%) diff --git a/container/oracle/initdb.d/02_ddl.sql b/container/oracle/initdb.d/02_ddl.sql index 9661a82..5ab6c89 100644 --- a/container/oracle/initdb.d/02_ddl.sql +++ b/container/oracle/initdb.d/02_ddl.sql @@ -47,20 +47,60 @@ CREATE SEQUENCE JAM_OWNER.WORKGROUP_ID NOCACHE ORDER; +CREATE TABLE JAM_OWNER.WORKGROUP +( + WORKGROUP_ID INTEGER NOT NULL , + NAME VARCHAR2(64 CHAR) NOT NULL , + LEADER_ROLE_NAME VARCHAR2(64 CHAR) NOT NULL , + CONSTRAINT WORKGROUP_PK PRIMARY KEY (WORKGROUP_ID) +); + +CREATE TABLE JAM_OWNER.FACILITY +( + FACILITY_ID INTEGER NOT NULL, + NAME VARCHAR2(64 CHAR) NOT NULL, + PATH VARCHAR2(32 CHAR) NOT NULL, + RF_WORKGROUP_ID INTEGER NOT NULL, + BEAM_WORKGROUP_ID INTEGER NOT NULL, + WEIGHT INTEGER NOT NULL, + CONSTRAINT FACILITY_PK PRIMARY KEY (FACILITY_ID), + CONSTRAINT FACILITY_AK1 UNIQUE (NAME), + CONSTRAINT FACILITY_FK1 FOREIGN KEY (RF_WORKGROUP_ID) REFERENCES JAM_OWNER.WORKGROUP (WORKGROUP_ID), + CONSTRAINT FACILITY_FK2 FOREIGN KEY (BEAM_WORKGROUP_ID) REFERENCES JAM_OWNER.WORKGROUP (WORKGROUP_ID) +); + +CREATE TABLE JAM_OWNER.RF_OPERATION +( + RF_OPERATION_ID INTEGER NOT NULL, + NAME VARCHAR2(64 CHAR) NOT NULL, + FACILITY_ID INTEGER NOT NULL, + ACTIVE_YN CHAR(1 BYTE) DEFAULT 'Y' NOT NULL, + WEIGHT INTEGER NOT NULL, + CONSTRAINT RF_OPERATION_PK PRIMARY KEY (RF_OPERATION_ID), + CONSTRAINT RF_OPERATION_CK1 CHECK (ACTIVE_YN IN ('Y', 'N')) +); + +-- Should be renamed BEAM_OPERATION CREATE TABLE JAM_OWNER.BEAM_DESTINATION ( - BEAM_DESTINATION_ID INTEGER NOT NULL , - NAME VARCHAR2(64 CHAR) NOT NULL , - MACHINE VARCHAR2(32 CHAR) DEFAULT 'CEBAF' NOT NULL , - CURRENT_LIMIT_UNITS VARCHAR2(3 CHAR) DEFAULT 'uA' NOT NULL , - ACTIVE_YN CHAR(1 BYTE) DEFAULT 'Y' NOT NULL CONSTRAINT BEAM_DESTINATION_CK1 CHECK (ACTIVE_YN IN ('Y', 'N')), + BEAM_DESTINATION_ID INTEGER NOT NULL, + --OPERATION_TYPE VARCHAR2(4 CHAR) DEFAULT 'BEAM' NOT NULL, + NAME VARCHAR2(64 CHAR) NOT NULL, + FACILITY_ID INTEGER NOT NULL, + CURRENT_LIMIT_UNITS VARCHAR2(3 CHAR) DEFAULT 'uA' NOT NULL, + ACTIVE_YN CHAR(1 BYTE) DEFAULT 'Y' NOT NULL, WEIGHT INTEGER NOT NULL, - CONSTRAINT BEAM_DESTINATION_PK PRIMARY KEY (BEAM_DESTINATION_ID) + CONSTRAINT BEAM_DESTINATION_PK PRIMARY KEY (BEAM_DESTINATION_ID), + CONSTRAINT BEAM_DESTINATION_FK1 FOREIGN KEY (FACILITY_ID) REFERENCES JAM_OWNER.FACILITY (FACILITY_ID), + CONSTRAINT BEAM_DESTINATION_CK1 CHECK (ACTIVE_YN IN ('Y', 'N')) + --CONSTRAINT BEAM_DESTINATION_CK2 CHECK (OPERATION_TYPE IN ('BEAM', 'RF')) ); +-- Rename BEAM_AUTHORIZATION CREATE TABLE JAM_OWNER.AUTHORIZATION ( AUTHORIZATION_ID INTEGER NOT NULL , + --OPERATION_TYPE VARCHAR2(4 CHAR) DEFAULT 'BEAM' NOT NULL, MODIFIED_DATE DATE NOT NULL , MODIFIED_BY VARCHAR2(64 CHAR) NOT NULL , AUTHORIZATION_DATE DATE NOT NULL , @@ -69,6 +109,7 @@ CREATE TABLE JAM_OWNER.AUTHORIZATION CONSTRAINT AUTHORIZATION_PK PRIMARY KEY (AUTHORIZATION_ID) ); +-- Rename BEAM_OPERATION_AUTHORIZATION CREATE TABLE JAM_OWNER.DESTINATION_AUTHORIZATION ( BEAM_DESTINATION_ID INTEGER NOT NULL , @@ -82,27 +123,20 @@ CREATE TABLE JAM_OWNER.DESTINATION_AUTHORIZATION CONSTRAINT DESTINATION_AUTHORIZATION_FK2 FOREIGN KEY (AUTHORIZATION_ID) REFERENCES JAM_OWNER.AUTHORIZATION (AUTHORIZATION_ID) ); -CREATE TABLE JAM_OWNER.WORKGROUP -( - WORKGROUP_ID INTEGER NOT NULL , - NAME VARCHAR2(64 CHAR) NOT NULL , - LEADER_ROLE_NAME VARCHAR2(64 CHAR) NOT NULL , - CONSTRAINT WORKGROUP_PK PRIMARY KEY (WORKGROUP_ID) -); - CREATE TABLE JAM_OWNER.CREDITED_CONTROL ( - CREDITED_CONTROL_ID INTEGER NOT NULL , - NAME VARCHAR2(128 CHAR) NOT NULL , - DESCRIPTION VARCHAR2(2048 CHAR) NULL , - WORKGROUP_ID INTEGER NOT NULL , - WEIGHT INTEGER NULL , - VERIFICATION_FREQUENCY VARCHAR2(128 CHAR) NULL , - COMMENTS VARCHAR2(2048) NULL , + CREDITED_CONTROL_ID INTEGER NOT NULL, + NAME VARCHAR2(128 CHAR) NOT NULL, + DESCRIPTION VARCHAR2(2048 CHAR) NULL, + WORKGROUP_ID INTEGER NOT NULL, + WEIGHT INTEGER NULL, + VERIFICATION_FREQUENCY VARCHAR2(128 CHAR) NULL, + COMMENTS VARCHAR2(2048) NULL, CONSTRAINT CREDITED_CONTROL_PK PRIMARY KEY (CREDITED_CONTROL_ID), CONSTRAINT CREDITED_CONTROL_FK1 FOREIGN KEY (WORKGROUP_ID) REFERENCES JAM_OWNER.WORKGROUP(WORKGROUP_ID) ); +-- Should be renamed VERIFICATION_STATUS CREATE TABLE JAM_OWNER.VERIFICATION ( VERIFICATION_ID INTEGER NOT NULL , @@ -110,11 +144,12 @@ CREATE TABLE JAM_OWNER.VERIFICATION CONSTRAINT VERIFICATION_PK PRIMARY KEY (VERIFICATION_ID) ); +-- RENAME BEAM_CONTROL_VERIFICATION CREATE TABLE JAM_OWNER.CONTROL_VERIFICATION ( - CONTROL_VERIFICATION_ID INTEGER NOT NULL , + CONTROL_VERIFICATION_ID INTEGER NOT NULL , -- RENAME BEAM_CONTROL_VERIFICATION_ID CREDITED_CONTROL_ID INTEGER NULL , - BEAM_DESTINATION_ID INTEGER NOT NULL , + BEAM_DESTINATION_ID INTEGER NOT NULL , -- rename BEAM_OPERATION_ID VERIFICATION_ID INTEGER NOT NULL, VERIFICATION_DATE DATE NULL , VERIFIED_BY VARCHAR(64 CHAR) NULL , @@ -129,6 +164,7 @@ CREATE TABLE JAM_OWNER.CONTROL_VERIFICATION CONSTRAINT CONTROL_VERIFICATION_FK3 FOREIGN KEY (VERIFICATION_ID) REFERENCES JAM_OWNER.VERIFICATION (VERIFICATION_ID) ON DELETE SET NULL ); +-- RENAME BEAM_VERIFICATION_HISTORY CREATE TABLE JAM_OWNER.VERIFICATION_HISTORY ( VERIFICATION_HISTORY_ID INTEGER NOT NULL , diff --git a/container/oracle/initdb.d/03_default_data.sql b/container/oracle/initdb.d/03_default_data.sql index 0c6a75c..67b1b3d 100644 --- a/container/oracle/initdb.d/03_default_data.sql +++ b/container/oracle/initdb.d/03_default_data.sql @@ -6,9 +6,26 @@ insert into JAM_OWNER.VERIFICATION (VERIFICATION_ID, NAME) values (50, 'Provisio insert into JAM_OWNER.VERIFICATION (VERIFICATION_ID, NAME) values (100, 'Not Verified'); -- Populate Workgroup -insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (JAM_OWNER.WORKGROUP_ID.nextval, 'Group 1', 'group1Leaders'); -insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (JAM_OWNER.WORKGROUP_ID.nextval, 'Group 2', 'group2Leaders'); -insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (JAM_OWNER.WORKGROUP_ID.nextval, 'Group 3', 'group3Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (1, 'Group 1', 'group1Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (2, 'Group 2', 'group2Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (3, 'Group 3', 'group3Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (4, 'Group 4', 'group4Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (5, 'Group 5', 'group5Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (6, 'Group 6', 'group6Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (7, 'Group 7', 'group7Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (8, 'Group 8', 'group8Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (9, 'Group 9', 'group9Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (10, 'Group 10', 'group10Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (11, 'Group 11', 'group11Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (12, 'Group 12', 'group12Leaders'); +insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (13, 'Group 13', 'group13Leaders'); + +-- Populate Facilities +insert into JAM_OWNER.FACILITY (FACILITY_ID, NAME, PATH, RF_WORKGROUP_ID, BEAM_WORKGROUP_ID, WEIGHT) values (1, 'CEBAF', '/cebaf', 4, 5, 1); +insert into JAM_OWNER.FACILITY (FACILITY_ID, NAME, PATH, RF_WORKGROUP_ID, BEAM_WORKGROUP_ID, WEIGHT) values (2, 'LERF', '/lerf', 6, 7, 2); +insert into JAM_OWNER.FACILITY (FACILITY_ID, NAME, PATH, RF_WORKGROUP_ID, BEAM_WORKGROUP_ID, WEIGHT) values (3, 'UITF', '/uitf', 8, 9, 3); +insert into JAM_OWNER.FACILITY (FACILITY_ID, NAME, PATH, RF_WORKGROUP_ID, BEAM_WORKGROUP_ID, WEIGHT) values (4, 'CMTF', '/cmtf', 10, 11, 4); +insert into JAM_OWNER.FACILITY (FACILITY_ID, NAME, PATH, RF_WORKGROUP_ID, BEAM_WORKGROUP_ID, WEIGHT) values (5, 'VTA', '/vta', 12, 13, 5); -- Populate Credited Controls insert into JAM_OWNER.CREDITED_CONTROL (CREDITED_CONTROL_ID,NAME,DESCRIPTION,WORKGROUP_ID,WEIGHT,VERIFICATION_FREQUENCY) values (JAM_OWNER.CREDITED_CONTROL_ID.nextval,'Control 1','Control 1 Description',1,1,'1 Year'); @@ -19,16 +36,16 @@ insert into JAM_OWNER.CREDITED_CONTROL (CREDITED_CONTROL_ID,NAME,DESCRIPTION,WOR insert into JAM_OWNER.CREDITED_CONTROL (CREDITED_CONTROL_ID,NAME,DESCRIPTION,WORKGROUP_ID,WEIGHT,VERIFICATION_FREQUENCY) values (JAM_OWNER.CREDITED_CONTROL_ID.nextval,'Control 6','Control 6 Description',1,6,'1 Year'); -- Populate Beam Destinations -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, MACHINE, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 1', 'CEBAF', 'uA', 'Y', 1); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, MACHINE, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 2', 'CEBAF', 'uA', 'Y', 2); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, MACHINE, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 3', 'CEBAF', 'uA', 'Y', 3); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, MACHINE, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 4', 'LERF', 'uA', 'Y', 4); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, MACHINE, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 5', 'LERF', 'uA', 'Y', 5); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, MACHINE, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 6', 'LERF', 'uA', 'Y', 6); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, MACHINE, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 7', 'UITF', 'uA', 'Y', 7); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, MACHINE, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 8', 'UITF', 'uA', 'Y', 8); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, MACHINE, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 9', 'UITF', 'uA', 'Y', 9); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, MACHINE, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Injector RF Operations', 'CEBAF', 'uA', 'Y', 9); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 1', 1, 'uA', 'Y', 1); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 2', 1, 'uA', 'Y', 2); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 3', 1, 'uA', 'Y', 3); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 4', 2, 'uA', 'Y', 4); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 5', 2, 'uA', 'Y', 5); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 6', 2, 'uA', 'Y', 6); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 7', 3, 'uA', 'Y', 7); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 8', 3, 'uA', 'Y', 8); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 9', 3, 'uA', 'Y', 9); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Injector RF Operations', 1, 'uA', 'Y', 9); -- Populate Initial Control Verification insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 1, 1, 100, sysdate, 'admin', null, null, 'admin', sysdate); diff --git a/src/main/java/org/jlab/jam/business/session/BeamDestinationFacade.java b/src/main/java/org/jlab/jam/business/session/BeamDestinationFacade.java index 96f4a87..a994f6d 100644 --- a/src/main/java/org/jlab/jam/business/session/BeamDestinationFacade.java +++ b/src/main/java/org/jlab/jam/business/session/BeamDestinationFacade.java @@ -1,6 +1,7 @@ package org.jlab.jam.business.session; import java.math.BigInteger; +import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -10,8 +11,10 @@ import javax.persistence.PersistenceContext; import javax.persistence.Query; import javax.persistence.TypedQuery; +import javax.persistence.criteria.*; import org.jlab.jam.persistence.entity.BeamDestination; import org.jlab.jam.persistence.entity.ControlVerification; +import org.jlab.jam.persistence.entity.Facility; /** * @author ryans @@ -46,7 +49,7 @@ public List findActiveDestinations() { public List findCebafDestinations() { Query q = em.createNativeQuery( - "select * from JAM_OWNER.beam_destination where machine = 'CEBAF' and ACTIVE_YN = 'Y' order by weight", + "select * from JAM_OWNER.beam_destination where FACILITY_ID = 1 and ACTIVE_YN = 'Y' order by weight", BeamDestination.class); return q.getResultList(); @@ -57,7 +60,7 @@ public List findCebafDestinations() { public List findLerfDestinations() { Query q = em.createNativeQuery( - "select * from JAM_OWNER.beam_destination where machine = 'LERF' and ACTIVE_YN = 'Y' order by weight", + "select * from JAM_OWNER.beam_destination where facility_id = 2 and ACTIVE_YN = 'Y' order by weight", BeamDestination.class); return q.getResultList(); @@ -68,7 +71,7 @@ public List findLerfDestinations() { public List findUitfDestinations() { Query q = em.createNativeQuery( - "select * from JAM_OWNER.beam_destination where machine = 'UITF' and ACTIVE_YN = 'Y' order by weight", + "select * from JAM_OWNER.beam_destination where facility_id = 3 and ACTIVE_YN = 'Y' order by weight", BeamDestination.class); return q.getResultList(); @@ -107,4 +110,32 @@ public int compare(ControlVerification o1, ControlVerification o2) { return destination; } + + @PermitAll + public List findByFacility(Facility facility) { + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(BeamDestination.class); + Root root = cq.from(BeamDestination.class); + + List filters = new ArrayList<>(); + + filters.add(cb.equal(root.get("facility"), facility)); + + filters.add(cb.equal(root.get("active"), true)); + + if (!filters.isEmpty()) { + cq.where(cb.and(filters.toArray(new Predicate[] {}))); + } + + List orders = new ArrayList<>(); + Path p0 = root.get("weight"); + Order o0 = cb.desc(p0); + orders.add(o0); + cq.orderBy(orders); + + cq.select(root); + TypedQuery q = getEntityManager().createQuery(cq); + + return q.getResultList(); + } } diff --git a/src/main/java/org/jlab/jam/business/session/FacilityFacade.java b/src/main/java/org/jlab/jam/business/session/FacilityFacade.java new file mode 100644 index 0000000..466b3b2 --- /dev/null +++ b/src/main/java/org/jlab/jam/business/session/FacilityFacade.java @@ -0,0 +1,60 @@ +package org.jlab.jam.business.session; + +import java.util.ArrayList; +import java.util.List; +import javax.annotation.security.PermitAll; +import javax.ejb.Stateless; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.*; +import org.jlab.jam.persistence.entity.Facility; + +/** + * @author ryans + */ +@Stateless +public class FacilityFacade extends AbstractFacade { + @PersistenceContext(unitName = "jamPU") + private EntityManager em; + + @Override + protected EntityManager getEntityManager() { + return em; + } + + public FacilityFacade() { + super(Facility.class); + } + + @PermitAll + public Facility findByPath(String pathInfo) { + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(Facility.class); + Root root = cq.from(Facility.class); + + List filters = new ArrayList<>(); + + filters.add(cb.equal(root.get("path"), pathInfo)); + + if (!filters.isEmpty()) { + cq.where(cb.and(filters.toArray(new Predicate[] {}))); + } + + cq.select(root); + TypedQuery q = getEntityManager().createQuery(cq).setFirstResult(0).setMaxResults(2); + List recordList = q.getResultList(); + + Facility facility = null; + + if (recordList.size() > 1) { + throw new RuntimeException("Duplicate facility paths configured"); + } + + if (recordList.size() > 0) { + facility = recordList.get(0); + } + + return facility; + } +} diff --git a/src/main/java/org/jlab/jam/persistence/entity/BeamDestination.java b/src/main/java/org/jlab/jam/persistence/entity/BeamDestination.java index a9cf971..3d50124 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/BeamDestination.java +++ b/src/main/java/org/jlab/jam/persistence/entity/BeamDestination.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Objects; import javax.persistence.*; +import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import org.jlab.jam.persistence.view.BeamDestinationVerification; import org.jlab.smoothness.persistence.util.YnStringToBoolean; @@ -16,9 +17,10 @@ public class BeamDestination { @Column(name = "BEAM_DESTINATION_ID", nullable = false, precision = 0) private BigInteger beamDestinationId; - @Basic - @Column(name = "MACHINE", nullable = false, length = 32) - private String machine; + @NotNull + @ManyToOne + @JoinColumn(name = "FACILITY_ID", referencedColumnName = "FACILITY_ID", nullable = false) + private Facility facility; @Basic @Column(name = "CURRENT_LIMIT_UNITS", nullable = false, length = 3) @@ -74,12 +76,12 @@ public void setBeamDestinationId(BigInteger beamDestinationId) { this.beamDestinationId = beamDestinationId; } - public String getMachine() { - return machine; + public Facility getFacility() { + return facility; } - public void setMachine(String machine) { - this.machine = machine; + public void setFacility(Facility facility) { + this.facility = facility; } public String getCurrentLimitUnits() { @@ -104,14 +106,14 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; BeamDestination that = (BeamDestination) o; return Objects.equals(beamDestinationId, that.beamDestinationId) - && Objects.equals(machine, that.machine) + && Objects.equals(facility, that.facility) && Objects.equals(currentLimitUnits, that.currentLimitUnits) && Objects.equals(name, that.name); } @Override public int hashCode() { - return Objects.hash(beamDestinationId, machine, currentLimitUnits, name); + return Objects.hash(beamDestinationId, facility, currentLimitUnits, name); } @Override @@ -119,8 +121,8 @@ public String toString() { return "BeamDestination{" + "beamDestinationId=" + beamDestinationId - + ", machine='" - + machine + + ", facility='" + + facility + '\'' + ", currentLimitUnits='" + currentLimitUnits diff --git a/src/main/java/org/jlab/jam/persistence/entity/Facility.java b/src/main/java/org/jlab/jam/persistence/entity/Facility.java new file mode 100644 index 0000000..01874d8 --- /dev/null +++ b/src/main/java/org/jlab/jam/persistence/entity/Facility.java @@ -0,0 +1,117 @@ +package org.jlab.jam.persistence.entity; + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.Objects; +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +/** + * @author ryans + */ +@Entity +@Table(name = "FACILITY", schema = "JAM_OWNER") +public class Facility implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @Basic(optional = false) + @NotNull + @Column(name = "FACILITY_ID", nullable = false, precision = 22, scale = 0) + private BigInteger facilityId; + + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 64) + @Column(nullable = false, length = 64) + private String name; + + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 32) + @Column(nullable = false, length = 32) + private String path; + + @NotNull + @JoinColumn(name = "RF_WORKGROUP_ID", referencedColumnName = "WORKGROUP_ID", nullable = false) + @ManyToOne(optional = false, fetch = FetchType.EAGER) + private Workgroup rfWorkgroup; + + @NotNull + @JoinColumn(name = "BEAM_WORKGROUP_ID", referencedColumnName = "WORKGROUP_ID", nullable = false) + @ManyToOne(optional = false, fetch = FetchType.EAGER) + private Workgroup beamWorkgroup; + + @Basic(optional = false) + @NotNull + @Column(name = "WEIGHT", nullable = false) + private BigInteger weight; + + public BigInteger getFacilityId() { + return facilityId; + } + + public void setFacilityId(BigInteger facilityId) { + this.facilityId = facilityId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public Workgroup getRfWorkgroup() { + return rfWorkgroup; + } + + public void setRfWorkgroup(Workgroup rfWorkgroup) { + this.rfWorkgroup = rfWorkgroup; + } + + public Workgroup getBeamWorkgroup() { + return beamWorkgroup; + } + + public void setBeamWorkgroup(Workgroup beamWorkgroup) { + this.beamWorkgroup = beamWorkgroup; + } + + public BigInteger getWeight() { + return weight; + } + + public void setWeight(BigInteger weight) { + this.weight = weight; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 97 * hash + (this.facilityId != null ? this.facilityId.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Facility other = (Facility) obj; + return Objects.equals(this.facilityId, other.facilityId); + } +} diff --git a/src/main/java/org/jlab/jam/presentation/controller/ContextRootController.java b/src/main/java/org/jlab/jam/presentation/controller/ContextRootController.java new file mode 100644 index 0000000..af51b82 --- /dev/null +++ b/src/main/java/org/jlab/jam/presentation/controller/ContextRootController.java @@ -0,0 +1,32 @@ +package org.jlab.jam.presentation.controller; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @author ryans + */ +@WebServlet( + name = "ContextRootController", + urlPatterns = {""}) +public class ContextRootController extends HttpServlet { + + /** + * Handles the HTTP GET method. + * + * @param request servlet request + * @param response servlet response + * @throws ServletException if a servlet-specific error occurs + * @throws IOException if an I/O error occurs + */ + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + response.sendRedirect(request.getContextPath() + "/authorizations/cebaf"); + } +} diff --git a/src/main/java/org/jlab/jam/presentation/controller/BeamPermissions.java b/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java similarity index 86% rename from src/main/java/org/jlab/jam/presentation/controller/BeamPermissions.java rename to src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java index e883864..0d292f0 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/BeamPermissions.java +++ b/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java @@ -21,13 +21,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.jlab.jam.business.session.AuthorizationFacade; -import org.jlab.jam.business.session.BeamDestinationFacade; -import org.jlab.jam.business.session.ControlVerificationFacade; -import org.jlab.jam.persistence.entity.Authorization; -import org.jlab.jam.persistence.entity.BeamDestination; -import org.jlab.jam.persistence.entity.DestinationAuthorization; -import org.jlab.jam.persistence.entity.DestinationAuthorizationPK; +import org.jlab.jam.business.session.*; +import org.jlab.jam.persistence.entity.*; import org.jlab.smoothness.business.exception.UserFriendlyException; import org.jlab.smoothness.business.util.TimeUtil; import org.jlab.smoothness.presentation.util.ParamConverter; @@ -36,14 +31,15 @@ * @author ryans */ @WebServlet( - name = "BeamPermissions", - urlPatterns = {"/permissions"}) -public class BeamPermissions extends HttpServlet { + name = "FacilityAuthorization", + urlPatterns = {"/authorizations/*"}) +public class FacilityAuthorization extends HttpServlet { - private static final Logger LOGGER = Logger.getLogger(BeamPermissions.class.getName()); + private static final Logger LOGGER = Logger.getLogger(FacilityAuthorization.class.getName()); @EJB AuthorizationFacade authorizationFacade; @EJB BeamDestinationFacade beamDestinationFacade; @EJB ControlVerificationFacade verificationFacade; + @EJB FacilityFacade facilityFacade; /** * Handles the HTTP GET method. @@ -57,25 +53,38 @@ public class BeamPermissions extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + String pathInfo = request.getPathInfo(); + + System.err.println("PathInfo: " + pathInfo); + + Facility facility = facilityFacade.findByPath(pathInfo); + + if (facility == null) { + throw new ServletException("Facility not found"); + } + + List facilityList = + facilityFacade.findAll(new AbstractFacade.OrderDirective("weight")); + verificationFacade.performExpirationCheck(false); Authorization authorization = authorizationFacade.findCurrent(); - List cebafDestinationList = beamDestinationFacade.findCebafDestinations(); - List lerfDestinationList = beamDestinationFacade.findLerfDestinations(); - List uitfDestinationList = beamDestinationFacade.findUitfDestinations(); + List beamList = beamDestinationFacade.findByFacility(facility); Map destinationAuthorizationMap = authorizationFacade.createDestinationAuthorizationMap(authorization); + request.setAttribute("facility", facility); + request.setAttribute("facilityList", facilityList); request.setAttribute("unitsMap", authorizationFacade.getUnitsMap()); request.setAttribute("authorization", authorization); - request.setAttribute("cebafDestinationList", cebafDestinationList); - request.setAttribute("lerfDestinationList", lerfDestinationList); - request.setAttribute("uitfDestinationList", uitfDestinationList); + request.setAttribute("beamList", beamList); request.setAttribute("destinationAuthorizationMap", destinationAuthorizationMap); - request.getRequestDispatcher("WEB-INF/views/permissions.jsp").forward(request, response); + request + .getRequestDispatcher("/WEB-INF/views/facility-authorization.jsp") + .forward(request, response); } /** diff --git a/src/main/java/org/jlab/jam/presentation/util/BeamAuthFunctions.java b/src/main/java/org/jlab/jam/presentation/util/BeamAuthFunctions.java index da255ea..5a94768 100644 --- a/src/main/java/org/jlab/jam/presentation/util/BeamAuthFunctions.java +++ b/src/main/java/org/jlab/jam/presentation/util/BeamAuthFunctions.java @@ -32,13 +32,13 @@ public static List beamModeList(String facility, String destination) { modes = RF_LIST; } else { switch (facility) { - case "cebaf": + case "CEBAF": modes = CEBAF_LIST; break; - case "lerf": + case "LERF": modes = LERF_LIST; break; - case "uitf": + case "UITF": modes = UITF_LIST; break; } diff --git a/src/main/webapp/WEB-INF/tags/authorization-page.tag b/src/main/webapp/WEB-INF/tags/authorization-page.tag new file mode 100644 index 0000000..e79dca5 --- /dev/null +++ b/src/main/webapp/WEB-INF/tags/authorization-page.tag @@ -0,0 +1,37 @@ +<%@tag description="The Authorization Page Template Tag" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> +<%@taglib prefix="t" tagdir="/WEB-INF/tags" %> +<%@attribute name="title" %> +<%@attribute name="stylesheets" fragment="true" %> +<%@attribute name="scripts" fragment="true" %> + + + + + + + + + +
+
+
+

Auth

+ +
+
+
+ +
+
+
+
diff --git a/src/main/webapp/WEB-INF/tags/destination-permissions-table.tag b/src/main/webapp/WEB-INF/tags/destination-permissions-table.tag index a937246..b0c1724 100644 --- a/src/main/webapp/WEB-INF/tags/destination-permissions-table.tag +++ b/src/main/webapp/WEB-INF/tags/destination-permissions-table.tag @@ -5,9 +5,8 @@ <%@taglib prefix="s" uri="http://jlab.org/jsp/smoothness" %> <%@taglib prefix="beamauth" uri="http://jlab.org/beamauth/functions"%> <%@taglib prefix="t" tagdir="/WEB-INF/tags"%> -<%@attribute name="destinationList" required="true" type="java.util.List"%> +<%@attribute name="beamList" required="true" type="java.util.List"%> <%@attribute name="isHistory" required="true" type="java.lang.Boolean"%> -<%@attribute name="facility" required="true" type="java.lang.String"%> @@ -28,7 +27,7 @@ - + @@ -50,7 +49,7 @@
diff --git a/src/main/webapp/WEB-INF/tags/page.tag b/src/main/webapp/WEB-INF/tags/page.tag index fdddea0..76d0b95 100644 --- a/src/main/webapp/WEB-INF/tags/page.tag +++ b/src/main/webapp/WEB-INF/tags/page.tag @@ -18,7 +18,7 @@
    - Permissions + Authorizations Credited Controls Beam Destinations Control Participation diff --git a/src/main/webapp/WEB-INF/tags/permissions-page.tag b/src/main/webapp/WEB-INF/tags/permissions-page.tag index 15a0caa..ada3cde 100644 --- a/src/main/webapp/WEB-INF/tags/permissions-page.tag +++ b/src/main/webapp/WEB-INF/tags/permissions-page.tag @@ -1,28 +1,30 @@ -<%@tag description="Destination Table Tag" pageEncoding="UTF-8"%> +<%@tag description="Permissions Table Tag" pageEncoding="UTF-8"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@taglib prefix="s" uri="http://jlab.org/jsp/smoothness" %> <%@taglib prefix="beamauth" uri="http://jlab.org/beamauth/functions"%> <%@taglib prefix="t" tagdir="/WEB-INF/tags"%> -<%@attribute name="cebafDestinationList" required="true" type="java.util.List"%> -<%@attribute name="lerfDestinationList" required="true" type="java.util.List"%> +<%@attribute name="rfList" required="true" type="java.util.List"%> +<%@attribute name="beamList" required="true" type="java.util.List"%> <%@attribute name="isEditable" required="true" type="java.lang.Boolean"%> <%@attribute name="isHistory" required="true" type="java.lang.Boolean"%>
    -

    Permissions +

    +

    RF Operations

    +
+ + + +
Note: Blank/Empty Current Limit results in "Dump Power Limited"
-

CEBAF

- -

LERF

- -

UITF

- +

Beam Operations

+

Notes

diff --git a/src/main/webapp/WEB-INF/views/permissions.jsp b/src/main/webapp/WEB-INF/views/facility-authorization.jsp similarity index 83% rename from src/main/webapp/WEB-INF/views/permissions.jsp rename to src/main/webapp/WEB-INF/views/facility-authorization.jsp index b1d6e9f..ddb8bcf 100644 --- a/src/main/webapp/WEB-INF/views/permissions.jsp +++ b/src/main/webapp/WEB-INF/views/facility-authorization.jsp @@ -4,7 +4,7 @@ <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@taglib prefix="beamauth" uri="http://jlab.org/beamauth/functions"%> <%@taglib prefix="t" tagdir="/WEB-INF/tags"%> - + @@ -13,7 +13,7 @@
- +
A new log entry was created: @@ -22,4 +22,4 @@
- + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 0a94077..0f4154b 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -3,9 +3,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"> - - permissions - appName JLab Authorization Manager From 94257c731e5e435be25c52cce4debdbfb4cf76f5 Mon Sep 17 00:00:00 2001 From: Ryan Slominski Date: Mon, 27 Jan 2025 16:03:50 -0500 Subject: [PATCH 02/44] Separate Facilities --- README.md | 4 +- container/oracle/initdb.d/02_ddl.sql | 264 +++++++++----- container/oracle/initdb.d/03_default_data.sql | 78 ++-- ...cade.java => BeamAuthorizationFacade.java} | 82 +++-- ...ava => BeamControlVerificationFacade.java} | 264 +++++++------- ...> BeamDestinationAuthorizationFacade.java} | 9 +- .../session/BeamDestinationFacade.java | 10 +- .../jam/business/session/ComponentFacade.java | 13 +- .../session/CreditedControlFacade.java | 6 +- .../business/session/DailyScheduledCheck.java | 2 +- .../session/RFAuthorizationFacade.java | 345 ++++++++++++++++++ .../jam/business/session/RFSegmentFacade.java | 58 +++ .../session/VerificationHistoryFacade.java | 16 +- .../persistence/entity/BeamAuthorization.java | 168 +++++++++ ...tion.java => BeamControlVerification.java} | 75 ++-- ...va => BeamControlVerificationHistory.java} | 79 ++-- .../persistence/entity/BeamDestination.java | 6 +- ...java => BeamDestinationAuthorization.java} | 42 +-- .../persistence/entity/CreditedControl.java | 15 +- .../entity/DestinationAuthorizationPK.java | 29 +- ...uthorization.java => RFAuthorization.java} | 57 +-- .../entity/RFControlVerification.java | 212 +++++++++++ .../entity/RFControlVerificationHistory.java | 166 +++++++++ .../jam/persistence/entity/RFSegment.java | 125 +++++++ .../entity/RFSegmentAuthorization.java | 158 ++++++++ .../entity/SegmentAuthorizationPK.java | 80 ++++ .../view/BeamDestinationVerification.java | 8 +- .../AuthorizationHistoryController.java | 8 +- .../BeamDestinationInformation.java | 8 +- .../controller/CreditedControls.java | 10 +- ...nationsAuthorizationHistoryController.java | 20 +- .../controller/FacilityAuthorization.java | 35 +- .../VerificationHistoryController.java | 12 +- .../presentation/controller/ajax/EditCc.java | 8 +- .../ajax/ToggleControlParticipation.java | 4 +- .../tags/destination-permissions-table.tag | 20 +- .../webapp/WEB-INF/tags/permissions-page.tag | 88 ++--- .../WEB-INF/tags/rf-operations-table.tag | 85 +++++ .../views/beam-destination-information.jsp | 8 +- .../WEB-INF/views/credited-controls.jsp | 12 +- .../verification-history.jsp | 4 +- .../webapp/WEB-INF/views/destinations.jsp | 12 +- .../permissions/authorization-history.jsp | 6 +- .../destinations-authorization-history.jsp | 6 +- src/main/webapp/resources/css/permissions.css | 7 + src/main/webapp/resources/js/permissions.js | 8 +- 46 files changed, 2126 insertions(+), 606 deletions(-) rename src/main/java/org/jlab/jam/business/session/{AuthorizationFacade.java => BeamAuthorizationFacade.java} (77%) rename src/main/java/org/jlab/jam/business/session/{ControlVerificationFacade.java => BeamControlVerificationFacade.java} (71%) rename src/main/java/org/jlab/jam/business/session/{DestinationAuthorizationFacade.java => BeamDestinationAuthorizationFacade.java} (56%) create mode 100644 src/main/java/org/jlab/jam/business/session/RFAuthorizationFacade.java create mode 100644 src/main/java/org/jlab/jam/business/session/RFSegmentFacade.java create mode 100644 src/main/java/org/jlab/jam/persistence/entity/BeamAuthorization.java rename src/main/java/org/jlab/jam/persistence/entity/{ControlVerification.java => BeamControlVerification.java} (60%) rename src/main/java/org/jlab/jam/persistence/entity/{VerificationHistory.java => BeamControlVerificationHistory.java} (55%) rename src/main/java/org/jlab/jam/persistence/entity/{DestinationAuthorization.java => BeamDestinationAuthorization.java} (75%) rename src/main/java/org/jlab/jam/persistence/entity/{Authorization.java => RFAuthorization.java} (65%) create mode 100644 src/main/java/org/jlab/jam/persistence/entity/RFControlVerification.java create mode 100644 src/main/java/org/jlab/jam/persistence/entity/RFControlVerificationHistory.java create mode 100644 src/main/java/org/jlab/jam/persistence/entity/RFSegment.java create mode 100644 src/main/java/org/jlab/jam/persistence/entity/RFSegmentAuthorization.java create mode 100644 src/main/java/org/jlab/jam/persistence/entity/SegmentAuthorizationPK.java create mode 100644 src/main/webapp/WEB-INF/tags/rf-operations-table.tag diff --git a/README.md b/README.md index 404f697..1bb85d2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # jam [![CI](https://github.com/JeffersonLab/jam/actions/workflows/ci.yaml/badge.svg)](https://github.com/JeffersonLab/jam/actions/workflows/ci.yaml) [![Docker](https://img.shields.io/docker/v/jeffersonlab/jam?sort=semver&label=DockerHub)](https://hub.docker.com/r/jeffersonlab/jam) -A [Java EE 8](https://en.wikipedia.org/wiki/Jakarta_EE) web application for both beam and RF operations authorization at Jefferson Lab built with the [Smoothness](https://github.com/JeffersonLab/smoothness) web template. +A [Java EE 8](https://en.wikipedia.org/wiki/Jakarta_EE) web application for both beam and RF operations beamAuthorization at Jefferson Lab built with the [Smoothness](https://github.com/JeffersonLab/smoothness) web template. ![Screenshot](https://github.com/JeffersonLab/jam/raw/main/Screenshot.png?raw=true "Screenshot") @@ -16,7 +16,7 @@ A [Java EE 8](https://en.wikipedia.org/wiki/Jakarta_EE) web application for both --- ## Overview -The Authorization application allows the Director of Operations (or a delegate) to clearly communicate and document authorization for various facilities at JLab to either generate beam or engage in RF operations. For beam generation the maximum current and beam mode ("permissions") that are authorized are provided for a given beam destination. This information is stored in a database and presented via the web for easy access. There are three beam generating facilities, each with their own set of beam destinations and beam modes: CEBAF, LERF, UITF. There are seven facilities which generate RF: CEBAF Injector, CEBAF North Linac, CEBAF South Linac, LERF, CMTF, and VTA. In addition to director authorization, the app also tracks Credited Controls and their verification. Each beam destination is assigned a set of controls and each control is assigned to a particular responsible group. A beam desintation is ready for beam only if all the controls assigned are verified by their responsible group. Both group verifications and director permissions have expirations. Emails and Jefferson Lab logbook entires are created to aid communication of new director permissions, responsible group verifications (upgrades and downgrades), and verification and permissions expirations. +The Authorization application allows the Director of Operations (or a delegate) to clearly communicate and document beamAuthorization for various facilities at JLab to either generate beam or engage in RF operations. For beam generation the maximum current and beam mode ("permissions") that are authorized are provided for a given beam destination. This information is stored in a database and presented via the web for easy access. There are three beam generating facilities, each with their own set of beam destinations and beam modes: CEBAF, LERF, UITF. There are seven facilities which generate RF: CEBAF Injector, CEBAF North Linac, CEBAF South Linac, LERF, CMTF, and VTA. In addition to director beamAuthorization, the app also tracks Credited Controls and their verification. Each beam destination is assigned a set of controls and each control is assigned to a particular responsible group. A beam desintation is ready for beam only if all the controls assigned are verified by their responsible group. Both group verifications and director permissions have expirations. Emails and Jefferson Lab logbook entires are created to aid communication of new director permissions, responsible group verifications (upgrades and downgrades), and verification and permissions expirations. ### Roles - **Operations Director** - Responsible for authorizing beam diff --git a/container/oracle/initdb.d/02_ddl.sql b/container/oracle/initdb.d/02_ddl.sql index 5ab6c89..f220ce5 100644 --- a/container/oracle/initdb.d/02_ddl.sql +++ b/container/oracle/initdb.d/02_ddl.sql @@ -1,7 +1,9 @@ alter session set container = XEPDB1; ---DROP SEQUENCE JAM_OWNER.AUTHORIZATION_ID; ---DROP SEQUENCE JAM_OWNER.DESTINATION_ID; +--DROP SEQUENCE JAM_OWNER.RF_AUTHORIZATION_ID; +--DROP SEQUENCE JAM_OWNER.BEAM_AUTHORIZATION_ID; +--DROP SEQUENCE JAM_OWNER.RF_SEGMENT_ID; +--DROP SEQUENCE JAM_OWNER.BEAM_DESTINATION_ID; --DROP SEQUENCE JAM_OWNER.CONTROL_VERIFICATION_ID; --DROP SEQUENCE JAM_OWNER.CREDITED_CONTROL_ID; --DROP SEQUENCE JAM_OWNER.VERIFICATION_HISTORY_ID; @@ -16,17 +18,32 @@ alter session set container = XEPDB1; --DROP TABLE JAM_OWNER.BEAM_DESTINATION CASCADE CONSTRAINTS PURGE; --DROP TABLE JAM_OWNER.WORKGROUP CASCADE CONSTRAINTS PURGE; -CREATE SEQUENCE JAM_OWNER.AUTHORIZATION_ID +CREATE SEQUENCE JAM_OWNER.RF_AUTHORIZATION_ID START WITH 1 NOCYCLE NOCACHE ORDER; -CREATE SEQUENCE JAM_OWNER.DESTINATION_ID +CREATE SEQUENCE JAM_OWNER.BEAM_AUTHORIZATION_ID START WITH 1 NOCYCLE NOCACHE ORDER; -CREATE SEQUENCE JAM_OWNER.CONTROL_VERIFICATION_ID +CREATE SEQUENCE JAM_OWNER.RF_SEGMENT_ID + START WITH 1 + NOCYCLE + NOCACHE + ORDER; +CREATE SEQUENCE JAM_OWNER.BEAM_DESTINATION_ID + START WITH 1 + NOCYCLE + NOCACHE + ORDER; +CREATE SEQUENCE JAM_OWNER.RF_CONTROL_VERIFICATION_ID + START WITH 1 + NOCYCLE + NOCACHE + ORDER; +CREATE SEQUENCE JAM_OWNER.BEAM_CONTROL_VERIFICATION_ID START WITH 1 NOCYCLE NOCACHE @@ -36,7 +53,12 @@ CREATE SEQUENCE JAM_OWNER.CREDITED_CONTROL_ID NOCYCLE NOCACHE ORDER; -CREATE SEQUENCE JAM_OWNER.VERIFICATION_HISTORY_ID +CREATE SEQUENCE JAM_OWNER.RF_CONTROL_VERIFICATION_HISTORY_ID + START WITH 1 + NOCYCLE + NOCACHE + ORDER; +CREATE SEQUENCE JAM_OWNER.BEAM_CONTROL_VERIFICATION_HISTORY_ID START WITH 1 NOCYCLE NOCACHE @@ -69,22 +91,20 @@ CREATE TABLE JAM_OWNER.FACILITY CONSTRAINT FACILITY_FK2 FOREIGN KEY (BEAM_WORKGROUP_ID) REFERENCES JAM_OWNER.WORKGROUP (WORKGROUP_ID) ); -CREATE TABLE JAM_OWNER.RF_OPERATION +CREATE TABLE JAM_OWNER.RF_SEGMENT ( - RF_OPERATION_ID INTEGER NOT NULL, - NAME VARCHAR2(64 CHAR) NOT NULL, - FACILITY_ID INTEGER NOT NULL, - ACTIVE_YN CHAR(1 BYTE) DEFAULT 'Y' NOT NULL, - WEIGHT INTEGER NOT NULL, - CONSTRAINT RF_OPERATION_PK PRIMARY KEY (RF_OPERATION_ID), - CONSTRAINT RF_OPERATION_CK1 CHECK (ACTIVE_YN IN ('Y', 'N')) + RF_SEGMENT_ID INTEGER NOT NULL, + NAME VARCHAR2(64 CHAR) NOT NULL, + FACILITY_ID INTEGER NOT NULL, + ACTIVE_YN CHAR(1 BYTE) DEFAULT 'Y' NOT NULL, + WEIGHT INTEGER NOT NULL, + CONSTRAINT RF_SEGMENT_PK PRIMARY KEY (RF_SEGMENT_ID), + CONSTRAINT RF_SEGMENT_CK1 CHECK (ACTIVE_YN IN ('Y', 'N')) ); --- Should be renamed BEAM_OPERATION CREATE TABLE JAM_OWNER.BEAM_DESTINATION ( BEAM_DESTINATION_ID INTEGER NOT NULL, - --OPERATION_TYPE VARCHAR2(4 CHAR) DEFAULT 'BEAM' NOT NULL, NAME VARCHAR2(64 CHAR) NOT NULL, FACILITY_ID INTEGER NOT NULL, CURRENT_LIMIT_UNITS VARCHAR2(3 CHAR) DEFAULT 'uA' NOT NULL, @@ -93,34 +113,55 @@ CREATE TABLE JAM_OWNER.BEAM_DESTINATION CONSTRAINT BEAM_DESTINATION_PK PRIMARY KEY (BEAM_DESTINATION_ID), CONSTRAINT BEAM_DESTINATION_FK1 FOREIGN KEY (FACILITY_ID) REFERENCES JAM_OWNER.FACILITY (FACILITY_ID), CONSTRAINT BEAM_DESTINATION_CK1 CHECK (ACTIVE_YN IN ('Y', 'N')) - --CONSTRAINT BEAM_DESTINATION_CK2 CHECK (OPERATION_TYPE IN ('BEAM', 'RF')) ); --- Rename BEAM_AUTHORIZATION -CREATE TABLE JAM_OWNER.AUTHORIZATION +CREATE TABLE JAM_OWNER.RF_AUTHORIZATION +( + RF_AUTHORIZATION_ID INTEGER NOT NULL, + MODIFIED_DATE DATE NOT NULL, + MODIFIED_BY VARCHAR2(64 CHAR) NOT NULL, + AUTHORIZATION_DATE DATE NOT NULL, + AUTHORIZED_BY VARCHAR(64 CHAR) NOT NULL, + COMMENTS VARCHAR2(2048 CHAR) NULL, + CONSTRAINT RF_AUTHORIZATION_PK PRIMARY KEY (RF_AUTHORIZATION_ID) +); + +CREATE TABLE JAM_OWNER.BEAM_AUTHORIZATION +( + BEAM_AUTHORIZATION_ID INTEGER NOT NULL, + MODIFIED_DATE DATE NOT NULL, + MODIFIED_BY VARCHAR2(64 CHAR) NOT NULL, + AUTHORIZATION_DATE DATE NOT NULL, + AUTHORIZED_BY VARCHAR(64 CHAR) NOT NULL, + COMMENTS VARCHAR2(2048 CHAR) NULL, + CONSTRAINT BEAM_AUTHORIZATION_PK PRIMARY KEY (BEAM_AUTHORIZATION_ID) +); + +CREATE TABLE JAM_OWNER.BEAM_DESTINATION_AUTHORIZATION ( - AUTHORIZATION_ID INTEGER NOT NULL , - --OPERATION_TYPE VARCHAR2(4 CHAR) DEFAULT 'BEAM' NOT NULL, - MODIFIED_DATE DATE NOT NULL , - MODIFIED_BY VARCHAR2(64 CHAR) NOT NULL , - AUTHORIZATION_DATE DATE NOT NULL , - AUTHORIZED_BY VARCHAR(64 CHAR) NOT NULL , - COMMENTS VARCHAR2(2048 CHAR) NULL , - CONSTRAINT AUTHORIZATION_PK PRIMARY KEY (AUTHORIZATION_ID) + BEAM_DESTINATION_ID INTEGER NOT NULL, + BEAM_AUTHORIZATION_ID INTEGER NOT NULL, + BEAM_MODE VARCHAR2(16) NOT NULL, + CW_LIMIT NUMBER(24,12) NULL, + COMMENTS VARCHAR2(256) NULL, + EXPIRATION_DATE DATE NULL, + CONSTRAINT BEAM_DESTINATION_AUTHORIZATION_PK PRIMARY KEY (BEAM_DESTINATION_ID,BEAM_AUTHORIZATION_ID), + CONSTRAINT BEAM_DESTINATION_AUTHORIZATION_FK1 FOREIGN KEY (BEAM_DESTINATION_ID) REFERENCES JAM_OWNER.BEAM_DESTINATION (BEAM_DESTINATION_ID), + CONSTRAINT BEAM_DESTINATION_AUTHORIZATION_FK2 FOREIGN KEY (BEAM_AUTHORIZATION_ID) REFERENCES JAM_OWNER.BEAM_AUTHORIZATION (BEAM_AUTHORIZATION_ID), + CONSTRAINT BEAM_DESTINATION_AUTHORIZATION_CK1 CHECK (BEAM_MODE IN ('None', 'Tune', 'CW', 'Ceramic Viewer', 'Viewer Limited', 'High Duty Cycle', 'BLM Checkout', 'RF Only')) ); --- Rename BEAM_OPERATION_AUTHORIZATION -CREATE TABLE JAM_OWNER.DESTINATION_AUTHORIZATION +CREATE TABLE JAM_OWNER.RF_SEGMENT_AUTHORIZATION ( - BEAM_DESTINATION_ID INTEGER NOT NULL , - AUTHORIZATION_ID INTEGER NOT NULL , - BEAM_MODE VARCHAR2(16) NOT NULL CONSTRAINT DESTINATION_AUTHORIZATION_CK1 CHECK (BEAM_MODE IN ('None', 'Tune', 'CW', 'Ceramic Viewer', 'Viewer Limited', 'High Duty Cycle', 'BLM Checkout', 'RF Only')), - CW_LIMIT NUMBER(24,12) NULL , - COMMENTS VARCHAR2(256) NULL , - EXPIRATION_DATE DATE NULL , - CONSTRAINT DESTINATION_AUTHORIZATION_PK PRIMARY KEY (BEAM_DESTINATION_ID,AUTHORIZATION_ID), - CONSTRAINT DESTINATION_AUTHORIZATION_FK1 FOREIGN KEY (BEAM_DESTINATION_ID) REFERENCES JAM_OWNER.BEAM_DESTINATION (BEAM_DESTINATION_ID), - CONSTRAINT DESTINATION_AUTHORIZATION_FK2 FOREIGN KEY (AUTHORIZATION_ID) REFERENCES JAM_OWNER.AUTHORIZATION (AUTHORIZATION_ID) + RF_SEGMENT_ID INTEGER NOT NULL, + RF_AUTHORIZATION_ID INTEGER NOT NULL, + RF_MODE VARCHAR2(16) NOT NULL, + COMMENTS VARCHAR2(256) NULL, + EXPIRATION_DATE DATE NULL, + CONSTRAINT RF_SEGMENT_AUTHORIZATION_PK PRIMARY KEY (RF_SEGMENT_ID,RF_AUTHORIZATION_ID), + CONSTRAINT RF_SEGMENT_AUTHORIZATION_FK1 FOREIGN KEY (RF_SEGMENT_ID) REFERENCES JAM_OWNER.RF_SEGMENT (RF_SEGMENT_ID), + CONSTRAINT RF_SEGMENT_AUTHORIZATION_FK2 FOREIGN KEY (RF_AUTHORIZATION_ID) REFERENCES JAM_OWNER.RF_AUTHORIZATION (RF_AUTHORIZATION_ID), + CONSTRAINT RF_SEGMENT_AUTHORIZATION_CK1 CHECK (RF_MODE IN ('None', 'RF ON')) ); CREATE TABLE JAM_OWNER.CREDITED_CONTROL @@ -136,55 +177,87 @@ CREATE TABLE JAM_OWNER.CREDITED_CONTROL CONSTRAINT CREDITED_CONTROL_FK1 FOREIGN KEY (WORKGROUP_ID) REFERENCES JAM_OWNER.WORKGROUP(WORKGROUP_ID) ); --- Should be renamed VERIFICATION_STATUS -CREATE TABLE JAM_OWNER.VERIFICATION -( - VERIFICATION_ID INTEGER NOT NULL , - NAME VARCHAR2(128 CHAR) NOT NULL , - CONSTRAINT VERIFICATION_PK PRIMARY KEY (VERIFICATION_ID) -); - --- RENAME BEAM_CONTROL_VERIFICATION -CREATE TABLE JAM_OWNER.CONTROL_VERIFICATION -( - CONTROL_VERIFICATION_ID INTEGER NOT NULL , -- RENAME BEAM_CONTROL_VERIFICATION_ID - CREDITED_CONTROL_ID INTEGER NULL , - BEAM_DESTINATION_ID INTEGER NOT NULL , -- rename BEAM_OPERATION_ID - VERIFICATION_ID INTEGER NOT NULL, - VERIFICATION_DATE DATE NULL , - VERIFIED_BY VARCHAR(64 CHAR) NULL , - EXPIRATION_DATE DATE NULL , - COMMENTS VARCHAR2(2048 CHAR) NULL , - MODIFIED_BY VARCHAR2(64 CHAR) NOT NULL , - MODIFIED_DATE DATE NOT NULL , - CONSTRAINT CONTROL_VERIFICATION_PK PRIMARY KEY (CONTROL_VERIFICATION_ID), - CONSTRAINT CONTROL_VERIFICATION_AK1 UNIQUE (CREDITED_CONTROL_ID,BEAM_DESTINATION_ID), - CONSTRAINT CONTROL_VERIFICATION_FK1 FOREIGN KEY (CREDITED_CONTROL_ID) REFERENCES JAM_OWNER.CREDITED_CONTROL (CREDITED_CONTROL_ID) ON DELETE CASCADE, - CONSTRAINT CONTROL_VERIFICATION_FK2 FOREIGN KEY (BEAM_DESTINATION_ID) REFERENCES JAM_OWNER.BEAM_DESTINATION (BEAM_DESTINATION_ID) ON DELETE CASCADE, - CONSTRAINT CONTROL_VERIFICATION_FK3 FOREIGN KEY (VERIFICATION_ID) REFERENCES JAM_OWNER.VERIFICATION (VERIFICATION_ID) ON DELETE SET NULL -); - --- RENAME BEAM_VERIFICATION_HISTORY -CREATE TABLE JAM_OWNER.VERIFICATION_HISTORY -( - VERIFICATION_HISTORY_ID INTEGER NOT NULL , - CONTROL_VERIFICATION_ID INTEGER NOT NULL , - VERIFICATION_ID INTEGER NOT NULL , - VERIFIED_BY VARCHAR2(64 CHAR) NULL , - VERIFICATION_DATE DATE NOT NULL , - EXPIRATION_DATE DATE NULL , - COMMENTS VARCHAR2(2048 CHAR) NULL , - MODIFIED_BY VARCHAR2(64 CHAR) NOT NULL , - MODIFIED_DATE DATE NOT NULL , - CONSTRAINT VERIFICATION_HISTORY_PK PRIMARY KEY (VERIFICATION_HISTORY_ID), - CONSTRAINT VERIFICATION_HISTORY_FK1 FOREIGN KEY (CONTROL_VERIFICATION_ID) REFERENCES JAM_OWNER.CONTROL_VERIFICATION (CONTROL_VERIFICATION_ID) ON DELETE CASCADE, - CONSTRAINT VERIFICATION_HISTORY_FK3 FOREIGN KEY (VERIFICATION_ID) REFERENCES JAM_OWNER.VERIFICATION (VERIFICATION_ID) ON DELETE SET NULL -); - -CREATE OR REPLACE FORCE VIEW JAM_OWNER.BEAM_DESTINATION_VERIFICATION (BEAM_DESTINATION_ID, VERIFICATION_ID, EXPIRATION_DATE) AS +CREATE TABLE JAM_OWNER.VERIFICATION_STATUS +( + VERIFICATION_STATUS_ID INTEGER NOT NULL , + NAME VARCHAR2(128 CHAR) NOT NULL , + CONSTRAINT VERIFICATION_STATUS_PK PRIMARY KEY (VERIFICATION_STATUS_ID) +); + +CREATE TABLE JAM_OWNER.RF_CONTROL_VERIFICATION +( + RF_CONTROL_VERIFICATION_ID INTEGER NOT NULL, + CREDITED_CONTROL_ID INTEGER NULL, + RF_SEGMENT_ID INTEGER NOT NULL, + VERIFICATION_STATUS_ID INTEGER NOT NULL, + VERIFICATION_DATE DATE NULL, + VERIFIED_BY VARCHAR(64 CHAR) NULL, + EXPIRATION_DATE DATE NULL, + COMMENTS VARCHAR2(2048 CHAR) NULL, + MODIFIED_BY VARCHAR2(64 CHAR) NOT NULL, + MODIFIED_DATE DATE NOT NULL, + CONSTRAINT RF_CONTROL_VERIFICATION_PK PRIMARY KEY (RF_CONTROL_VERIFICATION_ID), + CONSTRAINT RF_CONTROL_VERIFICATION_AK1 UNIQUE (CREDITED_CONTROL_ID,RF_SEGMENT_ID), + CONSTRAINT RF_CONTROL_VERIFICATION_FK1 FOREIGN KEY (CREDITED_CONTROL_ID) REFERENCES JAM_OWNER.CREDITED_CONTROL (CREDITED_CONTROL_ID) ON DELETE CASCADE, + CONSTRAINT RF_CONTROL_VERIFICATION_FK2 FOREIGN KEY (RF_SEGMENT_ID) REFERENCES JAM_OWNER.RF_SEGMENT (RF_SEGMENT_ID) ON DELETE CASCADE, + CONSTRAINT RF_CONTROL_VERIFICATION_FK3 FOREIGN KEY (VERIFICATION_STATUS_ID) REFERENCES JAM_OWNER.VERIFICATION_STATUS (VERIFICATION_STATUS_ID) ON DELETE SET NULL +); + +CREATE TABLE JAM_OWNER.BEAM_CONTROL_VERIFICATION +( + BEAM_CONTROL_VERIFICATION_ID INTEGER NOT NULL, + CREDITED_CONTROL_ID INTEGER NULL, + BEAM_DESTINATION_ID INTEGER NOT NULL, + VERIFICATION_STATUS_ID INTEGER NOT NULL, + VERIFICATION_DATE DATE NULL, + VERIFIED_BY VARCHAR(64 CHAR) NULL, + EXPIRATION_DATE DATE NULL, + COMMENTS VARCHAR2(2048 CHAR) NULL, + MODIFIED_BY VARCHAR2(64 CHAR) NOT NULL, + MODIFIED_DATE DATE NOT NULL, + CONSTRAINT BEAM_CONTROL_VERIFICATION_PK PRIMARY KEY (BEAM_CONTROL_VERIFICATION_ID), + CONSTRAINT BEAM_CONTROL_VERIFICATION_AK1 UNIQUE (CREDITED_CONTROL_ID,BEAM_DESTINATION_ID), + CONSTRAINT BEAM_CONTROL_VERIFICATION_FK1 FOREIGN KEY (CREDITED_CONTROL_ID) REFERENCES JAM_OWNER.CREDITED_CONTROL (CREDITED_CONTROL_ID) ON DELETE CASCADE, + CONSTRAINT BEAM_CONTROL_VERIFICATION_FK2 FOREIGN KEY (BEAM_DESTINATION_ID) REFERENCES JAM_OWNER.BEAM_DESTINATION (BEAM_DESTINATION_ID) ON DELETE CASCADE, + CONSTRAINT BEAM_CONTROL_VERIFICATION_FK3 FOREIGN KEY (VERIFICATION_STATUS_ID) REFERENCES JAM_OWNER.VERIFICATION_STATUS (VERIFICATION_STATUS_ID) ON DELETE SET NULL +); + +CREATE TABLE JAM_OWNER.RF_CONTROL_VERIFICATION_HISTORY +( + RF_CONTROL_VERIFICATION_HISTORY_ID INTEGER NOT NULL, + RF_CONTROL_VERIFICATION_ID INTEGER NOT NULL, + VERIFICATION_STATUS_ID INTEGER NOT NULL, + VERIFIED_BY VARCHAR2(64 CHAR) NULL, + VERIFICATION_DATE DATE NOT NULL, + EXPIRATION_DATE DATE NULL, + COMMENTS VARCHAR2(2048 CHAR) NULL, + MODIFIED_BY VARCHAR2(64 CHAR) NOT NULL, + MODIFIED_DATE DATE NOT NULL, + CONSTRAINT RF_CONTROL_VERIFICATION_HISTORY_PK PRIMARY KEY (RF_CONTROL_VERIFICATION_HISTORY_ID), + CONSTRAINT RF_CONTROL_VERIFICATION_HISTORY_FK1 FOREIGN KEY (RF_CONTROL_VERIFICATION_ID) REFERENCES JAM_OWNER.RF_CONTROL_VERIFICATION (RF_CONTROL_VERIFICATION_ID) ON DELETE CASCADE, + CONSTRAINT RF_CONTROL_VERIFICATION_HISTORY_FK3 FOREIGN KEY (VERIFICATION_STATUS_ID) REFERENCES JAM_OWNER.VERIFICATION_STATUS (VERIFICATION_STATUS_ID) ON DELETE SET NULL +); + +CREATE TABLE JAM_OWNER.BEAM_CONTROL_VERIFICATION_HISTORY +( + BEAM_CONTROL_VERIFICATION_HISTORY_ID INTEGER NOT NULL, + BEAM_CONTROL_VERIFICATION_ID INTEGER NOT NULL, + VERIFICATION_STATUS_ID INTEGER NOT NULL, + VERIFIED_BY VARCHAR2(64 CHAR) NULL, + VERIFICATION_DATE DATE NOT NULL, + EXPIRATION_DATE DATE NULL, + COMMENTS VARCHAR2(2048 CHAR) NULL, + MODIFIED_BY VARCHAR2(64 CHAR) NOT NULL, + MODIFIED_DATE DATE NOT NULL, + CONSTRAINT BEAM_CONTROL_VERIFICATION_HISTORY_PK PRIMARY KEY (BEAM_CONTROL_VERIFICATION_HISTORY_ID), + CONSTRAINT BEAM_CONTROL_VERIFICATION_HISTORY_FK1 FOREIGN KEY (BEAM_CONTROL_VERIFICATION_ID) REFERENCES JAM_OWNER.BEAM_CONTROL_VERIFICATION (BEAM_CONTROL_VERIFICATION_ID) ON DELETE CASCADE, + CONSTRAINT BEAM_CONTROL_VERIFICATION_HISTORY_FK3 FOREIGN KEY (VERIFICATION_STATUS_ID) REFERENCES JAM_OWNER.VERIFICATION_STATUS (VERIFICATION_STATUS_ID) ON DELETE SET NULL +); + +CREATE OR REPLACE FORCE VIEW JAM_OWNER.BEAM_DESTINATION_VERIFICATION (BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, EXPIRATION_DATE) AS SELECT a.beam_destination_id, - NVL((SELECT MAX(VERIFICATION_ID) FROM JAM_OWNER.CONTROL_VERIFICATION b WHERE a.beam_destination_id = b.beam_destination_id), 1) AS VERIFICATION_ID, - (SELECT MIN(EXPIRATION_DATE) FROM JAM_OWNER.CONTROL_VERIFICATION b WHERE a.beam_destination_id = b.beam_destination_id) as EXPIRATION_DATE + NVL((SELECT MAX(VERIFICATION_STATUS_ID) FROM JAM_OWNER.BEAM_CONTROL_VERIFICATION b WHERE a.beam_destination_id = b.beam_destination_id), 1) AS VERIFICATION_STATUS_ID, + (SELECT MIN(EXPIRATION_DATE) FROM JAM_OWNER.BEAM_CONTROL_VERIFICATION b WHERE a.beam_destination_id = b.beam_destination_id) as EXPIRATION_DATE FROM JAM_OWNER.BEAM_DESTINATION a; CREATE TABLE JAM_OWNER.COMPONENT @@ -203,11 +276,18 @@ CREATE TABLE JAM_OWNER.COMPONENT select component_id, name, status_id from srm_owner.component join srm_owner.component_status_2 using (component_id) where system_id in (select system_id from srm_owner.system_application where application_id = 1) );*/ -CREATE TABLE JAM_OWNER.VERIFICATION_COMPONENT +CREATE TABLE JAM_OWNER.BEAM_CONTROL_VERIFICATION_COMPONENT +( + BEAM_CONTROL_VERIFICATION_ID INTEGER NOT NULL , + COMPONENT_ID INTEGER NOT NULL , + CONSTRAINT BEAM_CONTROL_VERIFICATION_COMPONENT_PK PRIMARY KEY (BEAM_CONTROL_VERIFICATION_ID, COMPONENT_ID), + CONSTRAINT BEAM_CONTROL_VERIFICATION_COMPONENT_FK1 FOREIGN KEY (BEAM_CONTROL_VERIFICATION_ID) REFERENCES JAM_OWNER.BEAM_CONTROL_VERIFICATION (BEAM_CONTROL_VERIFICATION_ID) ON DELETE CASCADE +); + +CREATE TABLE JAM_OWNER.RF_CONTROL_VERIFICATION_COMPONENT ( - CONTROL_VERIFICATION_ID INTEGER NOT NULL , - COMPONENT_ID INTEGER NOT NULL , - CONSTRAINT VERIFICATION_COMPONENT_PK PRIMARY KEY (CONTROL_VERIFICATION_ID, COMPONENT_ID), - CONSTRAINT VERIFICATION_COMPONENT_FK1 FOREIGN KEY (CONTROL_VERIFICATION_ID) REFERENCES JAM_OWNER.CONTROL_VERIFICATION (CONTROL_VERIFICATION_ID) ON DELETE CASCADE - --CONSTRAINT VERIFICATION_COMPONENT_FK2 FOREIGN KEY (COMPONENT_ID) REFERENCES JAM_OWNER.COMPONENT (COMPONENT_ID) ON DELETE CASCADE + RF_CONTROL_VERIFICATION_ID INTEGER NOT NULL , + COMPONENT_ID INTEGER NOT NULL , + CONSTRAINT RF_CONTROL_VERIFICATION_COMPONENT_PK PRIMARY KEY (RF_CONTROL_VERIFICATION_ID, COMPONENT_ID), + CONSTRAINT RF_CONTROL_VERIFICATION_COMPONENT_FK1 FOREIGN KEY (RF_CONTROL_VERIFICATION_ID) REFERENCES JAM_OWNER.RF_CONTROL_VERIFICATION (RF_CONTROL_VERIFICATION_ID) ON DELETE CASCADE ); \ No newline at end of file diff --git a/container/oracle/initdb.d/03_default_data.sql b/container/oracle/initdb.d/03_default_data.sql index 67b1b3d..fbf2f52 100644 --- a/container/oracle/initdb.d/03_default_data.sql +++ b/container/oracle/initdb.d/03_default_data.sql @@ -1,9 +1,9 @@ alter session set container = XEPDB1; -- Populate Verification -insert into JAM_OWNER.VERIFICATION (VERIFICATION_ID, NAME) values (1, 'Verified'); -insert into JAM_OWNER.VERIFICATION (VERIFICATION_ID, NAME) values (50, 'Provisionally Verified'); -insert into JAM_OWNER.VERIFICATION (VERIFICATION_ID, NAME) values (100, 'Not Verified'); +insert into JAM_OWNER.VERIFICATION_STATUS (VERIFICATION_STATUS_ID, NAME) values (1, 'Verified'); +insert into JAM_OWNER.VERIFICATION_STATUS (VERIFICATION_STATUS_ID, NAME) values (50, 'Provisionally Verified'); +insert into JAM_OWNER.VERIFICATION_STATUS (VERIFICATION_STATUS_ID, NAME) values (100, 'Not Verified'); -- Populate Workgroup insert into JAM_OWNER.WORKGROUP (WORKGROUP_ID, NAME, LEADER_ROLE_NAME) values (1, 'Group 1', 'group1Leaders'); @@ -36,49 +36,49 @@ insert into JAM_OWNER.CREDITED_CONTROL (CREDITED_CONTROL_ID,NAME,DESCRIPTION,WOR insert into JAM_OWNER.CREDITED_CONTROL (CREDITED_CONTROL_ID,NAME,DESCRIPTION,WORKGROUP_ID,WEIGHT,VERIFICATION_FREQUENCY) values (JAM_OWNER.CREDITED_CONTROL_ID.nextval,'Control 6','Control 6 Description',1,6,'1 Year'); -- Populate Beam Destinations -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 1', 1, 'uA', 'Y', 1); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 2', 1, 'uA', 'Y', 2); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 3', 1, 'uA', 'Y', 3); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 4', 2, 'uA', 'Y', 4); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 5', 2, 'uA', 'Y', 5); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 6', 2, 'uA', 'Y', 6); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 7', 3, 'uA', 'Y', 7); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 8', 3, 'uA', 'Y', 8); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Destination 9', 3, 'uA', 'Y', 9); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.destination_id.nextval, 'Injector RF Operations', 1, 'uA', 'Y', 9); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 1', 1, 'uA', 'Y', 1); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 2', 1, 'uA', 'Y', 2); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 3', 1, 'uA', 'Y', 3); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 4', 2, 'uA', 'Y', 4); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 5', 2, 'uA', 'Y', 5); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 6', 2, 'uA', 'Y', 6); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 7', 3, 'uA', 'Y', 7); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 8', 3, 'uA', 'Y', 8); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 9', 3, 'uA', 'Y', 9); +insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Injector RF Operations', 1, 'uA', 'Y', 9); -- Populate Initial Control Verification -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 1, 1, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 2, 2, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 3, 3, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 4, 4, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 5, 5, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 6, 6, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 1, 6, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 2, 5, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 3, 4, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 4, 3, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 5, 2, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 6, 1, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 1, 9, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 2, 8, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 3, 7, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 4, 6, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 5, 9, 100, sysdate, 'admin', null, null, 'admin', sysdate); -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 6, 4, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 1, 1, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 2, 2, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 3, 3, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 4, 4, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 5, 5, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 6, 6, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 1, 6, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 2, 5, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 3, 4, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 4, 3, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 5, 2, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 6, 1, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 1, 9, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 2, 8, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 3, 7, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 4, 6, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 5, 9, 100, sysdate, 'admin', null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 6, 4, 100, sysdate, 'admin', null, null, 'admin', sysdate); -- Test null VERIFIED_BY (Control 6, Destination 9) -insert into JAM_OWNER.control_verification (CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.control_verification_id.nextval, 6, 9, 100, sysdate, null, null, null, 'admin', sysdate); +insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 6, 9, 100, sysdate, null, null, null, 'admin', sysdate); -- Populate Initial Verification History (Control 1, Destination 1) -insert into JAM_OWNER.verification_history (VERIFICATION_HISTORY_ID, CONTROL_VERIFICATION_ID, VERIFICATION_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.verification_history_id.nextval, 1, 100, sysdate, 'tbrown', null, null, 'tbrown', sysdate); +insert into JAM_OWNER.beam_control_verification_history (BEAM_CONTROL_VERIFICATION_HISTORY_ID, BEAM_CONTROL_VERIFICATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_history_id.nextval, 1, 100, sysdate, 'tbrown', null, null, 'tbrown', sysdate); -- Populate Initial Authorization -insert into JAM_OWNER.authorization (AUTHORIZATION_ID, MODIFIED_BY, MODIFIED_DATE, AUTHORIZATION_DATE, AUTHORIZED_BY, COMMENTS) values(JAM_OWNER.authorization_id.nextval, 'tbrown', sysdate, sysdate, 'tbrown', 'testing'); +insert into JAM_OWNER.BEAM_AUTHORIZATION (BEAM_AUTHORIZATION_ID, MODIFIED_BY, MODIFIED_DATE, AUTHORIZATION_DATE, AUTHORIZED_BY, COMMENTS) values(JAM_OWNER.beam_authorization_id.nextval, 'tbrown', sysdate, sysdate, 'tbrown', 'testing'); -- Populate Initial Destination Authorization -insert into JAM_OWNER.destination_authorization (BEAM_DESTINATION_ID, AUTHORIZATION_ID, BEAM_MODE, CW_LIMIT, COMMENTS, EXPIRATION_DATE) values(1, 1, 'None', null, 'test 1', null); -insert into JAM_OWNER.destination_authorization (BEAM_DESTINATION_ID, AUTHORIZATION_ID, BEAM_MODE, CW_LIMIT, COMMENTS, EXPIRATION_DATE) values(2, 1, 'Tune', null, 'test 2', null); -insert into JAM_OWNER.destination_authorization (BEAM_DESTINATION_ID, AUTHORIZATION_ID, BEAM_MODE, CW_LIMIT, COMMENTS, EXPIRATION_DATE) values(3, 1, 'CW', 10, 'test 3', null); +insert into JAM_OWNER.beam_destination_authorization (BEAM_DESTINATION_ID, BEAM_AUTHORIZATION_ID, BEAM_MODE, CW_LIMIT, COMMENTS, EXPIRATION_DATE) values(1, 1, 'None', null, 'test 1', null); +insert into JAM_OWNER.beam_destination_authorization (BEAM_DESTINATION_ID, BEAM_AUTHORIZATION_ID, BEAM_MODE, CW_LIMIT, COMMENTS, EXPIRATION_DATE) values(2, 1, 'Tune', null, 'test 2', null); +insert into JAM_OWNER.beam_destination_authorization (BEAM_DESTINATION_ID, BEAM_AUTHORIZATION_ID, BEAM_MODE, CW_LIMIT, COMMENTS, EXPIRATION_DATE) values(3, 1, 'CW', 10, 'test 3', null); -- Populate Component insert into JAM_OWNER.COMPONENT (COMPONENT_ID, NAME, STATUS_ID) values (2763, '0L03', 1); @@ -88,5 +88,5 @@ insert into JAM_OWNER.COMPONENT (COMPONENT_ID, NAME, STATUS_ID) values (2766, '1 insert into JAM_OWNER.COMPONENT (COMPONENT_ID, NAME, STATUS_ID) values (2767, '1L04', 1); -- Populate Component Verification -insert into JAM_OWNER.VERIFICATION_COMPONENT (CONTROL_VERIFICATION_ID, COMPONENT_ID) values (1, 2763); -insert into JAM_OWNER.VERIFICATION_COMPONENT (CONTROL_VERIFICATION_ID, COMPONENT_ID) values (1, 2764); +insert into JAM_OWNER.BEAM_CONTROL_VERIFICATION_COMPONENT (BEAM_CONTROL_VERIFICATION_ID, COMPONENT_ID) values (1, 2763); +insert into JAM_OWNER.BEAM_CONTROL_VERIFICATION_COMPONENT (BEAM_CONTROL_VERIFICATION_ID, COMPONENT_ID) values (1, 2764); diff --git a/src/main/java/org/jlab/jam/business/session/AuthorizationFacade.java b/src/main/java/org/jlab/jam/business/session/BeamAuthorizationFacade.java similarity index 77% rename from src/main/java/org/jlab/jam/business/session/AuthorizationFacade.java rename to src/main/java/org/jlab/jam/business/session/BeamAuthorizationFacade.java index 8b96357..e587c50 100644 --- a/src/main/java/org/jlab/jam/business/session/AuthorizationFacade.java +++ b/src/main/java/org/jlab/jam/business/session/BeamAuthorizationFacade.java @@ -27,9 +27,9 @@ import javax.persistence.PersistenceContext; import javax.persistence.Query; import javax.persistence.TypedQuery; -import org.jlab.jam.persistence.entity.Authorization; +import org.jlab.jam.persistence.entity.BeamAuthorization; import org.jlab.jam.persistence.entity.BeamDestination; -import org.jlab.jam.persistence.entity.DestinationAuthorization; +import org.jlab.jam.persistence.entity.BeamDestinationAuthorization; import org.jlab.jlog.Body; import org.jlab.jlog.Library; import org.jlab.jlog.LogEntry; @@ -47,9 +47,9 @@ */ @Stateless @DeclareRoles({"jam-admin"}) -public class AuthorizationFacade extends AbstractFacade { +public class BeamAuthorizationFacade extends AbstractFacade { - private static final Logger LOGGER = Logger.getLogger(AuthorizationFacade.class.getName()); + private static final Logger LOGGER = Logger.getLogger(BeamAuthorizationFacade.class.getName()); @PersistenceContext(unitName = "jamPU") private EntityManager em; @@ -61,8 +61,8 @@ protected EntityManager getEntityManager() { return em; } - public AuthorizationFacade() { - super(Authorization.class); + public BeamAuthorizationFacade() { + super(BeamAuthorization.class); } @SuppressWarnings("unchecked") @@ -89,51 +89,52 @@ public HashMap getUnitsMap() { @SuppressWarnings("unchecked") @PermitAll - public Authorization findCurrent() { + public BeamAuthorization findCurrent() { Query q = em.createNativeQuery( - "select * from (select * from authorization order by modified_date desc) where rownum <= 1", - Authorization.class); + "select * from (select * from beam_authorization order by modified_date desc) where rownum <= 1", + BeamAuthorization.class); - List authorizationList = q.getResultList(); + List beamAuthorizationList = q.getResultList(); - Authorization authorization = null; + BeamAuthorization beamAuthorization = null; - if (authorizationList != null && !authorizationList.isEmpty()) { - authorization = authorizationList.get(0); + if (beamAuthorizationList != null && !beamAuthorizationList.isEmpty()) { + beamAuthorization = beamAuthorizationList.get(0); } - return authorization; + return beamAuthorization; } @SuppressWarnings("unchecked") @PermitAll - public List findHistory(int offset, int maxPerPage) { + public List findHistory(int offset, int maxPerPage) { Query q = em.createNativeQuery( - "select * from authorization order by authorization_date desc", Authorization.class); + "select * from authorization order by authorization_date desc", + BeamAuthorization.class); return q.setFirstResult(offset).setMaxResults(maxPerPage).getResultList(); } @PermitAll public Long countHistory() { - TypedQuery q = em.createQuery("select count(a) from Authorization a", Long.class); + TypedQuery q = em.createQuery("select count(a) from BeamAuthorization a", Long.class); return q.getSingleResult(); } @PermitAll - public Map createDestinationAuthorizationMap( - Authorization authorization) { - Map destinationAuthorizationMap = new HashMap<>(); + public Map createDestinationAuthorizationMap( + BeamAuthorization beamAuthorization) { + Map destinationAuthorizationMap = new HashMap<>(); - if (authorization != null && authorization.getDestinationAuthorizationList() != null) { - for (DestinationAuthorization destinationAuthorization : - authorization.getDestinationAuthorizationList()) { + if (beamAuthorization != null && beamAuthorization.getDestinationAuthorizationList() != null) { + for (BeamDestinationAuthorization beamDestinationAuthorization : + beamAuthorization.getDestinationAuthorizationList()) { destinationAuthorizationMap.put( - destinationAuthorization.getDestinationAuthorizationPK().getBeamDestinationId(), - destinationAuthorization); + beamDestinationAuthorization.getDestinationAuthorizationPK().getBeamDestinationId(), + beamDestinationAuthorization); } } @@ -142,27 +143,27 @@ public Map createDestinationAuthorizationM @RolesAllowed("jam-admin") public void saveAuthorization( - String comments, List destinationAuthorizationList) + String comments, List beamDestinationAuthorizationList) throws UserFriendlyException { String username = checkAuthenticated(); - Authorization authorization = new Authorization(); - authorization.setComments(comments); - authorization.setAuthorizationDate(new Date()); - authorization.setAuthorizedBy(username); - authorization.setModifiedDate(authorization.getAuthorizationDate()); - authorization.setModifiedBy(username); + BeamAuthorization beamAuthorization = new BeamAuthorization(); + beamAuthorization.setComments(comments); + beamAuthorization.setAuthorizationDate(new Date()); + beamAuthorization.setAuthorizedBy(username); + beamAuthorization.setModifiedDate(beamAuthorization.getAuthorizationDate()); + beamAuthorization.setModifiedBy(username); - create(authorization); + create(beamAuthorization); - for (DestinationAuthorization da : destinationAuthorizationList) { + for (BeamDestinationAuthorization da : beamDestinationAuthorizationList) { BeamDestination destination = destinationFacade.find(da.getDestinationAuthorizationPK().getBeamDestinationId()); if (!"None".equals(da.getBeamMode())) { // CW or Tune // Check if credited control agrees - if (!(destination.getVerification().getVerificationId() <= 50)) { + if (!(destination.getVerification().getVerificationStatusId() <= 50)) { throw new UserFriendlyException( "Beam Destination \"" + destination.getName() @@ -170,7 +171,7 @@ public void saveAuthorization( } // If provisional then there better be a comment - if (destination.getVerification().getVerificationId() == 50 + if (destination.getVerification().getVerificationStatusId() == 50 && (da.getComments() == null || da.getComments().trim().isEmpty())) { throw new UserFriendlyException( "Beam Destination \"" @@ -197,8 +198,9 @@ public void saveAuthorization( } } - da.setAuthorization(authorization); - da.getDestinationAuthorizationPK().setAuthorizationId(authorization.getAuthorizationId()); + da.setAuthorization(beamAuthorization); + da.getDestinationAuthorizationPK() + .setAuthorizationId(beamAuthorization.getBeamAuthorizationId()); em.persist(da); } @@ -239,9 +241,9 @@ public void sendOpsNewAuthorizationEmail(String linkHostName, String comments) public long sendELog(String proxyServer, String logbookServer) throws UserFriendlyException { String username = checkAuthenticated(); - Authorization authorization = findCurrent(); + BeamAuthorization beamAuthorization = findCurrent(); - if (authorization == null) { + if (beamAuthorization == null) { throw new UserFriendlyException("No authorizations found"); } diff --git a/src/main/java/org/jlab/jam/business/session/ControlVerificationFacade.java b/src/main/java/org/jlab/jam/business/session/BeamControlVerificationFacade.java similarity index 71% rename from src/main/java/org/jlab/jam/business/session/ControlVerificationFacade.java rename to src/main/java/org/jlab/jam/business/session/BeamControlVerificationFacade.java index c6de72c..91c8719 100644 --- a/src/main/java/org/jlab/jam/business/session/ControlVerificationFacade.java +++ b/src/main/java/org/jlab/jam/business/session/BeamControlVerificationFacade.java @@ -15,14 +15,8 @@ import javax.persistence.PersistenceContext; import javax.persistence.Query; import javax.persistence.TypedQuery; -import org.jlab.jam.persistence.entity.Authorization; -import org.jlab.jam.persistence.entity.BeamDestination; -import org.jlab.jam.persistence.entity.ControlVerification; -import org.jlab.jam.persistence.entity.CreditedControl; -import org.jlab.jam.persistence.entity.DestinationAuthorization; -import org.jlab.jam.persistence.entity.DestinationAuthorizationPK; -import org.jlab.jam.persistence.entity.VerificationHistory; -import org.jlab.jam.persistence.entity.Workgroup; +import org.jlab.jam.persistence.entity.*; +import org.jlab.jam.persistence.entity.BeamAuthorization; import org.jlab.jlog.Body; import org.jlab.jlog.Library; import org.jlab.jlog.LogEntry; @@ -40,16 +34,17 @@ */ @Stateless @DeclareRoles({"jam-admin"}) -public class ControlVerificationFacade extends AbstractFacade { +public class BeamControlVerificationFacade extends AbstractFacade { - private static final Logger LOGGER = Logger.getLogger(ControlVerificationFacade.class.getName()); + private static final Logger LOGGER = + Logger.getLogger(BeamControlVerificationFacade.class.getName()); @PersistenceContext(unitName = "jamPU") private EntityManager em; @EJB CreditedControlFacade controlFacade; @EJB BeamDestinationFacade destinationFacade; - @EJB AuthorizationFacade authorizationFacade; + @EJB BeamAuthorizationFacade beamAuthorizationFacade; @EJB BeamDestinationFacade beamDestinationFacade; @Override @@ -57,16 +52,16 @@ protected EntityManager getEntityManager() { return em; } - public ControlVerificationFacade() { - super(ControlVerification.class); + public BeamControlVerificationFacade() { + super(BeamControlVerification.class); } @PermitAll - public List findByBeamDestination(BigInteger beamDestinationId) { - TypedQuery q = + public List findByBeamDestination(BigInteger beamDestinationId) { + TypedQuery q = em.createQuery( - "select a from ControlVerification a join fetch a.creditedControl where a.beamDestination.beamDestinationId = :beamDestinationId order by a.creditedControl.weight asc", - ControlVerification.class); + "select a from BeamControlVerification a join fetch a.creditedControl where a.beamDestination.beamDestinationId = :beamDestinationId order by a.creditedControl.weight asc", + BeamControlVerification.class); q.setParameter("beamDestinationId", beamDestinationId); @@ -75,19 +70,19 @@ public List findByBeamDestination(BigInteger beamDestinatio @RolesAllowed("jam-admin") public void toggle(BigInteger controlId, BigInteger destinationId) { - ControlVerification verification = find(controlId, destinationId); + BeamControlVerification verification = find(controlId, destinationId); String username = checkAuthenticated(); if (verification == null) { - verification = new ControlVerification(); + verification = new BeamControlVerification(); verification.setModifiedBy(username); verification.setModifiedDate(new Date()); CreditedControl control = controlFacade.find(controlId); verification.setCreditedControl(control); BeamDestination destination = destinationFacade.find(destinationId); verification.setBeamDestination(destination); - verification.setVerificationId(100); + verification.setVerificationStatusId(100); create(verification); } else { remove(verification); @@ -95,18 +90,18 @@ public void toggle(BigInteger controlId, BigInteger destinationId) { } @PermitAll - public ControlVerification find(BigInteger controlId, BigInteger destinationId) { - TypedQuery q = + public BeamControlVerification find(BigInteger controlId, BigInteger destinationId) { + TypedQuery q = em.createQuery( - "select a from ControlVerification a where a.creditedControl.creditedControlId = :creditedControlId and a.beamDestination.beamDestinationId = :beamDestinationId", - ControlVerification.class); + "select a from BeamControlVerification a where a.creditedControl.creditedControlId = :creditedControlId and a.beamDestination.beamDestinationId = :beamDestinationId", + BeamControlVerification.class); q.setParameter("creditedControlId", controlId); q.setParameter("beamDestinationId", destinationId); - List verificationList = q.getResultList(); + List verificationList = q.getResultList(); - ControlVerification verification = null; + BeamControlVerification verification = null; if (verificationList != null && !verificationList.isEmpty()) { verification = verificationList.get(0); @@ -116,7 +111,7 @@ public ControlVerification find(BigInteger controlId, BigInteger destinationId) } @PermitAll - public List edit( + public List edit( BigInteger[] controlVerificationIdArray, Integer verificationId, Date verificationDate, @@ -152,7 +147,7 @@ public List edit( throw new UserFriendlyException("expiration date cannot be in the past"); } - List downgradeList = new ArrayList<>(); + List downgradeList = new ArrayList<>(); UserAuthorizationService auth = UserAuthorizationService.getInstance(); @@ -161,7 +156,7 @@ public List edit( throw new UserFriendlyException("control verification ID must not be null"); } - ControlVerification verification = find(controlVerificationId); + BeamControlVerification verification = find(controlVerificationId); if (verification == null) { throw new UserFriendlyException( @@ -169,8 +164,8 @@ public List edit( } boolean downgrade = - verification.getVerificationId() != verificationId - && verification.getVerificationId() < verificationId; + verification.getVerificationStatusId() != verificationId + && verification.getVerificationStatusId() < verificationId; // If verificationId is changing and it is a downgrade @@ -184,7 +179,7 @@ public List edit( verification.setModifiedBy(username); verification.setModifiedDate(modifiedDate); - verification.setVerificationId(verificationId); + verification.setVerificationStatusId(verificationId); verification.setVerificationDate(verificationDate); verification.setVerifiedBy(verifiedUsername); verification.setExpirationDate(expirationDate); @@ -194,15 +189,15 @@ public List edit( downgradeList.add(verification); } - VerificationHistory history = new VerificationHistory(); - history.setVerificationId(verificationId); + BeamControlVerificationHistory history = new BeamControlVerificationHistory(); + history.setVerificationStatusId(verificationId); history.setModifiedBy(username); history.setModifiedDate(modifiedDate); history.setVerificationDate(verificationDate); history.setVerifiedBy(verifiedUsername); history.setExpirationDate(expirationDate); history.setComments(comments); - history.setControlVerification(verification); + history.setBeamControlVerification(verification); em.persist(history); } @@ -216,17 +211,17 @@ public List edit( @PermitAll public String getExpiredMessageBody( String proxyServer, - List expiredAuthorizationList, - List expiredVerificationList, - List upcomingAuthorizationExpirationList, - List upcomingVerificationExpirationList) { + List expiredAuthorizationList, + List expiredVerificationList, + List upcomingAuthorizationExpirationList, + List upcomingVerificationExpirationList) { StringBuilder builder = new StringBuilder(); SimpleDateFormat formatter = new SimpleDateFormat(TimeUtil.getFriendlyDateTimePattern()); if (expiredAuthorizationList != null && !expiredAuthorizationList.isEmpty()) { builder.append("

--- Expired Director's Authorizations ---

\n"); - for (DestinationAuthorization authorization : expiredAuthorizationList) { + for (BeamDestinationAuthorization authorization : expiredAuthorizationList) { builder.append("\n
Beam Destination: "); builder.append(authorization.getDestination().getName()); builder.append("
\n
Expired On: "); @@ -242,7 +237,7 @@ public String getExpiredMessageBody( if (expiredVerificationList != null && !expiredVerificationList.isEmpty()) { builder.append("

--- Expired Credited Control Verifications ---

\n"); - for (ControlVerification v : expiredVerificationList) { + for (BeamControlVerification v : expiredVerificationList) { builder.append("
Credited Control: "); builder.append(v.getCreditedControl().getName()); @@ -266,7 +261,7 @@ public String getExpiredMessageBody( && !upcomingAuthorizationExpirationList.isEmpty()) { builder.append("

--- Director's Authorizations Expiring Soon ---

\n"); - for (DestinationAuthorization authorization : upcomingAuthorizationExpirationList) { + for (BeamDestinationAuthorization authorization : upcomingAuthorizationExpirationList) { builder.append("
Beam Destination: "); builder.append(authorization.getDestination().getName()); @@ -286,7 +281,7 @@ public String getExpiredMessageBody( && !upcomingVerificationExpirationList.isEmpty()) { builder.append("

--- Credited Control Verifications Expiring Soon ---

\n"); - for (ControlVerification v : upcomingVerificationExpirationList) { + for (BeamControlVerification v : upcomingVerificationExpirationList) { builder.append("
Credited Control: "); builder.append(v.getCreditedControl().getName()); @@ -315,17 +310,17 @@ public String getExpiredMessageBody( @PermitAll public String getVerificationDowngradedMessageBody( - String proxyServer, List downgradeList) { + String proxyServer, List downgradeList) { StringBuilder builder = new StringBuilder(); SimpleDateFormat formatter = new SimpleDateFormat(TimeUtil.getFriendlyDateTimePattern()); - ControlVerification verification = downgradeList.get(0); + BeamControlVerification verification = downgradeList.get(0); builder.append("
Credited Control: "); builder.append(verification.getCreditedControl().getName()); builder.append("
\n
Beam Destinations: "); - for (ControlVerification v : downgradeList) { + for (BeamControlVerification v : downgradeList) { builder.append("
"); builder.append(v.getBeamDestination().getName()); builder.append("
"); @@ -336,9 +331,11 @@ public String getVerificationDowngradedMessageBody( builder.append(Functions.formatUsername(verification.getVerifiedBy())); builder.append("
\n
Verification: "); builder.append( - verification.getVerificationId() == 1 + verification.getVerificationStatusId() == 1 ? "Verified" - : (verification.getVerificationId() == 50 ? "Provisionally Verified" : "Not Verified")); + : (verification.getVerificationStatusId() == 50 + ? "Provisionally Verified" + : "Not Verified")); builder.append("
\n
Comments: "); builder.append(IOUtil.escapeXml(verification.getComments())); builder @@ -402,13 +399,14 @@ public void sendVerificationDowngradedEmail(String body) throws UserFriendlyExce } @PermitAll - public List checkForAuthorizedButExpired(Authorization mostRecent) { - TypedQuery q = + public List checkForAuthorizedButExpired( + BeamAuthorization mostRecent) { + TypedQuery q = em.createQuery( - "select a from DestinationAuthorization a where a.authorization.authorizationId = :authId and a.expirationDate < sysdate and a.beamMode != 'None' and a.destination.active = true order by a.destinationAuthorizationPK.beamDestinationId asc", - DestinationAuthorization.class); + "select a from BeamDestinationAuthorization a where a.beamAuthorization.beamAuthorizationId = :authId and a.expirationDate < sysdate and a.beamMode != 'None' and a.destination.active = true order by a.destinationAuthorizationPK.beamDestinationId asc", + BeamDestinationAuthorization.class); - BigInteger authId = mostRecent.getAuthorizationId(); + BigInteger authId = mostRecent.getBeamAuthorizationId(); q.setParameter("authId", authId); @@ -416,44 +414,44 @@ public List checkForAuthorizedButExpired(Authorization } @PermitAll - public List checkForExpired() { - TypedQuery q = + public List checkForExpired() { + TypedQuery q = em.createQuery( - "select a from ControlVerification a join fetch a.creditedControl where a.expirationDate < sysdate and a.beamDestination.active = true order by a.creditedControl.weight asc", - ControlVerification.class); + "select a from BeamControlVerification a join fetch a.creditedControl where a.expirationDate < sysdate and a.beamDestination.active = true order by a.creditedControl.weight asc", + BeamControlVerification.class); return q.getResultList(); } @PermitAll - public List checkForVerifiedButExpired() { - TypedQuery q = + public List checkForVerifiedButExpired() { + TypedQuery q = em.createQuery( - "select a from ControlVerification a join fetch a.creditedControl where a.expirationDate < sysdate and a.beamDestination.active = true and a.verificationId in (1, 50) order by a.creditedControl.weight asc", - ControlVerification.class); + "select a from BeamControlVerification a join fetch a.creditedControl where a.expirationDate < sysdate and a.beamDestination.active = true and a.verificationStatusId in (1, 50) order by a.creditedControl.weight asc", + BeamControlVerification.class); return q.getResultList(); } @PermitAll - public void revokeExpiredAuthorizations(List authorizationList) { + public void revokeExpiredAuthorizations(List authorizationList) { LOGGER.log(Level.FINEST, "I think I've got something authorization-wise to downgrade"); this.clearDirectorPermissionByDestinationAuthorization(authorizationList); } @PermitAll - public void revokeExpiredVerifications(List expiredList) { + public void revokeExpiredVerifications(List expiredList) { Query q = em.createQuery( - "update ControlVerification a set a.verificationId = 100, a.comments = 'Expired', a.verifiedBy = null, a.verificationDate = :vDate, a.modifiedDate = :vDate, a.modifiedBy = 'authadm' where a.controlVerificationId in :list"); + "update BeamControlVerification a set a.verificationId = 100, a.comments = 'Expired', a.verifiedBy = null, a.verificationDate = :vDate, a.modifiedDate = :vDate, a.modifiedBy = 'authadm' where a.controlVerificationId in :list"); List expiredIdList = new ArrayList<>(); Date modifiedDate = new Date(); if (expiredList != null) { - for (ControlVerification v : expiredList) { - expiredIdList.add(v.getControlVerificationId()); + for (BeamControlVerification v : expiredList) { + expiredIdList.add(v.getBeamControlVerificationId()); } } @@ -470,28 +468,28 @@ public void revokeExpiredVerifications(List expiredList) { } @PermitAll - public void clearDirectorPermissionForExpired(List verificationList) { + public void clearDirectorPermissionForExpired(List verificationList) { clearDirectorPermissionByCreditedControl(verificationList, true); } @PermitAll - public void clearDirectorPermissionForDowngrade(List verificationList) { + public void clearDirectorPermissionForDowngrade(List verificationList) { clearDirectorPermissionByCreditedControl(verificationList, false); } private void clearDirectorPermissionByCreditedControl( - List verificationList, Boolean expiration) { + List verificationList, Boolean expiration) { String reason = "expiration"; if (!expiration) { reason = "downgrade"; } - Authorization authorization = authorizationFacade.findCurrent(); + BeamAuthorization beamAuthorization = beamAuthorizationFacade.findCurrent(); - Authorization authClone = authorization.createAdminClone(); + BeamAuthorization authClone = beamAuthorization.createAdminClone(); // authClone.setDestinationAuthorizationList(new ArrayList<>()); - List newList = new ArrayList<>(); + List newList = new ArrayList<>(); boolean atLeastOne = false; @@ -499,9 +497,10 @@ private void clearDirectorPermissionByCreditedControl( // are two ways in which a clear can happen and they can race to see who clears permissions // first: // (1) director's expiration vs (2) credited control expiration - if (authorization.getDestinationAuthorizationList() != null) { - for (DestinationAuthorization auth : authorization.getDestinationAuthorizationList()) { - DestinationAuthorization destClone = auth.createAdminClone(authClone); + if (beamAuthorization.getDestinationAuthorizationList() != null) { + for (BeamDestinationAuthorization auth : + beamAuthorization.getDestinationAuthorizationList()) { + BeamDestinationAuthorization destClone = auth.createAdminClone(authClone); // authClone.getDestinationAuthorizationList().add(destClone); newList.add(destClone); @@ -509,7 +508,7 @@ private void clearDirectorPermissionByCreditedControl( continue; // Already None so no need to revoke; move on to next } BigInteger destinationId = auth.getDestinationAuthorizationPK().getBeamDestinationId(); - for (ControlVerification verification : verificationList) { + for (BeamControlVerification verification : verificationList) { if (destinationId.equals(verification.getBeamDestination().getBeamDestinationId())) { destClone.setBeamMode("None"); destClone.setCwLimit(null); @@ -526,10 +525,10 @@ private void clearDirectorPermissionByCreditedControl( if (atLeastOne) { em.persist(authClone); - for (DestinationAuthorization da : newList) { + for (BeamDestinationAuthorization da : newList) { DestinationAuthorizationPK pk = new DestinationAuthorizationPK(); pk.setBeamDestinationId(da.getDestination().getBeamDestinationId()); - pk.setAuthorizationId(authClone.getAuthorizationId()); + pk.setAuthorizationId(authClone.getBeamAuthorizationId()); da.setDestinationAuthorizationPK(pk); em.persist(da); } @@ -537,12 +536,12 @@ private void clearDirectorPermissionByCreditedControl( } private void clearDirectorPermissionByDestinationAuthorization( - List destinationList) { - Authorization authorization = authorizationFacade.findCurrent(); + List destinationList) { + BeamAuthorization beamAuthorization = beamAuthorizationFacade.findCurrent(); - Authorization authClone = authorization.createAdminClone(); + BeamAuthorization authClone = beamAuthorization.createAdminClone(); // authClone.setDestinationAuthorizationList(new ArrayList<>()); - List newList = new ArrayList<>(); + List newList = new ArrayList<>(); boolean atLeastOne = false; @@ -550,9 +549,10 @@ private void clearDirectorPermissionByDestinationAuthorization( // are two ways in which a clear can happen and they can race to see who clears permissions // first: // (1) director's expiration vs (2) credited control expiration - if (authorization.getDestinationAuthorizationList() != null) { - for (DestinationAuthorization auth : authorization.getDestinationAuthorizationList()) { - DestinationAuthorization destClone = auth.createAdminClone(authClone); + if (beamAuthorization.getDestinationAuthorizationList() != null) { + for (BeamDestinationAuthorization auth : + beamAuthorization.getDestinationAuthorizationList()) { + BeamDestinationAuthorization destClone = auth.createAdminClone(authClone); // authClone.getDestinationAuthorizationList().add(destClone); newList.add(destClone); @@ -572,10 +572,10 @@ private void clearDirectorPermissionByDestinationAuthorization( if (atLeastOne) { em.persist(authClone); - for (DestinationAuthorization da : newList) { + for (BeamDestinationAuthorization da : newList) { DestinationAuthorizationPK pk = new DestinationAuthorizationPK(); pk.setBeamDestinationId(da.getDestination().getBeamDestinationId()); - pk.setAuthorizationId(authClone.getAuthorizationId()); + pk.setAuthorizationId(authClone.getBeamAuthorizationId()); da.setDestinationAuthorizationPK(pk); em.persist(da); } @@ -583,34 +583,35 @@ private void clearDirectorPermissionByDestinationAuthorization( } @PermitAll - public void insertExpiredHistory(List verificationList, Date modifiedDate) { - for (ControlVerification v : verificationList) { - VerificationHistory history = new VerificationHistory(); + public void insertExpiredHistory( + List verificationList, Date modifiedDate) { + for (BeamControlVerification v : verificationList) { + BeamControlVerificationHistory history = new BeamControlVerificationHistory(); history.setModifiedBy("jam-admin"); history.setModifiedDate(modifiedDate); - history.setVerificationId(100); + history.setVerificationStatusId(100); history.setVerificationDate(modifiedDate); history.setVerifiedBy(null); history.setExpirationDate(v.getExpirationDate()); history.setComments("Expired"); - history.setControlVerification(v); + history.setBeamControlVerification(v); em.persist(history); } } @PermitAll - public List checkForUpcomingVerificationExpirations() { - TypedQuery q = + public List checkForUpcomingVerificationExpirations() { + TypedQuery q = em.createQuery( - "select a from ControlVerification a join fetch a.creditedControl where a.expirationDate >= sysdate and (a.expirationDate - 7) <= sysdate and a.verificationId in (1, 50) and a.beamDestination.active = true order by a.creditedControl.weight asc", - ControlVerification.class); + "select a from BeamControlVerification a join fetch a.creditedControl where a.expirationDate >= sysdate and (a.expirationDate - 7) <= sysdate and a.verificationStatusId in (1, 50) and a.beamDestination.active = true order by a.creditedControl.weight asc", + BeamControlVerification.class); return q.getResultList(); } - private List checkForUpcomingAuthorizationExpirations( - Authorization auth) { - List upcomingExpirations = new ArrayList<>(); + private List checkForUpcomingAuthorizationExpirations( + BeamAuthorization auth) { + List upcomingExpirations = new ArrayList<>(); Date now = new Date(); Calendar cal = Calendar.getInstance(); @@ -618,7 +619,7 @@ private List checkForUpcomingAuthorizationExpirations( Date threeDaysFromNow = cal.getTime(); if (auth.getDestinationAuthorizationList() != null) { - for (DestinationAuthorization dest : auth.getDestinationAuthorizationList()) { + for (BeamDestinationAuthorization dest : auth.getDestinationAuthorizationList()) { if (!"None".equals(dest.getBeamMode()) && dest.getExpirationDate().after(now) && dest.getExpirationDate().before(threeDaysFromNow)) { @@ -632,10 +633,10 @@ private List checkForUpcomingAuthorizationExpirations( @PermitAll public void notifyAdmins( - List expiredAuthorizationList, - List expiredVerificationList, - List upcomingAuthorizationExpirationList, - List upcomingVerificationExpirationList, + List expiredAuthorizationList, + List expiredVerificationList, + List upcomingAuthorizationExpirationList, + List upcomingVerificationExpirationList, String proxyServer) throws MessagingException, UserFriendlyException { String toCsv = System.getenv("BAM_UPCOMING_EXPIRATION_EMAIL_CSV"); @@ -659,8 +660,8 @@ public void notifyAdmins( @PermitAll public void notifyOps( - List expiredAuthorizationList, - List expiredVerificationList, + List expiredAuthorizationList, + List expiredVerificationList, String proxyServer) throws MessagingException, UserFriendlyException { String toCsv = System.getenv("BAM_EXPIRED_EMAIL_CSV"); @@ -681,21 +682,21 @@ public void notifyOps( @PermitAll public void notifyGroups( - List expiredList, - List upcomingExpirationsList, + List expiredList, + List upcomingExpirationsList, String proxyServer) throws MessagingException, UserFriendlyException { - Map> expiredGroupMap = new HashMap<>(); - Map> upcomingExpirationGroupMap = new HashMap<>(); + Map> expiredGroupMap = new HashMap<>(); + Map> upcomingExpirationGroupMap = new HashMap<>(); String subject = System.getenv("BAM_UPCOMING_EXPIRATION_SUBJECT"); LOGGER.log(Level.FINEST, "Expirations:"); if (expiredList != null) { - for (ControlVerification c : expiredList) { + for (BeamControlVerification c : expiredList) { LOGGER.log(Level.FINEST, c.toString()); Workgroup workgroup = c.getCreditedControl().getGroup(); - List groupList = expiredGroupMap.get(workgroup); + List groupList = expiredGroupMap.get(workgroup); if (groupList == null) { groupList = new ArrayList<>(); expiredGroupMap.put(workgroup, groupList); @@ -708,10 +709,10 @@ public void notifyGroups( LOGGER.log(Level.FINEST, "Upcoming Expirations:"); if (upcomingExpirationsList != null) { - for (ControlVerification c : upcomingExpirationsList) { + for (BeamControlVerification c : upcomingExpirationsList) { LOGGER.log(Level.FINEST, c.toString()); Workgroup workgroup = c.getCreditedControl().getGroup(); - List groupList = upcomingExpirationGroupMap.get(workgroup); + List groupList = upcomingExpirationGroupMap.get(workgroup); if (groupList == null) { groupList = new ArrayList<>(); upcomingExpirationGroupMap.put(workgroup, groupList); @@ -743,8 +744,9 @@ public void notifyGroups( } } - List groupExpiredList = expiredGroupMap.get(w); - List groupUpcomingExpirationsList = upcomingExpirationGroupMap.get(w); + List groupExpiredList = expiredGroupMap.get(w); + List groupUpcomingExpirationsList = + upcomingExpirationGroupMap.get(w); String sender = System.getenv("BAM_EMAIL_SENDER"); @@ -770,10 +772,10 @@ public void notifyGroups( @PermitAll public void notifyUsersOfExpirationsAndUpcomingExpirations( - List expiredAuthorizationList, - List expiredVerificationList, - List upcomingAuthorizationExpirationList, - List upcomingVerificationExpirationList) { + List expiredAuthorizationList, + List expiredVerificationList, + List upcomingAuthorizationExpirationList, + List upcomingVerificationExpirationList) { boolean expiredAuth = (expiredAuthorizationList != null && !expiredAuthorizationList.isEmpty()); boolean expiredVer = (expiredVerificationList != null && !expiredVerificationList.isEmpty()); @@ -819,8 +821,8 @@ public void notifyUsersOfExpirationsAndUpcomingExpirations( @PermitAll public void performExpirationCheck(boolean checkForUpcoming) { LOGGER.log(Level.FINEST, "Expiration Check: Director's authorizations..."); - Authorization auth = authorizationFacade.findCurrent(); - List expiredAuthorizationList = null; + BeamAuthorization auth = beamAuthorizationFacade.findCurrent(); + List expiredAuthorizationList = null; if (auth != null) { expiredAuthorizationList = checkForAuthorizedButExpired(auth); @@ -831,7 +833,7 @@ public void performExpirationCheck(boolean checkForUpcoming) { } LOGGER.log(Level.FINEST, "Expiration Check: Checking for expired verifications..."); - List expiredVerificationList = + List expiredVerificationList = checkForVerifiedButExpired(); // only items which are "verified" or "provisionally // verified", but need to be "not verified" due to expiration if (expiredVerificationList != null && !expiredVerificationList.isEmpty()) { @@ -839,8 +841,8 @@ public void performExpirationCheck(boolean checkForUpcoming) { revokeExpiredVerifications(expiredVerificationList); } - List upcomingVerificationExpirationList = null; - List upcomingAuthorizationExpirationList = null; + List upcomingVerificationExpirationList = null; + List upcomingAuthorizationExpirationList = null; if (checkForUpcoming) { LOGGER.log( Level.FINEST, "Expiration Check: Checking for upcoming verification expirations..."); @@ -861,17 +863,17 @@ public void performExpirationCheck(boolean checkForUpcoming) { } @PermitAll - public ControlVerification findWithCreditedControl(BigInteger controlVerificationId) { - TypedQuery q = + public BeamControlVerification findWithCreditedControl(BigInteger controlVerificationId) { + TypedQuery q = em.createQuery( - "select a from ControlVerification a join fetch a.creditedControl where a.controlVerificationId = :id", - ControlVerification.class); + "select a from BeamControlVerification a join fetch a.creditedControl where a.beamControlVerificationId = :id", + BeamControlVerification.class); q.setParameter("id", controlVerificationId); - List resultList = q.getResultList(); + List resultList = q.getResultList(); - ControlVerification verification = null; + BeamControlVerification verification = null; if (resultList != null && !resultList.isEmpty()) { verification = resultList.get(0); diff --git a/src/main/java/org/jlab/jam/business/session/DestinationAuthorizationFacade.java b/src/main/java/org/jlab/jam/business/session/BeamDestinationAuthorizationFacade.java similarity index 56% rename from src/main/java/org/jlab/jam/business/session/DestinationAuthorizationFacade.java rename to src/main/java/org/jlab/jam/business/session/BeamDestinationAuthorizationFacade.java index 81116df..3375aee 100644 --- a/src/main/java/org/jlab/jam/business/session/DestinationAuthorizationFacade.java +++ b/src/main/java/org/jlab/jam/business/session/BeamDestinationAuthorizationFacade.java @@ -3,13 +3,14 @@ import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; -import org.jlab.jam.persistence.entity.DestinationAuthorization; +import org.jlab.jam.persistence.entity.BeamDestinationAuthorization; /** * @author ryans */ @Stateless -public class DestinationAuthorizationFacade extends AbstractFacade { +public class BeamDestinationAuthorizationFacade + extends AbstractFacade { @PersistenceContext(unitName = "jamPU") private EntityManager em; @@ -18,7 +19,7 @@ protected EntityManager getEntityManager() { return em; } - public DestinationAuthorizationFacade() { - super(DestinationAuthorization.class); + public BeamDestinationAuthorizationFacade() { + super(BeamDestinationAuthorization.class); } } diff --git a/src/main/java/org/jlab/jam/business/session/BeamDestinationFacade.java b/src/main/java/org/jlab/jam/business/session/BeamDestinationFacade.java index a994f6d..a170b4c 100644 --- a/src/main/java/org/jlab/jam/business/session/BeamDestinationFacade.java +++ b/src/main/java/org/jlab/jam/business/session/BeamDestinationFacade.java @@ -12,8 +12,8 @@ import javax.persistence.Query; import javax.persistence.TypedQuery; import javax.persistence.criteria.*; +import org.jlab.jam.persistence.entity.BeamControlVerification; import org.jlab.jam.persistence.entity.BeamDestination; -import org.jlab.jam.persistence.entity.ControlVerification; import org.jlab.jam.persistence.entity.Facility; /** @@ -94,15 +94,15 @@ public BeamDestination findWithVerificationList(BigInteger destinationId) { destination = destinationList.get(0); // JPAUtil.initialize(destination.getControlVerificationList()); - for (ControlVerification verification : destination.getControlVerificationList()) { + for (BeamControlVerification verification : destination.getBeamControlVerificationList()) { verification.getCreditedControl().getName(); } Collections.sort( - destination.getControlVerificationList(), - new Comparator() { + destination.getBeamControlVerificationList(), + new Comparator() { @Override - public int compare(ControlVerification o1, ControlVerification o2) { + public int compare(BeamControlVerification o1, BeamControlVerification o2) { return o1.getCreditedControl().compareTo(o2.getCreditedControl()); } }); diff --git a/src/main/java/org/jlab/jam/business/session/ComponentFacade.java b/src/main/java/org/jlab/jam/business/session/ComponentFacade.java index 250cd19..ed4ed83 100644 --- a/src/main/java/org/jlab/jam/business/session/ComponentFacade.java +++ b/src/main/java/org/jlab/jam/business/session/ComponentFacade.java @@ -7,9 +7,8 @@ import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; -import javax.persistence.criteria.*; +import org.jlab.jam.persistence.entity.BeamControlVerification; import org.jlab.jam.persistence.entity.Component; -import org.jlab.jam.persistence.entity.ControlVerification; import org.jlab.smoothness.business.exception.UserFriendlyException; /** @@ -25,7 +24,7 @@ protected EntityManager getEntityManager() { return em; } - @EJB ControlVerificationFacade controlVerificationFacade; + @EJB BeamControlVerificationFacade beamControlVerificationFacade; public ComponentFacade() { super(Component.class); @@ -42,7 +41,7 @@ public void removeComponent(BigInteger verificationId, BigInteger componentId) throw new UserFriendlyException("componentId is required"); } - ControlVerification verification = controlVerificationFacade.find(verificationId); + BeamControlVerification verification = beamControlVerificationFacade.find(verificationId); if (verification == null) { throw new UserFriendlyException("verification with ID " + verificationId + " not found"); @@ -58,7 +57,7 @@ public void removeComponent(BigInteger verificationId, BigInteger componentId) } } verification.setComponentList(newList); - controlVerificationFacade.edit(verification); + beamControlVerificationFacade.edit(verification); } } @@ -73,7 +72,7 @@ public void addComponent(BigInteger verificationId, BigInteger componentId) throw new UserFriendlyException("componentId is required"); } - ControlVerification verification = controlVerificationFacade.find(verificationId); + BeamControlVerification verification = beamControlVerificationFacade.find(verificationId); if (verification == null) { throw new UserFriendlyException("verification with ID " + verificationId + " not found"); @@ -93,6 +92,6 @@ public void addComponent(BigInteger verificationId, BigInteger componentId) componentList.add(component); - controlVerificationFacade.edit(verification); + beamControlVerificationFacade.edit(verification); } } diff --git a/src/main/java/org/jlab/jam/business/session/CreditedControlFacade.java b/src/main/java/org/jlab/jam/business/session/CreditedControlFacade.java index eaa57e0..3b0a746 100644 --- a/src/main/java/org/jlab/jam/business/session/CreditedControlFacade.java +++ b/src/main/java/org/jlab/jam/business/session/CreditedControlFacade.java @@ -34,7 +34,7 @@ public CreditedControlFacade() { public CreditedControl findWithVerificationList(BigInteger creditedControlId) { TypedQuery q = em.createQuery( - "select a from CreditedControl a JOIN FETCH a.controlVerificationList as b where b.beamDestination.active = true and a.creditedControlId = :creditedControlId", + "select a from CreditedControl a JOIN FETCH a.beamControlVerificationList as b where b.beamDestination.active = true and a.creditedControlId = :creditedControlId", CreditedControl.class); q.setParameter("creditedControlId", creditedControlId); @@ -47,7 +47,7 @@ public CreditedControl findWithVerificationList(BigInteger creditedControlId) { cc = ccList.get(0); // JPAUtil.initialize(cc.getControlVerificationList()); - Collections.sort(cc.getControlVerificationList()); + Collections.sort(cc.getBeamControlVerificationList()); } return cc; @@ -63,7 +63,7 @@ public List findAllWithVerificationList() { if (ccList != null) { for (CreditedControl cc : ccList) { - JPAUtil.initialize(cc.getControlVerificationList()); + JPAUtil.initialize(cc.getBeamControlVerificationList()); // Collections.sort(cc.getControlVerificationList()); } } diff --git a/src/main/java/org/jlab/jam/business/session/DailyScheduledCheck.java b/src/main/java/org/jlab/jam/business/session/DailyScheduledCheck.java index 00ca3cd..308b191 100644 --- a/src/main/java/org/jlab/jam/business/session/DailyScheduledCheck.java +++ b/src/main/java/org/jlab/jam/business/session/DailyScheduledCheck.java @@ -21,7 +21,7 @@ public class DailyScheduledCheck { private Timer timer; @Resource private TimerService timerService; - @EJB ControlVerificationFacade verificationFacade; + @EJB BeamControlVerificationFacade verificationFacade; @PostConstruct private void init() { diff --git a/src/main/java/org/jlab/jam/business/session/RFAuthorizationFacade.java b/src/main/java/org/jlab/jam/business/session/RFAuthorizationFacade.java new file mode 100644 index 0000000..d7a85a4 --- /dev/null +++ b/src/main/java/org/jlab/jam/business/session/RFAuthorizationFacade.java @@ -0,0 +1,345 @@ +package org.jlab.jam.business.session; + +import java.io.*; +import java.math.BigInteger; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.security.DeclareRoles; +import javax.annotation.security.PermitAll; +import javax.annotation.security.RolesAllowed; +import javax.ejb.EJB; +import javax.ejb.Stateless; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import javax.persistence.TypedQuery; +import org.jlab.jam.persistence.entity.*; +import org.jlab.jlog.Body; +import org.jlab.jlog.Library; +import org.jlab.jlog.LogEntry; +import org.jlab.jlog.LogEntryAdminExtension; +import org.jlab.jlog.exception.AttachmentSizeException; +import org.jlab.jlog.exception.LogCertificateException; +import org.jlab.jlog.exception.LogIOException; +import org.jlab.jlog.exception.LogRuntimeException; +import org.jlab.smoothness.business.exception.UserFriendlyException; +import org.jlab.smoothness.business.service.EmailService; +import org.jlab.smoothness.business.util.IOUtil; + +/** + * @author ryans + */ +@Stateless +@DeclareRoles({"jam-admin"}) +public class RFAuthorizationFacade extends AbstractFacade { + + private static final Logger LOGGER = Logger.getLogger(RFAuthorizationFacade.class.getName()); + + @PersistenceContext(unitName = "jamPU") + private EntityManager em; + + @EJB RFSegmentFacade segmentFacade; + + @Override + protected EntityManager getEntityManager() { + return em; + } + + public RFAuthorizationFacade() { + super(RFAuthorization.class); + } + + @SuppressWarnings("unchecked") + @PermitAll + public HashMap getUnitsMap() { + HashMap units = new HashMap<>(); + + Query q = + em.createNativeQuery( + "select a.BEAM_DESTINATION_ID, a.CURRENT_LIMIT_UNITS from beam_destination a where a.ACTIVE_YN = 'Y'"); + + List results = q.getResultList(); + + for (Object[] result : results) { + Object[] row = result; + Number id = (Number) row[0]; + String unit = (String) row[1]; + // LOGGER.log(Level.WARNING, "ID: {0}, Unit: {1}", new Object[]{id, unit}); + units.put(BigInteger.valueOf(id.longValue()), unit); + } + + return units; + } + + @SuppressWarnings("unchecked") + @PermitAll + public BeamAuthorization findCurrent() { + Query q = + em.createNativeQuery( + "select * from (select * from authorization order by modified_date desc) where rownum <= 1", + BeamAuthorization.class); + + List beamAuthorizationList = q.getResultList(); + + BeamAuthorization beamAuthorization = null; + + if (beamAuthorizationList != null && !beamAuthorizationList.isEmpty()) { + beamAuthorization = beamAuthorizationList.get(0); + } + + return beamAuthorization; + } + + @SuppressWarnings("unchecked") + @PermitAll + public List findHistory(int offset, int maxPerPage) { + Query q = + em.createNativeQuery( + "select * from authorization order by authorization_date desc", + BeamAuthorization.class); + + return q.setFirstResult(offset).setMaxResults(maxPerPage).getResultList(); + } + + @PermitAll + public Long countHistory() { + TypedQuery q = em.createQuery("select count(a) from BeamAuthorization a", Long.class); + + return q.getSingleResult(); + } + + @PermitAll + public Map createDestinationAuthorizationMap( + BeamAuthorization beamAuthorization) { + Map destinationAuthorizationMap = new HashMap<>(); + + if (beamAuthorization != null && beamAuthorization.getDestinationAuthorizationList() != null) { + for (BeamDestinationAuthorization beamDestinationAuthorization : + beamAuthorization.getDestinationAuthorizationList()) { + destinationAuthorizationMap.put( + beamDestinationAuthorization.getDestinationAuthorizationPK().getBeamDestinationId(), + beamDestinationAuthorization); + } + } + + return destinationAuthorizationMap; + } + + @RolesAllowed("jam-admin") + public void saveAuthorization( + String comments, List segmentAuthorizationList) + throws UserFriendlyException { + String username = checkAuthenticated(); + + RFAuthorization authorization = new RFAuthorization(); + authorization.setComments(comments); + authorization.setAuthorizationDate(new Date()); + authorization.setAuthorizedBy(username); + authorization.setModifiedDate(authorization.getAuthorizationDate()); + authorization.setModifiedBy(username); + + create(authorization); + + for (RFSegmentAuthorization da : segmentAuthorizationList) { + + RFSegment segment = segmentFacade.find(da.getSegmentAuthorizationPK().getRFSegmentId()); + if (!"None".equals(da.getRFMode())) { + + // Check if credited control agrees + if (!(segment.getVerification().getVerificationStatusId() <= 50)) { + throw new UserFriendlyException( + "Segment \"" + + segment.getName() + + "\" cannot authorize RF when credited controls are not verified"); + } + + // If provisional then there better be a comment + if (segment.getVerification().getVerificationStatusId() == 50 + && (da.getComments() == null || da.getComments().trim().isEmpty())) { + throw new UserFriendlyException( + "Segment \"" + + segment.getName() + + "\" must have a comment to explain why RF is permitted with provisional credited control status"); + } + + // Must provide an expiration date since ON + if (da.getExpirationDate() == null) { + throw new UserFriendlyException( + "Segment \"" + + segment.getName() + + "\" must have an expiration date since RF is allowed"); + } + + // Expiration must be in the future + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.HOUR_OF_DAY, 1); + if (da.getExpirationDate().before(cal.getTime())) { + throw new UserFriendlyException( + "Segment \"" + + segment.getName() + + "\" must have a future expiration date and minimum expiration is 1 hour from now"); + } + } + + da.setRFAuthorization(authorization); + da.getSegmentAuthorizationPK().setRFAuthorizationId(authorization.getRfAuthorizationId()); + em.persist(da); + } + + LOGGER.log(Level.FINE, "Director's Authorization saved successfully"); + } + + @RolesAllowed("jam-admin") + public void sendOpsNewAuthorizationEmail(String linkHostName, String comments) + throws UserFriendlyException { + + String toCsv = System.getenv("JAM_PERMISSIONS_EMAIL_CSV"); + + if (toCsv == null || toCsv.isEmpty()) { + LOGGER.log( + Level.WARNING, "Environment variable 'JAM_PERMISSIONS_EMAIL_CSV' not found, aborting"); + return; + } + + String subject = System.getenv("JAM_PERMISSIONS_SUBJECT"); + + String body = "" + linkHostName + "/jam"; + + body = body + "\n\n

Notes: " + comments + "

"; + + String sender = System.getenv("JAM_EMAIL_SENDER"); + + if (sender == null || sender.isEmpty()) { + LOGGER.log(Level.WARNING, "Environment variable 'JAM_EMAIL_SENDER' not found, aborting"); + return; + } + + EmailService emailService = new EmailService(); + + emailService.sendEmail(sender, sender, toCsv, null, subject, body, true); + } + + @RolesAllowed("jam-admin") + public long sendELog(String proxyServer, String logbookServer) throws UserFriendlyException { + String username = checkAuthenticated(); + + BeamAuthorization beamAuthorization = findCurrent(); + + if (beamAuthorization == null) { + throw new UserFriendlyException("No authorizations found"); + } + + // String body = getELogHTMLBody(authorization); + String body = getAlternateELogHTMLBody(proxyServer); + + String subject = System.getenv("JAM_PERMISSIONS_SUBJECT"); + + String logbooks = System.getenv("JAM_BOOKS_CSV"); + + if (logbooks == null || logbooks.isEmpty()) { + logbooks = "TLOG"; + LOGGER.log( + Level.WARNING, "Environment variable 'JAM_BOOKS_CSV' not found, using default TLOG"); + } + + Properties config = Library.getConfiguration(); + + config.setProperty("SUBMIT_URL", logbookServer + "/incoming"); + config.setProperty("FETCH_URL", logbookServer + "/entry"); + + LogEntry entry = new LogEntry(subject, logbooks); + + entry.setBody(body, Body.ContentType.HTML); + entry.setTags("Readme"); + + LogEntryAdminExtension extension = new LogEntryAdminExtension(entry); + extension.setAuthor(username); + + long logId; + + // System.out.println(entry.getXML()); + File tmpFile = null; + + try { + tmpFile = grabPermissionsScreenshot(); + entry.addAttachment(tmpFile.getAbsolutePath()); + logId = entry.submitNow(); + + } catch (IOException + | AttachmentSizeException + | LogIOException + | LogRuntimeException + | LogCertificateException e) { + throw new UserFriendlyException("Unable to send elog", e); + } finally { + if (tmpFile != null) { + boolean deleted = tmpFile.delete(); + if (!deleted) { + LOGGER.log( + Level.WARNING, "Temporary image file was not deleted {0}", tmpFile.getAbsolutePath()); + } + } + } + + return logId; + } + + private File grabPermissionsScreenshot() throws IOException { + + String puppetServer = System.getenv("PUPPET_SHOW_SERVER_URL"); + String internalServer = System.getenv("BACKEND_SERVER_URL"); + + if (puppetServer == null) { + puppetServer = "http://localhost"; + } + + if (internalServer == null) { + internalServer = "http://localhost"; + } + + internalServer = URLEncoder.encode(internalServer, StandardCharsets.UTF_8); + + URL url = + new URL( + puppetServer + + "/puppet-show/screenshot?url=" + + internalServer + + "%2Fjam%2Fpermissions%3Fprint%3DY&fullPage=true&filename=jam.png&ignoreHTTPSErrors=true"); + + LOGGER.log(Level.FINEST, "Fetching URL: {0}", url.toString()); + + File tmpFile = null; + InputStream in = null; + OutputStream out = null; + + try { + URLConnection con = url.openConnection(); + in = con.getInputStream(); + + tmpFile = File.createTempFile("jam", ".png"); + out = new FileOutputStream(tmpFile); + IOUtil.copy(in, out); + + } finally { + IOUtil.close(in, out); + } + return tmpFile; + } + + private String getAlternateELogHTMLBody(String server) { + StringBuilder builder = new StringBuilder(); + + builder.append( + "[figure:1]
\n\nAlways check the Beam Authorization web application for the latest credited controls status: "); + builder.append("JLab Authorization Manager
\n"); + + return builder.toString(); + } +} diff --git a/src/main/java/org/jlab/jam/business/session/RFSegmentFacade.java b/src/main/java/org/jlab/jam/business/session/RFSegmentFacade.java new file mode 100644 index 0000000..1431d16 --- /dev/null +++ b/src/main/java/org/jlab/jam/business/session/RFSegmentFacade.java @@ -0,0 +1,58 @@ +package org.jlab.jam.business.session; + +import java.util.ArrayList; +import java.util.List; +import javax.annotation.security.PermitAll; +import javax.ejb.Stateless; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.TypedQuery; +import javax.persistence.criteria.*; +import org.jlab.jam.persistence.entity.Facility; +import org.jlab.jam.persistence.entity.RFSegment; + +/** + * @author ryans + */ +@Stateless +public class RFSegmentFacade extends AbstractFacade { + @PersistenceContext(unitName = "jamPU") + private EntityManager em; + + @Override + protected EntityManager getEntityManager() { + return em; + } + + public RFSegmentFacade() { + super(RFSegment.class); + } + + @PermitAll + public List findByFacility(Facility facility) { + CriteriaBuilder cb = getEntityManager().getCriteriaBuilder(); + CriteriaQuery cq = cb.createQuery(RFSegment.class); + Root root = cq.from(RFSegment.class); + + List filters = new ArrayList<>(); + + filters.add(cb.equal(root.get("facility"), facility)); + + filters.add(cb.equal(root.get("active"), true)); + + if (!filters.isEmpty()) { + cq.where(cb.and(filters.toArray(new Predicate[] {}))); + } + + List orders = new ArrayList<>(); + Path p0 = root.get("weight"); + Order o0 = cb.desc(p0); + orders.add(o0); + cq.orderBy(orders); + + cq.select(root); + TypedQuery q = getEntityManager().createQuery(cq); + + return q.getResultList(); + } +} diff --git a/src/main/java/org/jlab/jam/business/session/VerificationHistoryFacade.java b/src/main/java/org/jlab/jam/business/session/VerificationHistoryFacade.java index e6d8e31..06348ed 100644 --- a/src/main/java/org/jlab/jam/business/session/VerificationHistoryFacade.java +++ b/src/main/java/org/jlab/jam/business/session/VerificationHistoryFacade.java @@ -7,13 +7,13 @@ import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.persistence.TypedQuery; -import org.jlab.jam.persistence.entity.VerificationHistory; +import org.jlab.jam.persistence.entity.BeamControlVerificationHistory; /** * @author ryans */ @Stateless -public class VerificationHistoryFacade extends AbstractFacade { +public class VerificationHistoryFacade extends AbstractFacade { @PersistenceContext(unitName = "jamPU") private EntityManager em; @@ -23,18 +23,18 @@ protected EntityManager getEntityManager() { } public VerificationHistoryFacade() { - super(VerificationHistory.class); + super(BeamControlVerificationHistory.class); } @PermitAll - public List findHistory( + public List findHistory( BigInteger controlVerificationId, int offset, int maxPerPage) { // join fetch a.controlVerification b join fetch b.creditedControl - TypedQuery q = + TypedQuery q = em.createQuery( - "select a from VerificationHistory a where a.controlVerification.controlVerificationId = :id order by a.verificationHistoryId desc", - VerificationHistory.class); + "select a from BeamControlVerificationHistory a where a.beamControlVerification.beamControlVerificationId = :id order by a.beamControlVerificationHistoryId desc", + BeamControlVerificationHistory.class); q.setParameter("id", controlVerificationId); @@ -45,7 +45,7 @@ public List findHistory( public Long countHistory(BigInteger controlVerificationId) { TypedQuery q = em.createQuery( - "select count(a) from VerificationHistory a where a.controlVerification.controlVerificationId = :id", + "select count(a) from BeamControlVerificationHistory a where a.beamControlVerification.beamControlVerificationId = :id", Long.class); q.setParameter("id", controlVerificationId); diff --git a/src/main/java/org/jlab/jam/persistence/entity/BeamAuthorization.java b/src/main/java/org/jlab/jam/persistence/entity/BeamAuthorization.java new file mode 100644 index 0000000..4601e25 --- /dev/null +++ b/src/main/java/org/jlab/jam/persistence/entity/BeamAuthorization.java @@ -0,0 +1,168 @@ +package org.jlab.jam.persistence.entity; + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.Date; +import java.util.List; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +/** + * @author ryans + */ +@Entity +@Table(schema = "JAM_OWNER") +@NamedQueries({ + @NamedQuery(name = "BeamAuthorization.findAll", query = "SELECT a FROM BeamAuthorization a") +}) +public class BeamAuthorization implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @SequenceGenerator( + name = "BeamAuthorizationId", + sequenceName = "BEAM_AUTHORIZATION_ID", + allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BeamAuthorizationId") + @Basic(optional = false) + @NotNull + @Column(name = "BEAM_AUTHORIZATION_ID", nullable = false, precision = 22, scale = 0) + private BigInteger beamAuthorizationId; + + @Basic(optional = false) + @NotNull + @Column(name = "AUTHORIZATION_DATE", nullable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date authorizationDate; + + @Basic(optional = false) + @NotNull + @Column(name = "MODIFIED_DATE", nullable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date modifiedDate; + + @NotNull + @Column(name = "AUTHORIZED_BY", nullable = false) + private String authorizedBy; + + @NotNull + @Column(name = "MODIFIED_BY", nullable = false) + private String modifiedBy; + + @Size(max = 2048) + @Column(length = 2048) + private String comments; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "beamAuthorization", fetch = FetchType.EAGER) + private List beamDestinationAuthorizationList; + + public BeamAuthorization() {} + + public BigInteger getBeamAuthorizationId() { + return beamAuthorizationId; + } + + public void setBeamAuthorizationId(BigInteger beamAuthorizationId) { + this.beamAuthorizationId = beamAuthorizationId; + } + + public Date getAuthorizationDate() { + return authorizationDate; + } + + public void setAuthorizationDate(Date authorizationDate) { + this.authorizationDate = authorizationDate; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public String getAuthorizedBy() { + return authorizedBy; + } + + public void setAuthorizedBy(String authorizedBy) { + this.authorizedBy = authorizedBy; + } + + public String getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + public List getDestinationAuthorizationList() { + return beamDestinationAuthorizationList; + } + + public void setDestinationAuthorizationList( + List beamDestinationAuthorizationList) { + this.beamDestinationAuthorizationList = beamDestinationAuthorizationList; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (beamAuthorizationId != null ? beamAuthorizationId.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof BeamAuthorization)) { + return false; + } + BeamAuthorization other = (BeamAuthorization) object; + return (this.beamAuthorizationId != null || other.beamAuthorizationId == null) + && (this.beamAuthorizationId == null + || this.beamAuthorizationId.equals(other.beamAuthorizationId)); + } + + @Override + public String toString() { + return "org.jlab.jam.persistence.entity.BeamAuthorization[beamAuthorizationId=" + + beamAuthorizationId + + " ]"; + } + + public BeamAuthorization createAdminClone() { + BeamAuthorization other = new BeamAuthorization(); + other.authorizationDate = this.authorizationDate; + other.authorizedBy = this.authorizedBy; + other.comments = this.comments; + other.setModifiedBy("jam-admin"); + other.setModifiedDate(new Date()); + return other; + } +} diff --git a/src/main/java/org/jlab/jam/persistence/entity/ControlVerification.java b/src/main/java/org/jlab/jam/persistence/entity/BeamControlVerification.java similarity index 60% rename from src/main/java/org/jlab/jam/persistence/entity/ControlVerification.java rename to src/main/java/org/jlab/jam/persistence/entity/BeamControlVerification.java index b83599d..948e5ed 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/ControlVerification.java +++ b/src/main/java/org/jlab/jam/persistence/entity/BeamControlVerification.java @@ -12,23 +12,25 @@ * @author ryans */ @Entity -@Table(name = "CONTROL_VERIFICATION", schema = "JAM_OWNER") +@Table(name = "BEAM_CONTROL_VERIFICATION", schema = "JAM_OWNER") @NamedQueries({ - @NamedQuery(name = "ControlVerification.findAll", query = "SELECT c FROM ControlVerification c") + @NamedQuery( + name = "BeamControlVerification.findAll", + query = "SELECT c FROM BeamControlVerification c") }) -public class ControlVerification implements Serializable, Comparable { +public class BeamControlVerification implements Serializable, Comparable { private static final long serialVersionUID = 1L; @Id @SequenceGenerator( - name = "ControlVerificationId", - sequenceName = "CONTROL_VERIFICATION_ID", + name = "BeamControlVerificationId", + sequenceName = "BEAM_CONTROL_VERIFICATION_ID", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ControlVerificationId") + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BeamControlVerificationId") @Basic(optional = false) @NotNull - @Column(name = "CONTROL_VERIFICATION_ID", nullable = false, precision = 22, scale = 0) - private BigInteger controlVerificationId; + @Column(name = "BEAM_CONTROL_VERIFICATION_ID", nullable = false, precision = 22, scale = 0) + private BigInteger beamControlVerificationId; @NotNull @JoinColumn(name = "BEAM_DESTINATION_ID", referencedColumnName = "BEAM_DESTINATION_ID") @@ -36,9 +38,9 @@ public class ControlVerification implements Serializable, Comparable verificationHistoryList; + @OneToMany(mappedBy = "beamControlVerification", fetch = FetchType.LAZY) + private List beamControlVerificationHistoryList; @JoinColumn(name = "CREDITED_CONTROL_ID", referencedColumnName = "CREDITED_CONTROL_ID") @ManyToOne(fetch = FetchType.LAZY) @@ -73,19 +75,19 @@ public class ControlVerification implements Serializable, Comparable componentList; - public ControlVerification() {} + public BeamControlVerification() {} - public BigInteger getControlVerificationId() { - return controlVerificationId; + public BigInteger getBeamControlVerificationId() { + return beamControlVerificationId; } - public void setControlVerificationId(BigInteger controlVerificationId) { - this.controlVerificationId = controlVerificationId; + public void setBeamControlVerificationId(BigInteger beamControlVerificationId) { + this.beamControlVerificationId = beamControlVerificationId; } public String getModifiedBy() { @@ -112,12 +114,12 @@ public void setBeamDestination(BeamDestination beamDestination) { this.beamDestination = beamDestination; } - public Integer getVerificationId() { - return verificationId; + public Integer getVerificationStatusId() { + return verificationStatusId; } - public void setVerificationId(Integer verificationId) { - this.verificationId = verificationId; + public void setVerificationStatusId(Integer verificationStatusId) { + this.verificationStatusId = verificationStatusId; } public Date getVerificationDate() { @@ -152,12 +154,13 @@ public void setComments(String comments) { this.comments = comments; } - public List getVerificationHistoryList() { - return verificationHistoryList; + public List getVerificationHistoryList() { + return beamControlVerificationHistoryList; } - public void setVerificationHistoryList(List verificationHistoryList) { - this.verificationHistoryList = verificationHistoryList; + public void setVerificationHistoryList( + List beamControlVerificationHistoryList) { + this.beamControlVerificationHistoryList = beamControlVerificationHistoryList; } public CreditedControl getCreditedControl() { @@ -179,31 +182,31 @@ public void setComponentList(List componentList) { @Override public int hashCode() { int hash = 0; - hash += (controlVerificationId != null ? controlVerificationId.hashCode() : 0); + hash += (beamControlVerificationId != null ? beamControlVerificationId.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set - if (!(object instanceof ControlVerification)) { + if (!(object instanceof BeamControlVerification)) { return false; } - ControlVerification other = (ControlVerification) object; - return (this.controlVerificationId != null || other.controlVerificationId == null) - && (this.controlVerificationId == null - || this.controlVerificationId.equals(other.controlVerificationId)); + BeamControlVerification other = (BeamControlVerification) object; + return (this.beamControlVerificationId != null || other.beamControlVerificationId == null) + && (this.beamControlVerificationId == null + || this.beamControlVerificationId.equals(other.beamControlVerificationId)); } @Override public String toString() { - return "org.jlab.beamauth.persistence.entity.ControlVerification[ controlVerificationId=" - + controlVerificationId + return "org.jlab.jam.persistence.entity.BeamControlVerification[ beamControlVerificationId=" + + beamControlVerificationId + " ]"; } @Override - public int compareTo(ControlVerification o) { + public int compareTo(BeamControlVerification o) { return this.beamDestination.getWeight().compareTo(o.beamDestination.getWeight()); } } diff --git a/src/main/java/org/jlab/jam/persistence/entity/VerificationHistory.java b/src/main/java/org/jlab/jam/persistence/entity/BeamControlVerificationHistory.java similarity index 55% rename from src/main/java/org/jlab/jam/persistence/entity/VerificationHistory.java rename to src/main/java/org/jlab/jam/persistence/entity/BeamControlVerificationHistory.java index 7d49046..603cc0a 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/VerificationHistory.java +++ b/src/main/java/org/jlab/jam/persistence/entity/BeamControlVerificationHistory.java @@ -22,24 +22,30 @@ * @author ryans */ @Entity -@Table(name = "VERIFICATION_HISTORY", schema = "JAM_OWNER") -public class VerificationHistory implements Serializable { +@Table(name = "BEAM_CONTROL_VERIFICATION_HISTORY", schema = "JAM_OWNER") +public class BeamControlVerificationHistory implements Serializable { private static final long serialVersionUID = 1L; @Id @SequenceGenerator( - name = "VerificationHistoryId", - sequenceName = "VERIFICATION_HISTORY_ID", + name = "BeamControlVerificationHistoryId", + sequenceName = "BEAM_CONTROL_VERIFICATION_HISTORY_ID", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "VerificationHistoryId") + @GeneratedValue( + strategy = GenerationType.SEQUENCE, + generator = "BeamControlVerificationHistoryId") @Basic(optional = false) @NotNull - @Column(name = "VERIFICATION_HISTORY_ID", nullable = false, precision = 22, scale = 0) - private BigInteger verificationHistoryId; - - @Column(name = "VERIFICATION_ID") + @Column( + name = "BEAM_CONTROL_VERIFICATION_HISTORY_ID", + nullable = false, + precision = 22, + scale = 0) + private BigInteger beamControlVerificationHistoryId; + + @Column(name = "VERIFICATION_STATUS_ID") @NotNull - private Integer verificationId; + private Integer verificationStatusId; @Column(name = "MODIFIED_BY", nullable = false) private String modifiedBy; @@ -68,26 +74,28 @@ public class VerificationHistory implements Serializable { @Column(name = "COMMENTS", nullable = true) private String comments; - @JoinColumn(name = "CONTROL_VERIFICATION_ID", referencedColumnName = "CONTROL_VERIFICATION_ID") + @JoinColumn( + name = "BEAM_CONTROL_VERIFICATION_ID", + referencedColumnName = "BEAM_CONTROL_VERIFICATION_ID") @ManyToOne(optional = false, fetch = FetchType.LAZY) - private ControlVerification controlVerification; + private BeamControlVerification beamControlVerification; - public VerificationHistory() {} + public BeamControlVerificationHistory() {} - public BigInteger getVerificationHistoryId() { - return verificationHistoryId; + public BigInteger getBeamControlVerificationHistoryId() { + return beamControlVerificationHistoryId; } - public void setVerificationHistoryId(BigInteger verificationHistoryId) { - this.verificationHistoryId = verificationHistoryId; + public void setBeamControlVerificationHistoryId(BigInteger beamControlVerificationHistoryId) { + this.beamControlVerificationHistoryId = beamControlVerificationHistoryId; } - public Integer getVerificationId() { - return verificationId; + public Integer getVerificationStatusId() { + return verificationStatusId; } - public void setVerificationId(Integer verificationId) { - this.verificationId = verificationId; + public void setVerificationStatusId(Integer verificationStatusId) { + this.verificationStatusId = verificationStatusId; } public String getModifiedBy() { @@ -138,37 +146,42 @@ public void setComments(String comments) { this.comments = comments; } - public ControlVerification getControlVerification() { - return controlVerification; + public BeamControlVerification getBeamControlVerification() { + return beamControlVerification; } - public void setControlVerification(ControlVerification controlVerificationId) { - this.controlVerification = controlVerificationId; + public void setBeamControlVerification(BeamControlVerification beamControlVerificationId) { + this.beamControlVerification = beamControlVerificationId; } @Override public int hashCode() { int hash = 0; - hash += (verificationHistoryId != null ? verificationHistoryId.hashCode() : 0); + hash += + (beamControlVerificationHistoryId != null + ? beamControlVerificationHistoryId.hashCode() + : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set - if (!(object instanceof VerificationHistory)) { + if (!(object instanceof BeamControlVerificationHistory)) { return false; } - VerificationHistory other = (VerificationHistory) object; - return (this.verificationHistoryId != null || other.verificationHistoryId == null) - && (this.verificationHistoryId == null - || this.verificationHistoryId.equals(other.verificationHistoryId)); + BeamControlVerificationHistory other = (BeamControlVerificationHistory) object; + return (this.beamControlVerificationHistoryId != null + || other.beamControlVerificationHistoryId == null) + && (this.beamControlVerificationHistoryId == null + || this.beamControlVerificationHistoryId.equals( + other.beamControlVerificationHistoryId)); } @Override public String toString() { - return "org.jlab.beamauth.persistence.entity.VerificationHistory[ verificationHistoryId=" - + verificationHistoryId + return "org.jlab.jam.persistence.entity.BeamControlVerificationHistory[ beamControlVerificationHistoryId=" + + beamControlVerificationHistoryId + " ]"; } } diff --git a/src/main/java/org/jlab/jam/persistence/entity/BeamDestination.java b/src/main/java/org/jlab/jam/persistence/entity/BeamDestination.java index 3d50124..e3c3922 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/BeamDestination.java +++ b/src/main/java/org/jlab/jam/persistence/entity/BeamDestination.java @@ -40,12 +40,12 @@ public class BeamDestination { private String name; @OneToMany(mappedBy = "beamDestination", fetch = FetchType.LAZY) - private List controlVerificationList; + private List beamControlVerificationList; private BigInteger weight; - public List getControlVerificationList() { - return controlVerificationList; + public List getBeamControlVerificationList() { + return beamControlVerificationList; } public String getName() { diff --git a/src/main/java/org/jlab/jam/persistence/entity/DestinationAuthorization.java b/src/main/java/org/jlab/jam/persistence/entity/BeamDestinationAuthorization.java similarity index 75% rename from src/main/java/org/jlab/jam/persistence/entity/DestinationAuthorization.java rename to src/main/java/org/jlab/jam/persistence/entity/BeamDestinationAuthorization.java index 0bd683b..01fb78c 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/DestinationAuthorization.java +++ b/src/main/java/org/jlab/jam/persistence/entity/BeamDestinationAuthorization.java @@ -23,13 +23,13 @@ * @author ryans */ @Entity -@Table(name = "DESTINATION_AUTHORIZATION", schema = "JAM_OWNER") +@Table(name = "BEAM_DESTINATION_AUTHORIZATION", schema = "JAM_OWNER") @NamedQueries({ @NamedQuery( - name = "DestinationAuthorization.findAll", - query = "SELECT d FROM DestinationAuthorization d") + name = "BeamDestinationAuthorization.findAll", + query = "SELECT d FROM BeamDestinationAuthorization d") }) -public class DestinationAuthorization implements Serializable { +public class BeamDestinationAuthorization implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId protected DestinationAuthorizationPK destinationAuthorizationPK; @@ -62,27 +62,27 @@ public class DestinationAuthorization implements Serializable { private BeamDestination destination; @JoinColumn( - name = "AUTHORIZATION_ID", - referencedColumnName = "AUTHORIZATION_ID", + name = "BEAM_AUTHORIZATION_ID", + referencedColumnName = "BEAM_AUTHORIZATION_ID", nullable = false, insertable = false, updatable = false) @ManyToOne(optional = false, fetch = FetchType.LAZY) - private Authorization authorization; + private BeamAuthorization beamAuthorization; - public DestinationAuthorization() {} + public BeamDestinationAuthorization() {} - public DestinationAuthorization(DestinationAuthorizationPK destinationAuthorizationPK) { + public BeamDestinationAuthorization(DestinationAuthorizationPK destinationAuthorizationPK) { this.destinationAuthorizationPK = destinationAuthorizationPK; } - public DestinationAuthorization( + public BeamDestinationAuthorization( DestinationAuthorizationPK destinationAuthorizationPK, String beamMode) { this.destinationAuthorizationPK = destinationAuthorizationPK; this.beamMode = beamMode; } - public DestinationAuthorization(BigInteger beamDestinationId, BigInteger authorizationId) { + public BeamDestinationAuthorization(BigInteger beamDestinationId, BigInteger authorizationId) { this.destinationAuthorizationPK = new DestinationAuthorizationPK(beamDestinationId, authorizationId); } @@ -131,12 +131,12 @@ public void setExpirationDate(Date expirationDate) { this.expirationDate = expirationDate; } - public Authorization getAuthorization() { - return authorization; + public BeamAuthorization getAuthorization() { + return beamAuthorization; } - public void setAuthorization(Authorization authorization) { - this.authorization = authorization; + public void setAuthorization(BeamAuthorization beamAuthorization) { + this.beamAuthorization = beamAuthorization; } @Override @@ -149,10 +149,10 @@ public int hashCode() { @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set - if (!(object instanceof DestinationAuthorization)) { + if (!(object instanceof BeamDestinationAuthorization)) { return false; } - DestinationAuthorization other = (DestinationAuthorization) object; + BeamDestinationAuthorization other = (BeamDestinationAuthorization) object; return (this.destinationAuthorizationPK != null || other.destinationAuthorizationPK == null) && (this.destinationAuthorizationPK == null || this.destinationAuthorizationPK.equals(other.destinationAuthorizationPK)); @@ -160,14 +160,14 @@ public boolean equals(Object object) { @Override public String toString() { - return "org.jlab.beamauth.persistence.entity.DestinationAuthorization[ destinationAuthorizationPK=" + return "org.jlab.jam.persistence.entity.BeamDestinationAuthorization[destinationAuthorizationPK=" + destinationAuthorizationPK + " ]"; } - public DestinationAuthorization createAdminClone(Authorization authClone) { - DestinationAuthorization other = new DestinationAuthorization(); - other.authorization = authClone; + public BeamDestinationAuthorization createAdminClone(BeamAuthorization authClone) { + BeamDestinationAuthorization other = new BeamDestinationAuthorization(); + other.beamAuthorization = authClone; other.beamMode = this.beamMode; other.comments = this.comments; other.cwLimit = this.cwLimit; diff --git a/src/main/java/org/jlab/jam/persistence/entity/CreditedControl.java b/src/main/java/org/jlab/jam/persistence/entity/CreditedControl.java index 10b7b9f..623d3f7 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/CreditedControl.java +++ b/src/main/java/org/jlab/jam/persistence/entity/CreditedControl.java @@ -61,7 +61,7 @@ public class CreditedControl implements Serializable, Comparable controlVerificationList; + private List beamControlVerificationList; public CreditedControl() {} @@ -125,18 +125,19 @@ public void setVerificationFrequency(String verificationFrequency) { this.verificationFrequency = verificationFrequency; } - public List getControlVerificationList() { - return controlVerificationList; + public List getBeamControlVerificationList() { + return beamControlVerificationList; } - public void setControlVerificationList(List controlVerificationList) { - this.controlVerificationList = controlVerificationList; + public void setBeamControlVerificationList( + List beamControlVerificationList) { + this.beamControlVerificationList = beamControlVerificationList; } public boolean hasBeamDestination(BeamDestination destination) { boolean hasDestination = false; - if (controlVerificationList != null) { - for (ControlVerification verification : controlVerificationList) { + if (beamControlVerificationList != null) { + for (BeamControlVerification verification : beamControlVerificationList) { if (verification.getBeamDestination().equals(destination)) { hasDestination = true; break; diff --git a/src/main/java/org/jlab/jam/persistence/entity/DestinationAuthorizationPK.java b/src/main/java/org/jlab/jam/persistence/entity/DestinationAuthorizationPK.java index dcc74d6..80bc7e5 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/DestinationAuthorizationPK.java +++ b/src/main/java/org/jlab/jam/persistence/entity/DestinationAuthorizationPK.java @@ -19,14 +19,14 @@ public class DestinationAuthorizationPK implements Serializable { @Basic(optional = false) @NotNull - @Column(name = "AUTHORIZATION_ID", nullable = false) - private BigInteger authorizationId; + @Column(name = "BEAM_AUTHORIZATION_ID", nullable = false) + private BigInteger beamAuthorizationId; public DestinationAuthorizationPK() {} - public DestinationAuthorizationPK(BigInteger beamDestinationId, BigInteger authorizationId) { + public DestinationAuthorizationPK(BigInteger beamDestinationId, BigInteger beamAuthorizationId) { this.beamDestinationId = beamDestinationId; - this.authorizationId = authorizationId; + this.beamAuthorizationId = beamAuthorizationId; } public BigInteger getBeamDestinationId() { @@ -37,19 +37,19 @@ public void setBeamDestinationId(BigInteger beamDestinationId) { this.beamDestinationId = beamDestinationId; } - public BigInteger getAuthorizationId() { - return authorizationId; + public BigInteger getBeamAuthorizationId() { + return beamAuthorizationId; } - public void setAuthorizationId(BigInteger authorizationId) { - this.authorizationId = authorizationId; + public void setAuthorizationId(BigInteger beamAuthorizationId) { + this.beamAuthorizationId = beamAuthorizationId; } @Override public int hashCode() { int hash = 0; hash += (beamDestinationId != null ? beamDestinationId.hashCode() : 0); - hash += (authorizationId != null ? authorizationId.hashCode() : 0); + hash += (beamAuthorizationId != null ? beamAuthorizationId.hashCode() : 0); return hash; } @@ -65,16 +65,17 @@ public boolean equals(Object object) { && !this.beamDestinationId.equals(other.beamDestinationId))) { return false; } - return (this.authorizationId != null || other.authorizationId == null) - && (this.authorizationId == null || this.authorizationId.equals(other.authorizationId)); + return (this.beamAuthorizationId != null || other.beamAuthorizationId == null) + && (this.beamAuthorizationId == null + || this.beamAuthorizationId.equals(other.beamAuthorizationId)); } @Override public String toString() { - return "org.jlab.beamauth.persistence.entity.DestinationAuthorizationPK[ beamDestinationId=" + return "org.jlab.jam.persistence.entity.DestinationAuthorizationPK[ beamDestinationId=" + beamDestinationId - + ", authorizationId=" - + authorizationId + + ", beamAuthorizationId=" + + beamAuthorizationId + " ]"; } } diff --git a/src/main/java/org/jlab/jam/persistence/entity/Authorization.java b/src/main/java/org/jlab/jam/persistence/entity/RFAuthorization.java similarity index 65% rename from src/main/java/org/jlab/jam/persistence/entity/Authorization.java rename to src/main/java/org/jlab/jam/persistence/entity/RFAuthorization.java index 4122905..132e145 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/Authorization.java +++ b/src/main/java/org/jlab/jam/persistence/entity/RFAuthorization.java @@ -28,21 +28,21 @@ @Entity @Table(schema = "JAM_OWNER") @NamedQueries({ - @NamedQuery(name = "Authorization.findAll", query = "SELECT a FROM Authorization a") + @NamedQuery(name = "RFAuthorization.findAll", query = "SELECT a FROM RFAuthorization a") }) -public class Authorization implements Serializable { +public class RFAuthorization implements Serializable { private static final long serialVersionUID = 1L; @Id @SequenceGenerator( - name = "AuthorizationId", - sequenceName = "AUTHORIZATION_ID", + name = "RFAuthorizationId", + sequenceName = "RF_AUTHORIZATION_ID", allocationSize = 1) - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AuthorizationId") + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "RFAuthorizationId") @Basic(optional = false) @NotNull - @Column(name = "AUTHORIZATION_ID", nullable = false, precision = 22, scale = 0) - private BigInteger authorizationId; + @Column(name = "RF_AUTHORIZATION_ID", nullable = false, precision = 22, scale = 0) + private BigInteger rfAuthorizationId; @Basic(optional = false) @NotNull @@ -68,17 +68,17 @@ public class Authorization implements Serializable { @Column(length = 2048) private String comments; - @OneToMany(cascade = CascadeType.ALL, mappedBy = "authorization", fetch = FetchType.EAGER) - private List destinationAuthorizationList; + @OneToMany(cascade = CascadeType.ALL, mappedBy = "rfAuthorization", fetch = FetchType.EAGER) + private List rfSegmentAuthorizationList; - public Authorization() {} + public RFAuthorization() {} - public BigInteger getAuthorizationId() { - return authorizationId; + public BigInteger getRfAuthorizationId() { + return rfAuthorizationId; } - public void setAuthorizationId(BigInteger authorizationId) { - this.authorizationId = authorizationId; + public void setRfAuthorizationId(BigInteger rfAuthorizationId) { + this.rfAuthorizationId = rfAuthorizationId; } public Date getAuthorizationDate() { @@ -121,42 +121,43 @@ public void setComments(String comments) { this.comments = comments; } - public List getDestinationAuthorizationList() { - return destinationAuthorizationList; + public List getRFSegmentAuthorizationList() { + return rfSegmentAuthorizationList; } - public void setDestinationAuthorizationList( - List destinationAuthorizationList) { - this.destinationAuthorizationList = destinationAuthorizationList; + public void setRFSegmentAuthorizationList( + List rfSegmentAuthorizationList) { + this.rfSegmentAuthorizationList = rfSegmentAuthorizationList; } @Override public int hashCode() { int hash = 0; - hash += (authorizationId != null ? authorizationId.hashCode() : 0); + hash += (rfAuthorizationId != null ? rfAuthorizationId.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set - if (!(object instanceof Authorization)) { + if (!(object instanceof RFAuthorization)) { return false; } - Authorization other = (Authorization) object; - return (this.authorizationId != null || other.authorizationId == null) - && (this.authorizationId == null || this.authorizationId.equals(other.authorizationId)); + RFAuthorization other = (RFAuthorization) object; + return (this.rfAuthorizationId != null || other.rfAuthorizationId == null) + && (this.rfAuthorizationId == null + || this.rfAuthorizationId.equals(other.rfAuthorizationId)); } @Override public String toString() { - return "org.jlab.beamauth.persistence.entity.Authorization[ authorizationId=" - + authorizationId + return "org.jlab.jam.persistence.entity.RFAuthorization[rfAuthorizationId=" + + rfAuthorizationId + " ]"; } - public Authorization createAdminClone() { - Authorization other = new Authorization(); + public RFAuthorization createAdminClone() { + RFAuthorization other = new RFAuthorization(); other.authorizationDate = this.authorizationDate; other.authorizedBy = this.authorizedBy; other.comments = this.comments; diff --git a/src/main/java/org/jlab/jam/persistence/entity/RFControlVerification.java b/src/main/java/org/jlab/jam/persistence/entity/RFControlVerification.java new file mode 100644 index 0000000..5f01049 --- /dev/null +++ b/src/main/java/org/jlab/jam/persistence/entity/RFControlVerification.java @@ -0,0 +1,212 @@ +package org.jlab.jam.persistence.entity; + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.Date; +import java.util.List; +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +/** + * @author ryans + */ +@Entity +@Table(name = "RF_CONTROL_VERIFICATION", schema = "JAM_OWNER") +@NamedQueries({ + @NamedQuery( + name = "RFControlVerification.findAll", + query = "SELECT c FROM RFControlVerification c") +}) +public class RFControlVerification implements Serializable, Comparable { + private static final long serialVersionUID = 1L; + + @Id + @SequenceGenerator( + name = "RFControlVerificationId", + sequenceName = "RF_CONTROL_VERIFICATION_ID", + allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "RFControlVerificationId") + @Basic(optional = false) + @NotNull + @Column(name = "RF_CONTROL_VERIFICATION_ID", nullable = false, precision = 22, scale = 0) + private BigInteger rfControlVerificationId; + + @NotNull + @JoinColumn(name = "RF_SEGMENT_ID", referencedColumnName = "RF_SEGMENT_ID") + @ManyToOne(fetch = FetchType.EAGER) + private RFSegment rfSegment; + + @Basic(optional = false) + @Column(name = "VERIFICATION_STATUS_ID") + @NotNull + private Integer verificationStatusId; + + @Column(name = "MODIFIED_BY", nullable = false) + private String modifiedBy; + + @Basic(optional = false) + @NotNull + @Column(name = "MODIFIED_DATE", nullable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date modifiedDate; + + @Column(name = "VERIFICATION_DATE") + @Temporal(TemporalType.TIMESTAMP) + private Date verificationDate; + + @Column(name = "VERIFIED_BY", nullable = true) + private String verifiedBy; + + @Column(name = "EXPIRATION_DATE") + @Temporal(TemporalType.TIMESTAMP) + private Date expirationDate; + + @Size(max = 2048) + @Column(length = 2048) + private String comments; + + @OneToMany(mappedBy = "rfControlVerification", fetch = FetchType.LAZY) + private List rfControlVerificationHistoryList; + + @JoinColumn(name = "CREDITED_CONTROL_ID", referencedColumnName = "CREDITED_CONTROL_ID") + @ManyToOne(fetch = FetchType.LAZY) + private CreditedControl creditedControl; + + @ManyToMany(fetch = FetchType.EAGER) + @JoinTable( + name = "RF_CONTROL_VERIFICATION_COMPONENT", + joinColumns = @JoinColumn(name = "RF_CONTROL_VERIFICATION_ID"), + inverseJoinColumns = @JoinColumn(name = "COMPONENT_ID")) + private List componentList; + + public RFControlVerification() {} + + public BigInteger getRFControlVerificationId() { + return rfControlVerificationId; + } + + public void setRFControlVerificationId(BigInteger rfControlVerificationId) { + this.rfControlVerificationId = rfControlVerificationId; + } + + public String getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public RFSegment getRFSegment() { + return rfSegment; + } + + public void setRFSegment(RFSegment rfSegment) { + this.rfSegment = rfSegment; + } + + public Integer getVerificationStatusId() { + return verificationStatusId; + } + + public void setVerificationStatusId(Integer verificationStatusId) { + this.verificationStatusId = verificationStatusId; + } + + public Date getVerificationDate() { + return verificationDate; + } + + public void setVerificationDate(Date verificationDate) { + this.verificationDate = verificationDate; + } + + public String getVerifiedBy() { + return verifiedBy; + } + + public void setVerifiedBy(String verifiedBy) { + this.verifiedBy = verifiedBy; + } + + public Date getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(Date expirationDate) { + this.expirationDate = expirationDate; + } + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + public List getRFControlVerificationHistoryList() { + return rfControlVerificationHistoryList; + } + + public void setRFControlVerificationHistoryList( + List rfControlVerificationHistoryList) { + this.rfControlVerificationHistoryList = rfControlVerificationHistoryList; + } + + public CreditedControl getCreditedControl() { + return creditedControl; + } + + public void setCreditedControl(CreditedControl creditedControl) { + this.creditedControl = creditedControl; + } + + public List getComponentList() { + return componentList; + } + + public void setComponentList(List componentList) { + this.componentList = componentList; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (rfControlVerificationId != null ? rfControlVerificationId.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof RFControlVerification)) { + return false; + } + RFControlVerification other = (RFControlVerification) object; + return (this.rfControlVerificationId != null || other.rfControlVerificationId == null) + && (this.rfControlVerificationId == null + || this.rfControlVerificationId.equals(other.rfControlVerificationId)); + } + + @Override + public String toString() { + return "org.jlab.jam.persistence.entity.RFControlVerification[ rfControlVerificationId=" + + rfControlVerificationId + + " ]"; + } + + @Override + public int compareTo(RFControlVerification o) { + return this.rfSegment.getWeight().compareTo(o.rfSegment.getWeight()); + } +} diff --git a/src/main/java/org/jlab/jam/persistence/entity/RFControlVerificationHistory.java b/src/main/java/org/jlab/jam/persistence/entity/RFControlVerificationHistory.java new file mode 100644 index 0000000..50e5405 --- /dev/null +++ b/src/main/java/org/jlab/jam/persistence/entity/RFControlVerificationHistory.java @@ -0,0 +1,166 @@ +package org.jlab.jam.persistence.entity; + +import java.io.Serializable; +import java.math.BigInteger; +import java.util.Date; +import javax.persistence.*; +import javax.validation.constraints.NotNull; + +/** + * @author ryans + */ +@Entity +@Table(name = "RF_CONTROL_VERIFICATION_HISTORY", schema = "JAM_OWNER") +public class RFControlVerificationHistory implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @SequenceGenerator( + name = "RFControlVerificationHistoryId", + sequenceName = "RF_CONTROL_VERIFICATION_HISTORY_ID", + allocationSize = 1) + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "RFControlVerificationHistoryId") + @Basic(optional = false) + @NotNull + @Column(name = "RF_CONTROL_VERIFICATION_HISTORY_ID", nullable = false, precision = 22, scale = 0) + private BigInteger rfControlVerificationHistoryId; + + @Column(name = "VERIFICATION_STATUS_ID") + @NotNull + private Integer verificationStatusId; + + @Column(name = "MODIFIED_BY", nullable = false) + private String modifiedBy; + + @Basic(optional = false) + @NotNull + @Column(name = "MODIFIED_DATE", nullable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date modifiedDate; + + @Column(name = "VERIFIED_BY", nullable = true) + private String verifiedBy; + + @Basic(optional = false) + @NotNull + @Column(name = "VERIFICATION_DATE", nullable = false) + @Temporal(TemporalType.TIMESTAMP) + private Date verificationDate; + + @Basic(optional = true) + @Column(name = "EXPIRATION_DATE", nullable = true) + @Temporal(TemporalType.TIMESTAMP) + private Date expirationDate; + + @Basic(optional = true) + @Column(name = "COMMENTS", nullable = true) + private String comments; + + @JoinColumn( + name = "RF_CONTROL_VERIFICATION_ID", + referencedColumnName = "RF_CONTROL_VERIFICATION_ID") + @ManyToOne(optional = false, fetch = FetchType.LAZY) + private RFControlVerification rfControlVerification; + + public RFControlVerificationHistory() {} + + public BigInteger getRFControlVerificationHistoryId() { + return rfControlVerificationHistoryId; + } + + public void setRFControlVerificationHistoryId(BigInteger rfControlVerificationHistoryId) { + this.rfControlVerificationHistoryId = rfControlVerificationHistoryId; + } + + public Integer getVerificationStatusId() { + return verificationStatusId; + } + + public void setVerificationStatusId(Integer verificationStatusId) { + this.verificationStatusId = verificationStatusId; + } + + public String getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public String getVerifiedBy() { + return verifiedBy; + } + + public void setVerifiedBy(String verifiedBy) { + this.verifiedBy = verifiedBy; + } + + public Date getVerificationDate() { + return verificationDate; + } + + public void setVerificationDate(Date verificationDate) { + this.verificationDate = verificationDate; + } + + public Date getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(Date expirationDate) { + this.expirationDate = expirationDate; + } + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + public RFControlVerification getRFControlVerification() { + return rfControlVerification; + } + + public void setRFControlVerification(RFControlVerification rfControlVerificationId) { + this.rfControlVerification = rfControlVerificationId; + } + + @Override + public int hashCode() { + int hash = 0; + hash += + (rfControlVerificationHistoryId != null ? rfControlVerificationHistoryId.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof RFControlVerificationHistory)) { + return false; + } + RFControlVerificationHistory other = (RFControlVerificationHistory) object; + return (this.rfControlVerificationHistoryId != null + || other.rfControlVerificationHistoryId == null) + && (this.rfControlVerificationHistoryId == null + || this.rfControlVerificationHistoryId.equals(other.rfControlVerificationHistoryId)); + } + + @Override + public String toString() { + return "org.jlab.jam.persistence.entity.RFControlVerificationHistory[ rfControlVerificationHistoryId=" + + rfControlVerificationHistoryId + + " ]"; + } +} diff --git a/src/main/java/org/jlab/jam/persistence/entity/RFSegment.java b/src/main/java/org/jlab/jam/persistence/entity/RFSegment.java new file mode 100644 index 0000000..2f563e8 --- /dev/null +++ b/src/main/java/org/jlab/jam/persistence/entity/RFSegment.java @@ -0,0 +1,125 @@ +package org.jlab.jam.persistence.entity; + +import java.math.BigInteger; +import java.util.List; +import java.util.Objects; +import javax.persistence.*; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import org.jlab.smoothness.persistence.util.YnStringToBoolean; + +@Entity +@Table(name = "RF_SEGMENT", schema = "JAM_OWNER") +public class RFSegment { + + @Id + @Column(name = "RF_SEGMENT_ID", nullable = false, precision = 0) + private BigInteger rfSegmentId; + + @NotNull + @ManyToOne + @JoinColumn(name = "FACILITY_ID", referencedColumnName = "FACILITY_ID", nullable = false) + private Facility facility; + + @Basic + @Column(name = "ACTIVE_YN", nullable = false, length = 1) + @Convert(converter = YnStringToBoolean.class) + private boolean active; + + @OneToOne(fetch = FetchType.EAGER) + @JoinColumn(name = "RF_SEGMENT_ID") + private RFControlVerification verification; + + @Size(max = 128) + @Column(length = 128) + private String name; + + @OneToMany(mappedBy = "rfSegment", fetch = FetchType.LAZY) + private List rfControlVerificationList; + + private BigInteger weight; + + public List getRFControlVerificationList() { + return rfControlVerificationList; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public BigInteger getWeight() { + return weight; + } + + public void setWeight(BigInteger weight) { + this.weight = weight; + } + + public RFControlVerification getVerification() { + return verification; + } + + public BigInteger getRFSegmentId() { + return rfSegmentId; + } + + public void setRFSegmentId(BigInteger rfSegmentId) { + this.rfSegmentId = rfSegmentId; + } + + public Facility getFacility() { + return facility; + } + + public void setFacility(Facility facility) { + this.facility = facility; + } + + public boolean isActive() { + return active; + } + + public void setActive(boolean active) { + this.active = active; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RFSegment that = (RFSegment) o; + return Objects.equals(rfSegmentId, that.rfSegmentId) + && Objects.equals(facility, that.facility) + && Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hash(rfSegmentId, facility, name); + } + + @Override + public String toString() { + return "BeamDestination{" + + "rfSegmentId=" + + rfSegmentId + + ", facility='" + + facility + + ", active=" + + active + + ", verification=" + + verification + + ", name='" + + name + + '\'' + + + // ", controlVerificationList=" + controlVerificationList + + ", weight=" + + weight + + '}'; + } +} diff --git a/src/main/java/org/jlab/jam/persistence/entity/RFSegmentAuthorization.java b/src/main/java/org/jlab/jam/persistence/entity/RFSegmentAuthorization.java new file mode 100644 index 0000000..695d501 --- /dev/null +++ b/src/main/java/org/jlab/jam/persistence/entity/RFSegmentAuthorization.java @@ -0,0 +1,158 @@ +package org.jlab.jam.persistence.entity; + +import java.io.Serializable; +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.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +/** + * @author ryans + */ +@Entity +@Table(name = "RF_SEGMENT_AUTHORIZATION", schema = "JAM_OWNER") +@NamedQueries({ + @NamedQuery( + name = "RFSegmentAuthorization.findAll", + query = "SELECT d FROM RFSegmentAuthorization d") +}) +public class RFSegmentAuthorization implements Serializable { + + private static final long serialVersionUID = 1L; + @EmbeddedId protected SegmentAuthorizationPK segmentAuthorizationPK; + + @Basic(optional = false) + @NotNull + @Size(min = 1, max = 16) + @Column(name = "RF_MODE", nullable = false, length = 16) + private String rfMode; + + @Basic(optional = true) + @Size(max = 256) + @Column(name = "COMMENTS", nullable = true, length = 256) + private String comments; + + @Column(name = "EXPIRATION_DATE") + @Temporal(TemporalType.TIMESTAMP) + private Date expirationDate; + + @JoinColumn( + name = "RF_SEGMENT_ID", + referencedColumnName = "RF_SEGMENT_ID", + nullable = false, + insertable = false, + updatable = false) + @ManyToOne(optional = false, fetch = FetchType.LAZY) + private RFSegment segment; + + @JoinColumn( + name = "RF_AUTHORIZATION_ID", + referencedColumnName = "RF_AUTHORIZATION_ID", + nullable = false, + insertable = false, + updatable = false) + @ManyToOne(optional = false, fetch = FetchType.LAZY) + private RFAuthorization rfAuthorization; + + public RFSegmentAuthorization() {} + + public RFSegmentAuthorization(SegmentAuthorizationPK segmentAuthorizationPK) { + this.segmentAuthorizationPK = segmentAuthorizationPK; + } + + public RFSegmentAuthorization(BigInteger rfSegmentId, BigInteger rfAuthorizationId) { + this.segmentAuthorizationPK = new SegmentAuthorizationPK(rfSegmentId, rfAuthorizationId); + } + + public SegmentAuthorizationPK getSegmentAuthorizationPK() { + return segmentAuthorizationPK; + } + + public void setSegmentAuthorizationPK(SegmentAuthorizationPK segmentAuthorizationPK) { + this.segmentAuthorizationPK = segmentAuthorizationPK; + } + + public RFSegment getSegment() { + return segment; + } + + public String getRFMode() { + return rfMode; + } + + public void setRFMode(String rfMode) { + this.rfMode = rfMode; + } + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + public Date getExpirationDate() { + return expirationDate; + } + + public void setExpirationDate(Date expirationDate) { + this.expirationDate = expirationDate; + } + + public RFAuthorization getRFAuthorization() { + return rfAuthorization; + } + + public void setRFAuthorization(RFAuthorization rfAuthorization) { + this.rfAuthorization = rfAuthorization; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (segmentAuthorizationPK != null ? segmentAuthorizationPK.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof RFSegmentAuthorization)) { + return false; + } + RFSegmentAuthorization other = (RFSegmentAuthorization) object; + return (this.segmentAuthorizationPK != null || other.segmentAuthorizationPK == null) + && (this.segmentAuthorizationPK == null + || this.segmentAuthorizationPK.equals(other.segmentAuthorizationPK)); + } + + @Override + public String toString() { + return "org.jlab.jam.persistence.entity.RFSegmentAuthorization[segmentAuthorizationPK=" + + segmentAuthorizationPK + + " ]"; + } + + public RFSegmentAuthorization createAdminClone(RFAuthorization authClone) { + RFSegmentAuthorization other = new RFSegmentAuthorization(); + other.rfAuthorization = authClone; + other.comments = this.comments; + other.expirationDate = this.expirationDate; + other.segment = this.segment; + + return other; + } +} diff --git a/src/main/java/org/jlab/jam/persistence/entity/SegmentAuthorizationPK.java b/src/main/java/org/jlab/jam/persistence/entity/SegmentAuthorizationPK.java new file mode 100644 index 0000000..ed327bd --- /dev/null +++ b/src/main/java/org/jlab/jam/persistence/entity/SegmentAuthorizationPK.java @@ -0,0 +1,80 @@ +package org.jlab.jam.persistence.entity; + +import java.io.Serializable; +import java.math.BigInteger; +import javax.persistence.Basic; +import javax.persistence.Column; +import javax.persistence.Embeddable; +import javax.validation.constraints.NotNull; + +/** + * @author ryans + */ +@Embeddable +public class SegmentAuthorizationPK implements Serializable { + @Basic(optional = false) + @NotNull + @Column(name = "RF_SEGMENT_ID", nullable = false) + private BigInteger rfSegmentId; + + @Basic(optional = false) + @NotNull + @Column(name = "RF_AUTHORIZATION_ID", nullable = false) + private BigInteger rfAuthorizationId; + + public SegmentAuthorizationPK() {} + + public SegmentAuthorizationPK(BigInteger rfSegmentId, BigInteger rfAuthorizationId) { + this.rfSegmentId = rfSegmentId; + this.rfAuthorizationId = rfAuthorizationId; + } + + public BigInteger getRFSegmentId() { + return rfSegmentId; + } + + public void setRFSegmentId(BigInteger rfSegmentId) { + this.rfSegmentId = rfSegmentId; + } + + public BigInteger getRFAuthorizationId() { + return rfAuthorizationId; + } + + public void setRFAuthorizationId(BigInteger rfAuthorizationId) { + this.rfAuthorizationId = rfAuthorizationId; + } + + @Override + public int hashCode() { + int hash = 0; + hash += (rfSegmentId != null ? rfSegmentId.hashCode() : 0); + hash += (rfAuthorizationId != null ? rfAuthorizationId.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object object) { + // TODO: Warning - this method won't work in the case the id fields are not set + if (!(object instanceof SegmentAuthorizationPK)) { + return false; + } + SegmentAuthorizationPK other = (SegmentAuthorizationPK) object; + if ((this.rfSegmentId == null && other.rfSegmentId != null) + || (this.rfSegmentId != null && !this.rfSegmentId.equals(other.rfSegmentId))) { + return false; + } + return (this.rfAuthorizationId != null || other.rfAuthorizationId == null) + && (this.rfAuthorizationId == null + || this.rfAuthorizationId.equals(other.rfAuthorizationId)); + } + + @Override + public String toString() { + return "org.jlab.jam.persistence.entity.SegmentAuthorizationPK[ rfSegmentId=" + + rfSegmentId + + ", authorizationId=" + + rfAuthorizationId + + " ]"; + } +} diff --git a/src/main/java/org/jlab/jam/persistence/view/BeamDestinationVerification.java b/src/main/java/org/jlab/jam/persistence/view/BeamDestinationVerification.java index 85d91f9..11af102 100644 --- a/src/main/java/org/jlab/jam/persistence/view/BeamDestinationVerification.java +++ b/src/main/java/org/jlab/jam/persistence/view/BeamDestinationVerification.java @@ -27,8 +27,8 @@ public class BeamDestinationVerification implements Serializable { @Column(name = "BEAM_DESTINATION_ID", nullable = false) private BigInteger beamDestinationId; - @Column(name = "VERIFICATION_ID") - private Integer verificationId; + @Column(name = "VERIFICATION_STATUS_ID") + private Integer verificationStatusId; @Column(name = "EXPIRATION_DATE") @Temporal(TemporalType.TIMESTAMP) @@ -40,8 +40,8 @@ public BigInteger getBeamDestinationId() { return beamDestinationId; } - public Integer getVerificationId() { - return verificationId; + public Integer getVerificationStatusId() { + return verificationStatusId; } public Date getExpirationDate() { diff --git a/src/main/java/org/jlab/jam/presentation/controller/AuthorizationHistoryController.java b/src/main/java/org/jlab/jam/presentation/controller/AuthorizationHistoryController.java index a07434f..ca7017f 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/AuthorizationHistoryController.java +++ b/src/main/java/org/jlab/jam/presentation/controller/AuthorizationHistoryController.java @@ -9,8 +9,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.jlab.jam.business.session.AuthorizationFacade; -import org.jlab.jam.persistence.entity.Authorization; +import org.jlab.jam.business.session.BeamAuthorizationFacade; +import org.jlab.jam.persistence.entity.BeamAuthorization; import org.jlab.smoothness.presentation.util.Paginator; import org.jlab.smoothness.presentation.util.ParamUtil; @@ -22,7 +22,7 @@ urlPatterns = {"/permissions/authorization-history"}) public class AuthorizationHistoryController extends HttpServlet { - @EJB AuthorizationFacade historyFacade; + @EJB BeamAuthorizationFacade historyFacade; /** * Handles the HTTP GET method. @@ -39,7 +39,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) int offset = ParamUtil.convertAndValidateNonNegativeInt(request, "offset", 0); int maxPerPage = 10; - List historyList = historyFacade.findHistory(offset, maxPerPage); + List historyList = historyFacade.findHistory(offset, maxPerPage); Long totalRecords = historyFacade.countHistory(); Paginator paginator = new Paginator(totalRecords.intValue(), offset, maxPerPage); diff --git a/src/main/java/org/jlab/jam/presentation/controller/BeamDestinationInformation.java b/src/main/java/org/jlab/jam/presentation/controller/BeamDestinationInformation.java index 2d8cd5b..22926fd 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/BeamDestinationInformation.java +++ b/src/main/java/org/jlab/jam/presentation/controller/BeamDestinationInformation.java @@ -9,10 +9,10 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.jlab.jam.business.session.BeamControlVerificationFacade; import org.jlab.jam.business.session.BeamDestinationFacade; -import org.jlab.jam.business.session.ControlVerificationFacade; +import org.jlab.jam.persistence.entity.BeamControlVerification; import org.jlab.jam.persistence.entity.BeamDestination; -import org.jlab.jam.persistence.entity.ControlVerification; import org.jlab.smoothness.presentation.util.ParamConverter; /** @@ -24,7 +24,7 @@ public class BeamDestinationInformation extends HttpServlet { @EJB BeamDestinationFacade beamDestinationFacade; - @EJB ControlVerificationFacade verificationFacade; + @EJB BeamControlVerificationFacade verificationFacade; /** * Handles the HTTP GET method. @@ -41,7 +41,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) BigInteger beamDestinationId = ParamConverter.convertBigInteger(request, "beamDestinationId"); BeamDestination beamDestination = null; - List verificationList = null; + List verificationList = null; if (beamDestinationId != null) { beamDestination = beamDestinationFacade.find(beamDestinationId); diff --git a/src/main/java/org/jlab/jam/presentation/controller/CreditedControls.java b/src/main/java/org/jlab/jam/presentation/controller/CreditedControls.java index a8ea903..bfc4430 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/CreditedControls.java +++ b/src/main/java/org/jlab/jam/presentation/controller/CreditedControls.java @@ -10,9 +10,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.jlab.jam.business.session.AbstractFacade.OrderDirective; -import org.jlab.jam.business.session.ControlVerificationFacade; +import org.jlab.jam.business.session.BeamControlVerificationFacade; import org.jlab.jam.business.session.CreditedControlFacade; -import org.jlab.jam.persistence.entity.ControlVerification; +import org.jlab.jam.persistence.entity.BeamControlVerification; import org.jlab.jam.persistence.entity.CreditedControl; import org.jlab.smoothness.presentation.util.ParamConverter; @@ -25,7 +25,7 @@ public class CreditedControls extends HttpServlet { @EJB CreditedControlFacade ccFacade; - @EJB ControlVerificationFacade verificationFacade; + @EJB BeamControlVerificationFacade verificationFacade; /** * Handles the HTTP GET method. @@ -41,8 +41,8 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) BigInteger creditedControlId = ParamConverter.convertBigInteger(request, "creditedControlId"); - List expiredList = null; - List expiringList = null; + List expiredList = null; + List expiringList = null; CreditedControl creditedControl = null; boolean adminOrLeader = false; diff --git a/src/main/java/org/jlab/jam/presentation/controller/DestinationsAuthorizationHistoryController.java b/src/main/java/org/jlab/jam/presentation/controller/DestinationsAuthorizationHistoryController.java index 05d8fbc..8d804ea 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/DestinationsAuthorizationHistoryController.java +++ b/src/main/java/org/jlab/jam/presentation/controller/DestinationsAuthorizationHistoryController.java @@ -10,11 +10,11 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.jlab.jam.business.session.AuthorizationFacade; +import org.jlab.jam.business.session.BeamAuthorizationFacade; import org.jlab.jam.business.session.BeamDestinationFacade; -import org.jlab.jam.persistence.entity.Authorization; +import org.jlab.jam.persistence.entity.BeamAuthorization; import org.jlab.jam.persistence.entity.BeamDestination; -import org.jlab.jam.persistence.entity.DestinationAuthorization; +import org.jlab.jam.persistence.entity.BeamDestinationAuthorization; import org.jlab.smoothness.presentation.util.ParamConverter; /** @@ -25,7 +25,7 @@ urlPatterns = {"/permissions/destinations-authorization-history"}) public class DestinationsAuthorizationHistoryController extends HttpServlet { - @EJB AuthorizationFacade authorizationFacade; + @EJB BeamAuthorizationFacade beamAuthorizationFacade; @EJB BeamDestinationFacade beamDestinationFacade; /** @@ -42,21 +42,21 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) BigInteger authorizationId = ParamConverter.convertBigInteger(request, "authorizationId"); - Authorization authorization = null; + BeamAuthorization beamAuthorization = null; if (authorizationId != null) { - authorization = authorizationFacade.find(authorizationId); + beamAuthorization = beamAuthorizationFacade.find(authorizationId); } List cebafDestinationList = beamDestinationFacade.findCebafDestinations(); List lerfDestinationList = beamDestinationFacade.findLerfDestinations(); List uitfDestinationList = beamDestinationFacade.findUitfDestinations(); - Map destinationAuthorizationMap = - authorizationFacade.createDestinationAuthorizationMap(authorization); + Map destinationAuthorizationMap = + beamAuthorizationFacade.createDestinationAuthorizationMap(beamAuthorization); - request.setAttribute("unitsMap", authorizationFacade.getUnitsMap()); - request.setAttribute("authorization", authorization); + request.setAttribute("unitsMap", beamAuthorizationFacade.getUnitsMap()); + request.setAttribute("authorization", beamAuthorization); request.setAttribute("cebafDestinationList", cebafDestinationList); request.setAttribute("lerfDestinationList", lerfDestinationList); request.setAttribute("uitfDestinationList", uitfDestinationList); diff --git a/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java b/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java index 0d292f0..8963535 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java +++ b/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java @@ -36,10 +36,11 @@ public class FacilityAuthorization extends HttpServlet { private static final Logger LOGGER = Logger.getLogger(FacilityAuthorization.class.getName()); - @EJB AuthorizationFacade authorizationFacade; + @EJB BeamAuthorizationFacade beamAuthorizationFacade; @EJB BeamDestinationFacade beamDestinationFacade; - @EJB ControlVerificationFacade verificationFacade; + @EJB BeamControlVerificationFacade verificationFacade; @EJB FacilityFacade facilityFacade; + @EJB RFSegmentFacade rfSegmentFacade; /** * Handles the HTTP GET method. @@ -68,17 +69,19 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) verificationFacade.performExpirationCheck(false); - Authorization authorization = authorizationFacade.findCurrent(); + BeamAuthorization beamAuthorization = beamAuthorizationFacade.findCurrent(); + List rfList = rfSegmentFacade.findByFacility(facility); List beamList = beamDestinationFacade.findByFacility(facility); - Map destinationAuthorizationMap = - authorizationFacade.createDestinationAuthorizationMap(authorization); + Map destinationAuthorizationMap = + beamAuthorizationFacade.createDestinationAuthorizationMap(beamAuthorization); request.setAttribute("facility", facility); request.setAttribute("facilityList", facilityList); - request.setAttribute("unitsMap", authorizationFacade.getUnitsMap()); - request.setAttribute("authorization", authorization); + request.setAttribute("unitsMap", beamAuthorizationFacade.getUnitsMap()); + request.setAttribute("authorization", beamAuthorization); + request.setAttribute("rfList", rfList); request.setAttribute("beamList", beamList); request.setAttribute("destinationAuthorizationMap", destinationAuthorizationMap); @@ -118,10 +121,10 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) } try { - List destinationAuthorizationList = + List beamDestinationAuthorizationList = convertDestinationAuthorizationList(request); - authorizationFacade.saveAuthorization(comments, destinationAuthorizationList); + beamAuthorizationFacade.saveAuthorization(comments, beamDestinationAuthorizationList); } catch (UserFriendlyException e) { errorReason = e.getUserMessage(); LOGGER.log(Level.INFO, "Unable to save authorization: " + errorReason); @@ -134,7 +137,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) String proxyServer = System.getenv("FRONTEND_SERVER_URL"); try { - authorizationFacade.sendOpsNewAuthorizationEmail(proxyServer, comments); + beamAuthorizationFacade.sendOpsNewAuthorizationEmail(proxyServer, comments); } catch (UserFriendlyException e) { errorReason = "Authorization was saved, but we were unable to send to ops an email. "; LOGGER.log(Level.SEVERE, errorReason, e); @@ -143,7 +146,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) try { String logbookServer = System.getenv("LOGBOOK_SERVER_URL"); - logId = authorizationFacade.sendELog(proxyServer, logbookServer); + logId = beamAuthorizationFacade.sendELog(proxyServer, logbookServer); } catch (Exception e) { errorReason = "Authorization was saved, but we were unable to send to eLog"; LOGGER.log(Level.SEVERE, errorReason, e); @@ -179,9 +182,9 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) } } - private List convertDestinationAuthorizationList( + private List convertDestinationAuthorizationList( HttpServletRequest request) throws UserFriendlyException { - List destinationAuthorizationList = new ArrayList<>(); + List beamDestinationAuthorizationList = new ArrayList<>(); String[] modeArray = request.getParameterValues("mode[]"); String[] limitStrArray = request.getParameterValues("limit[]"); String[] commentsArray = request.getParameterValues("comment[]"); @@ -203,7 +206,7 @@ private List convertDestinationAuthorizationList( for (int i = 0; i < modeArray.length; i++) { String mode = modeArray[i]; - DestinationAuthorization da = new DestinationAuthorization(); + BeamDestinationAuthorization da = new BeamDestinationAuthorization(); da.setBeamMode(mode); @@ -247,10 +250,10 @@ private List convertDestinationAuthorizationList( pk.setBeamDestinationId(beamDestinationId); da.setDestinationAuthorizationPK(pk); - destinationAuthorizationList.add(da); + beamDestinationAuthorizationList.add(da); } } - return destinationAuthorizationList; + return beamDestinationAuthorizationList; } } diff --git a/src/main/java/org/jlab/jam/presentation/controller/VerificationHistoryController.java b/src/main/java/org/jlab/jam/presentation/controller/VerificationHistoryController.java index 46e9ed6..7bb6a68 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/VerificationHistoryController.java +++ b/src/main/java/org/jlab/jam/presentation/controller/VerificationHistoryController.java @@ -10,11 +10,11 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.jlab.jam.business.session.ControlVerificationFacade; +import org.jlab.jam.business.session.BeamControlVerificationFacade; import org.jlab.jam.business.session.CreditedControlFacade; import org.jlab.jam.business.session.VerificationHistoryFacade; -import org.jlab.jam.persistence.entity.ControlVerification; -import org.jlab.jam.persistence.entity.VerificationHistory; +import org.jlab.jam.persistence.entity.BeamControlVerification; +import org.jlab.jam.persistence.entity.BeamControlVerificationHistory; import org.jlab.smoothness.presentation.util.Paginator; import org.jlab.smoothness.presentation.util.ParamConverter; import org.jlab.smoothness.presentation.util.ParamUtil; @@ -28,7 +28,7 @@ public class VerificationHistoryController extends HttpServlet { @EJB VerificationHistoryFacade historyFacade; - @EJB ControlVerificationFacade verificationFacade; + @EJB BeamControlVerificationFacade verificationFacade; @EJB CreditedControlFacade creditedControlFacade; /** @@ -48,10 +48,10 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) int offset = ParamUtil.convertAndValidateNonNegativeInt(request, "offset", 0); int maxPerPage = 10; - ControlVerification verification = + BeamControlVerification verification = verificationFacade.findWithCreditedControl(controlVerificationId); - List historyList = + List historyList = historyFacade.findHistory(controlVerificationId, offset, maxPerPage); Long totalRecords = historyFacade.countHistory(controlVerificationId); diff --git a/src/main/java/org/jlab/jam/presentation/controller/ajax/EditCc.java b/src/main/java/org/jlab/jam/presentation/controller/ajax/EditCc.java index 5c4cfde..abe7c78 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/ajax/EditCc.java +++ b/src/main/java/org/jlab/jam/presentation/controller/ajax/EditCc.java @@ -13,8 +13,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.jlab.jam.business.session.ControlVerificationFacade; -import org.jlab.jam.persistence.entity.ControlVerification; +import org.jlab.jam.business.session.BeamControlVerificationFacade; +import org.jlab.jam.persistence.entity.BeamControlVerification; import org.jlab.smoothness.business.exception.UserFriendlyException; import org.jlab.smoothness.presentation.util.ParamConverter; @@ -27,7 +27,7 @@ public class EditCc extends HttpServlet { private static final Logger logger = Logger.getLogger(EditCc.class.getName()); - @EJB ControlVerificationFacade verificationFacade; + @EJB BeamControlVerificationFacade verificationFacade; /** * Handles the HTTP POST method. @@ -42,7 +42,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String errorReason = null; - List downgradeList = null; + List downgradeList = null; try { BigInteger[] verificationIdArray = diff --git a/src/main/java/org/jlab/jam/presentation/controller/ajax/ToggleControlParticipation.java b/src/main/java/org/jlab/jam/presentation/controller/ajax/ToggleControlParticipation.java index 9067407..5e1a00d 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/ajax/ToggleControlParticipation.java +++ b/src/main/java/org/jlab/jam/presentation/controller/ajax/ToggleControlParticipation.java @@ -12,7 +12,7 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.jlab.jam.business.session.ControlVerificationFacade; +import org.jlab.jam.business.session.BeamControlVerificationFacade; import org.jlab.smoothness.presentation.util.ParamConverter; /** @@ -25,7 +25,7 @@ public class ToggleControlParticipation extends HttpServlet { private static final Logger logger = Logger.getLogger(ToggleControlParticipation.class.getName()); - @EJB ControlVerificationFacade verificationFacade; + @EJB BeamControlVerificationFacade verificationFacade; /** * Handles the HTTP POST method. diff --git a/src/main/webapp/WEB-INF/tags/destination-permissions-table.tag b/src/main/webapp/WEB-INF/tags/destination-permissions-table.tag index b0c1724..d634073 100644 --- a/src/main/webapp/WEB-INF/tags/destination-permissions-table.tag +++ b/src/main/webapp/WEB-INF/tags/destination-permissions-table.tag @@ -28,14 +28,14 @@ - + - + @@ -45,7 +45,7 @@ - +
- - + + @@ -90,10 +90,10 @@ - + - beamauth:now().time and destinationAuthorization.expirationDate.time < beamauth:twoDaysFromNow().time ? 'display: block;' : 'display: none;'}"/>">(Expiring Soon) + beamauth:now().time and beamDestinationAuthorization.expirationDate.time < beamauth:twoDaysFromNow().time ? 'display: block;' : 'display: none;'}"/>">(Expiring Soon) @@ -103,10 +103,10 @@ - + - + diff --git a/src/main/webapp/WEB-INF/tags/permissions-page.tag b/src/main/webapp/WEB-INF/tags/permissions-page.tag index ada3cde..986e6f5 100644 --- a/src/main/webapp/WEB-INF/tags/permissions-page.tag +++ b/src/main/webapp/WEB-INF/tags/permissions-page.tag @@ -9,64 +9,68 @@ <%@attribute name="beamList" required="true" type="java.util.List"%> <%@attribute name="isEditable" required="true" type="java.lang.Boolean"%> <%@attribute name="isHistory" required="true" type="java.lang.Boolean"%> - +

-

RF Operations

- - - - -
-
Note: Blank/Empty Current Limit results in "Dump Power Limited"
-

Beam Operations

- -

Notes

-
+
+

RF Operations

+
+ +
+
+
+

Beam Operations

+
+
Note: Blank/Empty Current Limit results in "Dump Power Limited"
+ +

Notes

+
- + - - + + -
-

Digital Signature

-
diff --git a/src/main/webapp/WEB-INF/tags/rf-operations-table.tag b/src/main/webapp/WEB-INF/tags/rf-operations-table.tag new file mode 100644 index 0000000..2e37b94 --- /dev/null +++ b/src/main/webapp/WEB-INF/tags/rf-operations-table.tag @@ -0,0 +1,85 @@ +<%@tag description="RF Operations Table Tag" pageEncoding="UTF-8"%> +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> +<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> +<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> +<%@taglib prefix="s" uri="http://jlab.org/jsp/smoothness" %> +<%@taglib prefix="beamauth" uri="http://jlab.org/beamauth/functions"%> +<%@taglib prefix="t" tagdir="/WEB-INF/tags"%> +<%@attribute name="rfList" required="true" type="java.util.List"%> +<%@attribute name="isHistory" required="true" type="java.lang.Boolean"%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SegmentApprovalDirector's StatusCredited Controls Status
CommentExpiration
+ + + + + + + + + + + + + + + + + + + + + beamauth:now().time and beamDestinationAuthorization.expirationDate.time < beamauth:twoDaysFromNow().time ? 'display: block;' : 'display: none;'}"/>">(Expiring Soon) + + + + + + + + + + + + + + + + + + beamauth:now().time and segment.verification.expirationDate.time < beamauth:twoDaysFromNow().time ? 'display: block;' : 'display: none;'}"/>">(Expiring Soon) + +
\ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/beam-destination-information.jsp b/src/main/webapp/WEB-INF/views/beam-destination-information.jsp index 654d79d..03395ce 100644 --- a/src/main/webapp/WEB-INF/views/beam-destination-information.jsp +++ b/src/main/webapp/WEB-INF/views/beam-destination-information.jsp @@ -18,10 +18,10 @@

- + - + @@ -46,10 +46,10 @@ - + - + diff --git a/src/main/webapp/WEB-INF/views/credited-controls.jsp b/src/main/webapp/WEB-INF/views/credited-controls.jsp index fed382e..401ca40 100644 --- a/src/main/webapp/WEB-INF/views/credited-controls.jsp +++ b/src/main/webapp/WEB-INF/views/credited-controls.jsp @@ -80,7 +80,7 @@

Verifications

- +
None
@@ -112,16 +112,16 @@ - - + + - + -
+
@@ -142,7 +142,7 @@ - History + History
diff --git a/src/main/webapp/WEB-INF/views/credited-controls/verification-history.jsp b/src/main/webapp/WEB-INF/views/credited-controls/verification-history.jsp index 56c0d1a..694c3f6 100644 --- a/src/main/webapp/WEB-INF/views/credited-controls/verification-history.jsp +++ b/src/main/webapp/WEB-INF/views/credited-controls/verification-history.jsp @@ -58,7 +58,7 @@ - + @@ -66,7 +66,7 @@ - + diff --git a/src/main/webapp/WEB-INF/views/destinations.jsp b/src/main/webapp/WEB-INF/views/destinations.jsp index ef7a8a5..000bae2 100644 --- a/src/main/webapp/WEB-INF/views/destinations.jsp +++ b/src/main/webapp/WEB-INF/views/destinations.jsp @@ -49,7 +49,7 @@

Verifications

- +
None
@@ -79,20 +79,20 @@ - - + + - + ; - + - + diff --git a/src/main/webapp/WEB-INF/views/permissions/authorization-history.jsp b/src/main/webapp/WEB-INF/views/permissions/authorization-history.jsp index c2afc80..49dc88c 100644 --- a/src/main/webapp/WEB-INF/views/permissions/authorization-history.jsp +++ b/src/main/webapp/WEB-INF/views/permissions/authorization-history.jsp @@ -35,7 +35,7 @@
- +
@@ -54,12 +54,12 @@ - +
Modified Date Destination DetailsDestination Details
-
+
diff --git a/src/main/webapp/WEB-INF/views/permissions/destinations-authorization-history.jsp b/src/main/webapp/WEB-INF/views/permissions/destinations-authorization-history.jsp index 07bcb0a..13c7e7e 100644 --- a/src/main/webapp/WEB-INF/views/permissions/destinations-authorization-history.jsp +++ b/src/main/webapp/WEB-INF/views/permissions/destinations-authorization-history.jsp @@ -18,16 +18,16 @@ Director's Authorization
  • - Historic Authorizations + Historic Authorizations
  • - History + History
  • - + diff --git a/src/main/webapp/resources/css/permissions.css b/src/main/webapp/resources/css/permissions.css index c362e0c..943159c 100644 --- a/src/main/webapp/resources/css/permissions.css +++ b/src/main/webapp/resources/css/permissions.css @@ -65,4 +65,11 @@ textarea[readonly] { } #cancel-button { vertical-align: bottom; +} + +.accordion .ui-widget-content a { + color: blue; +} +.accordion .ui-widget-content a:hover { + color: red; } \ No newline at end of file diff --git a/src/main/webapp/resources/js/permissions.js b/src/main/webapp/resources/js/permissions.js index 132c7c4..31b42ca 100644 --- a/src/main/webapp/resources/js/permissions.js +++ b/src/main/webapp/resources/js/permissions.js @@ -139,4 +139,10 @@ $(function () { hour: 8, beforeShow: function(i) { if ($(i).attr('readonly')) { return false; } } }).mask("99-aaa-9999 99:99", {placeholder: " "}); -}); + + $( ".accordion" ).accordion({ + collapsible: true, + heightStyle: "content", + active: 0 + }); +}); \ No newline at end of file From 1d4e62d5dc8366b859fa05ffbd8ac9ed26c2f4a6 Mon Sep 17 00:00:00 2001 From: Ryan Slominski Date: Mon, 27 Jan 2025 16:45:22 -0500 Subject: [PATCH 03/44] Separate Facilities --- container/oracle/initdb.d/03_default_data.sql | 12 ++- .../session/BeamDestinationFacade.java | 2 +- .../session/RFAuthorizationFacade.java | 42 +++++----- .../jam/business/session/RFSegmentFacade.java | 2 +- .../controller/FacilityAuthorization.java | 7 +- .../webapp/WEB-INF/tags/permissions-page.tag | 82 +++++++++++-------- .../WEB-INF/tags/rf-operations-table.tag | 15 ++-- 7 files changed, 92 insertions(+), 70 deletions(-) diff --git a/container/oracle/initdb.d/03_default_data.sql b/container/oracle/initdb.d/03_default_data.sql index fbf2f52..75c44b6 100644 --- a/container/oracle/initdb.d/03_default_data.sql +++ b/container/oracle/initdb.d/03_default_data.sql @@ -35,6 +35,15 @@ insert into JAM_OWNER.CREDITED_CONTROL (CREDITED_CONTROL_ID,NAME,DESCRIPTION,WOR insert into JAM_OWNER.CREDITED_CONTROL (CREDITED_CONTROL_ID,NAME,DESCRIPTION,WORKGROUP_ID,WEIGHT,VERIFICATION_FREQUENCY) values (JAM_OWNER.CREDITED_CONTROL_ID.nextval,'Control 5','Control 5 Description',1,5,'1 Year'); insert into JAM_OWNER.CREDITED_CONTROL (CREDITED_CONTROL_ID,NAME,DESCRIPTION,WORKGROUP_ID,WEIGHT,VERIFICATION_FREQUENCY) values (JAM_OWNER.CREDITED_CONTROL_ID.nextval,'Control 6','Control 6 Description',1,6,'1 Year'); +-- Populate RF Segments +insert into JAM_OWNER.rf_segment (RF_SEGMENT_ID, NAME, FACILITY_ID, ACTIVE_YN, WEIGHT) values(JAM_OWNER.rf_segment_id.nextval, 'Injector', 1, 'Y', 1); +insert into JAM_OWNER.rf_segment (RF_SEGMENT_ID, NAME, FACILITY_ID, ACTIVE_YN, WEIGHT) values(JAM_OWNER.rf_segment_id.nextval, 'North Linac', 1, 'Y', 2); +insert into JAM_OWNER.rf_segment (RF_SEGMENT_ID, NAME, FACILITY_ID, ACTIVE_YN, WEIGHT) values(JAM_OWNER.rf_segment_id.nextval, 'South Linac', 1, 'Y', 3); +insert into JAM_OWNER.rf_segment (RF_SEGMENT_ID, NAME, FACILITY_ID, ACTIVE_YN, WEIGHT) values(JAM_OWNER.rf_segment_id.nextval, 'Entire Facility', 2, 'Y', 1); +insert into JAM_OWNER.rf_segment (RF_SEGMENT_ID, NAME, FACILITY_ID, ACTIVE_YN, WEIGHT) values(JAM_OWNER.rf_segment_id.nextval, 'Entire Facility', 3, 'Y', 1); +insert into JAM_OWNER.rf_segment (RF_SEGMENT_ID, NAME, FACILITY_ID, ACTIVE_YN, WEIGHT) values(JAM_OWNER.rf_segment_id.nextval, 'Entire Facility', 4, 'Y', 1); +insert into JAM_OWNER.rf_segment (RF_SEGMENT_ID, NAME, FACILITY_ID, ACTIVE_YN, WEIGHT) values(JAM_OWNER.rf_segment_id.nextval, 'Entire Facility', 5, 'Y', 1); + -- Populate Beam Destinations insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 1', 1, 'uA', 'Y', 1); insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 2', 1, 'uA', 'Y', 2); @@ -45,9 +54,8 @@ insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 7', 3, 'uA', 'Y', 7); insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 8', 3, 'uA', 'Y', 8); insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Destination 9', 3, 'uA', 'Y', 9); -insert into JAM_OWNER.beam_destination (BEAM_DESTINATION_ID, NAME, FACILITY_ID, CURRENT_LIMIT_UNITS, ACTIVE_YN, WEIGHT) values(JAM_OWNER.beam_destination_id.nextval, 'Injector RF Operations', 1, 'uA', 'Y', 9); --- Populate Initial Control Verification +-- Populate Initial Beam Control Verification insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 1, 1, 100, sysdate, 'admin', null, null, 'admin', sysdate); insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 2, 2, 100, sysdate, 'admin', null, null, 'admin', sysdate); insert into JAM_OWNER.beam_control_verification (BEAM_CONTROL_VERIFICATION_ID, CREDITED_CONTROL_ID, BEAM_DESTINATION_ID, VERIFICATION_STATUS_ID, VERIFICATION_DATE, VERIFIED_BY, EXPIRATION_DATE, COMMENTS, MODIFIED_BY, MODIFIED_DATE) values(JAM_OWNER.beam_control_verification_id.nextval, 3, 3, 100, sysdate, 'admin', null, null, 'admin', sysdate); diff --git a/src/main/java/org/jlab/jam/business/session/BeamDestinationFacade.java b/src/main/java/org/jlab/jam/business/session/BeamDestinationFacade.java index a170b4c..2b1f07d 100644 --- a/src/main/java/org/jlab/jam/business/session/BeamDestinationFacade.java +++ b/src/main/java/org/jlab/jam/business/session/BeamDestinationFacade.java @@ -129,7 +129,7 @@ public List findByFacility(Facility facility) { List orders = new ArrayList<>(); Path p0 = root.get("weight"); - Order o0 = cb.desc(p0); + Order o0 = cb.asc(p0); orders.add(o0); cq.orderBy(orders); diff --git a/src/main/java/org/jlab/jam/business/session/RFAuthorizationFacade.java b/src/main/java/org/jlab/jam/business/session/RFAuthorizationFacade.java index d7a85a4..14aee2f 100644 --- a/src/main/java/org/jlab/jam/business/session/RFAuthorizationFacade.java +++ b/src/main/java/org/jlab/jam/business/session/RFAuthorizationFacade.java @@ -78,21 +78,21 @@ public HashMap getUnitsMap() { @SuppressWarnings("unchecked") @PermitAll - public BeamAuthorization findCurrent() { + public RFAuthorization findCurrent() { Query q = em.createNativeQuery( - "select * from (select * from authorization order by modified_date desc) where rownum <= 1", - BeamAuthorization.class); + "select * from (select * from rf_authorization order by modified_date desc) where rownum <= 1", + RFAuthorization.class); - List beamAuthorizationList = q.getResultList(); + List rfAuthorizationList = q.getResultList(); - BeamAuthorization beamAuthorization = null; + RFAuthorization rfAuthorization = null; - if (beamAuthorizationList != null && !beamAuthorizationList.isEmpty()) { - beamAuthorization = beamAuthorizationList.get(0); + if (rfAuthorizationList != null && !rfAuthorizationList.isEmpty()) { + rfAuthorization = rfAuthorizationList.get(0); } - return beamAuthorization; + return rfAuthorization; } @SuppressWarnings("unchecked") @@ -114,20 +114,20 @@ public Long countHistory() { } @PermitAll - public Map createDestinationAuthorizationMap( - BeamAuthorization beamAuthorization) { - Map destinationAuthorizationMap = new HashMap<>(); - - if (beamAuthorization != null && beamAuthorization.getDestinationAuthorizationList() != null) { - for (BeamDestinationAuthorization beamDestinationAuthorization : - beamAuthorization.getDestinationAuthorizationList()) { - destinationAuthorizationMap.put( - beamDestinationAuthorization.getDestinationAuthorizationPK().getBeamDestinationId(), - beamDestinationAuthorization); + public Map createSegmentAuthorizationMap( + RFAuthorization rfAuthorization) { + Map segmentAuthorizationMap = new HashMap<>(); + + if (rfAuthorization != null && rfAuthorization.getRFSegmentAuthorizationList() != null) { + for (RFSegmentAuthorization rfSegmentAuthorization : + rfAuthorization.getRFSegmentAuthorizationList()) { + segmentAuthorizationMap.put( + rfSegmentAuthorization.getSegmentAuthorizationPK().getRFSegmentId(), + rfSegmentAuthorization); } } - return destinationAuthorizationMap; + return segmentAuthorizationMap; } @RolesAllowed("jam-admin") @@ -228,9 +228,9 @@ public void sendOpsNewAuthorizationEmail(String linkHostName, String comments) public long sendELog(String proxyServer, String logbookServer) throws UserFriendlyException { String username = checkAuthenticated(); - BeamAuthorization beamAuthorization = findCurrent(); + RFAuthorization rfAuthorization = findCurrent(); - if (beamAuthorization == null) { + if (rfAuthorization == null) { throw new UserFriendlyException("No authorizations found"); } diff --git a/src/main/java/org/jlab/jam/business/session/RFSegmentFacade.java b/src/main/java/org/jlab/jam/business/session/RFSegmentFacade.java index 1431d16..97ec999 100644 --- a/src/main/java/org/jlab/jam/business/session/RFSegmentFacade.java +++ b/src/main/java/org/jlab/jam/business/session/RFSegmentFacade.java @@ -46,7 +46,7 @@ public List findByFacility(Facility facility) { List orders = new ArrayList<>(); Path p0 = root.get("weight"); - Order o0 = cb.desc(p0); + Order o0 = cb.asc(p0); orders.add(o0); cq.orderBy(orders); diff --git a/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java b/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java index 8963535..82d349c 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java +++ b/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java @@ -36,6 +36,7 @@ public class FacilityAuthorization extends HttpServlet { private static final Logger LOGGER = Logger.getLogger(FacilityAuthorization.class.getName()); + @EJB RFAuthorizationFacade rfAuthorizationFacade; @EJB BeamAuthorizationFacade beamAuthorizationFacade; @EJB BeamDestinationFacade beamDestinationFacade; @EJB BeamControlVerificationFacade verificationFacade; @@ -56,8 +57,6 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) String pathInfo = request.getPathInfo(); - System.err.println("PathInfo: " + pathInfo); - Facility facility = facilityFacade.findByPath(pathInfo); if (facility == null) { @@ -69,6 +68,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) verificationFacade.performExpirationCheck(false); + RFAuthorization rfAuthorization = rfAuthorizationFacade.findCurrent(); BeamAuthorization beamAuthorization = beamAuthorizationFacade.findCurrent(); List rfList = rfSegmentFacade.findByFacility(facility); @@ -77,6 +77,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) Map destinationAuthorizationMap = beamAuthorizationFacade.createDestinationAuthorizationMap(beamAuthorization); + Map segmentAuthorizationMap = + rfAuthorizationFacade.createSegmentAuthorizationMap(rfAuthorization); + request.setAttribute("facility", facility); request.setAttribute("facilityList", facilityList); request.setAttribute("unitsMap", beamAuthorizationFacade.getUnitsMap()); diff --git a/src/main/webapp/WEB-INF/tags/permissions-page.tag b/src/main/webapp/WEB-INF/tags/permissions-page.tag index 986e6f5..34e2eae 100644 --- a/src/main/webapp/WEB-INF/tags/permissions-page.tag +++ b/src/main/webapp/WEB-INF/tags/permissions-page.tag @@ -19,58 +19,72 @@

    RF Operations

    - + + + + + + None + +

    Beam Operations

    -
    Note: Blank/Empty Current Limit results in "Dump Power Limited"
    - -

    Notes

    -
    + + +
    Note: Blank/Empty Current Limit results in "Dump Power Limited"
    + +

    Notes

    +
    - + -
    -

    Digital Signature

    -
    diff --git a/src/main/webapp/WEB-INF/tags/rf-operations-table.tag b/src/main/webapp/WEB-INF/tags/rf-operations-table.tag index 2e37b94..5c5cbd0 100644 --- a/src/main/webapp/WEB-INF/tags/rf-operations-table.tag +++ b/src/main/webapp/WEB-INF/tags/rf-operations-table.tag @@ -26,14 +26,13 @@ - - + - + - + @@ -43,16 +42,16 @@ - + - + - + beamauth:now().time and beamDestinationAuthorization.expirationDate.time < beamauth:twoDaysFromNow().time ? 'display: block;' : 'display: none;'}"/>">(Expiring Soon) @@ -63,7 +62,6 @@ - @@ -76,7 +74,6 @@ beamauth:now().time and segment.verification.expirationDate.time < beamauth:twoDaysFromNow().time ? 'display: block;' : 'display: none;'}"/>">(Expiring Soon) - From cdf831dba38063cf1ffbf3c5aa806ed6b6e496ef Mon Sep 17 00:00:00 2001 From: Ryan Slominski Date: Mon, 27 Jan 2025 17:01:31 -0500 Subject: [PATCH 04/44] Separate Facilities --- .../jam/presentation/util/BeamAuthFunctions.java | 7 +++++++ src/main/webapp/WEB-INF/functions.tld | 5 +++++ .../webapp/WEB-INF/tags/rf-operations-table.tag | 15 ++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jlab/jam/presentation/util/BeamAuthFunctions.java b/src/main/java/org/jlab/jam/presentation/util/BeamAuthFunctions.java index 5a94768..d2da32c 100644 --- a/src/main/java/org/jlab/jam/presentation/util/BeamAuthFunctions.java +++ b/src/main/java/org/jlab/jam/presentation/util/BeamAuthFunctions.java @@ -47,6 +47,13 @@ public static List beamModeList(String facility, String destination) { return modes; } + public static List rfModeList(String facility, String segment) { + List modes = Arrays.asList("None", "RF On"); + ; + + return modes; + } + public static List laseModeList() { return Arrays.asList("None", "UV", "IR"); } diff --git a/src/main/webapp/WEB-INF/functions.tld b/src/main/webapp/WEB-INF/functions.tld index ea78d72..84c9f3a 100644 --- a/src/main/webapp/WEB-INF/functions.tld +++ b/src/main/webapp/WEB-INF/functions.tld @@ -15,6 +15,11 @@ org.jlab.jam.presentation.util.BeamAuthFunctions java.util.List beamModeList(java.lang.String, java.lang.String) + + rfModeList + org.jlab.jam.presentation.util.BeamAuthFunctions + java.util.List rfModeList(java.lang.String, java.lang.String) + laseModeList org.jlab.jam.presentation.util.BeamAuthFunctions diff --git a/src/main/webapp/WEB-INF/tags/rf-operations-table.tag b/src/main/webapp/WEB-INF/tags/rf-operations-table.tag index 5c5cbd0..2f536b2 100644 --- a/src/main/webapp/WEB-INF/tags/rf-operations-table.tag +++ b/src/main/webapp/WEB-INF/tags/rf-operations-table.tag @@ -14,12 +14,13 @@ Approval - Director's Status + Director's Status Credited Controls Status + RF Mode Comment Expiration @@ -41,6 +42,18 @@ + + +
    +
    + + +
    + From ac53394de2f254f78240aad4da8ab0509f3501d6 Mon Sep 17 00:00:00 2001 From: Ryan Slominski Date: Mon, 27 Jan 2025 17:32:21 -0500 Subject: [PATCH 05/44] Separate Facilities --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1bb85d2..fab5ad9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # jam [![CI](https://github.com/JeffersonLab/jam/actions/workflows/ci.yaml/badge.svg)](https://github.com/JeffersonLab/jam/actions/workflows/ci.yaml) [![Docker](https://img.shields.io/docker/v/jeffersonlab/jam?sort=semver&label=DockerHub)](https://hub.docker.com/r/jeffersonlab/jam) -A [Java EE 8](https://en.wikipedia.org/wiki/Jakarta_EE) web application for both beam and RF operations beamAuthorization at Jefferson Lab built with the [Smoothness](https://github.com/JeffersonLab/smoothness) web template. +A [Java EE 8](https://en.wikipedia.org/wiki/Jakarta_EE) web application for both beam and RF operations Authorization at Jefferson Lab built with the [Smoothness](https://github.com/JeffersonLab/smoothness) web template. ![Screenshot](https://github.com/JeffersonLab/jam/raw/main/Screenshot.png?raw=true "Screenshot") @@ -16,7 +16,7 @@ A [Java EE 8](https://en.wikipedia.org/wiki/Jakarta_EE) web application for both --- ## Overview -The Authorization application allows the Director of Operations (or a delegate) to clearly communicate and document beamAuthorization for various facilities at JLab to either generate beam or engage in RF operations. For beam generation the maximum current and beam mode ("permissions") that are authorized are provided for a given beam destination. This information is stored in a database and presented via the web for easy access. There are three beam generating facilities, each with their own set of beam destinations and beam modes: CEBAF, LERF, UITF. There are seven facilities which generate RF: CEBAF Injector, CEBAF North Linac, CEBAF South Linac, LERF, CMTF, and VTA. In addition to director beamAuthorization, the app also tracks Credited Controls and their verification. Each beam destination is assigned a set of controls and each control is assigned to a particular responsible group. A beam desintation is ready for beam only if all the controls assigned are verified by their responsible group. Both group verifications and director permissions have expirations. Emails and Jefferson Lab logbook entires are created to aid communication of new director permissions, responsible group verifications (upgrades and downgrades), and verification and permissions expirations. +The Authorization application allows the Director of Operations (or a delegate) to clearly communicate and document Authorization for various facilities at JLab to either generate beam or engage in RF operations. For beam generation the maximum current and beam mode ("permissions") that are authorized are provided for a given beam destination. This information is stored in a database and presented via the web for easy access. There are three beam generating facilities, each with their own set of beam destinations and beam modes: CEBAF, LERF, UITF. There are seven facilities which generate RF: CEBAF Injector, CEBAF North Linac, CEBAF South Linac, LERF, CMTF, and VTA. In addition to director Authorization, the app also tracks Credited Controls and their verification. Each beam destination is assigned a set of controls and each control is assigned to a particular responsible group. A beam desintation is ready for beam only if all the controls assigned are verified by their responsible group. Both group verifications and director permissions have expirations. Emails and Jefferson Lab logbook entires are created to aid communication of new director permissions, responsible group verifications (upgrades and downgrades), and verification and permissions expirations. ### Roles - **Operations Director** - Responsible for authorizing beam From d795a595383b2fa4bb229f7cdc84c30cd391721e Mon Sep 17 00:00:00 2001 From: Ryan Slominski Date: Mon, 27 Jan 2025 17:33:18 -0500 Subject: [PATCH 06/44] Separate Facilities --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fab5ad9..8fe990d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # jam [![CI](https://github.com/JeffersonLab/jam/actions/workflows/ci.yaml/badge.svg)](https://github.com/JeffersonLab/jam/actions/workflows/ci.yaml) [![Docker](https://img.shields.io/docker/v/jeffersonlab/jam?sort=semver&label=DockerHub)](https://hub.docker.com/r/jeffersonlab/jam) -A [Java EE 8](https://en.wikipedia.org/wiki/Jakarta_EE) web application for both beam and RF operations Authorization at Jefferson Lab built with the [Smoothness](https://github.com/JeffersonLab/smoothness) web template. +A [Java EE 8](https://en.wikipedia.org/wiki/Jakarta_EE) web application for both beam and RF operations authorization at Jefferson Lab built with the [Smoothness](https://github.com/JeffersonLab/smoothness) web template. ![Screenshot](https://github.com/JeffersonLab/jam/raw/main/Screenshot.png?raw=true "Screenshot") @@ -16,7 +16,7 @@ A [Java EE 8](https://en.wikipedia.org/wiki/Jakarta_EE) web application for both --- ## Overview -The Authorization application allows the Director of Operations (or a delegate) to clearly communicate and document Authorization for various facilities at JLab to either generate beam or engage in RF operations. For beam generation the maximum current and beam mode ("permissions") that are authorized are provided for a given beam destination. This information is stored in a database and presented via the web for easy access. There are three beam generating facilities, each with their own set of beam destinations and beam modes: CEBAF, LERF, UITF. There are seven facilities which generate RF: CEBAF Injector, CEBAF North Linac, CEBAF South Linac, LERF, CMTF, and VTA. In addition to director Authorization, the app also tracks Credited Controls and their verification. Each beam destination is assigned a set of controls and each control is assigned to a particular responsible group. A beam desintation is ready for beam only if all the controls assigned are verified by their responsible group. Both group verifications and director permissions have expirations. Emails and Jefferson Lab logbook entires are created to aid communication of new director permissions, responsible group verifications (upgrades and downgrades), and verification and permissions expirations. +The authorization application allows the Director of Operations (or a delegate) to clearly communicate and document authorization for various facilities at JLab to either generate beam or engage in RF operations. For beam generation the maximum current and beam mode ("permissions") that are authorized are provided for a given beam destination. This information is stored in a database and presented via the web for easy access. There are three beam generating facilities, each with their own set of beam destinations and beam modes: CEBAF, LERF, UITF. There are seven facilities which generate RF: CEBAF Injector, CEBAF North Linac, CEBAF South Linac, LERF, CMTF, and VTA. In addition to director authorization, the app also tracks Credited Controls and their verification. Each beam destination is assigned a set of controls and each control is assigned to a particular responsible group. A beam desintation is ready for beam only if all the controls assigned are verified by their responsible group. Both group verifications and director permissions have expirations. Emails and Jefferson Lab logbook entires are created to aid communication of new director permissions, responsible group verifications (upgrades and downgrades), and verification and permissions expirations. ### Roles - **Operations Director** - Responsible for authorizing beam From ce358db0343fcd39d3474ab20794745a31557ff0 Mon Sep 17 00:00:00 2001 From: Ryan Slominski Date: Tue, 28 Jan 2025 07:06:52 -0500 Subject: [PATCH 07/44] Separate Facilities --- src/main/webapp/WEB-INF/tags/rf-operations-table.tag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/WEB-INF/tags/rf-operations-table.tag b/src/main/webapp/WEB-INF/tags/rf-operations-table.tag index 2f536b2..0a37742 100644 --- a/src/main/webapp/WEB-INF/tags/rf-operations-table.tag +++ b/src/main/webapp/WEB-INF/tags/rf-operations-table.tag @@ -80,7 +80,7 @@ - + From 060aef67b474b06a1b0d23371028f4188cf70b25 Mon Sep 17 00:00:00 2001 From: Ryan Slominski Date: Tue, 28 Jan 2025 07:20:24 -0500 Subject: [PATCH 08/44] Separate Facilities --- .../webapp/WEB-INF/tags/destination-permissions-table.tag | 4 ++-- src/main/webapp/WEB-INF/tags/permissions-page.tag | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/WEB-INF/tags/destination-permissions-table.tag b/src/main/webapp/WEB-INF/tags/destination-permissions-table.tag index d634073..a8559da 100644 --- a/src/main/webapp/WEB-INF/tags/destination-permissions-table.tag +++ b/src/main/webapp/WEB-INF/tags/destination-permissions-table.tag @@ -101,13 +101,13 @@ - + - + diff --git a/src/main/webapp/WEB-INF/tags/permissions-page.tag b/src/main/webapp/WEB-INF/tags/permissions-page.tag index 34e2eae..136c5e3 100644 --- a/src/main/webapp/WEB-INF/tags/permissions-page.tag +++ b/src/main/webapp/WEB-INF/tags/permissions-page.tag @@ -75,7 +75,7 @@

    From 8f106ead7c17737c722cb4465fea74682296b665 Mon Sep 17 00:00:00 2001 From: Ryan Slominski Date: Tue, 28 Jan 2025 08:31:16 -0500 Subject: [PATCH 09/44] Separate Facilities --- .../session/BeamAuthorizationFacade.java | 2 +- .../persistence/entity/BeamAuthorization.java | 2 +- .../persistence/entity/RFAuthorization.java | 2 +- ...> BeamAuthorizationHistoryController.java} | 8 ++-- ...nationsAuthorizationHistoryController.java | 33 ++++++------- .../controller/FacilityAuthorization.java | 48 +++++++++++++++++-- .../webapp/WEB-INF/tags/permissions-page.tag | 2 +- .../permissions/authorization-history.jsp | 4 +- .../destinations-authorization-history.jsp | 8 ++-- 9 files changed, 76 insertions(+), 33 deletions(-) rename src/main/java/org/jlab/jam/presentation/controller/{AuthorizationHistoryController.java => BeamAuthorizationHistoryController.java} (92%) diff --git a/src/main/java/org/jlab/jam/business/session/BeamAuthorizationFacade.java b/src/main/java/org/jlab/jam/business/session/BeamAuthorizationFacade.java index e587c50..7520462 100644 --- a/src/main/java/org/jlab/jam/business/session/BeamAuthorizationFacade.java +++ b/src/main/java/org/jlab/jam/business/session/BeamAuthorizationFacade.java @@ -111,7 +111,7 @@ public BeamAuthorization findCurrent() { public List findHistory(int offset, int maxPerPage) { Query q = em.createNativeQuery( - "select * from authorization order by authorization_date desc", + "select * from beam_authorization order by authorization_date desc", BeamAuthorization.class); return q.setFirstResult(offset).setMaxResults(maxPerPage).getResultList(); 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 4601e25..20d6762 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/BeamAuthorization.java +++ b/src/main/java/org/jlab/jam/persistence/entity/BeamAuthorization.java @@ -26,7 +26,7 @@ * @author ryans */ @Entity -@Table(schema = "JAM_OWNER") +@Table(name = "BEAM_AUTHORIZATION", schema = "JAM_OWNER") @NamedQueries({ @NamedQuery(name = "BeamAuthorization.findAll", query = "SELECT a FROM BeamAuthorization a") }) 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 132e145..f6b4ccc 100644 --- a/src/main/java/org/jlab/jam/persistence/entity/RFAuthorization.java +++ b/src/main/java/org/jlab/jam/persistence/entity/RFAuthorization.java @@ -26,7 +26,7 @@ * @author ryans */ @Entity -@Table(schema = "JAM_OWNER") +@Table(name = "RF_AUTHORIZATION", schema = "JAM_OWNER") @NamedQueries({ @NamedQuery(name = "RFAuthorization.findAll", query = "SELECT a FROM RFAuthorization a") }) diff --git a/src/main/java/org/jlab/jam/presentation/controller/AuthorizationHistoryController.java b/src/main/java/org/jlab/jam/presentation/controller/BeamAuthorizationHistoryController.java similarity index 92% rename from src/main/java/org/jlab/jam/presentation/controller/AuthorizationHistoryController.java rename to src/main/java/org/jlab/jam/presentation/controller/BeamAuthorizationHistoryController.java index ca7017f..8149901 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/AuthorizationHistoryController.java +++ b/src/main/java/org/jlab/jam/presentation/controller/BeamAuthorizationHistoryController.java @@ -17,10 +17,8 @@ /** * @author ryans */ -@WebServlet( - name = "AuthorizationHistoryController", - urlPatterns = {"/permissions/authorization-history"}) -public class AuthorizationHistoryController extends HttpServlet { +@WebServlet(name = "BeamAuthorizationHistoryController") +public class BeamAuthorizationHistoryController extends HttpServlet { @EJB BeamAuthorizationFacade historyFacade; @@ -36,6 +34,8 @@ public class AuthorizationHistoryController extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + System.out.println("BeamAuthorizationHistoryController says hello"); + int offset = ParamUtil.convertAndValidateNonNegativeInt(request, "offset", 0); int maxPerPage = 10; diff --git a/src/main/java/org/jlab/jam/presentation/controller/DestinationsAuthorizationHistoryController.java b/src/main/java/org/jlab/jam/presentation/controller/DestinationsAuthorizationHistoryController.java index 8d804ea..c66d3a0 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/DestinationsAuthorizationHistoryController.java +++ b/src/main/java/org/jlab/jam/presentation/controller/DestinationsAuthorizationHistoryController.java @@ -12,17 +12,13 @@ import javax.servlet.http.HttpServletResponse; import org.jlab.jam.business.session.BeamAuthorizationFacade; import org.jlab.jam.business.session.BeamDestinationFacade; -import org.jlab.jam.persistence.entity.BeamAuthorization; -import org.jlab.jam.persistence.entity.BeamDestination; -import org.jlab.jam.persistence.entity.BeamDestinationAuthorization; +import org.jlab.jam.persistence.entity.*; import org.jlab.smoothness.presentation.util.ParamConverter; /** * @author ryans */ -@WebServlet( - name = "DestinationsAuthorizationHistoryController", - urlPatterns = {"/permissions/destinations-authorization-history"}) +@WebServlet(name = "DestinationsAuthorizationHistoryController") public class DestinationsAuthorizationHistoryController extends HttpServlet { @EJB BeamAuthorizationFacade beamAuthorizationFacade; @@ -40,26 +36,31 @@ public class DestinationsAuthorizationHistoryController extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - BigInteger authorizationId = ParamConverter.convertBigInteger(request, "authorizationId"); + BigInteger beamAuthorizationId = + ParamConverter.convertBigInteger(request, "beamAuthorizationId"); BeamAuthorization beamAuthorization = null; - if (authorizationId != null) { - beamAuthorization = beamAuthorizationFacade.find(authorizationId); + if (beamAuthorizationId != null) { + beamAuthorization = beamAuthorizationFacade.find(beamAuthorizationId); } - List cebafDestinationList = beamDestinationFacade.findCebafDestinations(); - List lerfDestinationList = beamDestinationFacade.findLerfDestinations(); - List uitfDestinationList = beamDestinationFacade.findUitfDestinations(); + Facility facility = (Facility) request.getAttribute("facility"); + + // TODO: Instead of querying for current list of destinations / segments then mapping to + // authorization, + // it would be better to grab list of destinations and segments that existed at time of + // authorization. + List rfList = null; + List beamList = beamDestinationFacade.findByFacility(facility); Map destinationAuthorizationMap = beamAuthorizationFacade.createDestinationAuthorizationMap(beamAuthorization); request.setAttribute("unitsMap", beamAuthorizationFacade.getUnitsMap()); - request.setAttribute("authorization", beamAuthorization); - request.setAttribute("cebafDestinationList", cebafDestinationList); - request.setAttribute("lerfDestinationList", lerfDestinationList); - request.setAttribute("uitfDestinationList", uitfDestinationList); + request.setAttribute("beamAuthorization", beamAuthorization); + request.setAttribute("rfList", rfList); + request.setAttribute("beamList", beamList); request.setAttribute("destinationAuthorizationMap", destinationAuthorizationMap); request diff --git a/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java b/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java index 82d349c..ae54d19 100644 --- a/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java +++ b/src/main/java/org/jlab/jam/presentation/controller/FacilityAuthorization.java @@ -4,6 +4,8 @@ import java.io.PrintWriter; import java.math.BigDecimal; import java.math.BigInteger; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -57,7 +59,21 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) String pathInfo = request.getPathInfo(); - Facility facility = facilityFacade.findByPath(pathInfo); + if (pathInfo == null || pathInfo.isEmpty()) { + throw new ServletException("Path is empty"); + } + + Path path = Paths.get(pathInfo); + + if (path.getNameCount() == 0) { + throw new ServletException("Path is root only"); + } + + String facilityPath = "/" + path.getName(0); + + System.err.println("facilityPath: " + facilityPath); + + Facility facility = facilityFacade.findByPath(facilityPath); if (facility == null) { throw new ServletException("Facility not found"); @@ -66,6 +82,34 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) List facilityList = facilityFacade.findAll(new AbstractFacade.OrderDirective("weight")); + request.setAttribute("facility", facility); + request.setAttribute("facilityList", facilityList); + + switch (path.getNameCount()) { + case 1: + System.err.println("1: facility"); + handleFacility(request, response, facility); + break; + case 2: + System.err.println("2: auth history"); + getServletContext() + .getNamedDispatcher("BeamAuthorizationHistoryController") + .forward(request, response); + break; + case 3: + System.err.println("3: destination history"); + getServletContext() + .getNamedDispatcher("DestinationsAuthorizationHistoryController") + .forward(request, response); + break; + default: + throw new ServletException("Path has too many segments"); + } + } + + private void handleFacility( + HttpServletRequest request, HttpServletResponse response, Facility facility) + throws ServletException, IOException { verificationFacade.performExpirationCheck(false); RFAuthorization rfAuthorization = rfAuthorizationFacade.findCurrent(); @@ -80,8 +124,6 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) Map segmentAuthorizationMap = rfAuthorizationFacade.createSegmentAuthorizationMap(rfAuthorization); - request.setAttribute("facility", facility); - request.setAttribute("facilityList", facilityList); request.setAttribute("unitsMap", beamAuthorizationFacade.getUnitsMap()); request.setAttribute("authorization", beamAuthorization); request.setAttribute("rfList", rfList); diff --git a/src/main/webapp/WEB-INF/tags/permissions-page.tag b/src/main/webapp/WEB-INF/tags/permissions-page.tag index 136c5e3..ca0ff80 100644 --- a/src/main/webapp/WEB-INF/tags/permissions-page.tag +++ b/src/main/webapp/WEB-INF/tags/permissions-page.tag @@ -75,7 +75,7 @@
    diff --git a/src/main/webapp/WEB-INF/views/permissions/authorization-history.jsp b/src/main/webapp/WEB-INF/views/permissions/authorization-history.jsp index 49dc88c..c556772 100644 --- a/src/main/webapp/WEB-INF/views/permissions/authorization-history.jsp +++ b/src/main/webapp/WEB-INF/views/permissions/authorization-history.jsp @@ -20,7 +20,7 @@