-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to eliniate session status and normalization changes on asses…
…sment_student
- Loading branch information
1 parent
ee50230
commit a1489dd
Showing
31 changed files
with
499 additions
and
240 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
2 changes: 1 addition & 1 deletion
2
api/src/main/java/ca/bc/gov/educ/eas/api/controller/v1/SessionController.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
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
22 changes: 22 additions & 0 deletions
22
api/src/main/java/ca/bc/gov/educ/eas/api/mappers/v1/AssessmentMapper.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.eas.api.mappers.v1; | ||
|
||
import ca.bc.gov.educ.eas.api.mappers.LocalDateTimeMapper; | ||
import ca.bc.gov.educ.eas.api.mappers.UUIDMapper; | ||
import ca.bc.gov.educ.eas.api.model.v1.AssessmentEntity; | ||
import ca.bc.gov.educ.eas.api.struct.v1.Assessment; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import org.mapstruct.factory.Mappers; | ||
|
||
@Mapper(uses = {UUIDMapper.class, LocalDateTimeMapper.class}) | ||
public interface AssessmentMapper { | ||
|
||
AssessmentMapper mapper = Mappers.getMapper(AssessmentMapper.class); | ||
|
||
@Mapping(target = "session.sessionID", source = "sessionEntity.sessionID") | ||
Assessment toStructure(AssessmentEntity entity); | ||
|
||
@Mapping(target = "sessionEntity.sessionID", source = "session.sessionID") | ||
AssessmentEntity toEntity(Assessment session); | ||
|
||
} |
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
50 changes: 50 additions & 0 deletions
50
api/src/main/java/ca/bc/gov/educ/eas/api/mappers/v1/AssessmentStudentSessionMapper.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,50 @@ | ||
package ca.bc.gov.educ.eas.api.mappers.v1; | ||
|
||
import ca.bc.gov.educ.eas.api.model.v1.AssessmentEntity; | ||
import ca.bc.gov.educ.eas.api.model.v1.AssessmentStudentEntity; | ||
import ca.bc.gov.educ.eas.api.repository.v1.AssessmentRepository; | ||
import ca.bc.gov.educ.eas.api.struct.v1.AssessmentStudent; | ||
import io.micrometer.common.util.StringUtils; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
@Component | ||
public class AssessmentStudentSessionMapper implements AssessmentStudentMapper { | ||
|
||
private final AssessmentRepository assessmentRepository; | ||
|
||
@Autowired | ||
public AssessmentStudentSessionMapper(AssessmentRepository assessmentRepository) { | ||
this.assessmentRepository = assessmentRepository; | ||
} | ||
|
||
@Override | ||
public AssessmentStudent toStructure(AssessmentStudentEntity entity) { | ||
return mapper.toStructure(entity); | ||
} | ||
|
||
@Override | ||
public AssessmentStudent mapAssessment(AssessmentStudent assessmentStudent) { | ||
Optional<AssessmentEntity> assessmentEntity; | ||
if (StringUtils.isNotEmpty(assessmentStudent.getAssessmentID())) { | ||
assessmentEntity = assessmentRepository.findById(UUID.fromString(assessmentStudent.getAssessmentID())); | ||
} else { | ||
assessmentEntity = assessmentRepository.findBySessionIdAndAssessmentType(UUID.fromString(assessmentStudent.getSessionID()), assessmentStudent.getAssessmentTypeCode()); | ||
} | ||
if (assessmentEntity.isPresent()) { | ||
assessmentStudent.setAssessmentID(assessmentEntity.get().getAssessmentID().toString()); | ||
} else { | ||
assessmentStudent.setAssessmentID(null); | ||
} | ||
return assessmentStudent; | ||
} | ||
|
||
@Override | ||
public AssessmentStudentEntity toModel(AssessmentStudent assessmentStudent) { | ||
return mapper.toModel(assessmentStudent); | ||
} | ||
|
||
} |
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
49 changes: 49 additions & 0 deletions
49
api/src/main/java/ca/bc/gov/educ/eas/api/model/v1/AssessmentEntity.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,49 @@ | ||
package ca.bc.gov.educ.eas.api.model.v1; | ||
|
||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.PastOrPresent; | ||
import lombok.*; | ||
import org.hibernate.annotations.DynamicUpdate; | ||
import org.hibernate.annotations.UuidGenerator; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.UUID; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@DynamicUpdate | ||
@Entity | ||
@Builder | ||
@Table(name = "ASSESSMENT") | ||
public class AssessmentEntity { | ||
|
||
@Id | ||
@GeneratedValue(generator = "UUID") | ||
@UuidGenerator | ||
@Column(name = "ASSESSMENT_ID", unique = true, updatable = false, columnDefinition = "BINARY(16)") | ||
private UUID assessmentID; | ||
|
||
@ToString.Exclude | ||
@EqualsAndHashCode.Exclude | ||
@ManyToOne(optional = false, targetEntity = SessionEntity.class) | ||
@JoinColumn(name = "SESSION_ID", referencedColumnName = "SESSION_ID", updatable = false) | ||
SessionEntity sessionEntity; | ||
|
||
@Column(name = "ASSESSMENT_TYPE_CODE", nullable = false, length = 10) | ||
private String assessmentTypeCode; | ||
|
||
@Column(name = "CREATE_USER", updatable = false, length = 100) | ||
private String createUser; | ||
|
||
@PastOrPresent | ||
@Column(name = "CREATE_DATE", updatable = false) | ||
private LocalDateTime createDate; | ||
|
||
@Column(name = "UPDATE_USER", nullable = false, length = 100) | ||
private String updateUser; | ||
|
||
@PastOrPresent | ||
@Column(name = "UPDATE_DATE", nullable = false) | ||
private LocalDateTime updateDate; | ||
} |
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
Oops, something went wrong.