コード例 #1
0
    @Override
    public Object convert(Class type, Object value) {
      try {
        IntegerNumberConverter converter = new IntegerNumberConverter();
        Integer studentNumber = (Integer) converter.convert(type, value);

        return Student.readStudentByNumber(studentNumber);
      } catch (ConversionException e) {
        return null;
      }
    }
コード例 #2
0
  private void setBestMatchingStudent() {
    Person personByFullDocumentId = null;
    Person personByPartialDocumentId = null;

    Collection<Person> fullDocumentIdPersonsCollection = readPersonsByCompleteDocumentId();
    Collection<Person> partialDocumentIdPersonsCollection = readPersonsByPartialDocumentId();
    if (fullDocumentIdPersonsCollection.size() > 1) {
      this.multiplePersonsFound = true;
      return;
    }

    if (fullDocumentIdPersonsCollection.size() == 1) {
      personByFullDocumentId = fullDocumentIdPersonsCollection.iterator().next();
    }

    if (partialDocumentIdPersonsCollection.size() == 1) {
      personByPartialDocumentId = partialDocumentIdPersonsCollection.iterator().next();
    }
    /*
     * We couldnt found the person with full and partial document id. Search
     * with with and check if the names are equals
     */
    Student studentReadByNumber =
        this.studentNumber != null ? Student.readStudentByNumber(this.studentNumber) : null;
    Person personFoundByStudent = null;
    if (studentReadByNumber != null) {
      personFoundByStudent = studentReadByNumber.getPerson();
    }

    if (personByFullDocumentId != null
        && personFoundByStudent != null
        && personByFullDocumentId != personFoundByStudent) {
      this.multiplePersonsFound = true;
      return;
    } else if (personByPartialDocumentId != null
        && personFoundByStudent != null
        && personByPartialDocumentId != personFoundByStudent) {
      this.multiplePersonsFound = true;
      return;
    }

    if (personByFullDocumentId != null) {
      this.person = personByFullDocumentId;
      this.student = this.person.getStudent();
    } else if (personByPartialDocumentId != null) {
      this.person = personByPartialDocumentId;
      this.student = this.person.getStudent();
    } else if (personFoundByStudent != null) {
      this.person = personFoundByStudent;
      this.student = this.person.getStudent();
    }
  }