List of usage examples for org.apache.commons.lang ObjectUtils toString
public static String toString(Object obj)
Gets the toString
of an Object
returning an empty string ("") if null
input.
ObjectUtils.toString(null) = "" ObjectUtils.toString("") = "" ObjectUtils.toString("bat") = "bat" ObjectUtils.toString(Boolean.TRUE) = "true"
From source file:org.medici.bia.controller.digitization.EditDetailsSchedoneController.java
/** * /*www. j a v a 2 s. co m*/ * @param command * @param result * @return */ @RequestMapping(method = RequestMethod.POST) public ModelAndView processSubmit(@Valid @ModelAttribute("command") EditDetailsSchedoneCommand command, BindingResult result) { getValidator().validate(command, result); if (result.hasErrors()) { return setupForm(command); } else { Map<String, Object> model = new HashMap<String, Object>(0); Schedone schedone = new Schedone(command.getSchedoneId()); schedone.setIstituto(command.getIstituto()); schedone.setFondo(command.getFondo()); if ((!ObjectUtils.toString(command.getSeriesRefNum()).equals("")) && (!ObjectUtils.toString(command.getSerie()).equals(""))) { schedone.setSerie(new SerieList(command.getSeriesRefNum())); } schedone.setNumeroUnita(command.getNumeroUnita()); schedone.setVolNum(command.getNumeroUnita()); if (command.getVolLetExt().equals("")) { schedone.setVolLetExt(null); } else { schedone.setVolLetExt(command.getVolLetExt()); } schedone.setDataInizioAnno(command.getDataInizioAnno()); schedone.setDataInizioMese( (command.getDataInizioMese() != null) ? new Month(command.getDataInizioMese()) : null); schedone.setDataInizioGiorno(command.getDataInizioGiorno()); schedone.setDataFineAnno(command.getDataFineAnno()); schedone.setDataFineMese( (command.getDataFineMese() != null) ? new Month(command.getDataFineMese()) : null); schedone.setDataFineGiorno(command.getDataFineGiorno()); schedone.setDescrizioneContenuto(command.getDescrizioneContenuto()); schedone.setDescrizioneContenutoEng(command.getDescrizioneContenutoEng()); schedone.setLegatura(command.getLegatura()); schedone.setSupporto(command.getSupporto()); schedone.setCartulazione(command.getCartulazione()); if (command.getNoteCartulazione().equals("")) { schedone.setNoteCartulazione(null); } else { schedone.setNoteCartulazione(command.getNoteCartulazione()); } if (command.getNoteCartulazioneEng().equals("")) { schedone.setNoteCartulazioneEng(null); } else { schedone.setNoteCartulazioneEng(command.getNoteCartulazioneEng()); } schedone.setCarteBianche(command.getCarteBianche()); schedone.setCarteMancanti(command.getCarteMancanti()); if (command.getDimensioniBase().equals("")) { schedone.setDimensioniBase(null); } else { schedone.setDimensioniBase(command.getDimensioniBase()); } schedone.setDimensioniAltezza(command.getDimensioniAltezza()); schedone.setTipoRipresa(command.getTipoRipresa()); schedone.setColoreImmagine(command.getColoreImmagine()); schedone.setRisoluzione(command.getRisoluzione()); schedone.setNomeFiles(command.getNomeFiles()); schedone.setResponsabileFotoRiproduzione(command.getResponsabileFotoRiproduzione()); schedone.setDataRipresaAnno(command.getDataRipresaAnno()); schedone.setDataRipresaMese( (command.getDataRipresaMese() != null) ? new Month(command.getDataRipresaMese()) : null); schedone.setDataRipresaGiorno(command.getDataRipresaGiorno()); schedone.setOperatore(command.getOperatore()); try { if (command.getSchedoneId().equals(0)) { schedone = getDigitizationService().addNewSchedone(schedone); model.put("schedone", schedone); //TODO: Create volume record if not entered return new ModelAndView("digitization/ShowSchedone", model); } else { schedone = getDigitizationService().editDetailsSchedone(schedone); model.put("schedone", schedone); return new ModelAndView("digitization/ShowSchedone", model); } } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); return new ModelAndView("error/EditDetailsSchedone", model); } } }
From source file:org.medici.bia.controller.docbase.EditCorrespondentsOrPeopleDocumentController.java
/** * /*w w w . j a va 2 s. co m*/ * @param command * @param result * @return */ @RequestMapping(method = RequestMethod.POST) public ModelAndView processSubmit( @Valid @ModelAttribute("command") EditCorrespondentsOrPeopleDocumentCommand command, BindingResult result) { getValidator().validate(command, result); if (result.hasErrors()) { return setupForm(command); } else { Map<String, Object> model = new HashMap<String, Object>(0); Document document = new Document(); document.setEntryId(command.getEntryId()); if (!ObjectUtils.toString(command.getSenderPeopleId()) .equals("")/* || !ObjectUtils.toString(command.getSenderPeopleDescription()).equals("")*/) { document.setSenderPeople(new People(command.getSenderPeopleId())); } else { document.setSenderPeople(new People(0)); } document.getSenderPeople().setMapNameLf(command.getSenderPeopleDescription()); if (ObjectUtils.toString(command.getSenderPeopleDescription()).equals("")) { document.setSenderPeopleUnsure(false); } else { document.setSenderPeopleUnsure(command.getSenderPeopleUnsure()); } if (ObjectUtils.toString(command.getSenderPlaceDescription()).equals("")) { document.setSenderPlace(new Place(0)); document.setSenderPlaceUnsure(false); } else { document.setSenderPlace(new Place(command.getSenderPlaceId())); document.setSenderPlaceUnsure(command.getSenderPlaceUnsure()); } document.setSendNotes(command.getSendNotes()); if (!ObjectUtils.toString(command.getRecipientPeopleId()) .equals("")/* || !ObjectUtils.toString(command.getRecipientPeopleDescription()).equals("")*/) { document.setRecipientPeople(new People(command.getRecipientPeopleId())); } else { document.setRecipientPeople(new People(0)); } document.getRecipientPeople().setMapNameLf(command.getRecipientPeopleDescription()); if (ObjectUtils.toString(command.getRecipientPeopleDescription()).equals("")) { document.setRecipientPeopleUnsure(false); } else { document.setRecipientPeopleUnsure(command.getRecipientPeopleUnsure()); } if (ObjectUtils.toString(command.getRecipientPlaceDescription()).equals("")) { document.setRecipientPlace(new Place(0)); document.setRecipientPlaceUnsure(false); } else { document.setRecipientPlace(new Place(command.getRecipientPlaceId())); document.setRecipientPlaceUnsure(command.getRecipientPlaceUnsure()); } document.setRecipNotes(command.getRecipNotes()); try { document = getDocBaseService().editCorrespondentsDocument(document); List<EplToLink> topicsDocument = getDocBaseService().findTopicsDocument(document.getEntryId()); model.put("topicsDocument", topicsDocument); HistoryNavigator historyNavigator = getDocBaseService().getHistoryNavigator(document); Image image = getManuscriptViewerService().findDocumentImageThumbnail(document); model.put("document", document); model.put("image", image); model.put("historyNavigator", historyNavigator); if (getDocBaseService().ifDocumentAlreadyPresentInMarkedList(document.getEntryId())) { model.put("inMarkedList", "true"); } else { model.put("inMarkedList", "false"); } } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); return new ModelAndView("error/EditCorrespondentsOrPeopleDocument", model); } return new ModelAndView("docbase/ShowDocument", model); } }
From source file:org.medici.bia.controller.docbase.EditTopicDocumentController.java
/** * //from ww w. j ava2s . c om * @param command * @param result * @return */ @RequestMapping(method = RequestMethod.POST) public ModelAndView processSubmit(@Valid @ModelAttribute("command") EditTopicDocumentCommand command, BindingResult result) { getValidator().validate(command, result); if (result.hasErrors()) { return setupForm(command); } else { Map<String, Object> model = new HashMap<String, Object>(0); EplToLink eplToLink = new EplToLink(command.getEplToId()); eplToLink.setDocument(new Document(command.getEntryId())); if (command.getTopicId() > 0) { eplToLink.setTopic(new TopicList(command.getTopicId())); } else { eplToLink.setTopic(null); } if (!ObjectUtils.toString(command.getPlaceDescription()).equals("")) { eplToLink.setPlace(new Place(command.getPlaceId())); } else { eplToLink.setPlace(null); } try { if (command.getEplToId().equals(0)) { getDocBaseService().addNewTopicDocument(eplToLink); } else { getDocBaseService().editTopicDocument(eplToLink); } } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); return new ModelAndView("error/ShowDocument", model); } return new ModelAndView("docbase/ShowDocument", model); } }
From source file:org.medici.bia.controller.docbase.EditTopicDocumentController.java
/** * /*from w w w.j av a 2s.c o m*/ * @param command * @return */ @RequestMapping(method = RequestMethod.GET) public ModelAndView setupForm(@ModelAttribute("command") EditTopicDocumentCommand command) { Map<String, Object> model = new HashMap<String, Object>(0); List<TopicList> topicsList = null; if ((command != null) && (command.getEntryId() > 0)) { if (command.getEplToId().equals(0)) { command.setPlaceDescription(null); command.setPlaceId(null); command.setTopicId(null); } else { try { EplToLink eplToLink = getDocBaseService().findTopicDocument(command.getEntryId(), command.getEplToId()); if (eplToLink.getPlace() != null) { command.setPlaceDescription(eplToLink.getPlace().getPlaceNameFull()); command.setPlaceId(eplToLink.getPlace().getPlaceAllId()); } else { command.setPlaceDescription(null); command.setPlaceId(null); } if (eplToLink.getTopic() != null) { command.setTopicId(eplToLink.getTopic().getTopicId()); } else { command.setTopicId(null); } } catch (ApplicationThrowable applicationThrowable) { return new ModelAndView("error/EditTopicDocument", model); } } try { topicsList = getDocBaseService().getTopicsList(); model.put("topicsList", topicsList); } catch (ApplicationThrowable ath) { return new ModelAndView("error/EditTopicDocument", model); } return new ModelAndView("docbase/EditTopicDocument", model); } else { // On Document creation, the research is always the current user. //command.setEntryId(); if (ObjectUtils.toString(command).equals("")) { command = new EditTopicDocumentCommand(); } command.setEplToId(null); command.setDateCreated(new Date()); command.setTopicId(null); command.setPlaceDescription(null); command.setPlaceId(null); } return new ModelAndView("docbase/EditTopicDocument", model); }
From source file:org.medici.bia.controller.docbase.ShowSameFolioDocumentsController.java
/** * //from w w w .jav a 2 s .co m * @param documentId * @param result * @return */ @RequestMapping(method = { RequestMethod.GET, RequestMethod.POST }) public ModelAndView processSubmit(@ModelAttribute("command") ShowSameFolioDocumentsCommand command, BindingResult result, HttpSession session) { Map<String, Object> model = new HashMap<String, Object>(0); List<String> outputFields = new ArrayList<String>(6); outputFields.add("Sender"); outputFields.add("Recipient"); outputFields.add("Date"); outputFields.add("Sender Location"); outputFields.add("Recipient Location"); outputFields.add("Volume / Insert / Folio"); model.put("outputFields", outputFields); model.put("volNum", command.getVolNum()); model.put("volLetExt", ObjectUtils.toString(command.getVolLetExt())); model.put("insertNum", ObjectUtils.toString(command.getInsertNum())); model.put("insertLet", ObjectUtils.toString(command.getInsertLet())); model.put("folioNum", command.getFolioNum()); model.put("folioMod", ObjectUtils.toString(command.getFolioMod())); model.put("folioRectoVerso", ObjectUtils.toString(command.getFolioRectoVerso())); return new ModelAndView("docbase/ShowSameFolioDocuments", model); }
From source file:org.medici.bia.controller.geobase.AjaxController.java
/** * //from www. j av a 2s .c om * @param searchType * @param sortingColumnNumber * @param sortingDirection * @param firstRecord * @param length * @return */ @SuppressWarnings("unused") private PaginationFilter generatePaginationFilter(Integer sortingColumnNumber, String sortingDirection, Integer firstRecord, Integer length) { PaginationFilter paginationFilter = new PaginationFilter(firstRecord, length); if (!ObjectUtils.toString(sortingColumnNumber).equals("")) { switch (sortingColumnNumber) { case 0: paginationFilter.addSortingCriteria("document.senderPeople.mapNameLf", sortingDirection); break; case 1: paginationFilter.addSortingCriteria("document.recipientPeople.mapNameLf", sortingDirection); break; case 2: paginationFilter.addSortingCriteria("document.sortableDateInt", sortingDirection); // paginationFilter.addSortingCriteria("document.docYear", sortingDirection); // //Month is an entity, so we don't have field with suffix // paginationFilter.addSortingCriteria("document.docMonthNum.monthNum", sortingDirection); // paginationFilter.addSortingCriteria("document.docDay", sortingDirection); break; case 3: paginationFilter.addSortingCriteria("document.senderPlace.placeName", sortingDirection); paginationFilter.addSortingCriteria("document.recipientPlace.placeName", sortingDirection); break; case 4: paginationFilter.addSortingCriteria("topic.topicTitle", sortingDirection); paginationFilter.addSortingCriteria("document.sortableDateInt", sortingDirection); // paginationFilter.addSortingCriteria("document.docYear", "asc"); // //Month is an entity, so we don't have field with suffix // paginationFilter.addSortingCriteria("document.docMonthNum.monthNum", "asc"); // paginationFilter.addSortingCriteria("document.docDay", "asc"); break; case 5: paginationFilter.addSortingCriteria("document.volume.volNum", sortingDirection); paginationFilter.addSortingCriteria("document.volume.volLetExt", sortingDirection); paginationFilter.addSortingCriteria("document.folioNum", sortingDirection); paginationFilter.addSortingCriteria("document.folioMod", sortingDirection); break; default: paginationFilter.addSortingCriteria("topic.topicTitle", sortingDirection); break; } } return paginationFilter; }
From source file:org.medici.bia.controller.geobase.EditDetailsPlaceController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView processSubmit(@Valid @ModelAttribute("command") EditDetailsPlaceCommand command, BindingResult result) {/*from ww w . j a va2 s.c om*/ getValidator().validate(command, result); if (result.hasErrors()) { return setupForm(command); } else { Map<String, Object> model = new HashMap<String, Object>(0); Place place = new Place(command.getPlaceAllId()); place.setResearcher(command.getResearcher()); place.setGeogKey(command.getGeogKey()); place.setPlType(command.getPlType()); place.setPlacesMemo(command.getPlacesMemo()); place.setPlParent(command.getPlParent()); place.setPlaceNameId(command.getPlaceNameId()); place.setPlaceName(command.getPlaceName()); if (command.getTermAccent().isEmpty()) { place.setTermAccent(command.getPlaceName()); } else { place.setTermAccent(command.getTermAccent()); } place.setPlSource(command.getPlSource()); place.setPrefFlag("P"); // TODO: complete to save the parent place if (!ObjectUtils.toString(command.getParentPlaceAllId()).equals("")) { place.setParentPlace(new Place(command.getParentPlaceAllId())); } else { place.setParentPlace(null); } try { if (command.getPlaceAllId().equals(0)) { place = getGeoBaseService().addNewPlace(place); List<Place> placeNames; placeNames = getGeoBaseService().findPlaceNames(place.getGeogKey()); model.put("placeNames", placeNames); model.put("place", place); HistoryNavigator historyNavigator = getGeoBaseService().getHistoryNavigator(place); model.put("historyNavigator", historyNavigator); return new ModelAndView("geobase/ShowPlace", model); } else { place = getGeoBaseService().editDetailsPlace(place); List<Place> placeNames = getGeoBaseService().findPlaceNames(place.getGeogKey()); model.put("placeNames", placeNames); model.put("place", place); model.put("topicsPlace", getGeoBaseService().findNumberOfTopicsPlace(place.getPlaceAllId())); model.put("docInTopics", getGeoBaseService().findNumberOfDocumentsInTopicsPlace(place.getPlaceAllId())); model.put("senderPlace", getGeoBaseService().findNumberOfSenderDocumentsPlace(place.getPlaceAllId())); model.put("recipientPlace", getGeoBaseService().findNumberOfRecipientDocumentsPlace(place.getPlaceAllId())); model.put("birthPlace", getGeoBaseService().findNumberOfBirthInPlace(place.getPlaceAllId())); model.put("activeStartPlace", getGeoBaseService().findNumberOfActiveStartInPlace(place.getPlaceAllId())); model.put("deathPlace", getGeoBaseService().findNumberOfDeathInPlace(place.getPlaceAllId())); model.put("activeEndPlace", getGeoBaseService().findNumberOfActiveEndInPlace(place.getPlaceAllId())); if (place.getPlaceGeographicCoordinates() != null) { model.put("linkGoogleMaps", HtmlUtils.generateLinkGoogleMaps(place.getPlaceGeographicCoordinates())); } else { model.put("linkGoogleMaps", null); } HistoryNavigator historyNavigator = getGeoBaseService().getHistoryNavigator(place); model.put("historyNavigator", historyNavigator); if (getGeoBaseService().ifPlaceAlreadyPresentInMarkedList(place.getPlaceAllId())) { model.put("inMarkedList", "true"); } else { model.put("inMarkedList", "false"); } return new ModelAndView("geobase/ShowPlace", model); } } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); return new ModelAndView("error/EditDetailsPlace", model); } } }
From source file:org.medici.bia.controller.geobase.EditExternalLinkPlaceController.java
/** * /*ww w.j a v a2s . com*/ * @param command * @return */ @RequestMapping(method = RequestMethod.GET) public ModelAndView setupForm(@ModelAttribute("command") EditExternalLinkPlaceCommand command) { Map<String, Object> model = new HashMap<String, Object>(0); if ((command != null) && (command.getPlaceAllId() > 0)) { if (command.getPlaceExternalLinksId().equals(0)) { command.setExternalLink(null); } else { try { PlaceExternalLinks placeExternalLinks = getGeoBaseService() .findPlaceExternalLinks(command.getPlaceAllId(), command.getPlaceExternalLinksId()); if (placeExternalLinks.getExternalLink() != null) { command.setExternalLink(placeExternalLinks.getExternalLink()); } else { command.setExternalLink(null); } if (placeExternalLinks.getDescription() != null) { command.setDescription(placeExternalLinks.getDescription()); } else { command.setDescription(null); } } catch (ApplicationThrowable th) { return new ModelAndView("error/EditExternalLinkPlace", model); } } } else { if (ObjectUtils.toString(command).equals("")) { command = new EditExternalLinkPlaceCommand(); } command.setPlaceExternalLinksId(null); command.setExternalLink(null); command.setDescription(null); } return new ModelAndView("geobase/EditExternalLinkPlace", model); }
From source file:org.medici.bia.controller.manuscriptviewer.PageTurnerDialogController.java
/** * /*from w w w.j ava 2s .com*/ * @param command * @return */ @RequestMapping(method = RequestMethod.GET) public ModelAndView setupForm(@ModelAttribute("command") PageTurnerCommand command, BindingResult result) { Map<String, Object> model = new HashMap<String, Object>(0); Image image = null; try { // we set default image as empty string, so we need only to update the record. model.put("image", ""); // If the request is made with entryId, we are asking a document if (!ObjectUtils.toString(command.getEntryId()).equals("")) { image = getManuscriptViewerService().findDocumentImage(command.getEntryId(), null, null, command.getImageType(), command.getImageProgTypeNum(), command.getImageOrder()); } else { image = getManuscriptViewerService().findVolumeImage(command.getSummaryId(), command.getVolNum(), command.getVolLetExt(), command.getImageType(), command.getImageProgTypeNum(), command.getImageOrder()); } model.put("image", image); } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); } try { // We check if this image has a document linked... List<Document> documents = getManuscriptViewerService().findLinkedDocument(command.getVolNum(), command.getVolLetExt(), image.getInsertNum(), image.getInsertLet(), image.getImageProgTypeNum(), image.getMissedNumbering(), image.getImageRectoVerso().toString()); model.put("entryId", documents != null && documents.size() > 0 ? documents.get(0).getEntryId() : null); Boolean hasInserts = getVolBaseService().hasInserts(command.getVolNum(), command.getVolLetExt()); model.put("hasInsert", hasInserts); } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); model.put("entryId", null); } if (command.getModeEdit()) { model.put("caller", "/de/mview/EditDocumentInManuscriptViewer.do"); } else { model.put("caller", "/src/mview/ShowDocumentInManuscriptViewer.do"); } return new ModelAndView("mview/PageTurnerDialog", model); }
From source file:org.medici.bia.controller.manuscriptviewer.ShowManuscriptViewerController.java
/** * /* ww w . jav a 2 s . c o m*/ * @param volumeId * @return */ @RequestMapping(method = RequestMethod.GET) public ModelAndView setupForm(@ModelAttribute("requestCommand") ShowManuscriptViewerRequestCommand command, BindingResult result) { Map<String, Object> model = new HashMap<String, Object>(0); Image image = null; try { // we set default image as empty string, so we need only to update the record. model.put("image", ""); // If the request is made with entryId, we are asking a document if (!ObjectUtils.toString(command.getEntryId()).equals("")) { image = getManuscriptViewerService().findDocumentImage(command.getEntryId(), null, null, command.getImageType(), command.getImageProgTypeNum(), command.getImageOrder()); } else { image = getManuscriptViewerService().findVolumeImage(command.getSummaryId(), command.getVolNum(), command.getVolLetExt(), command.getImageType(), command.getImageProgTypeNum(), command.getImageOrder()); } model.put("image", image); if (command.getAnnotationId() != null) { model.put("annotationId", command.getAnnotationId()); } } catch (ApplicationThrowable applicationThrowable) { model.put("applicationThrowable", applicationThrowable); } if (command.getFlashVersion()) { return new ModelAndView("mview/ShowManuscriptViewerFlash", model); } else { return new ModelAndView("mview/ShowManuscriptViewerHtml", model); } }