Skip to content

Commit

Permalink
Separate Facilities
Browse files Browse the repository at this point in the history
  • Loading branch information
slominskir committed Jan 27, 2025
1 parent 94257c7 commit 1d4e62d
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 70 deletions.
12 changes: 10 additions & 2 deletions container/oracle/initdb.d/03_default_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public List<BeamDestination> findByFacility(Facility facility) {

List<Order> orders = new ArrayList<>();
Path p0 = root.get("weight");
Order o0 = cb.desc(p0);
Order o0 = cb.asc(p0);
orders.add(o0);
cq.orderBy(orders);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ public HashMap<BigInteger, String> 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<BeamAuthorization> beamAuthorizationList = q.getResultList();
List<RFAuthorization> 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")
Expand All @@ -114,20 +114,20 @@ public Long countHistory() {
}

@PermitAll
public Map<BigInteger, BeamDestinationAuthorization> createDestinationAuthorizationMap(
BeamAuthorization beamAuthorization) {
Map<BigInteger, BeamDestinationAuthorization> destinationAuthorizationMap = new HashMap<>();

if (beamAuthorization != null && beamAuthorization.getDestinationAuthorizationList() != null) {
for (BeamDestinationAuthorization beamDestinationAuthorization :
beamAuthorization.getDestinationAuthorizationList()) {
destinationAuthorizationMap.put(
beamDestinationAuthorization.getDestinationAuthorizationPK().getBeamDestinationId(),
beamDestinationAuthorization);
public Map<BigInteger, RFSegmentAuthorization> createSegmentAuthorizationMap(
RFAuthorization rfAuthorization) {
Map<BigInteger, RFSegmentAuthorization> 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")
Expand Down Expand Up @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public List<RFSegment> findByFacility(Facility facility) {

List<Order> orders = new ArrayList<>();
Path p0 = root.get("weight");
Order o0 = cb.desc(p0);
Order o0 = cb.asc(p0);
orders.add(o0);
cq.orderBy(orders);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -69,6 +68,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)

verificationFacade.performExpirationCheck(false);

RFAuthorization rfAuthorization = rfAuthorizationFacade.findCurrent();
BeamAuthorization beamAuthorization = beamAuthorizationFacade.findCurrent();

List<RFSegment> rfList = rfSegmentFacade.findByFacility(facility);
Expand All @@ -77,6 +77,9 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response)
Map<BigInteger, BeamDestinationAuthorization> destinationAuthorizationMap =
beamAuthorizationFacade.createDestinationAuthorizationMap(beamAuthorization);

Map<BigInteger, RFSegmentAuthorization> segmentAuthorizationMap =
rfAuthorizationFacade.createSegmentAuthorizationMap(rfAuthorization);

request.setAttribute("facility", facility);
request.setAttribute("facilityList", facilityList);
request.setAttribute("unitsMap", beamAuthorizationFacade.getUnitsMap());
Expand Down
82 changes: 48 additions & 34 deletions src/main/webapp/WEB-INF/tags/permissions-page.tag
Original file line number Diff line number Diff line change
Expand Up @@ -19,58 +19,72 @@
<div class="accordion">
<h3>RF Operations</h3>
<div class="content">
<t:rf-operations-table rfList="${rfList}" isHistory="${isHistory}"/>
<c:choose>
<c:when test="${not empty rfList}">
<t:rf-operations-table rfList="${rfList}" isHistory="${isHistory}"/>
</c:when>
<c:otherwise>
None
</c:otherwise>
</c:choose>
</div>
</div>
<div class="accordion">
<h3>Beam Operations</h3>
<div class="content">
<div class="editable-field power-limited-note">Note: Blank/Empty Current Limit results in "Dump Power Limited"</div>
<t:destination-permissions-table beamList="${beamList}" isHistory="${isHistory}"/>
<h3>Notes</h3>
<div class="notes-field">
<c:choose>
<c:when test="${not empty beamList}">
<div class="editable-field power-limited-note">Note: Blank/Empty Current Limit results in "Dump Power Limited"</div>
<t:destination-permissions-table beamList="${beamList}" isHistory="${isHistory}"/>
<h3>Notes</h3>
<div class="notes-field">
<span class="readonly-field">
<c:out value="${fn:length(beamAuthorization.comments) == 0 ? 'None' : beamAuthorization.comments}"/>
</span>
<span class="editable-field">
<span class="editable-field">
<textarea id="comments" name="comments"><c:out value="${beamAuthorization.comments}"/></textarea>
</span>
</div>
<h3>Digital Signature</h3>
<div class="footer">
<div class="footer-row">
<div class="signature-field">
<c:choose>
<c:when test="${beamAuthorization ne null}">
<div class="readonly-field">Authorized by ${s:formatUsername(beamAuthorization.authorizedBy)} on <fmt:formatDate value="${beamAuthorization.authorizationDate}" pattern="${s:getFriendlyDateTimePattern()}"/></div>
</c:when>
<c:otherwise>
<div class="readonly-field">None</div>
</c:otherwise>
</c:choose>
<div class="editable-field notification-option-panel">
<p>
<label for="generate-elog-checkbox">Generate elog and email:</label>
<input id="generate-elog-checkbox" type="checkbox" name="notification" value="Y" checked="checked"/>
</p>
</div>
<div class="editable-field">Click the Save button to sign:
<span>
</div>
<h3>Digital Signature</h3>
<div class="footer">
<div class="footer-row">
<div class="signature-field">
<c:choose>
<c:when test="${beamAuthorization ne null}">
<div class="readonly-field">Authorized by ${s:formatUsername(beamAuthorization.authorizedBy)} on <fmt:formatDate value="${beamAuthorization.authorizationDate}" pattern="${s:getFriendlyDateTimePattern()}"/></div>
</c:when>
<c:otherwise>
<div class="readonly-field">None</div>
</c:otherwise>
</c:choose>
<div class="editable-field notification-option-panel">
<p>
<label for="generate-elog-checkbox">Generate elog and email:</label>
<input id="generate-elog-checkbox" type="checkbox" name="notification" value="Y" checked="checked"/>
</p>
</div>
<div class="editable-field">Click the Save button to sign:
<span>
<button id="save-button" class="ajax-button inline-button" type="button">Save</button>
<span class="cancel-text">
or
<a id="cancel-button" href="#">Cancel</a>
</span>
</span>
</div>
</div>
<div class="history-panel">
<c:if test="${not isHistory}">
<a data-dialog-title="Authorization History" href="permissions/beamAuthorization-history" title="Click for beamAuthorization history">History</a>
</c:if>
</div>
</div>
</div>
<div class="history-panel">
<c:if test="${not isHistory}">
<a data-dialog-title="Authorization History" href="permissions/beamAuthorization-history" title="Click for beamAuthorization history">History</a>
</c:if>
</div>
</div>
</div>
</c:when>
<c:otherwise>
None
</c:otherwise>
</c:choose>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 1d4e62d

Please sign in to comment.