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(); }
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; }
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(); }
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(); }
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(); }
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(); }
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; }
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(); }
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; }
// 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(); }
public static List<Post_thread> all() { return find.order().desc("id").fetch("user").setMaxRows(8).findList(); }
public static List<Doctor> allDoctors() { return find.all(); }
public static Doctor get(Long id) { return find.ref(id); }
public static int getTotalPrivatePageCount(String user, int pageSize) { PagingList<Scenario> pagingList = find.where().eq("members.email", user).findPagingList(pageSize); return pagingList.getTotalPageCount(); }
public static Scenario findInvolvingCheckpoint(Long checkpointId) { return find.where().eq("checkpoints.id", checkpointId).findUnique(); }
public static Post_thread getById(Long id) { return find.byId(id); }
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(); }
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); }
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(); }