示例#1
0
 public static Page<Office> page(
     int page, int pageSize, String sortBy, String order, String filter) {
   return find.where()
       .ilike("name", "%" + filter + "%")
       .orderBy(sortBy + " " + order)
       .findPagingList(pageSize)
       .getPage(page);
 }
示例#2
0
 /**
  * Return a page of Performance
  *
  * @param page Page to display
  * @param pageSize Number of computers per page
  * @param sortBy Computer property used for sorting
  * @param order Sort order (either or asc or desc)
  * @param filter Filter applied on the name column
  */
 public static Page<Performance> page(
     int page, int pageSize, String sortBy, String order, String filter) {
   return find.where()
       .ilike("name", "%" + filter + "%")
       .orderBy(sortBy + " " + order)
       .fetch("INSERT FOREIGN KEY NAME")
       .findPagingList(pageSize)
       .getPage(page);
 }
示例#3
0
 /**
  * Returns the PerformanceID of given performance time
  *
  * @param performanceTime Which subversion number to find ID for
  * @return id of Performance. Creates new one if no performanceTime already existed
  */
 public static Long getPerformanceID(String performanceTime) { // Used in saveRun
   Performance performance = find.where().eq("time", performanceTime).findUnique();
   if (performance == null) { // If no Performance was found... add it and return that id
     Performance newPerformance = new Performance();
     newPerformance.time = performanceTime;
     newPerformance.save();
     return newPerformance.id;
   }
   return performance.id;
 }
示例#4
0
 public static Doctor findByFullName(String fullName) {
   String[] fio = fullName.split(" ");
   String query = "find doctor where name=:name and surname=:surname and patronymic=:patronymic";
   /*Doctor doctor = Ebean.find(Doctor.class).setQuery(query).setParameter("surname", fio[0])
   .setParameter("name", fio[1]).setParameter("patronymic", fio[2]).findUnique(); */
   Doctor doctor =
       find.setQuery(query)
           .setParameter("surname", fio[0])
           .setParameter("name", fio[1])
           .setParameter("patronymic", fio[2])
           .findUnique();
   return doctor;
 }
示例#5
0
  // 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;
  }
示例#6
0
 public static IdentityDocType get(Long id) {
   return find.ref(id);
 }
示例#7
0
 public static void delete(Long id) {
   find.ref(id).delete();
 }
示例#8
0
 public static List<IdentityDocType> all() {
   return find.all();
 }
示例#9
0
 public static List<Doctor> allDoctors() {
   return find.all();
 }
示例#10
0
 public static Doctor get(Long id) {
   return find.ref(id);
 }