From: <rv...@us...> - 2010-03-16 16:55:10
|
Revision: 605 http://treebase.svn.sourceforge.net/treebase/?rev=605&view=rev Author: rvos Date: 2010-03-16 16:55:00 +0000 (Tue, 16 Mar 2010) Log Message: ----------- Now retrieves the specified object and saves it in the session so that the template can use it to fetch annotations and context links. Modified Paths: -------------- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/AnyObjectAsRDFController.java Modified: trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/AnyObjectAsRDFController.java =================================================================== --- trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/AnyObjectAsRDFController.java 2010-03-16 16:53:37 UTC (rev 604) +++ trunk/treebase-web/src/main/java/org/cipres/treebase/web/controllers/AnyObjectAsRDFController.java 2010-03-16 16:55:00 UTC (rev 605) @@ -3,12 +3,15 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.log4j.Logger; import org.cipres.treebase.NamespacedGUID; import org.cipres.treebase.PhyloWSPath; import org.cipres.treebase.TreebaseIDString; import org.cipres.treebase.TreebaseUtil; +import org.cipres.treebase.domain.TBPersistable; import org.cipres.treebase.domain.matrix.Matrix; import org.cipres.treebase.domain.study.Study; +import org.cipres.treebase.domain.study.StudyService; import org.cipres.treebase.domain.tree.PhyloTree; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.Controller; @@ -18,7 +21,18 @@ * */ public class AnyObjectAsRDFController implements Controller { + private static final Logger LOGGER = Logger.getLogger(AnyObjectAsRDFController.class); + private StudyService mStudyService; + + public StudyService getStudyService() { + return mStudyService; + } + + public void setStudyService(StudyService studyService) { + mStudyService = studyService; + } + public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { NamespacedGUID namespacedGUID = new NamespacedGUID(request.getParameter("namespacedGUID")); @@ -34,9 +48,16 @@ e.printStackTrace(); } if ( null != treebaseIDString ) { - if ( null != treebaseIDString.getTypePrefix() ) { - Class<?> theClass = TreebaseIDString.getClassForPrefix(treebaseIDString.getTypePrefix()); + LOGGER.info("TreeBASE ID String: "+treebaseIDString); + + String typePrefix = treebaseIDString.getTypePrefix(); + if ( null != typePrefix ) { + LOGGER.info("Type prefix: "+typePrefix); + + Class<?> theClass = TreebaseIDString.getClassForPrefix(typePrefix); if ( null != theClass ) { + LOGGER.info("Class: "+theClass); + if ( theClass.isAssignableFrom(PhyloTree.class) || theClass.isAssignableFrom(Matrix.class) || theClass.isAssignableFrom(Study.class) ) { @@ -46,12 +67,27 @@ request.setAttribute("hasRdf", true); } phyloWSPath = new PhyloWSPath(theClass.getPackage(),namespacedGUID); -// if ( theClass.isAssignableFrom(Annotatable.class) ) { -// request.setAttribute(arg0, arg1) -// } + + TBPersistable theObject = getStudyService().findByID(theClass, treebaseIDString.getId()); + if ( null != theObject ) { + request.getSession().setAttribute("theObject", theObject); + LOGGER.info("Object: "+theObject); + } + else { + LOGGER.info("Couldn't instantiate object of type "+theClass+" with ID "+treebaseIDString.getId()); + } } + else { + LOGGER.info("Couldn't get class for prefix "+typePrefix); + } } + else { + LOGGER.info("Couldn't get prefix for ID string" + treebaseIDString); + } } + else { + LOGGER.info("Couldn't get ID String"); + } request.getSession().setAttribute("namespacedGUID", namespacedGUID.toString()); // <c:set var="baseURL" value="http://localhost:8080/treebase-web/PhyloWS"/> // treebase.purl.domain=http://purl.org/phylo/treebase/phylows/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |