X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/blobdiff_plain/d43c60d25dd93d134b1fade49ca5aef462579d61..6ab939077b75134f676560103ea6fac26c6fa3d8:/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DerivedUnitFacadeController.java diff --git a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DerivedUnitFacadeController.java b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DerivedUnitFacadeController.java index 381a8953d6..81bf9fc11e 100644 --- a/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DerivedUnitFacadeController.java +++ b/cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DerivedUnitFacadeController.java @@ -1,9 +1,9 @@ // $Id$ /** * Copyright (C) 2009 EDIT -* European Distributed Institute of Taxonomy +* European Distributed Institute of Taxonomy * http://www.e-taxonomy.eu -* +* * The contents of this file are subject to the Mozilla Public License Version 1.1 * See LICENSE.TXT at the top of this package for the full license terms. */ @@ -30,7 +30,6 @@ import org.springframework.web.servlet.ModelAndView; import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException; import eu.etaxonomy.cdm.api.service.IOccurrenceService; -import eu.etaxonomy.cdm.model.media.Media; import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase; import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; import eu.etaxonomy.cdm.remote.editor.UUIDPropertyEditor; @@ -44,139 +43,148 @@ import eu.etaxonomy.cdm.remote.editor.UUIDPropertyEditor; @RequestMapping(value = {"/derivedUnitFacade/{uuid}"}) public class DerivedUnitFacadeController extends AbstractController{ - - private IOccurrenceService service; - - @Autowired - public void setService(IOccurrenceService service) { - this.service = service; - } - @InitBinder + private IOccurrenceService service; + + @Autowired + public void setService(IOccurrenceService service) { + this.service = service; + } + + @InitBinder public void initBinder(WebDataBinder binder) { - binder.registerCustomEditor(UUID.class, new UUIDPropertyEditor()); - } - - @RequestMapping(method = RequestMethod.GET) - public DerivedUnitFacade doGet( - @PathVariable("uuid") UUID uuid, - HttpServletRequest request, - HttpServletResponse response) throws IOException { - - logger.info("getGet() - " + request.getServletPath()); - DerivedUnitFacade duf = newFacadeFrom(uuid, response, null); - return duf; - } - - @RequestMapping(value = {"derivedUnitMedia"}, method = RequestMethod.GET) - public ModelAndView doGetDerivedUnitMedia( - @PathVariable("uuid") UUID uuid, - HttpServletRequest request, - HttpServletResponse response) throws IOException { - - logger.info("doGetDerivedUnitMedia() - " + request.getServletPath()); - ModelAndView mv = new ModelAndView(); - DerivedUnitFacade duf = newFacadeFrom(uuid, response,Arrays.asList(new String []{ - "derivedUnitMedia.representations.parts", "derivedUnitMedia.title"})); - mv.addObject(duf.getDerivedUnitMedia()); - return mv; - } - - @RequestMapping(value = {"fieldObjectMedia"}, method = RequestMethod.GET) - public ModelAndView doGetFieldObjectMedia( - @PathVariable("uuid") UUID uuid, - HttpServletRequest request, - HttpServletResponse response) throws IOException { - - logger.info("doGetFieldObjectMedia() - " + request.getServletPath()); - ModelAndView mv = new ModelAndView(); - DerivedUnitFacade duf = newFacadeFrom(uuid, response,Arrays.asList(new String []{ - "fieldObjectMedia.representations.parts", "fieldObjectMedia.title"})); - mv.addObject(duf.getFieldObjectMedia()); - return mv; - } - -// TODO - //@RequestMapping(method = RequestMethod.GET, value = "{uuid}/collectingareas") - @RequestMapping( - value = {"collectingareas"}, - method = RequestMethod.GET) - public Object doGetCollectingAreas( - @PathVariable("uuid") UUID uuid, - HttpServletRequest request, - HttpServletResponse response) throws IOException { - - logger.info("doGetCollectingAreas() - " + request.getServletPath()); - DerivedUnitFacade duf = newFacadeFrom(uuid, - response, - Arrays.asList(new String []{"ecology"})); - return duf.getCollectingAreas(); - } - - @RequestMapping(method = RequestMethod.GET, value = "collection") - public Object doGetCollection( - @PathVariable("uuid") UUID uuid, - HttpServletRequest request, - HttpServletResponse response) throws IOException { - - logger.info("doGetCollection() - " + request.getServletPath()); - DerivedUnitFacade duf = newFacadeFrom(uuid, - response, - Arrays.asList(new String []{"collection"})); - return duf.getCollection(); - } - - - //TODO: - // public Point getExactLocation() => valueProcessor? - - - // public Collection getCollection() { - // public AgentBase getCollector() { - // public DerivedUnitBase getDerivedUnit() { - // public Map getDerivedUnitDefinitions(){ - // public List getDerivedUnitMedia() { - // public Set getDeterminations() { - // public Set getDuplicates(){ - // public Map getEcologyAll(){ - // public Map getFieldObjectDefinition() { - // public List getFieldObjectMedia() { - // public FieldObservation getFieldObservation(){ - // public GatheringEvent getGatheringEvent() { - // public String getGatheringEventDescription() { - // public Map getPlantDescriptionAll(){ ==> representation !! - // public PreservationMethod getPreservationMethod() - // public Set getSources(){ - // public TaxonNameBase getStoredUnder() { - - - private DerivedUnitFacade newFacadeFrom(UUID uuid, HttpServletResponse response, List extendedInitStrategy) - throws IOException { - List initStrategy = new ArrayList(DEFAULT_INIT_STRATEGY); - if(extendedInitStrategy != null && extendedInitStrategy.size() > 0){ - initStrategy.addAll(extendedInitStrategy); - } - SpecimenOrObservationBase sob = service.load(uuid, null); - if(sob instanceof DerivedUnitBase){ - try { - return service.getDerivedUnitFacade(((DerivedUnitBase)sob), initStrategy); - } catch (DerivedUnitFacadeNotSupportedException e) { - logger.error(e); //TODO ... - } - } else { - HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response); - } - return null; - } - - - - - - - - - - + binder.registerCustomEditor(UUID.class, new UUIDPropertyEditor()); + } + + @RequestMapping(method = RequestMethod.GET) + public DerivedUnitFacade doGet( + @PathVariable("uuid") UUID occurrenceUuid, + HttpServletRequest request, + HttpServletResponse response) throws IOException { + + logger.info("getGet() - " + request.getServletPath()); + DerivedUnitFacade duf = newFacadeFrom(occurrenceUuid, response, null); + return duf; + } + + @RequestMapping(value = {"derivedUnitMedia"}, method = RequestMethod.GET) + public ModelAndView doGetDerivedUnitMedia( + @PathVariable("uuid") UUID occurrenceUuid, + HttpServletRequest request, + HttpServletResponse response) throws IOException { + + logger.info("doGetDerivedUnitMedia() - " + request.getServletPath()); + ModelAndView mv = new ModelAndView(); + DerivedUnitFacade duf = newFacadeFrom(occurrenceUuid, response,Arrays.asList(new String []{ + "derivedUnitMedia", "derivedUnitMedia.title"})); + if(duf != null){ + mv.addObject(duf.getDerivedUnitMedia()); + } + return mv; + } + + @RequestMapping(value = {"fieldObjectMedia"}, method = RequestMethod.GET) + public ModelAndView doGetFieldObjectMedia( + @PathVariable("uuid") UUID occurrenceUuid, + HttpServletRequest request, + HttpServletResponse response) throws IOException { + + logger.info("doGetFieldObjectMedia() - " + request.getServletPath()); + ModelAndView mv = new ModelAndView(); + DerivedUnitFacade duf = newFacadeFrom(occurrenceUuid, response,Arrays.asList(new String []{ + "fieldObjectMedia", "fieldObjectMedia.title"})); + mv.addObject(duf.getFieldObjectMedia()); + return mv; + } + +// TODO + //@RequestMapping(method = RequestMethod.GET, value = "{uuid}/collectingareas") + @RequestMapping( + value = {"collectingareas"}, + method = RequestMethod.GET) + public Object doGetCollectingAreas( + @PathVariable("uuid") UUID occurrenceUuid, + HttpServletRequest request, + HttpServletResponse response) throws IOException { + + logger.info("doGetCollectingAreas() - " + request.getServletPath()); + DerivedUnitFacade duf = newFacadeFrom(occurrenceUuid, + response, + Arrays.asList(new String []{"ecology"})); + return duf.getCollectingAreas(); + } + + @RequestMapping(method = RequestMethod.GET, value = "collection") + public Object doGetCollection( + @PathVariable("uuid") UUID uuid, + HttpServletRequest request, + HttpServletResponse response) throws IOException { + + logger.info("doGetCollection() - " + request.getServletPath()); + DerivedUnitFacade duf = newFacadeFrom(uuid, + response, + Arrays.asList(new String []{"collection"})); + return duf.getCollection(); + } + + + //TODO: + // public Point getExactLocation() => valueProcessor? + + + // public Collection getCollection() { + // public AgentBase getCollector() { + // public DerivedUnitBase getDerivedUnit() { + // public Map getDerivedUnitDefinitions(){ + // public List getDerivedUnitMedia() { + // public Set getDeterminations() { + // public Set getDuplicates(){ + // public Map getEcologyAll(){ + // public Map getFieldObjectDefinition() { + // public List getFieldObjectMedia() { + // public FieldObservation getFieldObservation(){ + // public GatheringEvent getGatheringEvent() { + // public String getGatheringEventDescription() { + // public Map getPlantDescriptionAll(){ ==> representation !! + // public PreservationMethod getPreservationMethod() + // public Set getSources(){ + // public TaxonNameBase getStoredUnder() { + + + /** + * @param occurrenceUuid + * @param response + * @param extendedInitStrategy + * @return the requesed DerivedUnitFacade instance or null + * @throws IOException + */ + private DerivedUnitFacade newFacadeFrom(UUID occurrenceUuid, HttpServletResponse response, List extendedInitStrategy) + throws IOException { + List initStrategy = new ArrayList(initializationStrategy); + if(extendedInitStrategy != null && extendedInitStrategy.size() > 0){ + initStrategy.addAll(extendedInitStrategy); + } + SpecimenOrObservationBase sob = service.load(occurrenceUuid, null); + if(sob instanceof DerivedUnitBase){ + try { + return service.getDerivedUnitFacade(((DerivedUnitBase)sob), initStrategy); + } catch (DerivedUnitFacadeNotSupportedException e) { + logger.error(e); //TODO ... + } + } else { + HttpStatusMessage.UUID_REFERENCES_WRONG_TYPE.send(response); + } + return null; + } + + + + + + + + + + }