@@ -385,14 +385,15 @@ protected List<Location> locations(Long sessionId, Map<String, Set<String>> opti
385385 Set <String > flag = (options == null || "flag" .equals (ignoreCommand ) ? null : options .get ("flag" ));
386386 Set <String > departments = (options == null || "department" .equals (ignoreCommand ) ? null : options .get ("department" ));
387387 boolean nearby = (flag != null && (flag .contains ("nearby" ) || flag .contains ("Nearby" )));
388+ boolean examcap = (flag != null && (flag .contains ("examcap" ) || flag .contains ("Examination Capacity" )));
388389
389390 Set <String > featureTypes = new HashSet <String >();
390391 for (RoomFeatureType ft : RoomFeatureTypeDAO .getInstance ().findAll ())
391392 if (showRoomFeature (ft )) featureTypes .add (ft .getReference ().toLowerCase ().replace (' ' , '_' ));
392393
393394 List <Location > ret = new ArrayList <Location >();
394395 for (Location location : locations ) {
395- if (query != null && !query .match (new LocationMatcher (location , featureTypes , departments ))) continue ;
396+ if (query != null && !query .match (new LocationMatcher (location , featureTypes , departments ). setUseExamCapacity ( examcap ) )) continue ;
396397 if (nearby && building != null && !building .isEmpty () && (!(location instanceof Room ) || !building .contains (((Room )location ).getBuilding ().getAbbreviation ()))) continue ;
397398 ret .add (location );
398399 }
@@ -417,7 +418,7 @@ protected List<Location> locations(Long sessionId, Map<String, Set<String>> opti
417418 if (!coord .isEmpty ()) {
418419 for (Location location : locations ) {
419420 if (building != null && !building .isEmpty () && (location instanceof Room ) && building .contains (((Room )location ).getBuilding ().getAbbreviation ())) continue ;
420- if (query != null && !query .match (new LocationMatcher (location , featureTypes , departments ))) continue ;
421+ if (query != null && !query .match (new LocationMatcher (location , featureTypes , departments ). setUseExamCapacity ( examcap ) )) continue ;
421422 Coordinates c = new Coordinates (location );
422423 Double distance = null ;
423424 for (Coordinates x : coord ) {
@@ -465,10 +466,15 @@ private String suggestionQuery(String query) {
465466 @ Override
466467 public void suggestions (RoomFilterRpcRequest request , FilterRpcResponse response , EventContext context ) {
467468 fixRoomFeatureTypes (request );
469+
470+ Set <String > flag = request .getOptions ("flag" );
471+ boolean examcap = (flag != null && (flag .contains ("examcap" ) || flag .contains ("Examination Capacity" )));
468472
469473 Map <Long , Double > distances = new HashMap <Long , Double >();
470474 for (Location location : locations (request .getSessionId (), request .getOptions (), new Query (suggestionQuery (request .getText ())), 20 , distances , null , context )) {
471475 String hint = location .getRoomTypeLabel () + (location .getCapacity () == null ? "" : ", " + MESSAGES .hintRoomCapacity (location .getCapacity ().toString ()));
476+ if (examcap )
477+ hint = location .getRoomTypeLabel () + (location .getExamCapacity () == null ? "" : ", " + MESSAGES .hintRoomCapacity (location .getExamCapacity ().toString ()));
472478 Double dist = distances .get (location .getUniqueId ());
473479 if (dist != null ) hint += ", " + MESSAGES .hintRoomDistance (String .valueOf (Math .round (dist )));
474480 response .addSuggestion (location .getLabelWithDisplayName (), location .getLabel (), "(" + hint + ")" );
@@ -556,16 +562,19 @@ public static class LocationMatcher implements TermMatcher {
556562 private Location iLocation ;
557563 private Set <String > iFeatureTypes = null ;
558564 private Set <String > iDepartments = null ;
565+ private boolean iUseExamCapacity = false ;
559566
560567 public LocationMatcher (Location location , Set <String > featureTypes ) {
561568 this (location , featureTypes , null );
562569 }
563-
570+
564571 public LocationMatcher (Location location , Set <String > featureTypes , Set <String > departments ) {
565572 iLocation = location ;
566573 iFeatureTypes = featureTypes ;
567574 iDepartments = departments ;
568575 }
576+
577+ public LocationMatcher setUseExamCapacity (boolean useExamCapacity ) { iUseExamCapacity = useExamCapacity ; return this ; }
569578
570579 public Location getLocation () { return iLocation ; }
571580
@@ -629,7 +638,8 @@ public boolean match(String attr, String term) {
629638 min = Integer .parseInt (a ); max = Integer .parseInt (b );
630639 } catch (NumberFormatException e ) {}
631640 }
632- return min <= getLocation ().getCapacity () && getLocation ().getCapacity () <= max ;
641+ Integer capacity = (iUseExamCapacity ? getLocation ().getExamCapacity () : getLocation ().getCapacity ());
642+ return capacity != null && min <= capacity && capacity <= max ;
633643 } else if ("flag" .equals (attr ) && "event" .equalsIgnoreCase (term )) {
634644 return getLocation ().getEventDepartment () != null && getLocation ().getEventDepartment ().isAllowEvents () && getLocation ().getEffectiveEventStatus () != RoomTypeOption .Status .NoEventManagement ;
635645 } else if ("department" .equals (attr ) || "dept" .equals (attr ) || "event" .equals (attr ) || "control" .equals (attr )) {
@@ -757,6 +767,11 @@ public RoomQuery getQuery(Long sessionId, Map<String, Set<String>> options, Even
757767 }
758768 }
759769
770+
771+ Set <String > flags = (options == null ? null : options .get ("flag" ));
772+ boolean nearby = (flags != null && (flags .contains ("nearby" ) || flags .contains ("Nearby" )));
773+ boolean examcap = (flags != null && (flags .contains ("examcap" ) || flags .contains ("Examination Capacity" )));
774+
760775 Set <String > size = (options == null ? null : options .get ("size" ));
761776 if (size != null && !size .isEmpty ()) {
762777 String term = size .iterator ().next ();
@@ -787,22 +802,19 @@ public RoomQuery getQuery(Long sessionId, Map<String, Set<String>> options, Even
787802 }
788803 if (min > 0 ) {
789804 if (max < Integer .MAX_VALUE ) {
790- query .addWhere ("size" , "l.capacity >= :Xmin and l.capacity <= :Xmax" );
805+ query .addWhere ("size" , examcap ? "l.examCapacity >= :Xmin and l.examCapacity <= :Xmax" : "l.capacity >= :Xmin and l.capacity <= :Xmax" );
791806 query .addParameter ("size" , "Xmin" , min );
792807 query .addParameter ("size" , "Xmax" , max );
793808 } else {
794- query .addWhere ("size" , "l.capacity >= :Xmin" );
809+ query .addWhere ("size" , examcap ? "l.examCapacity >= :Xmin" : "l.capacity >= :Xmin" );
795810 query .addParameter ("size" , "Xmin" , min );
796811 }
797812 } else if (max < Integer .MAX_VALUE ) {
798- query .addWhere ("size" , "l.capacity <= :Xmax" );
813+ query .addWhere ("size" , examcap ? "l.examCapacity <= :Xmax" : "l.capacity <= :Xmax" );
799814 query .addParameter ("size" , "Xmax" , max );
800815 }
801816 }
802817
803- Set <String > flags = (options == null ? null : options .get ("flag" ));
804- boolean nearby = (flags != null && (flags .contains ("nearby" ) || flags .contains ("Nearby" )));
805-
806818 Set <String > buildings = (options == null ? null : options .get ("building" ));
807819 if (buildings != null && !buildings .isEmpty () && !nearby ) {
808820 String building = "" ;
0 commit comments