Skip to content

Commit

Permalink
Added code in getAnimalReplacementFee to retrieve the replacement fee…
Browse files Browse the repository at this point in the history
… from the demographics table.
  • Loading branch information
aschmidt34 committed Feb 7, 2024
1 parent 0c278a9 commit 7aa155a
Showing 1 changed file with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public String getWeightFromAnimalID(Container currentContainer, User currentUser
* 2. "No animal replacement fee to be paid (causeOfDeath death)".
* 3. "".
*/
public String getAnimalReplacementFee(Container currentContainer, User currentUser, String causeOfDeath) {
public String getAnimalReplacementFee(Container currentContainer, User currentUser, String causeOfDeath, String animalID) {
//Sets up variables.
StringBuilder returnFee = new StringBuilder();
SimpleFilter queryFilter = new SimpleFilter(FieldKey.fromString("Value"), causeOfDeath, CompareType.EQUAL);
Expand All @@ -384,7 +384,32 @@ public void exec(ResultSet rs) throws SQLException {
//Returns fee.
//TODO: Ask Daniel if this an empty fee (instead of 'fee' or 'no fee') should be 'no fee'.
if (returnFee.toString().equals("Fee")) {
return ("Animal replacement fee to be paid (" + causeOfDeath + " death)");


//TODO: Added this for hotfix, clean up later.
SimpleFilter feeFilter = new SimpleFilter("id", animalID, CompareType.EQUAL);
TableSelector feeTable = new TableSelector(QueryService.get().getUserSchema(currentUser, currentContainer, "study").getTable("demographics"), feeFilter, null);
//Gets fee from table.
StringBuilder updatedFee = new StringBuilder();
if (feeTable != null) {
if (feeTable.getRowCount() > 0) {
myTable.forEach(new Selector.ForEachBlock<ResultSet>() {
@Override
public void exec(ResultSet rs) throws SQLException {
updatedFee.append(rs.getString("prepaid"));
}
});
}
}
if (!updatedFee.isEmpty()) {
return updatedFee.toString();
}
else {
return ("Animal replacement fee to be paid (" + causeOfDeath + " death)");
}
//TODO: End of hotfix changes.


}
else if (returnFee.toString().equals("No Fee")) {
return ("No animal replacement fee to be paid (" + causeOfDeath + " death)");
Expand Down Expand Up @@ -554,7 +579,7 @@ public DeathNecropsyObject(Container c, User u, String animalID, String hostName
//Gets animal replacement fee.
//TODO: What should I return when this is null? Currently I just have it return a blank string.
if (necropsyTypeOfDeath != null) {
this.animalReplacementFee = notificationToolkit.getAnimalReplacementFee(c, u, this.necropsyTypeOfDeath);
this.animalReplacementFee = notificationToolkit.getAnimalReplacementFee(c, u, this.necropsyTypeOfDeath, animalID);
}

//Creates task id with hyperlink.
Expand Down

0 comments on commit 7aa155a

Please sign in to comment.