comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java @ 6665:b7945db8a43b

issue1413: Only show unknown sediment loads of selected unit type. Therefore, adjusted the factory to take the units name. Unfortunately, names in db do not match values of data items. Thus do manual replacing. In Facet and Calculate, take the chosen unit via access and to the string replacement. In Facet, do not transform data (we assume it comes in unit as labeled in the db), and removed the possibility of m3/a-data of unknown yields in a t/a diagram and vice versa.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 25 Jul 2013 15:08:13 +0200
parents a4f60641e445
children 7ea933f9c6ea
comparison
equal deleted inserted replaced
6664:4ae1fbaaacdd 6665:b7945db8a43b
113 " ti.stop_time AS end " + 113 " ti.stop_time AS end " +
114 "FROM sediment_yield sy " + 114 "FROM sediment_yield sy " +
115 " JOIN rivers r ON sy.river_id = r.id " + 115 " JOIN rivers r ON sy.river_id = r.id " +
116 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " + 116 " JOIN time_intervals ti ON sy.time_interval_id = ti.id " +
117 " JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " + 117 " JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " +
118 "WHERE r.name = :river" + 118 " JOIN units u ON sy.unit_id = u.id " +
119 " AND gf.name = 'unknown'"; 119 "WHERE r.name = :river " +
120 " AND gf.name = 'unknown' " +
121 " AND u.name = :unit";
120 122
121 public static final String SQL_SELECT_EPOCHS_DATA = 123 public static final String SQL_SELECT_EPOCHS_DATA =
122 "SELECT" + 124 "SELECT" +
123 " sy.description AS description, " + 125 " sy.description AS description, " +
124 " ti.start_time AS startYear, " + 126 " ti.start_time AS startYear, " +
548 load.addKm((Double)row[4], fraction); 550 load.addKm((Double)row[4], fraction);
549 } 551 }
550 return load; 552 return load;
551 } 553 }
552 554
553 public static SedimentLoad[] getSedimentLoadUnknown(String river) { 555 /**
556 * Return sediment loads with 'unknown' fraction type.
557 * @param unit Restrict result set to those of given unit.
558 */
559 public static SedimentLoad[] getSedimentLoadUnknown(String river, String unit) {
554 Session session = SessionHolder.HOLDER.get(); 560 Session session = SessionHolder.HOLDER.get();
555 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_UNKNOWN) 561 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_UNKNOWN)
556 .addScalar("description", StandardBasicTypes.STRING) 562 .addScalar("description", StandardBasicTypes.STRING)
557 .addScalar("startYear", StandardBasicTypes.DATE) 563 .addScalar("startYear", StandardBasicTypes.DATE)
558 .addScalar("end", StandardBasicTypes.DATE); 564 .addScalar("end", StandardBasicTypes.DATE);
559 sqlQuery.setString("river", river); 565 sqlQuery.setString("river", river);
566 sqlQuery.setString("unit", unit);
560 List<Object[]> results = sqlQuery.list(); 567 List<Object[]> results = sqlQuery.list();
561 SedimentLoad[] loads = new SedimentLoad[results.size()]; 568 SedimentLoad[] loads = new SedimentLoad[results.size()];
562 int counter = 0; 569 int counter = 0;
563 for (Object[] row: results) { 570 for (Object[] row: results) {
564 loads[counter] = new SedimentLoad( 571 loads[counter] = new SedimentLoad(

http://dive4elements.wald.intevation.org