public static List<String> fioList() { List<String> theList = new ArrayList<String>(); for (Doctor doctor : allDoctors()) { theList.add(doctor.getFullName()); } return theList; }
// TODO: repair choosing doctor by typename public static List<String> fioListByType(String doctorTypeName) { /*String query = "find doctor fetch doctor_type.doctor_type_id"; List<Doctor> doctors = Ebean.find(Doctor.class) .setQuery(query) .setParameter("doctor_type_id", new Long(1)) .findList(); */ String sql = "SELECT * FROM DOCTOR LEFT JOIN DOCTOR_TYPE ON DOCTOR_TYPE.ID = DOCTOR.DOCTOR_TYPE_ID"; SqlQuery sqlQuery = Ebean.createSqlQuery(sql); List<SqlRow> list = sqlQuery.findList(); /*RawSql rawSql = RawSqlBuilder.parse(sql).create(); javax.persistence.Query<Doctor> query = Ebean.find(Doctor.class); query.setRawSql(rawSql); //.columnMapping("id", "doctor.id") //.columnMapping("name", "doctor.name") //.columnMapping("surname", "doctor.surname") //.columnMapping("patronymic", "doctor.patronymic") //.columnMapping("patronymic", "doctor_type.doctor_type_name"); List<Doctor> doctors = query.findList(); */ // List<Doctor> doctors = Ebean.find(Doctor.class) // .fetch("doctor_type","doctor.doctor_type_id") // .findList(); // List<Doctor> doctors = find.fetch("doctor_type") // .where().eq("doctor.doctor_type_name", doctorTypeName) // .findList(); /*com.avaje.ebean.Query q = Ebean.createQuery(Doctor.class); q.join("doctor_type"); final List<Doctor> eventList = q.findList();*/ List<Doctor> doctors = find.where().eq("doctor_type_id", new Long(1)).findList(); List<String> theList = new ArrayList<String>(); for (Doctor doctor : doctors) { theList.add(doctor.getFullName()); } return theList; }