From 2f775f8e03ede34da479272defd11f93ac46ec02 Mon Sep 17 00:00:00 2001 From: says0528 Date: Wed, 31 Jul 2024 15:10:35 -0400 Subject: [PATCH] Room Utilization and Occupancy Modified Room Utilization and Occupancy Report Data Helpers to allow data to be broken down by class section and room controlling department. --- .../timetable/gwt/resources/GwtMessages.java | 14 +- .../timetable/util/OccupancyHelper.java | 5 +- .../util/RoomSummaryReportsHelper.java | 215 ++++++++++++- .../util/RoomUsageAndOccupancyData.java | 302 ++++++++++++++++-- .../timetable/util/RoomUtilizationHelper.java | 22 +- 5 files changed, 502 insertions(+), 56 deletions(-) diff --git a/JavaSource/org/unitime/timetable/gwt/resources/GwtMessages.java b/JavaSource/org/unitime/timetable/gwt/resources/GwtMessages.java index bb7a81ab35..94fa1f3173 100644 --- a/JavaSource/org/unitime/timetable/gwt/resources/GwtMessages.java +++ b/JavaSource/org/unitime/timetable/gwt/resources/GwtMessages.java @@ -6963,12 +6963,24 @@ public interface GwtMessages extends Messages { @DefaultMessage("Utilization_Type") String utilSqlUtilizationType(); - @DefaultMessage("Department") + @DefaultMessage("Course_Department") String utilSqlDepartment(); @DefaultMessage("Subject") String utilSqlSubject(); + @DefaultMessage("Course_Number") + String utilSqlCourseNbr(); + + @DefaultMessage("Instr_Type") + String utilSqlItype(); + + @DefaultMessage("Section") + String utilSqlSection(); + + @DefaultMessage("Room_Controling_Dept") + String utilSqlRoomDept(); + @DefaultMessage("Size_Group") String utilSqlRangeOfSizes(); diff --git a/JavaSource/org/unitime/timetable/util/OccupancyHelper.java b/JavaSource/org/unitime/timetable/util/OccupancyHelper.java index a149ad5c7e..70c1d7e994 100644 --- a/JavaSource/org/unitime/timetable/util/OccupancyHelper.java +++ b/JavaSource/org/unitime/timetable/util/OccupancyHelper.java @@ -119,8 +119,9 @@ protected String getBaseQueryAdditionalSelectColumns() { @Override public String getPivotedQuery(ArrayList allDays, ArrayList weekDays, Integer saturday, String campus, String year, String term, ArrayList headerRow, - boolean includeDayOfWkTimeOfDayInHeaderRow, boolean includeSubjectArea, boolean includeDept) { - return getPivotedBaseSummaryQuery(allDays, weekDays, saturday, campus, year, term, headerRow, includeDayOfWkTimeOfDayInHeaderRow, includeSubjectArea, includeDept); + boolean includeDayOfWkTimeOfDayInHeaderRow, boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment) { + return getPivotedBaseSummaryQuery(allDays, weekDays, saturday, campus, year, term, headerRow, includeDayOfWkTimeOfDayInHeaderRow, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment); } @Override diff --git a/JavaSource/org/unitime/timetable/util/RoomSummaryReportsHelper.java b/JavaSource/org/unitime/timetable/util/RoomSummaryReportsHelper.java index b43241ab31..a80d1209c3 100644 --- a/JavaSource/org/unitime/timetable/util/RoomSummaryReportsHelper.java +++ b/JavaSource/org/unitime/timetable/util/RoomSummaryReportsHelper.java @@ -999,10 +999,54 @@ protected String getNumRoomsCalculation() { sb.append("and om.stop_period = m.stop_period"); newline(sb, 8); sb.append(") as nbr_rooms"); - return sb.toString(); + return sb.toString(); } + protected String getRoomControllingRoomDeptQuery() { + StringBuffer sb = new StringBuffer(); + newline(sb, 4); + sb.append("(select concat(concat(rdpt.dept_code, ' - '), rdpt.name)"); + newline(sb, 8); + sb.append("from ") + .append(getSchema()) + .append(".room_dept rd"); + newline(sb, 8); + sb.append("inner join ") + .append(getSchema()) + .append(".department rdpt on rdpt.uniqueId = rd.department_id"); + newline(sb, 8); + sb.append("where rd.room_id = r.uniqueId and rd.is_control = 1)"); + return(sb.toString()); + } + + protected String getSectionNumberDecodeCase() { + StringBuffer sb = new StringBuffer(); + newline(sb, 4); + sb.append("( case "); + newline(sb, 8); + sb.append(" when (ss.subpart_suffix is null and c.section_number is null)"); + newline(sb, 8); + sb.append(" then null"); + newline(sb, 8); + sb.append(" when (ss.subpart_suffix is null and c.section_number is not null)"); + newline(sb, 8); + sb.append(" then to_char(c.section_number)"); + newline(sb, 8); + sb.append(" when (ss.subpart_suffix != '-')"); + newline(sb, 8); + sb.append(" then concat(to_char(c.section_number), ss.subpart_suffix)"); + newline(sb, 8); + sb.append(" else to_char(c.section_number)"); + newline(sb, 8); + sb.append(" end )"); + return(sb.toString()); + } protected String getBaseQuerySelectClause(boolean includeSubjectArea, boolean includeDept) { + return getBaseQuerySelectClause(includeSubjectArea, includeDept, false, false); + } + + protected String getBaseQuerySelectClause(boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment) { StringBuffer sb = new StringBuffer(); sb.append("select distinct sess.academic_initiative as ") .append(MESSAGES.utilSqlAcademicInitiative()) @@ -1075,12 +1119,35 @@ protected String getBaseQuerySelectClause(boolean includeSubjectArea, boolean in .append(MESSAGES.utilSqlDepartment()) .append(","); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + sb.append(getRoomControllingRoomDeptQuery()); + newline(sb, 4); + sb.append("as ") + .append(MESSAGES.utilSqlRoomDept()) + .append(","); + + } + if (includeSubjectArea || includeSection) { newline(sb, 4); sb.append("sa.subject_area_abbreviation as ") .append(MESSAGES.utilSqlSubject()) .append(","); } + if (includeSection) { + newline(sb, 4); + sb.append("co.course_nbr as ") + .append(MESSAGES.utilSqlCourseNbr()) + .append(","); + newline(sb, 4); + sb.append("i.abbv as ") + .append(MESSAGES.utilSqlItype()) + .append(","); + sb.append(getSectionNumberDecodeCase()); + newline(sb, 4); + sb.append("as ") + .append(MESSAGES.utilSqlSection()) + .append(","); + } sb.append(getBaseQueryAdditionalSelectColumns()); newline(sb, 4); sb.append(getNumRoomsCalculation()); @@ -1182,8 +1249,13 @@ protected String getBaseQueryWhereClause(String campus, String year, String term } protected String getBaseQuery(String campus, String year, String term, boolean includeSubjectArea, boolean includeDept) { + return getBaseQuery(campus, year, term, includeSubjectArea, includeDept, false, false); + } + + protected String getBaseQuery(String campus, String year, String term, boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment) { StringBuffer sb = new StringBuffer(); - sb.append(getBaseQuerySelectClause(includeSubjectArea, includeDept)); + sb.append(getBaseQuerySelectClause(includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment)); newline(sb, 0); sb.append(getBaseQueryFromClause()); newline(sb, 0); @@ -1280,6 +1352,17 @@ protected String getPivotedBaseSummaryQuery(ArrayList allDays, ArrayLis Integer saturday, String campus, String year, String term, ArrayList headerRow, boolean includeDayOfWkTimeOfDayInHeaderRow, boolean includeSubjectArea, boolean includeDept) { + return getPivotedBaseSummaryQuery(allDays, weekDays, + saturday, campus, year, term, + headerRow, includeDayOfWkTimeOfDayInHeaderRow, + includeSubjectArea, includeDept, false, false); + } + + protected String getPivotedBaseSummaryQuery(ArrayList allDays, ArrayList weekDays, + Integer saturday, String campus, String year, String term, + ArrayList headerRow, boolean includeDayOfWkTimeOfDayInHeaderRow, + boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment) { StringBuffer sb = new StringBuffer(); sb.append("select "); appendSelectedField(sb, "z", MESSAGES.utilSqlAcademicInitiative(), false, true); @@ -1325,11 +1408,27 @@ protected String getPivotedBaseSummaryQuery(ArrayList allDays, ArrayLis appendSelectedField(sb, "z", MESSAGES.utilSqlDepartment(), false, true); headerRow.add(MESSAGES.utilSqlDepartment()); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + newline(sb, 4); + appendSelectedField(sb, "z", MESSAGES.utilSqlRoomDept(), false, true); + headerRow.add(MESSAGES.utilSqlRoomDept()); + } + if (includeSubjectArea || includeSection) { newline(sb, 4); appendSelectedField(sb, "z", MESSAGES.utilSqlSubject(), false, true); headerRow.add(MESSAGES.utilSqlSubject()); } + if (includeSection) { + newline(sb, 4); + appendSelectedField(sb, "z", MESSAGES.utilSqlCourseNbr(), false, true); + headerRow.add(MESSAGES.utilSqlCourseNbr()); + newline(sb, 4); + appendSelectedField(sb, "z", MESSAGES.utilSqlItype(), false, true); + headerRow.add(MESSAGES.utilSqlItype()); + newline(sb, 4); + appendSelectedField(sb, "z", MESSAGES.utilSqlSection(), false, true); + headerRow.add(MESSAGES.utilSqlSection()); + } newline(sb, 4); appendSelectedField(sb, "z", MESSAGES.utilSqlEventType(), false, true); @@ -1358,7 +1457,7 @@ protected String getPivotedBaseSummaryQuery(ArrayList allDays, ArrayLis } newline(sb, 0); sb.append("from ("); - sb.append(getBaseQuery(campus, year, term, includeSubjectArea, includeDept)); + sb.append(getBaseQuery(campus, year, term, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment)); sb.append(") z"); newline(sb, 0); sb.append("group by "); @@ -1393,19 +1492,48 @@ protected String getPivotedBaseSummaryQuery(ArrayList allDays, ArrayLis newline(sb, 4); appendSelectedField(sb, "z", MESSAGES.utilSqlDepartment(), true, false); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + newline(sb, 4); + appendSelectedField(sb, "z", MESSAGES.utilSqlRoomDept(), true, false); + } + if (includeSubjectArea || includeSection) { newline(sb, 4); appendSelectedField(sb, "z", MESSAGES.utilSqlSubject(), true, false); } + if (includeSection) { + newline(sb, 4); + appendSelectedField(sb, "z", MESSAGES.utilSqlCourseNbr(), true, false); + newline(sb, 4); + appendSelectedField(sb, "z", MESSAGES.utilSqlItype(), true, false); + newline(sb, 4); + appendSelectedField(sb, "z", MESSAGES.utilSqlSection(), true, false); + } return(sb.toString()); } - public abstract String getPivotedQuery(ArrayList allDays, ArrayList weekDays, Integer saturday, String campus, String year, String term, ArrayList headerRow, boolean includeDayOfWkTimeOfDayInHeaderRow, boolean includeSubjectArea, boolean includeDept); + public String getPivotedQuery(ArrayList allDays, ArrayList weekDays, + Integer saturday, String campus, String year, String term, ArrayList headerRow, + boolean includeDayOfWkTimeOfDayInHeaderRow, boolean includeSubjectArea, boolean includeDept) { + return getPivotedQuery(allDays, weekDays, saturday, campus, year, term, headerRow, + includeDayOfWkTimeOfDayInHeaderRow, includeSubjectArea, includeDept, false, false); + }; + + public abstract String getPivotedQuery(ArrayList allDays, ArrayList weekDays, + Integer saturday, String campus, String year, String term, ArrayList headerRow, + boolean includeDayOfWkTimeOfDayInHeaderRow, boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment); + + protected String getSortedRoomUtilizationQuery(ArrayList allDays, ArrayList weekDays, + Integer saturday, String campus, String year, String term, ArrayList headerRow, + boolean includeSubjectArea, boolean includeDept) { + return getSortedRoomUtilizationQuery(allDays, weekDays, saturday, campus, year, term, headerRow, + includeSubjectArea, includeDept, false, false); + } - protected String getSortedRoomUtilizationQuery(ArrayList allDays, ArrayList weekDays, Integer saturday, String campus, String year, String term, ArrayList headerRow, boolean includeSubjectArea, boolean includeDept) { + protected String getSortedRoomUtilizationQuery(ArrayList allDays, ArrayList weekDays, Integer saturday, String campus, String year, String term, ArrayList headerRow, boolean includeSubjectArea, boolean includeDept, boolean includeSection, boolean includeRoomControlingDepartment) { StringBuffer sb = new StringBuffer() ; - sb.append(getPivotedQuery(allDays, weekDays, saturday, campus, year, term, headerRow, true, includeSubjectArea, includeDept)); + sb.append(getPivotedQuery(allDays, weekDays, saturday, campus, year, term, headerRow, true, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment)); newline(sb, 0); sb.append("order by ") .append(MESSAGES.utilSqlAcademicInitiative()) @@ -1427,15 +1555,35 @@ protected String getSortedRoomUtilizationQuery(ArrayList allDays, Array newline(sb, 10); sb.append(MESSAGES.utilSqlDepartment()); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlRoomDept()); + } + if (includeSubjectArea || includeSection) { sb.append(","); newline(sb, 10); sb.append(MESSAGES.utilSqlSubject()); } + if (includeSection) { + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlCourseNbr()); + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlItype()); + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlSection()); + } return(sb.toString()); } public String getUnpivotedRoomUtilizationQuery(ArrayList allDays, ArrayList weekDays, Integer saturday, String campus, String year, String term, ArrayList headerRow, boolean includeSubjectArea, boolean includeDept) { + return getUnpivotedRoomUtilizationQuery(allDays, weekDays, saturday, campus, year, term, headerRow, includeSubjectArea, includeDept, false, false); + } + + public String getUnpivotedRoomUtilizationQuery(ArrayList allDays, ArrayList weekDays, Integer saturday, String campus, String year, String term, ArrayList headerRow, boolean includeSubjectArea, boolean includeDept, boolean includeSection, boolean includeRoomControlingDepartment) { StringBuffer sb = new StringBuffer() ; ArrayList newColumns = new ArrayList(); ArrayList dayTimeColumnPrefixes = new ArrayList(); @@ -1455,7 +1603,7 @@ public String getUnpivotedRoomUtilizationQuery(ArrayList allDays, Array newline(sb, 0); sb.append("("); newline(sb, 0); - sb.append(getPivotedQuery (allDays, weekDays, saturday, campus, year, term, headerRow, false, includeSubjectArea, includeDept)); + sb.append(getPivotedQuery (allDays, weekDays, saturday, campus, year, term, headerRow, false, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment)); newline(sb, 0); sb.append(") y"); newline(sb, 0); @@ -1480,8 +1628,12 @@ public String getUnpivotedRoomUtilizationQuery(ArrayList allDays, Array } protected String getSortedUnpivotedRoomUtilizationQuery(ArrayList allDays, ArrayList weekDays, Integer saturday, String campus, String year, String term, ArrayList headerRow, boolean includeSubjectArea, boolean includeDept) { + return getSortedUnpivotedRoomUtilizationQuery(allDays, weekDays, saturday, campus, year, term, headerRow, includeSubjectArea, includeDept, false, false); + } + + protected String getSortedUnpivotedRoomUtilizationQuery(ArrayList allDays, ArrayList weekDays, Integer saturday, String campus, String year, String term, ArrayList headerRow, boolean includeSubjectArea, boolean includeDept, boolean includeSection, boolean includeRoomControlingDepartment) { StringBuffer sb = new StringBuffer() ; - sb.append(getUnpivotedRoomUtilizationQuery(allDays, weekDays, saturday, campus, year, term, headerRow, includeSubjectArea, includeDept)); + sb.append(getUnpivotedRoomUtilizationQuery(allDays, weekDays, saturday, campus, year, term, headerRow, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment)); newline(sb, 0); sb.append("order by ") .append(MESSAGES.utilSqlAcademicInitiative()) @@ -1503,11 +1655,27 @@ protected String getSortedUnpivotedRoomUtilizationQuery(ArrayList allDa newline(sb, 10); sb.append(MESSAGES.utilSqlDepartment()); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlRoomDept()); + } + if (includeSubjectArea || includeSection) { sb.append(","); newline(sb, 10); sb.append(MESSAGES.utilSqlSubject()); } + if (includeSection) { + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlCourseNbr()); + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlItype()); + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlSection()); + } sb.append(","); newline(sb, 10); sb.append(MESSAGES.utilSqlDayTime()); @@ -1515,16 +1683,20 @@ protected String getSortedUnpivotedRoomUtilizationQuery(ArrayList allDa } public String getPivotedAndUnpivotedUtilizationQueries(Session acadSession, boolean includeSubjectArea, boolean includeDept) { + return getPivotedAndUnpivotedUtilizationQueries(acadSession, includeSubjectArea, includeDept, false, false); + } + + public String getPivotedAndUnpivotedUtilizationQueries(Session acadSession, boolean includeSubjectArea, boolean includeDept, boolean includeSection, boolean includeRoomControlingDepartment) { StringBuffer sb = new StringBuffer() ; ArrayList headerRow1 = new ArrayList(); ArrayList headerRow2 = new ArrayList(); - String utilQuery = getSortedRoomUtilizationQuery(getAllDays(), getWeekDays(), getSaturday(), acadSession.getAcademicInitiative(), acadSession.getAcademicYear(), acadSession.getAcademicTerm(), headerRow1, includeSubjectArea, includeDept); + String utilQuery = getSortedRoomUtilizationQuery(getAllDays(), getWeekDays(), getSaturday(), acadSession.getAcademicInitiative(), acadSession.getAcademicYear(), acadSession.getAcademicTerm(), headerRow1, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment); sb.append(utilQuery); sb.append(";"); newline(sb, 0); newline(sb, 0); - String unpivotedUtilQuery = getSortedUnpivotedRoomUtilizationQuery(getAllDays(), getWeekDays(), getSaturday(), acadSession.getAcademicInitiative(), acadSession.getAcademicYear(), acadSession.getAcademicTerm(), headerRow2, includeSubjectArea, includeDept); + String unpivotedUtilQuery = getSortedUnpivotedRoomUtilizationQuery(getAllDays(), getWeekDays(), getSaturday(), acadSession.getAcademicInitiative(), acadSession.getAcademicYear(), acadSession.getAcademicTerm(), headerRow2, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment); sb.append(unpivotedUtilQuery); sb.append(";"); newline(sb, 0); @@ -1532,15 +1704,24 @@ public String getPivotedAndUnpivotedUtilizationQueries(Session acadSession, bool } public List> getQueryResultsForSortedRoomUtilizationQuery(Session acadSession, boolean includeSubjectArea, boolean includeDept){ + return getQueryResultsForSortedRoomUtilizationQuery(acadSession, includeSubjectArea, includeDept, false, false); + } + + public List> getQueryResultsForSortedRoomUtilizationQuery(Session acadSession, boolean includeSubjectArea, boolean includeDept, boolean includeSection, boolean includeRoomControlingDepartment){ ArrayList headerRow = new ArrayList(); - String query = getSortedRoomUtilizationQuery(getAllDays(), getWeekDays(), getSaturday(), acadSession.getAcademicInitiative(), acadSession.getAcademicYear(), acadSession.getAcademicTerm(), headerRow, includeSubjectArea, includeDept); + String query = getSortedRoomUtilizationQuery(getAllDays(), getWeekDays(), getSaturday(), acadSession.getAcademicInitiative(), acadSession.getAcademicYear(), acadSession.getAcademicTerm(), headerRow, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment); return getUtilQueryResultsForQuery(query, headerRow); } public List> getQueryResultsForSortedUnPivotedRoomUtilizationQuery(Session acadSession, boolean includeSubjectArea, boolean includeDept){ + return getQueryResultsForSortedUnPivotedRoomUtilizationQuery(acadSession, includeSubjectArea, includeDept, false, false); + } + + public List> getQueryResultsForSortedUnPivotedRoomUtilizationQuery(Session acadSession, boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment){ ArrayList headerRow = new ArrayList(); - String query = getSortedUnpivotedRoomUtilizationQuery(getAllDays(), getWeekDays(), getSaturday(), acadSession.getAcademicInitiative(), acadSession.getAcademicYear(), acadSession.getAcademicTerm(), headerRow, includeSubjectArea, includeDept); + String query = getSortedUnpivotedRoomUtilizationQuery(getAllDays(), getWeekDays(), getSaturday(), acadSession.getAcademicInitiative(), acadSession.getAcademicYear(), acadSession.getAcademicTerm(), headerRow, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment); return getUtilQueryResultsForQuery(query, headerRow); } diff --git a/JavaSource/org/unitime/timetable/util/RoomUsageAndOccupancyData.java b/JavaSource/org/unitime/timetable/util/RoomUsageAndOccupancyData.java index 11a67be900..ddbbfcfa8e 100644 --- a/JavaSource/org/unitime/timetable/util/RoomUsageAndOccupancyData.java +++ b/JavaSource/org/unitime/timetable/util/RoomUsageAndOccupancyData.java @@ -130,10 +130,39 @@ private void appendValuesAreNull(StringBuffer sb, String table1, String table2, } private void fromClause(StringBuffer sb, Session acadSession, boolean hasDayTime, boolean includeSubjectArea, boolean includeDept, boolean isCheckNull) { + fromClause(sb, acadSession, hasDayTime, includeSubjectArea, includeDept, false, false, isCheckNull); + } + + private void fromClause(StringBuffer sb, Session acadSession, boolean hasDayTime, boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment, boolean isCheckNull) { ArrayList headerRow1 = new ArrayList(); ArrayList headerRow2 = new ArrayList(); - String utilizationQuery = getRoomUtilizationHelper().getUnpivotedRoomUtilizationQuery(getRoomUtilizationHelper().getAllDays(), getRoomUtilizationHelper().getWeekDays(), getRoomUtilizationHelper().getSaturday(), acadSession.getAcademicInitiative(), acadSession.getAcademicYear(), acadSession.getAcademicTerm(), headerRow1, includeSubjectArea, includeDept); - String occupancyQuery = getOccupancyHelper().getUnpivotedRoomUtilizationQuery(getRoomUtilizationHelper().getAllDays(), getRoomUtilizationHelper().getWeekDays(), getRoomUtilizationHelper().getSaturday(), acadSession.getAcademicInitiative(), acadSession.getAcademicYear(), acadSession.getAcademicTerm(), headerRow2, includeSubjectArea, includeDept); + String utilizationQuery = getRoomUtilizationHelper() + .getUnpivotedRoomUtilizationQuery( + getRoomUtilizationHelper().getAllDays(), + getRoomUtilizationHelper().getWeekDays(), + getRoomUtilizationHelper().getSaturday(), + acadSession.getAcademicInitiative(), + acadSession.getAcademicYear(), + acadSession.getAcademicTerm(), + headerRow1, + includeSubjectArea, + includeDept, + includeSection, + includeRoomControlingDepartment); + String occupancyQuery = getOccupancyHelper() + .getUnpivotedRoomUtilizationQuery( + getRoomUtilizationHelper().getAllDays(), + getRoomUtilizationHelper().getWeekDays(), + getRoomUtilizationHelper().getSaturday(), + acadSession.getAcademicInitiative(), + acadSession.getAcademicYear(), + acadSession.getAcademicTerm(), + headerRow2, + includeSubjectArea, + includeDept, + includeSection, + includeRoomControlingDepartment); sb.append("from"); newline(sb, 0); @@ -177,7 +206,15 @@ private void fromClause(StringBuffer sb, Session acadSession, boolean hasDayTime appendValueNotNullAndEqualsSql(sb, roomUsageTable, seatUsageTable, MESSAGES.utilSqlDepartment(), true); } } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + newline(sb, 4); + if (isCheckNull) { + appendValuesAreNull(sb, roomUsageTable, seatUsageTable, MESSAGES.utilSqlRoomDept(), true); + } else { + appendValueNotNullAndEqualsSql(sb, roomUsageTable, seatUsageTable, MESSAGES.utilSqlRoomDept(), true); + } + } + if (includeSubjectArea || includeSection) { newline(sb, 4); if (isCheckNull) { appendValuesAreNull(sb, roomUsageTable, seatUsageTable, MESSAGES.utilSqlSubject(), true); @@ -185,6 +222,27 @@ private void fromClause(StringBuffer sb, Session acadSession, boolean hasDayTime appendValueNotNullAndEqualsSql(sb, roomUsageTable, seatUsageTable, MESSAGES.utilSqlSubject(), true); } } + if (includeSection) { + newline(sb, 4); + if (isCheckNull) { + appendValuesAreNull(sb, roomUsageTable, seatUsageTable, MESSAGES.utilSqlCourseNbr(), true); + } else { + appendValueNotNullAndEqualsSql(sb, roomUsageTable, seatUsageTable, MESSAGES.utilSqlCourseNbr(), true); + } + newline(sb, 4); + if (isCheckNull) { + appendValuesAreNull(sb, roomUsageTable, seatUsageTable, MESSAGES.utilSqlItype(), true); + } else { + appendValueNotNullAndEqualsSql(sb, roomUsageTable, seatUsageTable, MESSAGES.utilSqlItype(), true); + } + newline(sb, 4); + if (isCheckNull) { + appendValuesAreNull(sb, roomUsageTable, seatUsageTable, MESSAGES.utilSqlSection(), true); + } else { + appendValueNotNullAndEqualsSql(sb, roomUsageTable, seatUsageTable, MESSAGES.utilSqlSection(), true); + } + + } newline(sb, 4); appendValueEqualsSql(sb, roomUsageTable, seatUsageTable, MESSAGES.utilSqlEventType(), true); newline(sb, 4); @@ -322,7 +380,15 @@ private void appendSelectedField(StringBuffer sb, String tableName, String field } } - public void getRoomUsageAndOccupancyQuery(StringBuffer sb, Session acadSession, boolean includeSubjectArea, boolean includeDept, boolean isCheckNull, ArrayList headerRow) { + public void getRoomUsageAndOccupancyQuery(StringBuffer sb, Session acadSession, boolean includeSubjectArea, boolean includeDept, + boolean isCheckNull, ArrayList headerRow) { + getRoomUsageAndOccupancyQuery(sb, acadSession, includeSubjectArea, includeDept, + false, false, isCheckNull, headerRow); + + } + + public void getRoomUsageAndOccupancyQuery(StringBuffer sb, Session acadSession, boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment, boolean isCheckNull, ArrayList headerRow) { sb.append("select "); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlAcademicInitiative(), false, true, headerRow); @@ -350,10 +416,22 @@ public void getRoomUsageAndOccupancyQuery(StringBuffer sb, Session acadSession, newline(sb, 4); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlDepartment(), false, true, headerRow); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlRoomDept(), false, true, headerRow); + } + if (includeSubjectArea || includeSection) { newline(sb, 4); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlSubject(), false, true, headerRow); } + if (includeSection) { + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlCourseNbr(), false, true, headerRow); + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlItype(), false, true, headerRow); + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlSection(), false, true, headerRow); + } newline(sb, 4); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlEventType(), false, true, headerRow); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlEventTypeDescription(), false, true, headerRow); @@ -412,25 +490,31 @@ public void getRoomUsageAndOccupancyQuery(StringBuffer sb, Session acadSession, newline(sb, 4); appendDataZeroIfNull(sb, seatUsageTable, MESSAGES.utilSqlStationsRequested(), false, headerRow); newline(sb, 0); - fromClause(sb, acadSession, true, includeSubjectArea, includeDept, isCheckNull); + fromClause(sb, acadSession, true, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment,isCheckNull); newline(sb, 0); } - + public String getRoomUsageAndOccupancyQuery(Session acadSession, boolean includeSubjectArea, boolean includeDept, ArrayList headerRow) { + return getRoomUsageAndOccupancyQuery(acadSession, includeSubjectArea, includeDept, false, false, headerRow); + } + + + public String getRoomUsageAndOccupancyQuery(Session acadSession, boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment, ArrayList headerRow) { StringBuffer sb = new StringBuffer(); - getRoomUsageAndOccupancyQuery(sb, acadSession, includeSubjectArea, includeDept, false, headerRow); + getRoomUsageAndOccupancyQuery(sb, acadSession, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment, false, headerRow); newline(sb, 0); sb.append("where ") .append(roomUsageTable) .append(".") .append(MESSAGES.utilSqlAcademicInitiative()) .append(" is not null"); - if (includeDept || includeSubjectArea) { + if (includeDept || includeSubjectArea || includeSection || includeRoomControlingDepartment) { sb.append(" union all "); newline(sb, 0); - getRoomUsageAndOccupancyQuery(sb, acadSession, includeSubjectArea, includeDept, true, null); + getRoomUsageAndOccupancyQuery(sb, acadSession, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment, true, null); newline(sb, 0); sb.append("where ") .append(roomUsageTable) @@ -460,11 +544,27 @@ public String getRoomUsageAndOccupancyQuery(Session acadSession, boolean include newline(sb, 10); sb.append(MESSAGES.utilSqlDepartment()); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlRoomDept()); + } + if (includeSubjectArea || includeSection) { sb.append(","); newline(sb, 10); sb.append(MESSAGES.utilSqlSubject()); } + if (includeSection) { + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlCourseNbr()); + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlItype()); + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlSection()); + } sb.append(","); newline(sb, 4); sb.append(MESSAGES.utilSqlDayTime()); @@ -476,6 +576,16 @@ public String getRoomUsageAndOccupancyQuery(Session acadSession, boolean include public void getBuildingUsageAndOccupancyTimeDayQuery(StringBuffer sb, Session acadSession, boolean isByRoomType, boolean includeSubjectArea, boolean includeDept, boolean isCheckNull, ArrayList headerRow) { + getBuildingUsageAndOccupancyTimeDayQuery(sb, acadSession, + isByRoomType, includeSubjectArea, includeDept, + false, false, + isCheckNull, headerRow); + } + + public void getBuildingUsageAndOccupancyTimeDayQuery(StringBuffer sb, Session acadSession, + boolean isByRoomType, boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment, + boolean isCheckNull, ArrayList headerRow) { sb.append("select "); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlAcademicInitiative(), false, true, headerRow); @@ -492,10 +602,24 @@ public void getBuildingUsageAndOccupancyTimeDayQuery(StringBuffer sb, Session ac newline(sb, 4); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlDepartment(), false, true, headerRow); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlRoomDept(), false, true, headerRow); + + } + if (includeSubjectArea || includeSection) { newline(sb, 4); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlSubject(), false, true, headerRow); } + if (includeSection) { + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlCourseNbr(), false, true, headerRow); + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlItype(), false, true, headerRow); + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlSection(), false, true, headerRow); + + } newline(sb, 4); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlEventType(), false, true, headerRow); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlEventTypeDescription(), false, true, headerRow); @@ -514,7 +638,7 @@ public void getBuildingUsageAndOccupancyTimeDayQuery(StringBuffer sb, Session ac newline(sb, 4); appendSumZeroIfNull(sb, seatUsageTable, MESSAGES.utilSqlStationsRequested(), false, headerRow); newline(sb, 0); - fromClause(sb, acadSession, true, includeSubjectArea, includeDept, isCheckNull); + fromClause(sb, acadSession, true, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment, isCheckNull); newline(sb, 0); sb.append("where ") .append(roomUsageTable) @@ -542,10 +666,23 @@ public void getBuildingUsageAndOccupancyTimeDayQuery(StringBuffer sb, Session ac newline(sb, 4); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlDepartment(), false, true, null); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlRoomDept(), false, true, null); + } + if (includeSubjectArea || includeSection) { newline(sb, 4); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlSubject(), false, true, null); } + if (includeSection) { + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlCourseNbr(), false, true, null); + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlItype(), false, true, null); + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlSection(), false, true, null); + + } newline(sb, 4); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlDayTime(), false, false, null); @@ -555,13 +692,21 @@ public void getBuildingUsageAndOccupancyTimeDayQuery(StringBuffer sb, Session ac public String getBuildingUsageAndOccupancyTimeDayQuery(Session acadSession, boolean isByRoomType, boolean includeSubjectArea, boolean includeDept, ArrayList headerRow) { + return getBuildingUsageAndOccupancyTimeDayQuery(acadSession, isByRoomType, + includeSubjectArea, includeDept, + false, false, headerRow); + } + + public String getBuildingUsageAndOccupancyTimeDayQuery(Session acadSession, boolean isByRoomType, + boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment, ArrayList headerRow) { StringBuffer sb = new StringBuffer(); - getBuildingUsageAndOccupancyTimeDayQuery(sb, acadSession, isByRoomType, includeSubjectArea, includeDept, false, headerRow); + getBuildingUsageAndOccupancyTimeDayQuery(sb, acadSession, isByRoomType, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment,false, headerRow); newline(sb, 0); - if(includeDept || includeSubjectArea) { + if(includeDept || includeSubjectArea || includeSection || includeRoomControlingDepartment) { sb.append(" union all "); newline(sb, 0); - getBuildingUsageAndOccupancyTimeDayQuery(sb, acadSession, isByRoomType, includeSubjectArea, includeDept, true, null); + getBuildingUsageAndOccupancyTimeDayQuery(sb, acadSession, isByRoomType, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment, true, null); newline(sb, 0); } newline(sb, 0); @@ -584,11 +729,27 @@ public String getBuildingUsageAndOccupancyTimeDayQuery(Session acadSession, bool sb.append(MESSAGES.utilSqlDepartment()); sb.append(","); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + newline(sb, 10); + sb.append(MESSAGES.utilSqlRoomDept()); + sb.append(","); + } + if (includeSubjectArea || includeSection) { newline(sb, 10); sb.append(MESSAGES.utilSqlSubject()); sb.append(","); } + if (includeSection) { + newline(sb, 10); + sb.append(MESSAGES.utilSqlCourseNbr()); + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlItype()); + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlSection()); + sb.append(","); + } newline(sb, 10); sb.append(MESSAGES.utilSqlEventType()); sb.append(","); @@ -604,9 +765,9 @@ public String getBuildingUsageAndOccupancyTimeDayQuery(Session acadSession, bool } - private void buildingData(StringBuffer sb, Session acadSession, boolean isByRoomType, boolean includeSubjectArea, - boolean includeDept, boolean isCheckNull, ArrayList headerRow) { + boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment, boolean isCheckNull, ArrayList headerRow) { sb.append("("); newline(sb, 0); @@ -638,10 +799,22 @@ private void buildingData(StringBuffer sb, Session acadSession, boolean isByRoom newline(sb, 4); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlDepartment(), false, true, headerRow); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlRoomDept(), false, true, headerRow); + } + if (includeSubjectArea || includeSection) { newline(sb, 4); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlSubject(), false, true, headerRow); } + if (includeSection) { + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlCourseNbr(), false, true, headerRow); + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlItype(), false, true, headerRow); + newline(sb, 4); + appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlSection(), false, true, headerRow); + } newline(sb, 4); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlEventType(), false, true, headerRow); appendSelectedField(sb, roomUsageTable, MESSAGES.utilSqlEventTypeDescription(), false, true, headerRow); @@ -674,7 +847,7 @@ private void buildingData(StringBuffer sb, Session acadSession, boolean isByRoom appendSelectedField(sb, seatUsageTable, MESSAGES.utilSqlStationsRequested() + MESSAGES.utilSqlTotalAllHoursSuffix(), false, false, headerRow); newline(sb, 4); newline(sb, 0); - fromClause(sb, acadSession, false, includeSubjectArea, includeDept, isCheckNull); + fromClause(sb, acadSession, false, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment, isCheckNull); newline(sb, 0); sb.append(") ") .append(buildingDataTable); @@ -684,6 +857,14 @@ private void buildingData(StringBuffer sb, Session acadSession, boolean isByRoom public void getBuildingUsageAndOccupancyQuery(StringBuffer sb, Session acadSession, boolean isByRoomType, boolean includeSubjectArea, boolean includeDept, boolean isCheckNull, ArrayList headerRow) { + getBuildingUsageAndOccupancyQuery(sb, acadSession, isByRoomType, includeSubjectArea, + includeDept, false, false, isCheckNull, headerRow); + } + + + public void getBuildingUsageAndOccupancyQuery(StringBuffer sb, Session acadSession, boolean isByRoomType, boolean includeSubjectArea, + boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment, boolean isCheckNull, ArrayList headerRow) { newline(sb, 0); sb.append("select "); @@ -701,10 +882,22 @@ public void getBuildingUsageAndOccupancyQuery(StringBuffer sb, Session acadSessi newline(sb, 4); appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlDepartment(), false, true, headerRow); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + newline(sb, 4); + appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlRoomDept(), false, true, headerRow); + } + if (includeSubjectArea || includeSection) { newline(sb, 4); appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlSubject(), false, true, headerRow); } + if (includeSection) { + newline(sb, 4); + appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlCourseNbr(), false, true, headerRow); + newline(sb, 4); + appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlItype(), false, true, headerRow); + newline(sb, 4); + appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlSection(), false, true, headerRow); + } newline(sb, 4); appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlEventType(), false, true, headerRow); appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlEventTypeDescription(), false, true, headerRow); @@ -763,7 +956,7 @@ public void getBuildingUsageAndOccupancyQuery(StringBuffer sb, Session acadSessi newline(sb, 0); sb.append("from"); newline(sb, 0); - buildingData(sb, acadSession, isByRoomType, includeSubjectArea, includeDept, isCheckNull, null); + buildingData(sb, acadSession, isByRoomType, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment, isCheckNull, null); newline(sb, 0); sb.append("where ") .append(buildingDataTable) @@ -791,24 +984,42 @@ public void getBuildingUsageAndOccupancyQuery(StringBuffer sb, Session acadSessi newline(sb, 4); appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlDepartment(), true, false, null); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + newline(sb, 4); + appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlRoomDept(), true, false, null); + } + if (includeSubjectArea || includeSection) { newline(sb, 4); appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlSubject(), true, false, null); } + if (includeSection) { + newline(sb, 4); + appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlCourseNbr(), true, false, null); + newline(sb, 4); + appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlItype(), true, false, null); + newline(sb, 4); + appendSelectedField(sb, buildingDataTable, MESSAGES.utilSqlSection(), true, false, null); + } newline(sb, 0); } - public String getBuildingUsageAndOccupancyQuery(Session acadSession, boolean isByRoomType, boolean includeSubjectArea, boolean includeDept, ArrayList headerRow) { + public String getBuildingUsageAndOccupancyQuery(Session acadSession, boolean isByRoomType, boolean includeSubjectArea, boolean includeDept, + ArrayList headerRow) { + return getBuildingUsageAndOccupancyQuery(acadSession, isByRoomType, includeSubjectArea, includeDept, + false, false, headerRow); + } + public String getBuildingUsageAndOccupancyQuery(Session acadSession, boolean isByRoomType, boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment, ArrayList headerRow) { StringBuffer sb = new StringBuffer(); - getBuildingUsageAndOccupancyQuery(sb, acadSession, isByRoomType, includeSubjectArea, includeDept, false, headerRow); + getBuildingUsageAndOccupancyQuery(sb, acadSession, isByRoomType, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment, false, headerRow); newline(sb, 0); - if(includeDept || includeSubjectArea) { + if(includeDept || includeSubjectArea || includeSection || includeRoomControlingDepartment) { newline(sb, 0); sb.append(" union all "); newline(sb, 0); - getBuildingUsageAndOccupancyQuery(sb, acadSession, isByRoomType, includeSubjectArea, includeDept, true, null); + getBuildingUsageAndOccupancyQuery(sb, acadSession, isByRoomType, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment, true, null); newline(sb, 0); } newline(sb, 0); @@ -831,11 +1042,27 @@ public String getBuildingUsageAndOccupancyQuery(Session acadSession, boolean isB sb.append(MESSAGES.utilSqlDepartment()); sb.append(","); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + newline(sb, 10); + sb.append(MESSAGES.utilSqlRoomDept()); + sb.append(","); + } + if (includeSubjectArea || includeSection) { newline(sb, 10); sb.append(MESSAGES.utilSqlSubject()); sb.append(","); } + if (includeSection) { + newline(sb, 10); + sb.append(MESSAGES.utilSqlCourseNbr()); + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlItype()); + sb.append(","); + newline(sb, 10); + sb.append(MESSAGES.utilSqlSection()); + sb.append(","); + } newline(sb, 10); sb.append(MESSAGES.utilSqlEventType()); sb.append(","); @@ -848,11 +1075,22 @@ public String getBuildingUsageAndOccupancyQuery(Session acadSession, boolean isB public String getBuildingUsageAndOccupancyByRoomTypeQuery(Session acadSession, boolean includeSubjectArea, boolean includeDept, ArrayList headerRow) { - return getBuildingUsageAndOccupancyQuery(acadSession, true, includeSubjectArea, includeDept, headerRow); + return getBuildingUsageAndOccupancyByRoomTypeQuery(acadSession, includeSubjectArea, includeDept, false, false, headerRow); + } + + public String getBuildingUsageAndOccupancyByRoomTypeQuery(Session acadSession, boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment, ArrayList headerRow) { + return getBuildingUsageAndOccupancyQuery(acadSession, true, includeSubjectArea, includeDept, + includeSection, includeRoomControlingDepartment, headerRow); } public String getBuildingUsageAndOccupancyWholeBuildingQuery(Session acadSession, boolean includeSubjectArea, boolean includeDept, ArrayList headerRow) { - return getBuildingUsageAndOccupancyQuery(acadSession, false, includeSubjectArea, includeDept, headerRow); + return getBuildingUsageAndOccupancyWholeBuildingQuery(acadSession, includeSubjectArea, includeDept, false, false, headerRow); + } + + public String getBuildingUsageAndOccupancyWholeBuildingQuery(Session acadSession, boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment, ArrayList headerRow) { + return getBuildingUsageAndOccupancyQuery(acadSession, false, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment, headerRow); } protected void indent(StringBuffer stringBuffer, int indentSizeInChars) { diff --git a/JavaSource/org/unitime/timetable/util/RoomUtilizationHelper.java b/JavaSource/org/unitime/timetable/util/RoomUtilizationHelper.java index ca6d5ec81d..45c2e498d5 100644 --- a/JavaSource/org/unitime/timetable/util/RoomUtilizationHelper.java +++ b/JavaSource/org/unitime/timetable/util/RoomUtilizationHelper.java @@ -67,7 +67,8 @@ protected String getBaseQueryAdditionalSelectColumns() { @Override public String getPivotedQuery(ArrayList allDays, ArrayList weekDays, Integer saturday, String campus, String year, String term, ArrayList headerRow, - boolean includeDayOfWkTimeOfDayInHeaderRow, boolean includeSubjectArea, boolean includeDept) { + boolean includeDayOfWkTimeOfDayInHeaderRow, boolean includeSubjectArea, boolean includeDept, + boolean includeSection, boolean includeRoomControlingDepartment) { StringBuffer sb = new StringBuffer(); sb.append("select "); appendSelectedField(sb, "zz", MESSAGES.utilSqlAcademicInitiative(), false, true); @@ -98,11 +99,23 @@ public String getPivotedQuery(ArrayList allDays, ArrayList wee newline(sb, 4); appendSelectedField(sb, "zz", MESSAGES.utilSqlDepartment(), false, true); } - if (includeSubjectArea) { + if (includeRoomControlingDepartment) { + newline(sb, 4); + appendSelectedField(sb, "zz", MESSAGES.utilSqlRoomDept(), false, true); + } + if (includeSubjectArea || includeSection) { newline(sb, 4); appendSelectedField(sb, "zz", MESSAGES.utilSqlSubject(), false, true); } - + if (includeSection) { + newline(sb, 4); + appendSelectedField(sb, "zz", MESSAGES.utilSqlCourseNbr(), false, true); + newline(sb, 4); + appendSelectedField(sb, "zz", MESSAGES.utilSqlItype(), false, true); + newline(sb, 4); + appendSelectedField(sb, "zz", MESSAGES.utilSqlSection(), false, true); + + } newline(sb, 4); appendSelectedField(sb, "zz", MESSAGES.utilSqlEventType(), false, true); newline(sb, 4); @@ -124,7 +137,8 @@ public String getPivotedQuery(ArrayList allDays, ArrayList wee newline(sb, 0); sb.append("from ( "); newline(sb,4); - sb.append(getPivotedBaseSummaryQuery(allDays, weekDays, saturday, campus, year, term, headerRow, includeDayOfWkTimeOfDayInHeaderRow, includeSubjectArea, includeDept)); + sb.append(getPivotedBaseSummaryQuery(allDays, weekDays, saturday, campus, year, term, + headerRow, includeDayOfWkTimeOfDayInHeaderRow, includeSubjectArea, includeDept, includeSection, includeRoomControlingDepartment)); newline(sb,4); sb.append(" ) zz "); return sb.toString();