-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GRAD2-3018 - Adds tables, data, and get endpoint for student grade codes
- Loading branch information
Showing
15 changed files
with
359 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/StudentGradeCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ca.bc.gov.educ.api.gradstudent.model.dto; | ||
|
||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = false) | ||
@Component | ||
@SuppressWarnings("squid:S1700") | ||
public class StudentGradeCode extends BaseModel { | ||
private String studentGradeCode; | ||
private String label; | ||
private int displayOrder; | ||
private String description; | ||
private LocalDateTime effectiveDate; | ||
private LocalDateTime expiryDate; | ||
private String expected; | ||
} |
47 changes: 47 additions & 0 deletions
47
api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/StudentGradeCodeEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package ca.bc.gov.educ.api.gradstudent.model.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.*; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Data | ||
@EqualsAndHashCode(callSuper = false) | ||
@Entity | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Table(name = "STUDENT_GRADE_CODE") | ||
public class StudentGradeCodeEntity extends BaseEntity { | ||
|
||
@Id | ||
@Column(name = "STUDENT_GRADE_CODE", unique = true, updatable = false) | ||
private String studentGradeCode; | ||
|
||
@NotNull(message = "label cannot be null") | ||
@Column(name = "LABEL") | ||
private String label; | ||
|
||
@NotNull(message = "displayOrder cannot be null") | ||
@Column(name = "DISPLAY_ORDER") | ||
private Integer displayOrder; | ||
|
||
@NotNull(message = "description cannot be null") | ||
@Column(name = "DESCRIPTION") | ||
private String description; | ||
|
||
@NotNull(message = "effectiveDate cannot be null") | ||
@Column(name = "EFFECTIVE_DATE") | ||
private LocalDateTime effectiveDate; | ||
|
||
@Column(name = "EXPIRY_DATE") | ||
private LocalDateTime expiryDate; | ||
|
||
@NotNull(message = "expected cannot be null") | ||
@Column(name = "EXPECTED") | ||
private String expected; | ||
} |
22 changes: 22 additions & 0 deletions
22
...in/java/ca/bc/gov/educ/api/gradstudent/model/transformer/StudentGradeCodeTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ca.bc.gov.educ.api.gradstudent.model.transformer; | ||
|
||
import ca.bc.gov.educ.api.gradstudent.model.dto.StudentGradeCode; | ||
import ca.bc.gov.educ.api.gradstudent.model.entity.StudentGradeCodeEntity; | ||
import org.modelmapper.ModelMapper; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class StudentGradeCodeTransformer { | ||
|
||
@Autowired | ||
ModelMapper modelMapper; | ||
|
||
public StudentGradeCode transformToDTO (StudentGradeCodeEntity entity) { | ||
return modelMapper.map(entity, StudentGradeCode.class); | ||
} | ||
|
||
public StudentGradeCodeEntity transformToEntity(StudentGradeCode studentGradeCode) { | ||
return modelMapper.map(studentGradeCode, StudentGradeCodeEntity.class); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/StudentGradeCodeRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package ca.bc.gov.educ.api.gradstudent.repository; | ||
|
||
import ca.bc.gov.educ.api.gradstudent.model.entity.StudentGradeCodeEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface StudentGradeCodeRepository extends JpaRepository<StudentGradeCodeEntity, String> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
api/src/main/resources/db/migration/1.0/V1.0.69__DDL-CREATE_TABLE-STUDENT_GRADE_CODE.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- API_GRAD_STUDENT.STUDENT_GRADE_CODE definition | ||
|
||
CREATE TABLE "STUDENT_GRADE_CODE" | ||
( "STUDENT_GRADE_CODE" VARCHAR2(2) NOT NULL, | ||
"LABEL" VARCHAR2(30) NOT NULL, | ||
"DESCRIPTION" VARCHAR2(125) NOT NULL, | ||
"DISPLAY_ORDER" NUMBER NOT NULL, | ||
"EFFECTIVE_DATE" DATE NOT NULL, | ||
"EXPIRY_DATE" DATE, | ||
"EXPECTED" VARCHAR2(1) NOT NULL, | ||
"CREATE_DATE" DATE DEFAULT SYSTIMESTAMP NOT NULL, | ||
"CREATE_USER" VARCHAR2(32) DEFAULT USER NOT NULL, | ||
"UPDATE_DATE" DATE DEFAULT SYSTIMESTAMP NOT NULL, | ||
"UPDATE_USER" VARCHAR2(32) DEFAULT USER NOT NULL, | ||
CONSTRAINT "STUDENT_GRADE_CODE_PK" PRIMARY KEY ("STUDENT_GRADE_CODE") | ||
USING INDEX TABLESPACE "API_GRAD_IDX" | ||
) SEGMENT CREATION IMMEDIATE | ||
NOCOMPRESS LOGGING | ||
TABLESPACE "API_GRAD_DATA" NO INMEMORY ; |
65 changes: 65 additions & 0 deletions
65
api/src/main/resources/db/migration/1.0/V1.0.70__DML-INSERT_DATA-STUDENT_GRADE_CODES.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('01','Grade 1','First grade',110,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('02','Grade 2','Second grade',120,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('03','Grade 3','Third grade',130,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('04','Grade 4','Fourth grade',140,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('05','Grade 5','Fifth grade',150,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('06','Grade 6','Sixth grade',160,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('07','Grade 7','Seventh grade',170,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('08','Grade 8','Eighth grade',10,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('09','Grade 9','Ninth grade',20,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('10','Grade 10','Tenth grade',30,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('11','Grade 11','Eleventh grade',40,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('12','Grade 12','Twelfth grade',50,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('AD','Adult Grad','Student on the Adult Graduation Program who is expected to graduate this year (subgrade)',60,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('AN','Adult Non Grad','Student on the Adult Graduation Program who is not expected to graduate this year (subgrade)',70,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('GA','Graduated Adult','An adult student who has graduated in BC or another jurisdiction (subgrade)',90,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('GR','Graduated','Used by MyEdBC schools only when a student withdraws or the school believes they have finished their program',100,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('KF','Kindergarten Full-time','After 2012, the only valid grade code for kindergarten (subgrade)',180,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('SU','Secondary Upgraded','Secondary upgraded (subgrade)',190,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('EU','Elementary Upgraded','Elementary ungraded (subgrade)',200,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('HS','Home School','Students whose parents provide their educational program and who are registered with the school (subgrade)',80,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('KH','Kindergarten Half','Kindergarten half-time, applicable only until 2012 (subgrade)',210,TIMESTAMP'2024-10-01 00:00:00.0',TIMESTAMP'2012-06-30 00:00:00.0', 'N'); | ||
|
||
INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED) | ||
VALUES ('OT','Other','A historic grade code applied by TRAX when an unexpected grade code was submitted for a student',220,TIMESTAMP'2024-10-01 00:00:00.0',TIMESTAMP'2024-10-01 00:00:00.0', 'Y'); |
47 changes: 47 additions & 0 deletions
47
api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/BaseIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package ca.bc.gov.educ.api.gradstudent.controller; | ||
|
||
import ca.bc.gov.educ.api.gradstudent.EducGradStudentApiApplication; | ||
import ca.bc.gov.educ.api.gradstudent.model.entity.StudentGradeCodeEntity; | ||
import ca.bc.gov.educ.api.gradstudent.repository.StudentGradeCodeRepository; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@SpringBootTest(classes = {EducGradStudentApiApplication.class}) | ||
@ActiveProfiles("test") | ||
@AutoConfigureMockMvc | ||
public abstract class BaseIntegrationTest { | ||
|
||
@Autowired | ||
StudentGradeCodeRepository studentGradeCodeRepository; | ||
|
||
@BeforeEach | ||
public void before() { | ||
studentGradeCodeRepository.saveAll(studentGradeCodeData()); | ||
} | ||
|
||
@AfterEach | ||
public void resetState() { | ||
studentGradeCodeRepository.deleteAll(); | ||
} | ||
|
||
public List<StudentGradeCodeEntity> studentGradeCodeData() { | ||
List<StudentGradeCodeEntity> entities = new ArrayList<>(); | ||
entities.add(StudentGradeCodeEntity.builder().studentGradeCode("07").description("Grade 7").label("Grade 7").effectiveDate(LocalDateTime.now()).expected("N").displayOrder(1).build()); | ||
|
||
entities.add(StudentGradeCodeEntity.builder().studentGradeCode("08").description("Grade 8").label("Grade 8").effectiveDate(LocalDateTime.now()).expected("Y").displayOrder(2).build()); | ||
|
||
entities.add(StudentGradeCodeEntity.builder().studentGradeCode("09").description("Grade 9").label("Grade 9").effectiveDate(LocalDateTime.now()).expected("Y").displayOrder(3).build()); | ||
|
||
entities.add(StudentGradeCodeEntity.builder().studentGradeCode("10").description("Grade 10").label("Grade 10").effectiveDate(LocalDateTime.now()).expected("Y").displayOrder(4).build()); | ||
|
||
return entities; | ||
} | ||
} |
Oops, something went wrong.