Examples of TreebaseIDString


Examples of org.cipres.treebase.TreebaseIDString

 
 
  public ModelAndView handleRequest(HttpServletRequest request,
      HttpServletResponse response) throws Exception {
    NamespacedGUID namespacedGUID = new NamespacedGUID(request.getParameter("namespacedGUID"));
    TreebaseIDString treebaseIDString = null;
    PhyloWSPath phyloWSPath = null;
    request.setAttribute("hasWebPage", false);
    request.setAttribute("hasNexus", false);
    request.setAttribute("hasNeXML", false);
    request.setAttribute("hasRdf", false);
    try {
      treebaseIDString = namespacedGUID.getTreebaseIDString();
    } catch ( Exception e ) {
      e.printStackTrace();
    }
    if ( null != treebaseIDString ) {
      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) ) {
            request.setAttribute("hasWebPage", true);
            request.setAttribute("hasNexus", true);
            request.setAttribute("hasNeXML", true);
            request.setAttribute("hasRdf", true);
          }
          phyloWSPath = new PhyloWSPath(theClass.getPackage(),namespacedGUID);
         
          TBPersistable theObject = getStudyService().findByID(theClass, treebaseIDString.getId());
          if ( null != theObject ) {
            Study theContainingStudy = theObject.getStudy();
            if (null != theContainingStudy && ! theContainingStudy.isPublished()) {
                  response.setContentType("text/plain");
                  response.setStatus(HttpServletResponse.SC_SEE_OTHER);       
                  response.setHeader("Location", "/treebase-web/accessviolation.html");
                  return null;
                }
            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);
        }
View Full Code Here

Examples of org.cipres.treebase.TreebaseIDString

      case byID:
        matches = (Collection<Study>) doSearchByIDString(request, studyService, Study.class, searchTerm);
        break;
      case byLegacyID:
      {
        TreebaseIDString legacyID = null;
        boolean malformed = false;
        try {
          legacyID = new TreebaseIDString(searchTerm, Study.class);
        } catch (MalformedTreebaseIDString e) {
          malformed = true;
        }
        if (malformed || legacyID.getTBClass() != Study.class) {
          addMessage(request, "Legacy ID number '" + searchTerm + "' is not valid; try S#### or just ####");
          matches = null;
          break;
        }
        matches = (Collection<Study>) studyService.findByTBStudyID("S" + legacyID.getId().toString());
        break;
      }
      case inAbstract:
        matches = studyService.findByAbstract(keywordSearchTerm);
        break;
View Full Code Here

