From e973478178f77662f893843c107c6476327d1ff9 Mon Sep 17 00:00:00 2001 From: Jarold Wong Date: Thu, 11 Jul 2019 10:24:36 -0700 Subject: [PATCH 1/4] Add appointment percentage to sectionGroups --- .../V228__Add_AppointmentPercentage_To_SectionGroups.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/main/resources/db/migration/V228__Add_AppointmentPercentage_To_SectionGroups.sql diff --git a/src/main/resources/db/migration/V228__Add_AppointmentPercentage_To_SectionGroups.sql b/src/main/resources/db/migration/V228__Add_AppointmentPercentage_To_SectionGroups.sql new file mode 100644 index 000000000..84e2d92df --- /dev/null +++ b/src/main/resources/db/migration/V228__Add_AppointmentPercentage_To_SectionGroups.sql @@ -0,0 +1,2 @@ +ALTER TABLE `SectionGroups` ADD COLUMN `TaAppointmentPercentage` INT(11) NULL; +ALTER TABLE `SectionGroups` ADD COLUMN `ReaderAppointmentPercentage` INT(11) NULL; From 1925899192d8bce635b594157f9919dbe7ae913b Mon Sep 17 00:00:00 2001 From: Jarold Wong Date: Thu, 11 Jul 2019 11:37:42 -0700 Subject: [PATCH 2/4] Update SectionGroup with appointment percentages --- .../api/components/course/CourseViewController.java | 3 +++ .../api/deserializers/SectionGroupDeserializer.java | 8 ++++++++ .../edu/ucdavis/dss/ipa/entities/SectionGroup.java | 12 +++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/ucdavis/dss/ipa/api/components/course/CourseViewController.java b/src/main/java/edu/ucdavis/dss/ipa/api/components/course/CourseViewController.java index 0c8baac0c..c1f648a9c 100644 --- a/src/main/java/edu/ucdavis/dss/ipa/api/components/course/CourseViewController.java +++ b/src/main/java/edu/ucdavis/dss/ipa/api/components/course/CourseViewController.java @@ -129,6 +129,9 @@ public SectionGroup updateSectionGroup(@PathVariable long sectionGroupId, @Reque originalSectionGroup.setTeachingAssistantAppointments(sectionGroup.getTeachingAssistantAppointments()); originalSectionGroup.setReaderAppointments(sectionGroup.getReaderAppointments()); + originalSectionGroup.setTaAppointmentPercentage(sectionGroup.getTaAppointmentPercentage()); + originalSectionGroup.setReaderAppointmentPercentage(sectionGroup.getReaderAppointmentPercentage()); + return sectionGroupService.save(originalSectionGroup); } diff --git a/src/main/java/edu/ucdavis/dss/ipa/api/deserializers/SectionGroupDeserializer.java b/src/main/java/edu/ucdavis/dss/ipa/api/deserializers/SectionGroupDeserializer.java index a8979a250..09fe64c28 100644 --- a/src/main/java/edu/ucdavis/dss/ipa/api/deserializers/SectionGroupDeserializer.java +++ b/src/main/java/edu/ucdavis/dss/ipa/api/deserializers/SectionGroupDeserializer.java @@ -48,6 +48,14 @@ public Object deserialize(JsonParser jsonParser, DeserializationContext deserial sg.setReaderAppointments(node.get("readerAppointments").floatValue()); } + if (node.has("taAppointmentPercentage") && node.hasNonNull("taAppointmentPercentage")) { + sg.setTaAppointmentPercentage(node.get("taAppointmentPercentage").intValue()); + } + + if (node.has("readerAppointmentPercentage") && node.hasNonNull("readerAppointmentPercentage")) { + sg.setReaderAppointmentPercentage(node.get("readerAppointmentPercentage").intValue()); + } + if (node.has("showTheStaff")) { sg.setShowTheStaff(node.get("showTheStaff").booleanValue()); } diff --git a/src/main/java/edu/ucdavis/dss/ipa/entities/SectionGroup.java b/src/main/java/edu/ucdavis/dss/ipa/entities/SectionGroup.java index 719dad9cc..5a40530f4 100644 --- a/src/main/java/edu/ucdavis/dss/ipa/entities/SectionGroup.java +++ b/src/main/java/edu/ucdavis/dss/ipa/entities/SectionGroup.java @@ -33,7 +33,7 @@ public class SectionGroup extends BaseEntity { private List teachingAssignments = new ArrayList(); private List activities = new ArrayList(); private String termCode; - private Integer plannedSeats; + private Integer plannedSeats, taAppointmentPercentage, readerAppointmentPercentage; private Float teachingAssistantAppointments, readerAppointments; private Boolean showTheStaff = false; @@ -191,4 +191,14 @@ public Float getReaderAppointments() { public void setReaderAppointments(Float readerAppointments) { this.readerAppointments = readerAppointments; } + + @JsonProperty + public Integer getTaAppointmentPercentage() { return taAppointmentPercentage; } + + public void setTaAppointmentPercentage(Integer taAppointmentPercentage) { this.taAppointmentPercentage = taAppointmentPercentage; } + + @JsonProperty + public Integer getReaderAppointmentPercentage() { return readerAppointmentPercentage; } + + public void setReaderAppointmentPercentage(Integer readerAppointmentPercentage) { this.readerAppointmentPercentage = readerAppointmentPercentage; } } From b9867cdf35839d89d5c05660687edcf22a65d3fb Mon Sep 17 00:00:00 2001 From: Jarold Wong Date: Mon, 15 Jul 2019 11:36:34 -0700 Subject: [PATCH 3/4] Add appointment percentage to sectionGroupCosts --- .../edu/ucdavis/dss/ipa/entities/SectionGroupCost.java | 10 +++++++++- ...228__Add_AppointmentPercentage_To_SectionGroups.sql | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/ucdavis/dss/ipa/entities/SectionGroupCost.java b/src/main/java/edu/ucdavis/dss/ipa/entities/SectionGroupCost.java index 2af3e0c0f..601facbad 100644 --- a/src/main/java/edu/ucdavis/dss/ipa/entities/SectionGroupCost.java +++ b/src/main/java/edu/ucdavis/dss/ipa/entities/SectionGroupCost.java @@ -23,7 +23,7 @@ public class SectionGroupCost extends BaseEntity { private long id; private BudgetScenario budgetScenario; - private Integer sectionCount; + private Integer sectionCount, taAppointmentPercentage, readerAppointmentPercentage; private Long enrollment; private Instructor instructor; private Instructor originalInstructor; @@ -64,6 +64,10 @@ public void setTaCount(Float taCount) { this.taCount = taCount; } + public Integer getTaAppointmentPercentage() { return taAppointmentPercentage; } + + public void setTaAppointmentPercentage(Integer taAppointmentPercentage) { this.taAppointmentPercentage = taAppointmentPercentage; } + public Integer getSectionCount() { return sectionCount; } @@ -80,6 +84,10 @@ public void setReaderCount(Float readerCount) { this.readerCount = readerCount; } + public Integer getReaderAppointmentPercentage() { return readerAppointmentPercentage; } + + public void setReaderAppointmentPercentage(Integer readerAppointmentPercentage) { this.readerAppointmentPercentage = readerAppointmentPercentage; } + public BigDecimal getCost() { return cost; } diff --git a/src/main/resources/db/migration/V228__Add_AppointmentPercentage_To_SectionGroups.sql b/src/main/resources/db/migration/V228__Add_AppointmentPercentage_To_SectionGroups.sql index 84e2d92df..cf08de42b 100644 --- a/src/main/resources/db/migration/V228__Add_AppointmentPercentage_To_SectionGroups.sql +++ b/src/main/resources/db/migration/V228__Add_AppointmentPercentage_To_SectionGroups.sql @@ -1,2 +1,4 @@ ALTER TABLE `SectionGroups` ADD COLUMN `TaAppointmentPercentage` INT(11) NULL; ALTER TABLE `SectionGroups` ADD COLUMN `ReaderAppointmentPercentage` INT(11) NULL; +ALTER TABLE `SectionGroupCosts` ADD COLUMN `TaAppointmentPercentage` INT(11) NULL; +ALTER TABLE `SectionGroupCosts` ADD COLUMN `ReaderAppointmentPercentage` INT(11) NULL; From 40a6f4c6f4e874e4eff1be181358bccf4ddbf20e Mon Sep 17 00:00:00 2001 From: Jarold Wong Date: Mon, 15 Jul 2019 11:53:22 -0700 Subject: [PATCH 4/4] Add appointment percentage to update from sectionGroup --- .../ipa/services/jpa/JpaSectionGroupCostService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/edu/ucdavis/dss/ipa/services/jpa/JpaSectionGroupCostService.java b/src/main/java/edu/ucdavis/dss/ipa/services/jpa/JpaSectionGroupCostService.java index 1d24af3ff..163b89711 100644 --- a/src/main/java/edu/ucdavis/dss/ipa/services/jpa/JpaSectionGroupCostService.java +++ b/src/main/java/edu/ucdavis/dss/ipa/services/jpa/JpaSectionGroupCostService.java @@ -169,11 +169,21 @@ public SectionGroupCost updateFromSectionGroup(SectionGroup sectionGroup, Budget sectionGroupCost.setTaCount(sectionGroup.getTeachingAssistantAppointments()); } + if (sectionGroupCost.getTaAppointmentPercentage() != sectionGroup.getTaAppointmentPercentage()) { + updateRequired = true; + sectionGroupCost.setTaAppointmentPercentage(sectionGroup.getReaderAppointmentPercentage()); + } + if (sectionGroupCost.getReaderCount() != sectionGroup.getReaderAppointments()) { updateRequired = true; sectionGroupCost.setReaderCount(sectionGroup.getReaderAppointments()); } + if (sectionGroupCost.getReaderAppointmentPercentage() != sectionGroup.getReaderAppointmentPercentage()) { + updateRequired = true; + sectionGroupCost.setReaderAppointmentPercentage(sectionGroup.getReaderAppointmentPercentage()); + } + Instructor instructor = null; InstructorType instructorType = null;