Package org.cipres.treebase.domain.study

Examples of org.cipres.treebase.domain.study.Citation


   *
   * @param citationType
   * @return
   */
  private Citation createCitation (String citationType) {
      Citation citation;
      if ( citationType.equals("Journal Article") ) {
        citation = Citation.factory(ArticleCitation.CITATION_TYPE_ARTICLE);
      }
      else if ( citationType.equals("Book Section") ) {
        citation = Citation.factory(InBookCitation.CITATION_TYPE_BOOKSECTION);
            }
      else if ( citationType.equals("Book") ) {
        citation = Citation.factory(BookCitation.CITATION_TYPE_BOOK);
      }
      else {
        warn("Unrecognized citation type: " + citationType);
        return null;
      }
     
      citation.setCitationStatus(getCitationStatusHome().findStatusInPrep());
      citation.setId(getCitationService().save(citation));
      getCurrentSession().flush();

      return citation;
  }
View Full Code Here


      Study study = findStudy(tb1StudyId);
      if ( study == null ) {
        warn("No such study (TB1 accession): " + tb1StudyId);
        return;
      }
      Citation citationStub = study.getCitation();
      Citation citation = null;
      if ( citationStub != null ) {
        warn("Study "+tb1StudyId+" already associated with a citation "+citationStub.getId());
//         In general, citation stubs already exist for each study. However, these
//         stubs are all of type ArticleCitation, which means that, in the case of
//         BookCitations (for example) we'll get a class cast exception when we try
//         to cast the citation to a book in order to set the editors.
        //getCitationService().deleteCitation(citationStub);
        //citation = createCitation(fields[0]);
        citation = citationStub;
      }   
      else {
        warn("No citation stub association with study (TB1 accession) " + tb1StudyId);
        citation = createCitation(fields[0]);
      }
      if ( citation == null ) {
        warn("No citation was instantiated, skipping this record (TB1 accession) "+tb1StudyId);
        return;
      }
      for ( int i = 0; i < fields.length; i++ ) {
        if ( ! TreebaseUtil.isEmpty(fields[i]) ) {
          switch(i) {
            case 0: citation.setCitationType(fields[i]); break;
            case 1: setAuthors(citation,fields[i],personHome,false); break;
            case 2: citation.setPublishYear(Integer.parseInt(fields[i])); break;
            case 3: if ( citation instanceof BookCitation ) {
              ((BookCitation)citation).setBookTitle(fields[i]);
              citation.setTitle(fields[i]);
            } else {
              citation.setTitle(fields[i]);
            } break;
            case 4: setAuthors(citation,fields[i],personHome,true); break;
            case 5: if ( citation instanceof ArticleCitation ) {
              ((ArticleCitation)citation).setJournal(fields[i]);
              warn("Setting journal name "+fields[i]);
            } else {
              warn("Setting book title "+fields[i]);
              ((BookCitation)citation).setBookTitle(fields[i]);
            } break;
            case 6: if ( citation instanceof BookCitation ) {                          
              ((BookCitation)citation).setCity(fields[i]);
            } else {
              warn("Record has an entry for city, yet it's not a book (TB1 accession) "+tb1StudyId);
            } break;
            case 7: if ( citation instanceof BookCitation ) {                          
              ((BookCitation)citation).setPublisher(fields[i]);
            } else {
              warn("Record has an entry for publisher, yet it's not a book (TB1 accession) "+tb1StudyId);
            } break;
            case 8: if ( citation instanceof ArticleCitation ) {
              ((ArticleCitation)citation).setVolume(fields[i]);
            } else {
              warn("Record has an entry for volume, yet it's not an article (TB1 accession) "+tb1StudyId);
            } break;
            case 10: if ( citation instanceof ArticleCitation ) {
              ((ArticleCitation)citation).setIssue(fields[i]);
            } else {
              warn("Record has an entry for issue, yet it's not an article (TB1 accession)"+tb1StudyId);
            } break;
            case 11: citation.setPages(fields[i]); break;
            case 15: if ( fields[i].equals("in press") ) {
              citation.setCitationStatusDescription(CitationStatus.INPRESS);                         
            }
            case 16: citation.setKeywords(fields[i]); break;
            case 17: citation.setAbstract(checkAbstractLength(fields[i])); break;
            case 18: citation.setStudy(study); break;
            case 19: citation.setURL(fields[i]); break;
            case 20: citation.setDoi(fields[i]); break;
            default: warn("Empty field expected, found: " + fields[i] + " for line: " + /*was: line */fields.toString()); break;
          }
        }
      }
      warn("Storing citation "+citation.getId());
      warn(citation.getAuthorsCitationStyleWithoutHtml());  
      if ( ! testMode ) {
          study.setCitation(citation);
          getStudyService().update(study);
          Long id = study.getCitation().getId();
          warn("Stored citation at ID " + id);
View Full Code Here

          Study study = findStudy(tb1StudyId);
          if ( study == null ) {
            warn("No such study (TB1 accession): " + tb1StudyId);
            continue LINE;
          }
          Citation citationStub = study.getCitation();
          Citation citation = null;
          if ( citationStub != null ) {
            warn("Study "+tb1StudyId+" already associated with a citation "+citationStub.getId());
//             In general, citation stubs already exist for each study. However, these
//             stubs are all of type ArticleCitation, which means that, in the case of
//             BookCitations (for example) we'll get a class cast exception when we try
//             to cast the citation to a book in order to set the editors.
            //getCitationService().deleteCitation(citationStub);
            //citation = createCitation(fields[0]);
            citation = citationStub;
          }   
          else {
            warn("No citation stub association with study (TB1 accession) " + tb1StudyId);
            citation = createCitation(fields[0]);
          }
          if ( citation == null ) {
            warn("No citation was instantiated, skipping this record (TB1 accession) "+tb1StudyId);
            continue LINE;
          }
          for ( int i = 0; i < fields.length; i++ ) {
            if ( ! TreebaseUtil.isEmpty(fields[i]) ) {
              switch(i) {
                case 0: citation.setCitationType(fields[i]); break;
                case 1: setAuthors(citation,fields[i],personHome,false); break;
                case 2: citation.setPublishYear(Integer.parseInt(fields[i])); break;
                case 3: if ( citation instanceof BookCitation ) {
                  ((BookCitation)citation).setBookTitle(fields[i]);
                  citation.setTitle(fields[i]);
                } else {
                  citation.setTitle(fields[i]);
                } break;
                case 4: setAuthors(citation,fields[i],personHome,true); break;
                case 5: if ( citation instanceof ArticleCitation ) {
                  ((ArticleCitation)citation).setJournal(fields[i]);
                  warn("Setting journal name "+fields[i]);
                } else {
                  warn("Setting book title "+fields[i]);
                  ((BookCitation)citation).setBookTitle(fields[i]);
                } break;
                case 6: if ( citation instanceof BookCitation ) {                          
                  ((BookCitation)citation).setCity(fields[i]);
                } else {
                  warn("Record has an entry for city, yet it's not a book (TB1 accession) "+tb1StudyId);
                } break;
                case 7: if ( citation instanceof BookCitation ) {                          
                  ((BookCitation)citation).setPublisher(fields[i]);
                } else {
                  warn("Record has an entry for publisher, yet it's not a book (TB1 accession) "+tb1StudyId);
                } break;
                case 8: if ( citation instanceof ArticleCitation ) {
                  ((ArticleCitation)citation).setVolume(fields[i]);
                } else {
                  warn("Record has an entry for volume, yet it's not an article (TB1 accession) "+tb1StudyId);
                } break;
                case 10: if ( citation instanceof ArticleCitation ) {
                  ((ArticleCitation)citation).setIssue(fields[i]);
                } else {
                  warn("Record has an entry for issue, yet it's not an article (TB1 accession)"+tb1StudyId);
                } break;
                case 11: citation.setPages(fields[i]); break;
                case 15: if ( fields[i].equals("in press") ) {
                  citation.setCitationStatusDescription(CitationStatus.INPRESS);                         
                }
                case 16: citation.setKeywords(fields[i]); break;
                case 17: citation.setAbstract(checkAbstractLength(fields[i])); break;
                case 18: citation.setStudy(study); break;
                case 19: citation.setURL(fields[i]); break;
                case 20: citation.setDoi(fields[i]); break;
                default: warn("Empty field expected, found: " + fields[i] + " for line: " + line); break;
              }
            }
          }
          warn("Storing citation "+citation.getId());
          warn(citation.getAuthorsCitationStyleWithoutHtml());  
          if ( ! testMode ) {
            study.setCitation(citation);
            getStudyService().update(study);
            Long id = study.getCitation().getId();
            if ( id > maxId ) {
View Full Code Here

   */
  private void deleteOrphanedCitations(Long maxId) {
    int duplicates = 0;
    for ( int i = 0; i < maxId.intValue(); i++ ) {
      Long id = new Long(i);
      Citation citation = (Citation)getCitationHome().findPersistedObjectByID(Citation.class, id);
      //warn("Checking id "+id);
      if ( citation != null ) {
        Study study = citation.getStudy();
        if ( study == null ) {
          warn("Removing orphan: "+citation.getId()+" "+citation.getAuthorsCitationStyleWithoutHtml());
          duplicates++;
          getCitationService().deleteCitation(citation);
        }
        else if ( study.getCitation().getId() != citation.getId() ) {
          warn("Orphan: "+citation.getId()+" "+citation.getAuthorsCitationStyle());
        }
        else {
          warn("Makes sense: citation "+citation.getId()+" -study-> "+study.getId());
        }
      }
    }
    warn("I removed "+duplicates+" orphans");
  }
View Full Code Here

  public Collection<Study> findByPublicationDateRange(Date from, Date until) {
    return getStudyHome().findByPublicationDateRange(from, until);
  }

  public Study findByDOI(String doi) {
    Citation citation = getCitationService().findByDOI(doi);
    if ( null != citation ) {
      return citation.getStudy();
    }
    else {
      return null;
    }
  }
View Full Code Here

  public void replaceCitation(Study pStudy, Citation pCitation) {
    if (pCitation == null || pStudy == null) {
      return;
    }

    Citation oldCitation = pStudy.getCitation();
    if (!pCitation.isCitationTypeChanged() && pStudy.getCitation() == pCitation) {
      update(pCitation);
    } else {
      Citation newCitation = Citation.factory(pCitation);

      newCitation.setStudy(pStudy);
      pStudy.setCitation(newCitation);

      if (oldCitation != null) {
        oldCitation.setStudy(null);
        getCitationHome().deletePersist(oldCitation);
View Full Code Here

  /**
   *
   * @see org.cipres.treebase.domain.study.CitationService#createCitation(java.lang.String)
   */
  public Citation createCitation(String pCitationType) {
    Citation c = Citation.factory(pCitationType);

    // set default date
    int current_month = Calendar.getInstance().get(Calendar.MONTH);
    int current_year = Calendar.getInstance().get(Calendar.YEAR);
    int current_day = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
    if (current_month >= 9 && current_day == 1) {
      current_year++;
    }

    // set default value for publication year
    c.setPublishYear(current_year);

    c.setCitationStatus(getCitationStatusHome().findStatusInPrep());

    return c;
  }
View Full Code Here

    private Map getRecordMap(Submission submission){
     
      Map map= new HashMap();
     
      Study study=submission.getStudy();
      Citation citation=study.getCitation();
      String publisher=null;
      if(!study.isPublished())return null;
     
      //System.out.println("ctype: "+citation.getCitationType());
      try{
      if(citation.getCitationType().toUpperCase().contains("BOOK"))
           publisher=((BookCitation)citation).getPublisher();
      else publisher=((ArticleCitation)citation).getJournal();
     
     
      List<Person> authors=citation.getAuthors();
      
   
      map.put("title", IdentifyUtil.escape4XML(study.getId(),citation.getTitle()));
      map.put("creator", authors)
      //VG 2010-11-17  fixing SF:3079602 (multiple keywords into multiple <dc:subject> elements)
      //--map.put("subject", IdentifyUtil.escape4XML(study.getId(),citation.getKeywords()));
      map.put("subject", splitKeywords(study.getId(),citation.getKeywords()));
        if(study.getName()!=null&study.getNotes()!=null)     
          map.put("description", IdentifyUtil.escape4XML(study.getId(),study.getName()+" "+study.getNotes()));
        else if(study.getNotes()==null)
          map.put("description",IdentifyUtil.escape4XML(study.getId(),study.getName()));
        else
          map.put("description",IdentifyUtil.escape4XML(study.getId(),study.getNotes()));
      map.put("publisher", IdentifyUtil.escape4XML(study.getId(),publisher));           
      map.put("date", citation.getPublishYear());
      map.put("identifier", "purl.org/phylo/treebase/phylows/study/TB2:S"+study.getId());
      map.put("datestamp", study.getLastModifiedDate());
     
      }catch(Exception e){
        //study 253 citation= null, data should be fixed
View Full Code Here

    String selectedCitationType = request.getParameter("citationType");

    // Map<String, Object> studyMap = (Map)
    // request.getSession().getAttribute(Constants.STUDY_MAP);

    Citation c = null;
    Study study = ControllerUtil.findStudy(request, getStudyService());
    // if (studyMap != null) {

    // map Citation object data to CitationCommand object
    c = study.getCitation();
    // }

    if (c == null) {
      // citation has not been created yet
      // create a default citaiton:
      c = getCitationService().createCitation(selectedCitationType);

      // set default for URL
      c.setURL("http://");

      study.setCitation(c);
      c.setStudy(study);
    } else if (selectedCitationType != null
      && !c.getCitationType().equalsIgnoreCase(selectedCitationType)) {

      // morph the citation to the selected type:
      c.setCitationType(selectedCitationType);
      c = Citation.factory(c);

      study.setCitation(c);
      c.setStudy(study);
    }

    // if (citation != null) {
    // BeanUtils.copyProperties(citationCommand, citation);
    // }
View Full Code Here

    HttpServletResponse response,
    Object command,
    BindException errors) throws Exception {

    // retrieve command object and map data to Domain object's Citation
    Citation citation = (Citation) command;
   
    // track if errors have occurred
    boolean check = false;
   
    // instantiate list of error messages
    List<String> myErrors = new ArrayList<String>();
    myErrors.add("Sorry, form could not be submitted or updated.");

    /* process pubmed ID */
    if (!TreebaseUtil.isEmpty(citation.getPMID())) {
      check = validatePMID(citation,myErrors);
    }

    /* process DOI */
    if (!TreebaseUtil.isEmpty(citation.getDoi())) {
      String doiId = citation.getDoi().trim();
      if (!doiId.startsWith("10.")) {
        check = true;
        myErrors.add("Invalid DOI -- DOI must start with 10.");

      } else if (!doiId.contains("/")) {
        check = true;
        myErrors.add("DOI must contain / separating a prefix & suffix.");
      }
    }

    /* process URL */
    if (!TreebaseUtil.isEmpty(citation.getURL())) {
      String url = citation.getURL().trim();
      if (!url.startsWith("http://")) {
        check = true;
        myErrors.add("URL must start with: http://");
      }
    }

    if (check) {
      request.setAttribute("errors", myErrors);
      return showForm(request, response, errors);
    }
   
    String publicationStatusUpdate = citation.getStatusDescriptionUpdate();
    if (request.getParameter(ACTION_SUBMIT) != null) {
      User user = ControllerUtil.getUser(request, mUserService);
      Study study = ControllerUtil.findStudy(request, mStudyService);
      if (citation.isCitationTypeChanged()) {
        // need to create a new citation object for the study:
        replaceCitation(study, citation);
      } else if (citation != study.getCitation()) {
        study.setCitation(citation);
        citation.setStudy(study);
      }
      if (publicationStatusUpdate != null) {
        CitationStatus publicationStatus = getCitationService()
          .findCitationStatusByDescription(publicationStatusUpdate);
        citation.setCitationStatus(publicationStatus);
      }
      mStudyService.update(study);
      ControllerUtil.saveStudy(request, study);
      return new ModelAndView(new RedirectView("citationForm.html"));
    } else if (request.getParameter(ACTION_UPDATE) != null) {
      if (publicationStatusUpdate != null) {
        CitationStatus publicationStatus = getCitationService()
          .findCitationStatusByDescription(publicationStatusUpdate);
        citation.setCitationStatus(publicationStatus);
      }
      //if (citation.isCitationTypeChanged()) {
        Study study = ControllerUtil.findStudy(request, mStudyService);
        replaceCitation(study, citation);
        mStudyService.update(study);
View Full Code Here

TOP

Related Classes of org.cipres.treebase.domain.study.Citation

Copyright © 2018 www.massapicom. 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.