@@ -139,6 +139,8 @@ public class TestResultsController extends SpringActionController
139139 private static final Logger _log = LogManager .getLogger (TestResultsController .class );
140140 private static final SimpleDateFormat MDYFormat = new SimpleDateFormat ("MM/dd/yyyy" );
141141
142+ private static final String KEY_SUCCESS = "Success" ;
143+
142144 private static final DefaultActionResolver _actionResolver = new DefaultActionResolver (TestResultsController .class );
143145
144146 // Tab name constants for menu highlighting
@@ -486,15 +488,15 @@ public Object execute(TrainRunForm form, BindException errors)
486488 {
487489 if (form .getRunId () == null )
488490 {
489- return new ApiSimpleResponse (Map .of ("Success" , false , "error" , "runId is required" ));
491+ return new ApiSimpleResponse (Map .of (KEY_SUCCESS , false , "error" , "runId is required" ));
490492 }
491493 int runId = form .getRunId ();
492494 String trainString = form .getTrain ();
493495 if (!Strings .CI .equals (trainString , "true" ) &&
494496 !Strings .CI .equals (trainString , "false" ) &&
495497 !Strings .CI .equals (trainString , "force" ))
496498 {
497- return new ApiSimpleResponse (Map .of ("Success" , false , "error" , "train must be one of: true, false, force" ));
499+ return new ApiSimpleResponse (Map .of (KEY_SUCCESS , false , "error" , "train must be one of: true, false, force" ));
498500 }
499501 boolean train = Strings .CI .equals (trainString , "true" ); // true = add to training set, false = remove
500502 boolean force = Strings .CI .equals (trainString , "force" );
@@ -511,9 +513,9 @@ public Object execute(TrainRunForm form, BindException errors)
511513 if (!force )
512514 {
513515 if (details .length == 0 )
514- return new ApiSimpleResponse (Map .of ("Success" , false , "error" , "run does not exist: " + runId ));
516+ return new ApiSimpleResponse (Map .of (KEY_SUCCESS , false , "error" , "run does not exist: " + runId ));
515517 else if ((train && !foundRuns .isEmpty ()) || (!train && foundRuns .isEmpty ()))
516- return new ApiSimpleResponse (Map .of ("Success" , false , "error" , "no action necessary" ));
518+ return new ApiSimpleResponse (Map .of (KEY_SUCCESS , false , "error" , "no action necessary" ));
517519 }
518520 DbScope scope = TestResultsSchema .getSchema ().getScope ();
519521 try (DbScope .Transaction transaction = scope .ensureTransaction ())
@@ -550,7 +552,7 @@ else if ((train && !foundRuns.isEmpty()) || (!train && foundRuns.isEmpty()))
550552 new SqlExecutor (scope ).execute (sqlFragmentUpdate );
551553 transaction .commit ();
552554 }
553- return new ApiSimpleResponse ("Success" , true );
555+ return new ApiSimpleResponse (KEY_SUCCESS , true );
554556 }
555557 }
556558
@@ -623,6 +625,10 @@ public ModelAndView getView(ShowUserForm form, BindException errors) throws Exce
623625 ensureRunDataCached (runs , false );
624626
625627 TestsDataBean bean = new TestsDataBean (runs , user == null ? new User [0 ] : new User []{user });
628+ bean .setStartDate (startDate );
629+ bean .setEndDate (endDate );
630+ bean .setUsername (userName );
631+ bean .setDataInclude (dataInclude );
626632 JspView <TestsDataBean > view = new JspView <>("/org/labkey/testresults/view/user.jsp" , bean );
627633 view .setTitle ("User Results" );
628634 return view ;
@@ -956,7 +962,7 @@ public Object execute(RunIdForm form, BindException errors)
956962 ApiSimpleResponse response = new ApiSimpleResponse ();
957963 if (form .getRunId () == null )
958964 {
959- response .put ("Success" , false );
965+ response .put (KEY_SUCCESS , false );
960966 response .put ("error" , "runId is required" );
961967 return response ;
962968 }
@@ -972,11 +978,11 @@ public Object execute(RunIdForm form, BindException errors)
972978 Table .delete (TestResultsSchema .getTableInfoTestRuns (), rowId ); // delete run last because of foreign key
973979 transaction .commit ();
974980 } catch (Exception x ) {
975- response .put ("Success" , false );
981+ response .put (KEY_SUCCESS , false );
976982 response .put ("error" , x .getMessage ());
977983 return response ;
978984 }
979- response .put ("Success" , true );
985+ response .put (KEY_SUCCESS , true );
980986 return response ;
981987 }
982988 }
@@ -1003,7 +1009,7 @@ public Object execute(FlagRunForm form, BindException errors)
10031009 ApiSimpleResponse response = new ApiSimpleResponse ();
10041010 if (form .getRunId () == null )
10051011 {
1006- response .put ("Success" , false );
1012+ response .put (KEY_SUCCESS , false );
10071013 response .put ("error" , "runId is required" );
10081014 return response ;
10091015 }
@@ -1014,19 +1020,24 @@ public Object execute(FlagRunForm form, BindException errors)
10141020 SimpleFilter filter = new SimpleFilter ();
10151021 filter .addCondition (FieldKey .fromParts ("id" ), rowId );
10161022 try (DbScope .Transaction transaction = TestResultsSchema .getSchema ().getScope ().ensureTransaction ()) {
1017- RunDetail [] details = new TableSelector (TestResultsSchema .getTableInfoTestRuns (), filter , null ).getArray (RunDetail .class );
1018- RunDetail detail = details [0 ];
1023+ RunDetail detail = new TableSelector (TestResultsSchema .getTableInfoTestRuns (), filter , null ).getObject (RunDetail .class );
1024+ if (detail == null )
1025+ {
1026+ response .put (KEY_SUCCESS , false );
1027+ response .put ("error" , "run not found: " + rowId );
1028+ return response ;
1029+ }
10191030 if (form .getFlag () == null ) // if not specified keep same
10201031 flag = detail .isFlagged ();
10211032 detail .setFlagged (flag );
10221033 Table .update (null , TestResultsSchema .getTableInfoTestRuns (), detail , detail .getId ());
10231034 transaction .commit ();
10241035 } catch (Exception x ) {
1025- response .put ("Success" , false );
1036+ response .put (KEY_SUCCESS , false );
10261037 response .put ("error" , x .getMessage ());
10271038 return response ;
10281039 }
1029- response .put ("Success" , true );
1040+ response .put (KEY_SUCCESS , true );
10301041 return response ;
10311042 }
10321043 }
@@ -1591,7 +1602,7 @@ public Object execute(RetrainAllForm form, BindException errors)
15911602 transaction .commit ();
15921603
15931604 ApiSimpleResponse response = new ApiSimpleResponse ();
1594- response .put ("Success" , true );
1605+ response .put (KEY_SUCCESS , true );
15951606 response .put ("usersRetrained" , usersRetrained );
15961607 response .put ("totalTrainRuns" , totalTrainRuns );
15971608 response .put ("mode" , form .getMode ());
@@ -1601,7 +1612,7 @@ public Object execute(RetrainAllForm form, BindException errors)
16011612 {
16021613 _log .error ("Error in RetrainAllAction" , e );
16031614 ApiSimpleResponse response = new ApiSimpleResponse ();
1604- response .put ("Success" , false );
1615+ response .put (KEY_SUCCESS , false );
16051616 response .put ("error" , e .getMessage ());
16061617 return response ;
16071618 }
@@ -1654,13 +1665,13 @@ else if (xml.isEmpty())
16541665 } catch (Exception e ) {
16551666 _log .info ("XML failed to parse/store" );
16561667 _log .info ("Attempting to save file for a future post attempt" );
1657- res .put ("Success" , false );
1668+ res .put (KEY_SUCCESS , false );
16581669 res .put ("Message" , "Error Parsing XML attempting to save the XML file... " + NIGHTLY_POSTER .SaveXML (file , getContainer ()));
16591670 res .put ("Exception" , e + NIGHTLY_POSTER .getStackTraceText (e ));
16601671 return new ApiSimpleResponse (res );
16611672 }
16621673
1663- return new ApiSimpleResponse ("Success" , true );
1674+ return new ApiSimpleResponse (KEY_SUCCESS , true );
16641675 }
16651676
16661677 private void DebugRequest (HttpServletRequest hsRequest )
0 commit comments