Beispiel #1
0
 public static int getTotalPrivateSearchPageCount(String searchTerm, String user, int pageSize) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("members.email", user)
           .icontains("name", searchTerm)
           .findPagingList(pageSize);
   return pagingList.getTotalPageCount();
 }
Beispiel #2
0
 public static List<Post_thread> all(String usrInterest) {
   return find.where()
       .eq("interest", usrInterest)
       .order()
       .desc("id")
       .fetch("user")
       .setMaxRows(8)
       .findList();
 }
 /**
  * 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);
 }
 /**
  * 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;
 }
Beispiel #5
0
 public static int getTotalToAcceptPageCount(Date currentDate, int pageSize) {
   return find.where()
       .eq("isAccepted", false)
       .eq("isPublic", true)
       .or(
           com.avaje.ebean.Expr.lt("expirationDate", currentDate),
           com.avaje.ebean.Expr.isNull("expirationDate"))
       .findPagingList(pageSize)
       .getTotalPageCount();
 }
Beispiel #6
0
 public static List<Scenario> findInvolvingUserSearch(
     String searchTerm, String user, int pageSize, int pageNum) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("members.email", user)
           .icontains("name", searchTerm)
           .findPagingList(pageSize);
   Page<Scenario> page = pagingList.getPage(pageNum);
   return page.getList();
 }
Beispiel #7
0
 public static int getTotalPublicAcceptedNotExpiredPageCount(int pageSize, Date currentDate) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("isPublic", true)
           .eq("isAccepted", true)
           .or(
               com.avaje.ebean.Expr.lt("expirationDate", currentDate),
               com.avaje.ebean.Expr.isNull("expirationDate"))
           .findPagingList(pageSize);
   return pagingList.getTotalPageCount();
 }
Beispiel #8
0
 public static List<Scenario> findToAccept(Date currentDate, int pageSize, int pageNum) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("isAccepted", false)
           .eq("isPublic", true)
           .or(
               com.avaje.ebean.Expr.lt("expirationDate", currentDate),
               com.avaje.ebean.Expr.isNull("expirationDate"))
           .findPagingList(pageSize);
   Page<Scenario> page = pagingList.getPage(pageNum);
   return page.getList();
 }
Beispiel #9
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;
 }
Beispiel #10
0
 public static List<Scenario> findPublicAcceptedNotExpiredSearch(
     String searchTerm, Date currentDate, int pageSize, int pageNum) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("isPublic", true)
           .eq("isAccepted", true)
           .or(
               com.avaje.ebean.Expr.gt("expirationDate", currentDate),
               com.avaje.ebean.Expr.isNull("expirationDate"))
           .icontains("name", searchTerm)
           .findPagingList(pageSize);
   Page<Scenario> page = pagingList.getPage(pageNum);
   return page.getList();
 }
Beispiel #11
0
 public static Scenario edit(
     Long scenarioId,
     String newName,
     Boolean newIsPublic,
     Date newExpirationDate,
     Boolean isAccepted) {
   Scenario scenario = find.ref(scenarioId);
   if (newName != null && !newName.equals(scenario.name)) {
     scenario.name = newName;
   }
   if (newIsPublic != null && newIsPublic != scenario.isPublic) {
     scenario.isPublic = newIsPublic;
   }
   if (newExpirationDate != null && !newExpirationDate.equals(scenario.expirationDate)) {
     scenario.expirationDate = newExpirationDate;
   }
   scenario.isAccepted = isAccepted;
   scenario.editedBy = null;
   scenario.save();
   return scenario;
 }
Beispiel #12
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;
  }
 public static void delete(Long id) {
   find.ref(id).delete();
 }
Beispiel #14
0
 public static List<Post_thread> all() {
   return find.order().desc("id").fetch("user").setMaxRows(8).findList();
 }
Beispiel #15
0
 public static List<Doctor> allDoctors() {
   return find.all();
 }
Beispiel #16
0
 public static Doctor get(Long id) {
   return find.ref(id);
 }
Beispiel #17
0
 public static int getTotalPrivatePageCount(String user, int pageSize) {
   PagingList<Scenario> pagingList =
       find.where().eq("members.email", user).findPagingList(pageSize);
   return pagingList.getTotalPageCount();
 }
Beispiel #18
0
 public static Scenario findInvolvingCheckpoint(Long checkpointId) {
   return find.where().eq("checkpoints.id", checkpointId).findUnique();
 }
Beispiel #19
0
 public static Post_thread getById(Long id) {
   return find.byId(id);
 }
Beispiel #20
0
 public static boolean isMember(Long scenarioId, String userEmail) {
   return find.where().eq("members.email", userEmail).eq("id", scenarioId).findRowCount() > 0;
 }
 public static List<IdentityDocType> all() {
   return find.all();
 }
Beispiel #22
0
 public static List<Scenario> findOwned(String userEmail) {
   return find.where().eq("owner.email", userEmail).findList();
 }
 public static IdentityDocType get(Long id) {
   return find.ref(id);
 }
Beispiel #24
0
 public static List<Scenario> findInvolvingUser(String user, int pageSize, int pageNum) {
   PagingList<Scenario> pagingList =
       find.where().eq("members.email", user).findPagingList(pageSize);
   Page<Scenario> page = pagingList.getPage(pageNum);
   return page.getList();
 }