Package org.cipres.treebase.domain.admin

Examples of org.cipres.treebase.domain.admin.Person


       
    List<Node> al = getNodes(pubRoot,"creator",dcterms);
    for(int i = 0; i<al.size(); i++) {
        String []names = al.get(i).getText().split(",");
      if(names.length >1 ){
        Person p = new Person ();
        names[1]=names[1].trim();
        if(!(names[1].contains(" ")))p.setFirstName(names[1]);
        else {         
         
          p.setFirstName(names[1].trim().substring(0,names[1].indexOf(" ")));
          p.setMiddleName(names[1].trim().substring(names[1].indexOf(" ")));
        }
        p.setLastName(names[0]);
        citation.addAuthor(p);
      }
    }   
   
    try{
View Full Code Here


   
    ContextManager.getCitationService().save(theCitation);
 
    // Create or link authors
    for (ValueSection a : aux.getSections("AUTHOR")) {
      Person theAuthor = new Person();
      theAuthor.setFirstName(a.getsval("first_name"));
      theAuthor.setLastName(a.getsval("last_name"));
      theAuthor.setMiddleName("");
//      ContextManager.getPersonService().save(theAuthor);
      // TB1 "author_id" ??
      Person oldAuthor = ContextManager.getPersonService().findByExactMatch(theAuthor);
      if (oldAuthor != null) {
        theAuthor = oldAuthor;
      } else {
        ContextManager.getPersonService().createPerson(theAuthor);
        theAuthor = ContextManager.getPersonService().findByExactMatch(theAuthor);
View Full Code Here

    Citation cit = s.getCitation();
    cit.setAuthors(new ArrayList<Person>());
    ContextManager.getCitationHome().flush();
   
    for (ValueSection authorSection : aux.getSections("AUTHOR")) {
      Person theAuthor = new Person();
      theAuthor.setFirstName(authorSection.getsval("first_name"));
      theAuthor.setLastName(authorSection.getsval("last_name"));
      Person oldAuthor = ContextManager.getPersonService().findByExactMatch(theAuthor);
      if (oldAuthor == null) {
        out.println("Can't find person " + theAuthor.getFullName() + "; skipping");
        t.rollback();
        return new ValueNone();
      }
      out.println("  Adding author " + oldAuthor.getFullName() + "(" + oldAuthor.getId() + ")");
      cit.addAuthor(oldAuthor);
    }
    t.commit();
    return v;
  }
View Full Code Here

      logger.info("\n\t\tRunning Test: " + testName);
    }

    // 1. create a new Person:
    String newName = testName + " test " + Math.random();
    Person p = new Person();
    p.setFirstName("testF");
    p.setLastName("testLD");

    String email = "test@cipres.treebase.org";
    p.setEmailAddressString(email);

    PersonHome fixture = getPersonHome();
    fixture.store(p);

    // force commit immediately, important:
    setComplete();
    endTransaction();
    logger.info("person created: " + p.getLastName() + "id = " + p.getId());

    // 2. verify
    String sqlStr = "select count(*) from Person where person_id=" + p.getId();
    int count = jdbcTemplate.queryForInt(sqlStr);
    assertTrue(count == 1);

    // 3. delete
    // fixture.delete(testRole);
View Full Code Here

      // 2. find by user name:
      PersonHome fixture = getPersonHome();
      Long anId = Long.parseLong(ids.get(0));

      Person result = fixture.findPersistedObjectByID(Person.class, anId);

      // 3. verify
      assertTrue("Result is null", result != null);
      assertTrue("Result id does not match.", result.getId().equals(anId));

      if (logger.isInfoEnabled()) {
        logger.info(testName + " verified id =" + anId);
      }
    }
View Full Code Here

    if (logger.isInfoEnabled()) {
      logger.info("\n\t\tRunning Test: " + testName);
    }

    // 1. find a valid person first:
    Person p = (Person) loadObject(Person.class);

    assertTrue("Empty Person table.", p != null);

    // 2. create a new person object and test:
    Person newP = new Person();
    newP.setEmailAddressString(p.getEmailAddressString());
    newP.setFirstName(p.getFirstName());
    newP.setLastName(p.getLastName());

    PersonHome fixture = getPersonHome();
    Person result = fixture.findByExactMatch(newP);

    // 3. verify
    assertTrue(result != null);
    assertTrue(result.getLastName().equals(result.getLastName()));

    // Notes: this is a dangerous verification. Let's see if it works:
    assertTrue(result.getId().equals(p.getId()));

    if (logger.isInfoEnabled()) {
      logger.info(testName + " verified id =" + p.getId() + " lastname =" + p.getLastName());
    }
