@@ -167,7 +167,7 @@ public Object updateRoles( @PathVariable User user, @RequestParam(required = fal
167
167
}
168
168
} catch ( RoleException e ) {
169
169
redirectAttributes .addFlashAttribute ( "message" , e .getMessage () );
170
- redirectAttributes .addFlashAttribute ( "error" , true );
170
+ redirectAttributes .addFlashAttribute ( "error" , Boolean . TRUE );
171
171
}
172
172
return "redirect:/admin/users/" + user .getId ();
173
173
@@ -361,9 +361,9 @@ public Object deleteOntology( @PathVariable(required = false) Ontology ontology,
361
361
redirectAttributes .addFlashAttribute ( "message" , String .format ( "The %s category has been deleted." , messageSource .getMessage ( ontology .getResolvableTitle (), locale ) ) );
362
362
return "redirect:/admin/ontologies" ;
363
363
} catch ( DataIntegrityViolationException e ) {
364
- log .warn ( String .format ( "An administrator attempted to delete %s, but it failed: %s" , ontology , e .getMessage () ) );
364
+ log .warn ( String .format ( "An administrator attempted to delete %s, but it failed: %s" , ontology . toString (). replaceAll ( "[ \r \n ]" , "" ) , e .getMessage () ) );
365
365
modelAndView .setStatus ( HttpStatus .BAD_REQUEST );
366
- modelAndView .addObject ( "error" , true );
366
+ modelAndView .addObject ( "error" , Boolean . TRUE );
367
367
modelAndView .addObject ( "message" , String .format ( "The %s category could not be deleted because it is being used. Instead, you should deactivate it." , messageSource .getMessage ( ontology .getResolvableTitle (), locale ) ) );
368
368
}
369
369
}
@@ -592,9 +592,9 @@ public void validate( Object target, Errors errors ) {
592
592
.filter ( row -> !row .isEmpty () )
593
593
.map ( SimpleOntologyTermForm ::getTermId )
594
594
.filter ( termId -> !StringUtils .isEmpty ( termId ) ) // empty or null term IDs are generated
595
- .collect ( Collectors .groupingBy ( t -> t , Collectors .counting () ) );
595
+ .collect ( Collectors .groupingBy ( identity () , Collectors .counting () ) );
596
596
if ( countsByTermId .values ().stream ().anyMatch ( x -> x > 1 ) ) {
597
- errors .rejectValue ( "ontologyTerms" , "AdminController.SimpleOntologyForm.ontologyTerms.nonUniqueTermIds" , "termId must be unique" );
597
+ errors .rejectValue ( "ontologyTerms" , "AdminController.SimpleOntologyForm.ontologyTerms.nonUniqueTermIds" );
598
598
}
599
599
600
600
// validate non-empty rows
@@ -643,19 +643,19 @@ public Object updateOntology( @PathVariable(required = false) Ontology ontology,
643
643
return new ModelAndView ( "admin/ontology" , HttpStatus .BAD_REQUEST )
644
644
.addAllObjects ( defaultsForOntologyModelAndView ( ontology ) )
645
645
.addObject ( "message" , "The provided ontology cannot be updated because it lacks an external URL." )
646
- .addObject ( "error" , true );
646
+ .addObject ( "error" , Boolean . TRUE );
647
647
} else {
648
648
Resource urlResource = ontologyService .resolveOntologyUrl ( ontology .getOntologyUrl () );
649
649
try ( Reader reader = new InputStreamReader ( urlResource .getInputStream () ) ) {
650
650
ontologyService .updateFromObo ( ontology , reader );
651
651
int numActivated = ontologyService .propagateSubtreeActivation ( ontology );
652
652
redirectAttributes .addFlashAttribute ( "message" , String .format ( "Updated %s from %s. %d terms got activated via subtree propagation." , messageSource .getMessage ( ontology .getResolvableTitle (), locale ), ontology .getOntologyUrl (), numActivated ) );
653
653
} catch ( IOException | ParseException e ) {
654
- log .warn ( String .format ( "Failed to update ontology %s from administrative section." , ontology ), e );
654
+ log .warn ( String .format ( "Failed to update ontology %s from administrative section." , ontology . toString (). replaceAll ( "[ \r \n ]" , "" ) ), e );
655
655
return new ModelAndView ( "admin/ontology" , HttpStatus .BAD_REQUEST )
656
656
.addAllObjects ( defaultsForOntologyModelAndView ( ontology ) )
657
657
.addObject ( "message" , String .format ( "Failed to update %s: %s" , messageSource .getMessage ( ontology .getResolvableTitle (), locale ), e .getMessage () ) )
658
- .addObject ( "error" , true );
658
+ .addObject ( "error" , Boolean . TRUE );
659
659
}
660
660
}
661
661
return "redirect:/admin/ontologies/" + ontology .getId ();
@@ -673,14 +673,12 @@ public Object importOntology( @Valid ImportOntologyForm importOntologyForm, Bind
673
673
ontologyService .update ( ontology );
674
674
return "redirect:/admin/ontologies/" + ontology .getId ();
675
675
} catch ( OntologyNameAlreadyUsedException e ) {
676
- bindingResult .reject ( "AdminController.ImportOntologyForm.ontologyWithSameNameAlreadyUsed" , new String []{ e .getOntologyName () },
677
- String .format ( "An ontology with the same name '%s' is already used." , e .getOntologyName () ) );
676
+ bindingResult .reject ( "AdminController.ImportOntologyForm.ontologyWithSameNameAlreadyUsed" , new String []{ e .getOntologyName () }, null );
678
677
return new ModelAndView ( "admin/ontologies" , HttpStatus .BAD_REQUEST )
679
678
.addObject ( "simpleOntologyForm" , SimpleOntologyForm .withInitialRows () );
680
679
} catch ( IOException | ParseException e ) {
681
680
log .warn ( String .format ( "Failed to import ontology from submitted form: %s." , importOntologyForm ), e );
682
- bindingResult .reject ( "AdminController.ImportOntologyForm.failedToParseOboFormat" , new String []{ importOntologyForm .getFilename (), e .getMessage () },
683
- String .format ( "Failed to parse the ontology OBO format from %s: %s" , importOntologyForm .getFilename (), e .getMessage () ) );
681
+ bindingResult .reject ( "AdminController.ImportOntologyForm.failedToParseOboFormat" , new String []{ importOntologyForm .getFilename (), e .getMessage () }, null );
684
682
return new ModelAndView ( "admin/ontologies" , HttpStatus .INTERNAL_SERVER_ERROR )
685
683
.addObject ( "simpleOntologyForm" , SimpleOntologyForm .withInitialRows () );
686
684
}
@@ -711,7 +709,7 @@ public Object importReactomePathways( RedirectAttributes redirectAttributes ) {
711
709
} catch ( ReactomeException e ) {
712
710
log .error ( "Failed to import Reactome pathways. Could this be an issue with the ontology configuration?" , e );
713
711
redirectAttributes .addFlashAttribute ( "message" , "Failed to import Reactome pathways: " + e .getMessage () + "." );
714
- redirectAttributes .addFlashAttribute ( "error" , true );
712
+ redirectAttributes .addFlashAttribute ( "error" , Boolean . TRUE );
715
713
return "redirect:/admin/ontologies" ;
716
714
}
717
715
}
@@ -730,7 +728,7 @@ public Object updateReactomePathways( @PathVariable(required = false) Ontology o
730
728
} catch ( ReactomeException e ) {
731
729
log .error ( "Failed to update Reactome pathways. Could this be an issue with the ontology configuration?" , e );
732
730
redirectAttributes .addFlashAttribute ( "message" , "Failed to update Reactome pathways: " + e .getMessage () + "." );
733
- redirectAttributes .addFlashAttribute ( "error" , true );
731
+ redirectAttributes .addFlashAttribute ( "error" , Boolean . TRUE );
734
732
return "redirect:/admin/ontologies" ;
735
733
}
736
734
}
@@ -948,7 +946,7 @@ private Object activateOrDeactivateTerm( Ontology ontology,
948
946
* Provides the ontology in OBO format.
949
947
*/
950
948
@ GetMapping (value = "/admin/ontologies/{ontology}/download" , produces = "text/plain" )
951
- public ResponseEntity <StreamingResponseBody > downloadOntology ( @ PathVariable (required = false ) Ontology ontology ) {
949
+ public ResponseEntity <StreamingResponseBody > downloadOntology ( @ PathVariable (required = false ) Ontology ontology , TimeZone timeZone ) {
952
950
if ( ontology == null ) {
953
951
return ResponseEntity .notFound ().build ();
954
952
}
@@ -957,7 +955,7 @@ public ResponseEntity<StreamingResponseBody> downloadOntology( @PathVariable(req
957
955
headers .set ( "Content-Disposition" , String .format ( "attachment; filename=%s.obo" , ontology .getName () ) );
958
956
return new ResponseEntity <>( outputStream -> {
959
957
try ( Writer writer = new OutputStreamWriter ( outputStream ) ) {
960
- ontologyService .writeObo ( ontology , writer );
958
+ ontologyService .writeObo ( ontology , writer , timeZone );
961
959
}
962
960
}, headers , HttpStatus .OK );
963
961
}
@@ -1002,7 +1000,7 @@ public Object move( @PathVariable(required = false) Ontology ontology, @RequestP
1002
1000
d = OntologyService .Direction .DOWN ;
1003
1001
} else {
1004
1002
return new ModelAndView ( "admin/ontologies" , HttpStatus .BAD_REQUEST )
1005
- .addObject ( "error" , true )
1003
+ .addObject ( "error" , Boolean . TRUE )
1006
1004
.addObject ( "message" , String .format ( "Invalid direction %s." , direction ) )
1007
1005
.addObject ( "simpleOntologyForm" , SimpleOntologyForm .withInitialRows () );
1008
1006
}
0 commit comments