Sort animal, cares and consent behaviors lists by name.
This commit is contained in:
parent
d909883f9c
commit
8897a67c03
|
|
@ -91,7 +91,7 @@ public class AnimalDao extends PostgresSqlDao implements IAnimalDao {
|
|||
ResultSet resultSet = null;
|
||||
try {
|
||||
conn = mDataSource.getConnection();
|
||||
statement = conn.prepareStatement("SELECT * FROM "+TABLE_NAME+" WHERE owner = ?;");
|
||||
statement = conn.prepareStatement("SELECT * FROM "+TABLE_NAME+" WHERE owner = ? ORDER BY name ASC;");
|
||||
statement.setString(1, owner);
|
||||
System.out.println(IndexController.LOG_TAG + " SQL -> " + statement.toString());
|
||||
resultSet = statement.executeQuery();
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class CareDao extends PostgresSqlDao implements ICareDao {
|
|||
+ TABLE_NAME+".id as care_id, "+TABLE_NAME+".name as care_name, "+TABLE_NAME+".description as care_desc "
|
||||
+ "from "+TABLE_NAME+" "
|
||||
+ "left join "+AnimalDao.TABLE_NAME+" on "+TABLE_NAME+".animal = "+AnimalDao.TABLE_NAME+".id "
|
||||
+ "where "+AnimalDao.TABLE_NAME+".owner = ? and "+AnimalDao.TABLE_NAME+".id = ?;");
|
||||
+ "where "+AnimalDao.TABLE_NAME+".owner = ? and "+AnimalDao.TABLE_NAME+".id = ? ORDER BY "+TABLE_NAME+".name ASC;");
|
||||
statement.setString(1, owner);
|
||||
statement.setInt(2, animalId);
|
||||
System.out.println(IndexController.LOG_TAG + " SQL -> " + statement.toString());
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class ConsentBehaviorDao extends PostgresSqlDao implements IConsentBehavi
|
|||
+ TABLE_NAME+".id as cb_id, "+TABLE_NAME+".name as cb_name, "+TABLE_NAME+".description as cb_desc "
|
||||
+ "from "+TABLE_NAME+" "
|
||||
+ "left join "+AnimalDao.TABLE_NAME+" on "+TABLE_NAME+".animal = "+AnimalDao.TABLE_NAME+".id "
|
||||
+ "where "+AnimalDao.TABLE_NAME+".owner = ? and "+AnimalDao.TABLE_NAME+".id = ?;");
|
||||
+ "where "+AnimalDao.TABLE_NAME+".owner = ? and "+AnimalDao.TABLE_NAME+".id = ? ORDER BY "+TABLE_NAME+".name ASC;");
|
||||
statement.setString(1, owner);
|
||||
statement.setInt(2, animalId);
|
||||
System.out.println(IndexController.LOG_TAG + " SQL -> " + statement.toString());
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public class ProgressionDao extends PostgresSqlDao implements IProgressionDao {
|
|||
+ "from "+TABLE_NAME+" "
|
||||
+ "left join "+AnimalDao.TABLE_NAME+" on "+TABLE_NAME+".animal = "+AnimalDao.TABLE_NAME+".id "
|
||||
+ "left join "+ConsentBehaviorDao.TABLE_NAME+" on "+TABLE_NAME+".consent_behavior = "+ConsentBehaviorDao.TABLE_NAME+".id "
|
||||
+ "where "+AnimalDao.TABLE_NAME+".owner = ? and "+AnimalDao.TABLE_NAME+".id = ? and "+TABLE_NAME+".care = ?;");
|
||||
+ "where "+AnimalDao.TABLE_NAME+".owner = ? and "+AnimalDao.TABLE_NAME+".id = ? and "+TABLE_NAME+".care = ? ORDER BY "+ConsentBehaviorDao.TABLE_NAME+".name ASC;");
|
||||
statement.setString(1, animal.getOwner());
|
||||
statement.setInt(2, animal.getId());
|
||||
statement.setInt(3, careId);
|
||||
|
|
@ -193,7 +193,7 @@ public class ProgressionDao extends PostgresSqlDao implements IProgressionDao {
|
|||
+ "from "+TABLE_NAME+" "
|
||||
+ "left join "+AnimalDao.TABLE_NAME+" on "+TABLE_NAME+".animal = "+AnimalDao.TABLE_NAME+".id "
|
||||
+ "left join "+CareDao.TABLE_NAME+" on "+TABLE_NAME+".care = "+CareDao.TABLE_NAME+".id "
|
||||
+ "where "+AnimalDao.TABLE_NAME+".owner = ? and "+AnimalDao.TABLE_NAME+".id = ? and "+TABLE_NAME+".consent_behavior = ?;");
|
||||
+ "where "+AnimalDao.TABLE_NAME+".owner = ? and "+AnimalDao.TABLE_NAME+".id = ? and "+TABLE_NAME+".consent_behavior = ? ORDER BY "+CareDao.TABLE_NAME+".name ASC;");
|
||||
statement.setString(1, animal.getOwner());
|
||||
statement.setInt(2, animal.getId());
|
||||
statement.setInt(3, consentBehaviorId);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -89,11 +90,13 @@ public class Animal {
|
|||
}
|
||||
|
||||
public Collection<Care> getListCares() {
|
||||
return mapCares.values();
|
||||
return new TreeSet<>(mapCares.values());
|
||||
// return mapCares.values();
|
||||
}
|
||||
|
||||
public Collection<ConsentBehavior> getListConsentBehavior() {
|
||||
return mapConsentBehavior.values();
|
||||
return new TreeSet<>(mapConsentBehavior.values());
|
||||
// return mapConsentBehavior.values();
|
||||
}
|
||||
|
||||
public void addProgression(Progression progression) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ package fr.geoffrey.medical_training_tracker.dao.bean;
|
|||
*
|
||||
* @author Geoffrey
|
||||
*/
|
||||
public class Care {
|
||||
public class Care implements Comparable<Care>{
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
|
|
@ -58,4 +58,9 @@ public class Care {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Care o) {
|
||||
return name.compareTo(o.name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ package fr.geoffrey.medical_training_tracker.dao.bean;
|
|||
*
|
||||
* @author Geoffrey
|
||||
*/
|
||||
public class ConsentBehavior {
|
||||
public class ConsentBehavior implements Comparable<ConsentBehavior> {
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
|
|
@ -58,4 +58,9 @@ public class ConsentBehavior {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ConsentBehavior o) {
|
||||
return name.compareTo(o.name);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue