Added TrainingType.
This commit is contained in:
parent
32d601a78c
commit
cca23fa995
@ -20,7 +20,7 @@ public class NewObservation {
|
|||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private String observed;
|
private String observed, type;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
|
@ -14,7 +14,6 @@ import org.joda.time.DateTime;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor(access = AccessLevel.PROTECTED)
|
|
||||||
public class Observation {
|
public class Observation {
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -29,6 +28,10 @@ public class Observation {
|
|||||||
@JsonProperty
|
@JsonProperty
|
||||||
private String observed;
|
private String observed;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@JsonProperty
|
||||||
|
private TrainingType type;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private int monitoring, control, conservatism, teamwork, knowledge;
|
private int monitoring, control, conservatism, teamwork, knowledge;
|
||||||
@ -53,10 +56,25 @@ public class Observation {
|
|||||||
this.rawData = rawData;
|
this.rawData = rawData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Observation(int id, int siteId, String observed, String type, int monitoring, int control, int conservatism,
|
||||||
|
int teamwork, int knowledge, String rawData, DateTime date) {
|
||||||
|
this.id = id;
|
||||||
|
this.siteId = siteId;
|
||||||
|
this.observed = observed;
|
||||||
|
this.type = TrainingType.valueOf(type.toUpperCase());
|
||||||
|
this.monitoring = monitoring;
|
||||||
|
this.control = control;
|
||||||
|
this.conservatism = conservatism;
|
||||||
|
this.teamwork = teamwork;
|
||||||
|
this.knowledge = knowledge;
|
||||||
|
this.rawData = rawData;
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
public static class Mapper implements RowMapper<Observation>{
|
public static class Mapper implements RowMapper<Observation>{
|
||||||
|
|
||||||
public Observation map(ResultSet rs, StatementContext ctx) throws SQLException {
|
public Observation map(ResultSet rs, StatementContext ctx) throws SQLException {
|
||||||
return new Observation(rs.getInt("id"), rs.getInt("siteId"), rs.getString("observed"),
|
return new Observation(rs.getInt("id"), rs.getInt("siteId"), rs.getString("observed"), rs.getString("type"),
|
||||||
rs.getInt("monitoring"), rs.getInt("control"), rs.getInt("conservatism"), rs.getInt("teamwork"),
|
rs.getInt("monitoring"), rs.getInt("control"), rs.getInt("conservatism"), rs.getInt("teamwork"),
|
||||||
rs.getInt("knowledge"), rs.getString("rawData"), new DateTime(rs.getDate("date")));
|
rs.getInt("knowledge"), rs.getString("rawData"), new DateTime(rs.getDate("date")));
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
package uk.co.neviyn.Observations.core;
|
||||||
|
|
||||||
|
public enum TrainingType {
|
||||||
|
INITIAL, CONTINUING
|
||||||
|
}
|
@ -16,16 +16,16 @@ import uk.co.neviyn.Observations.core.Observation;
|
|||||||
public interface ObservationDao {
|
public interface ObservationDao {
|
||||||
|
|
||||||
@SqlUpdate("CREATE TABLE IF NOT EXISTS observations (id INTEGER PRIMARY KEY, siteId INTEGER, " +
|
@SqlUpdate("CREATE TABLE IF NOT EXISTS observations (id INTEGER PRIMARY KEY, siteId INTEGER, " +
|
||||||
"observed TEXT, monitoring INTEGER, control INTEGER, conservatism INTEGER, teamwork INTEGER, knowledge INTEGER, " +
|
"observed TEXT, type TEXT, monitoring INTEGER, control INTEGER, conservatism INTEGER, teamwork INTEGER, " +
|
||||||
"rawData TEXT, date DATE)")
|
"knowledge INTEGER, rawData TEXT, date DATE)")
|
||||||
void createObservationTable();
|
void createObservationTable();
|
||||||
|
|
||||||
@SqlUpdate("CREATE TABLE IF NOT EXISTS observation_tutor (tutorId INT NOT NULL, observationId INT NOT NULL, " +
|
@SqlUpdate("CREATE TABLE IF NOT EXISTS observation_tutor (tutorId INT NOT NULL, observationId INT NOT NULL, " +
|
||||||
"FOREIGN KEY (tutorID) REFERENCES tutor(id), FOREIGN KEY (observationId) REFERENCES observations(id))")
|
"FOREIGN KEY (tutorID) REFERENCES tutor(id), FOREIGN KEY (observationId) REFERENCES observations(id))")
|
||||||
void createObservationTutorTable();
|
void createObservationTutorTable();
|
||||||
|
|
||||||
@SqlUpdate("INSERT INTO observations (siteId, observed, monitoring, control, conservatism, teamwork, knowledge, " +
|
@SqlUpdate("INSERT INTO observations (siteId, observed, type, monitoring, control, conservatism, teamwork, knowledge, " +
|
||||||
"rawData, date) VALUES (:siteId, :observed, :monitoring, :control, :conservatism, :teamwork, :knowledge, " +
|
"rawData, date) VALUES (:siteId, :observed, :type, :monitoring, :control, :conservatism, :teamwork, :knowledge, " +
|
||||||
":rawData, :date)")
|
":rawData, :date)")
|
||||||
@GetGeneratedKeys
|
@GetGeneratedKeys
|
||||||
int addObservation(@BindBean NewObservation observation, @Bind("date") DateTime date);
|
int addObservation(@BindBean NewObservation observation, @Bind("date") DateTime date);
|
||||||
|
Loading…
Reference in New Issue
Block a user