/** * @param command * @param result * @return */ @RequestMapping(method = RequestMethod.POST) public ModelAndView searchCarta( @Valid @ModelAttribute("command") ShowExplorerVolumeCommand command, BindingResult result) { if (command.getInsertNum() != null || command.getInsertLet() != null || command.getImageProgTypeNum() != null || command.getMissedNumbering() != null) { // validation should be launched only when insert and folio details have a value (at least one // of them) getValidator().validate(command, result); } if (result.hasErrors()) { // in case of errors we need to remove imageType and imageProgTypeNum, so we return imageOrder // which is previous image. command.setImageType(null); // command.setImageProgTypeNum(null); return setupForm(command, result); } else { Map<String, Object> model = new HashMap<String, Object>(0); VolumeExplorer volumeExplorer = new VolumeExplorer(command.getSummaryId(), command.getVolNum(), command.getVolLetExt()); volumeExplorer.setImage(new Image()); if (!StringUtils.isNullableString(command.getInsertNum())) { volumeExplorer.getImage().setInsertNum(StringUtils.nullTrim(command.getInsertNum())); volumeExplorer.getImage().setInsertLet(StringUtils.nullTrim(command.getInsertLet())); } volumeExplorer.getImage().setImageProgTypeNum(command.getImageProgTypeNum()); volumeExplorer .getImage() .setMissedNumbering(StringUtils.nullTrim(command.getMissedNumbering())); volumeExplorer .getImage() .setImageRectoVerso( Image.ImageRectoVerso.convertFromString( StringUtils.nullTrim(command.getImageRectoVerso()))); volumeExplorer.getImage().setImageOrder(command.getImageOrder()); volumeExplorer.getImage().setImageType(command.getImageType()); volumeExplorer.setTotal(command.getTotal()); volumeExplorer.setTotalRubricario(command.getTotalRubricario()); volumeExplorer.setTotalCarta(command.getTotalCarta()); volumeExplorer.setTotalAppendix(command.getTotalAppendix()); volumeExplorer.setTotalOther(command.getTotalOther()); volumeExplorer.setTotalGuardia(command.getTotalGuardia()); try { Boolean hasInserts = getVolBaseService().hasInserts(command.getVolNum(), command.getVolLetExt()); model.put("hasInsert", hasInserts); volumeExplorer = getVolBaseService().getVolumeExplorer(volumeExplorer); model.put("volumeExplorer", volumeExplorer); } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); return new ModelAndView("error/ShowExplorerVolume", model); } if (BooleanUtils.isTrue(command.getModalWindow())) { return new ModelAndView("volbase/ShowExplorerVolumeModalWindow", model); } else { return new ModelAndView("volbase/ShowExplorerVolume", model); } } }
/** * @param volumeId * @return */ @RequestMapping(method = RequestMethod.GET) public ModelAndView setupForm( @ModelAttribute("command") ShowExplorerVolumeCommand command, BindingResult result) { Map<String, Object> model = new HashMap<String, Object>(0); VolumeExplorer volumeExplorer = new VolumeExplorer(command.getSummaryId(), command.getVolNum(), command.getVolLetExt()); volumeExplorer.setImage(new Image()); volumeExplorer.getImage().setImageProgTypeNum(command.getImageProgTypeNum()); volumeExplorer .getImage() .setMissedNumbering(StringUtils.nullTrim(command.getMissedNumbering())); volumeExplorer .getImage() .setImageRectoVerso( Image.ImageRectoVerso.convertFromString( StringUtils.nullTrim(command.getImageRectoVerso()))); volumeExplorer.getImage().setImageOrder(command.getImageOrder()); volumeExplorer.getImage().setImageType(command.getImageType()); volumeExplorer.getImage().setInsertNum(StringUtils.nullTrim(command.getInsertNum())); volumeExplorer .getImage() .setInsertLet( StringUtils.isNullableString(command.getInsertNum()) ? null : command.getInsertLet()); volumeExplorer.setTotal(command.getTotal()); volumeExplorer.setTotalRubricario(command.getTotalRubricario()); volumeExplorer.setTotalCarta(command.getTotalCarta()); volumeExplorer.setTotalAppendix(command.getTotalAppendix()); volumeExplorer.setTotalOther(command.getTotalOther()); volumeExplorer.setTotalGuardia(command.getTotalGuardia()); try { volumeExplorer = getVolBaseService().getVolumeExplorer(volumeExplorer); model.put("volumeExplorer", volumeExplorer); Boolean hasInserts = getVolBaseService().hasInserts(command.getVolNum(), command.getVolLetExt()); model.put("hasInsert", hasInserts); } catch (ApplicationThrowable ath) { } if (BooleanUtils.isTrue(command.getModalWindow())) { return new ModelAndView("volbase/ShowExplorerVolumeModalWindow", model); } else { return new ModelAndView("volbase/ShowExplorerVolume", model); } }