public static void update(Long idGroup, List<SqlRow> gpms) {
    Group group = Group.findById(idGroup);
    if (group == null) return;

    Ebean.beginTransaction();
    try {
      deleteForGroup(idGroup);

      Integer i = 1;
      for (SqlRow man : gpms) {
        Profile prof = Profile.lastProfileByGpmId(man.getLong("gpm"));
        if (prof == null) continue;

        CacheClassifier cc =
            new CacheClassifier(
                group,
                i++,
                prof.gpm.idGpm,
                prof.name,
                prof.image,
                (prof.gender == null) ? null : prof.gender.value,
                (prof.relationshipStatus == null) ? null : prof.relationshipStatus.status,
                prof.nFollowers);
        if (cc.name == null || cc.name.isEmpty())
          cc.name = Profile.getLastNotEmptyField(prof.gpm.id, "name");
        cc.save();
      }

      Ebean.commitTransaction();
    } finally {
      Ebean.endTransaction();
    }
  }
Exemple #2
0
 /** Rename a folder */
 public static String renameFolder(Integer project, String folder, String newName) {
   Ebean.createSqlUpdate(
           "update task set folder = :newName where folder = :folder and project_id = :project")
       .setParameter("folder", folder)
       .setParameter("newName", newName)
       .setParameter("project", project)
       .execute();
   return newName;
 }
Exemple #3
0
 /** Mark a task as done or not */
 public static void markAsDone(Integer taskId, Boolean done) {
   /*
   Task task = Task.find.ref(taskId);
   task.done = done;
   task.update();*/
   Ebean.createSqlUpdate("update task set done = :done where id = :id")
       .setParameter("id", taskId)
       .setParameter("done", done)
       .execute();
 }
Exemple #4
0
  // SELECT DOCTOR .id as id, concat(surname, ' ', name, ' ', patronymic) as fio, doctor_type_name
  // as type FROM DOCTOR LEFT JOIN DOCTOR_TYPE ON DOCTOR_TYPE.ID = DOCTOR.DOCTOR_TYPE_ID
  public static Map<String, String> fioMapByType(Long doctorTypeNameId) {
    // TODO: check this statement at latest version of PostgreSQL
    Map<String, String> theMap = new HashMap<String, String>();
    String sql =
        "SELECT DOCTOR.id as id, concat(surname, ' ', name, ' ', patronymic) as fio FROM DOCTOR LEFT JOIN DOCTOR_TYPE ON DOCTOR_TYPE.ID = DOCTOR.DOCTOR_TYPE_ID WHERE doctor_type.id=:type_id";
    SqlQuery sqlQuery = Ebean.createSqlQuery(sql).setParameter("type_id", doctorTypeNameId);
    List<SqlRow> rows = sqlQuery.findList();
    for (SqlRow row : rows) {
      theMap.put(row.getString("id"), row.getString("fio"));
    }

    return theMap;
  }
Exemple #5
0
  public static List<String> fioSQLListByType(String doctorTypeName) {
    // TODO: check this statement at latest version of PostgreSQL
    List<String> theList = new ArrayList<String>();
    String sql =
        "SELECT concat(surname, ' ', name, ' ', patronymic) as fio FROM DOCTOR LEFT JOIN DOCTOR_TYPE ON DOCTOR_TYPE.ID = DOCTOR.DOCTOR_TYPE_ID WHERE DOCTOR_TYPE_NAME=:DOCTOR_TYPE_NAME";
    SqlQuery sqlQuery = Ebean.createSqlQuery(sql).setParameter("DOCTOR_TYPE_NAME", doctorTypeName);
    List<SqlRow> rows = sqlQuery.findList();
    // List<SqlRow> rows = Doctor.fioSQLListByType("Терапевт");
    for (SqlRow row : rows) {
      // Logger.info("row: "+ row);
      theList.add(row.getString("fio"));
    }

    return theList;
  }
Exemple #6
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;
  }