Examples of org.cipres.treebase.TreebaseIDString

    Collection<Taxon> taxaFound = new ArrayList<Taxon>();
    switch(namingAuthority) {
      case TREEBASE :
        LOGGER.debug("Going to search for TreeBASE IDs")
        if (null != index && ! index.endsWith(".tb1") ) {
          TreebaseIDString idstr;
          try {
            idstr = new TreebaseIDString(identifier, Taxon.class, true);
            Taxon match = getTaxonHome().findPersistedObjectByID(idstr.getTBClass(), idstr.getId());
            if ( match != null ) {
              taxaFound.add(match);
            }         
          } catch (MalformedTreebaseIDString e) {
            addMessage(request, "Ignoring malformed taxon ID string '" + identifier + "'; try 'Tx####' or just a number");
View Full Code Here

Examples of org.cipres.treebase.TreebaseIDString

      session.setAttribute(Constants.REVIEWER_AGREEMENT_ACCEPTED, true);
    }
    Object xAccesCodeObject = session.getAttribute(Constants.X_ACCESS_CODE);
    if ( xAccesCodeObject != null ) {
      String suppliedHashedID = xAccesCodeObject.toString();
      TreebaseIDString tbidstr = new TreebaseIDString(Study.class,Long.parseLong(req.getParameter("id")));
      if ( suppliedHashedID.equals(tbidstr.getNamespacedGUID().getHashedIDString()) ) {
        passedHashedIDCheck = true;
        Object agreementAccepted = session.getAttribute(Constants.REVIEWER_AGREEMENT_ACCEPTED);
        if ( agreementAccepted == null || ((Boolean)agreementAccepted).booleanValue() == false ) {
          LOGGER.info("Going to display agreement - agreement acceptance: "+agreementAccepted);
          session.setAttribute("displayAgreement",true);
View Full Code Here

Examples of org.cipres.treebase.TreebaseIDString

  public <T extends TBPersistable> T findByID(Class T, Long id) {
    return (T) getDomainHome().getPersistedObjectByID(T, id);
  }
 
  public TBPersistable findByIDString(String idString) throws MalformedTreebaseIDString {
    TreebaseIDString id;
   
    id = new TreebaseIDString(idString, defaultResultClass());
    if (id == null) return null;
    else return  getDomainHome().findPersistedObjectByID(id.getTBClass(), id.getId());
  }
View Full Code Here

Examples of org.cipres.treebase.TreebaseIDString

   * Returns an object whose string representation is of the format
   * S1787
   */
  @Transient
  public TreebaseIDString getTreebaseIDString () {
    return new TreebaseIDString(this);
  }
View Full Code Here

Examples of org.cipres.treebase.TreebaseIDString

  public Collection<PhyloTree> findTrees(Taxon t) {
    return getTaxonLabelHome().findTrees(t);
  }

  public Taxon findTaxonByIDString(String idString) throws MalformedTreebaseIDString {
    TreebaseIDString id = new TreebaseIDString(idString, Taxon.class);
    return  getDomainHome().findPersistedObjectByID(id.getTBClass(), id.getId());
  }
View Full Code Here

Examples of org.cipres.treebase.TreebaseIDString

   * @param persistableClass
   * @return
   */
  protected Long readTreeBaseID(Annotatable annotatable) {
    try {
      TreebaseIDString treebaseIDString = new TreebaseIDString(annotatable.getId());
      return treebaseIDString.getId();
    } catch (MalformedTreebaseIDString e) {
      e.printStackTrace();
    }       
    return null;   
  }
View Full Code Here

Examples of org.cipres.treebase.TreebaseIDString

  public Collection<? extends TBPersistable> doSearchByIDString(HttpServletRequest req,
      AbstractService service, Class expectedClass, String idString) {
    Collection<TBPersistable> matches = new ArrayList<TBPersistable> ();
    TBPersistable t;
    try {
      TreebaseIDString ids = new TreebaseIDString(idString, expectedClass);
      if (ids.getTBClass() != expectedClass) {
        String expectedPrefix = TreebaseIDString.getPrefixForClass(expectedClass);
        addMessage(req, "ID number '" + idString + "' is not valid; try " + expectedPrefix + "#### or just ####");
        return null;
      }
      t = service.findByIDString(idString);
View Full Code Here

Examples of org.cipres.treebase.TreebaseIDString

        }
        else {
          String substr = pathInfo.replaceAll(".*/", "");
            try {
              NamespacedGUID namespacedGUID = new NamespacedGUID(substr);
              TreebaseIDString tbID = namespacedGUID.getTreebaseIDString();
            String serializationFormat = createSerializationFormat(req);             
              if ( hasWebPage(tbID.getTypePrefix()) && ! TreebaseUtil.isEmpty(serializationFormat) ) {
               
                // output format is html, re-direct to display services
                if ( serializationFormat.equals("html") ) {
                  url = createDisplayUrl(tbID.getId(),req);
                }
               
                // output format is something else, re-direct to download services
                else {
                      url = createDownloadUrl(tbID.getId(),serializationFormat,req);
                      if (!redirectDownload ) {
                        if (TBStudy != null) {
                          if (!ControllerUtil.isReviewerAccessGranted(req, TBStudy.getTreebaseIDString())) {
                            url = "/treebase-web/accessviolation.html";
                          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.