View Full Code Here

      logger.info("\n\t\tRunning Test: " + testName);
    }

    // 1. find a valid person first:
    User u = (User) loadObject(User.class);
    Person p = u.getPerson();

    if (logger.isInfoEnabled()) {
      logger.info("username = " + u.getUsername() + " persopn =" + p.getFirstName() + " "
        + p.getLastName());
    }

    // 2. test:
    UserHome fixture = getUserHome();
    User result = fixture.findByPerson(p);
View Full Code Here

   *
   * @see org.cipres.treebase.domain.admin.PersonService#mergePerson(java.lang.Long,
   *      java.lang.Long)
   */
  public int mergePerson(Long pSourceId, Long pTargetId) {
    Person personSrc = getPersonHome().findPersistedObjectByID(Person.class, pSourceId);
    Person personTarget = getPersonHome().findPersistedObjectByID(Person.class, pTargetId);
    if (personSrc == null || personTarget == null) {
      return -1;
    }

    // If there are two user accounts, then both are pointing to the same target person.
View Full Code Here

      if ( nameParts.length < 2 ) {
        warn("Can't split record on spaces: '"+authorNames[i]+"'");
      }
      String[] firstNames = nameParts[1].split(" ");
      Collection<Person> persons = personHome.findByLastName(nameParts[0]);
      Person person = null;
      // exactly one match
      if ( persons.size() == 1 ) {
        Person tempPerson = persons.iterator().next();
        if ( initialsMatch(tempPerson,firstNames) ) {
          person = tempPerson;
        }
      }
      // more than one match: find a person with matching initials
      else if ( persons.size() > 1 ) {
        Iterator<Person> personIterator = persons.iterator();
        while ( personIterator.hasNext() ) {
          Person tempPerson = personIterator.next();
          if ( initialsMatch(tempPerson,firstNames) ) {
            person = tempPerson;
            break;
          }
        }       
      } 
      if ( person == null ) {
        warn("Couldn't find person "+authorNames[i]+", creating new one");
        person = new Person();       
        person.setLastName(nameParts[0]);
        person.setFirstName(nameParts[1]);
        person.setMiddleName("");
        person.setEmailAddressString("");
        //personHome.save(person);   //-- VG 2010-02-24  These were messing up parent transactions by
View Full Code Here

      }
      rearrangeList(idsList, request);
      return returnView();
    }

    Person author_editor = (Person) command;

    if (request.getParameter("method") == null) {

      List<String> errorsEncountered = verifyEachParameter(author_editor);
      if (errorsEncountered.size() > 0) {
        errorsEncountered.add(
          0,
          "Sorry, form could not be submissitted for reasons see below.");
        request.getSession().setAttribute("errors", errorsEncountered);
        return returnView();
      }

      author_editor.setFirstName(author_editor.getFirstName().trim());
      author_editor.setLastName(author_editor.getLastName().trim());

      if (author_editor.getMiddleName().trim().length() > 0) {
        author_editor.setMiddleName(author_editor.getMiddleName().trim());
      }
    }

    // Get the existing list of authors for the citation
    Study study = ControllerUtil.findStudy(request, mStudyService);
    Citation citation = study.getCitation();

    if (citation == null) {
      request.getSession().setAttribute(
        "errors",
        "Please provide the citataion for this study first.");
      return showForm(request, response, bindExp);
    }

    // list of original author/editors associated with the citation
    List<Person> currentPersons = getPeople(citation);

    // Check permission that the user has the edit right:
    // Currently it is not necessary since the only delete link can be hacked by direct editing
    // the url.
    // but the delete can only work with this particular study.
    TBPermission perm = getStudyService().getPermission(request.getRemoteUser(), study.getId());
    if (perm != TBPermission.WRITE) {
      // Give error message and return
      // return;
    }

    if (request.getParameter(ACTION_CANCEL) == null) {
      // update the author list based the user selection
      if (request.getParameter("method") != null
        && request.getParameter("method").equals(ACTION_DELETE)) {
        String id = request.getParameter("id");
        for (Person person : currentPersons) {
          if (person.getId().equals(Long.parseLong((id)))) {
            currentPersons.remove(person);
            break;
          }
        }
      }
      else if (request.getParameter(ACTION_SUBMIT) != null
        || request.getParameter("Submit and Continue") != null) {
         // look for match in "Person" table
        Person p = mPersonService.findByExactMatch(author_editor);
        // no match
        if (p == null) {
          // add "author" to Person table
          mPersonService.createPerson(author_editor);
          // add "author" to citation_author table
View Full Code Here

TOP

Related Classes of org.cipres.treebase.domain.admin.Person

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.