Exemplo n.º 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();
 }
Exemplo n.º 2
0
 public static List<Post_thread> all(String usrInterest) {
   return find.where()
       .eq("interest", usrInterest)
       .order()
       .desc("id")
       .fetch("user")
       .setMaxRows(8)
       .findList();
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
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;
 }
Exemplo n.º 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();
 }
Exemplo n.º 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();
 }
Exemplo n.º 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();
 }
Exemplo n.º 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();
 }
Exemplo n.º 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;
 }
Exemplo n.º 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();
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
  }
Exemplo n.º 13
0
 public static void delete(Long id) {
   find.ref(id).delete();
 }
Exemplo n.º 14
0
 public static List<Post_thread> all() {
   return find.order().desc("id").fetch("user").setMaxRows(8).findList();
 }
Exemplo n.º 15
0
 public static List<Doctor> allDoctors() {
   return find.all();
 }
Exemplo n.º 16
0
 public static Doctor get(Long id) {
   return find.ref(id);
 }
Exemplo n.º 17
0
 public static int getTotalPrivatePageCount(String user, int pageSize) {
   PagingList<Scenario> pagingList =
       find.where().eq("members.email", user).findPagingList(pageSize);
   return pagingList.getTotalPageCount();
 }
Exemplo n.º 18
0
 public static Scenario findInvolvingCheckpoint(Long checkpointId) {
   return find.where().eq("checkpoints.id", checkpointId).findUnique();
 }
Exemplo n.º 19
0
 public static Post_thread getById(Long id) {
   return find.byId(id);
 }
Exemplo n.º 20
0
 public static boolean isMember(Long scenarioId, String userEmail) {
   return find.where().eq("members.email", userEmail).eq("id", scenarioId).findRowCount() > 0;
 }
Exemplo n.º 21
0
 public static List<IdentityDocType> all() {
   return find.all();
 }
Exemplo n.º 22
0
 public static List<Scenario> findOwned(String userEmail) {
   return find.where().eq("owner.email", userEmail).findList();
 }
Exemplo n.º 23
0
 public static IdentityDocType get(Long id) {
   return find.ref(id);
 }
Exemplo n.º 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();
 }