-
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.
story(ccls-2289) cleardown opa assessment log
- Loading branch information
1 parent
cb01b4a
commit 2d1b8da
Showing
8 changed files
with
412 additions
and
8 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
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
51 changes: 51 additions & 0 deletions
51
...-service/src/main/java/uk/gov/laa/ccms/caab/assessment/constants/OpaAssessmentLogMap.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,51 @@ | ||
package uk.gov.laa.ccms.caab.assessment.constants; | ||
|
||
import java.util.Arrays; | ||
import lombok.Getter; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
/** | ||
* Enum representing the mapping between session assessment types and log assessment types. | ||
*/ | ||
@Getter | ||
@Slf4j | ||
public enum OpaAssessmentLogMap { | ||
MEANS("meansAssessment", "MEANS"), | ||
MEANS_PREPOP("meansAssessment_PREPOP", "MEANS"), | ||
MERITS("meritsAssessment", "MERITS"), | ||
MERITS_PREPOP("meritsAssessment_PREPOP", "MERITS"), | ||
BILLING("billingAssessment", "BILL"), | ||
BILLING_PREPOP("billingAssessment_PREPOP", "BILL"), | ||
POA("poaAssessment", "POA"), | ||
POA_PREPOP("poaAssessment_PREPOP", "POA"); | ||
|
||
|
||
private final String sessionAssessmentType; | ||
private final String logAssessmentType; | ||
|
||
OpaAssessmentLogMap(final String sessionAssessmentType, final String logAssessmentType) { | ||
this.sessionAssessmentType = sessionAssessmentType; | ||
this.logAssessmentType = logAssessmentType; | ||
} | ||
|
||
/** | ||
* Finds the log assessment type based on the session assessment type. | ||
* | ||
* @param sessionAssessmentType the session assessment type | ||
* @return the corresponding log assessment type, or null if not found | ||
*/ | ||
public static String findLogAssessmentTypeBySessionAssessmentType( | ||
final String sessionAssessmentType) { | ||
return Arrays.stream(OpaAssessmentLogMap.values()) | ||
.filter(assessmentLogMap -> assessmentLogMap.getSessionAssessmentType() | ||
.equalsIgnoreCase(sessionAssessmentType)) | ||
.map(OpaAssessmentLogMap::getLogAssessmentType) | ||
.findFirst() | ||
.orElseGet(() -> { | ||
log.warn("Invalid session assessment type: {}", sessionAssessmentType); | ||
return null; | ||
}); | ||
} | ||
|
||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...ssment-service/src/main/java/uk/gov/laa/ccms/caab/assessment/entity/OpaAssessmentLog.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 uk.gov.laa.ccms.caab.assessment.entity; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Lob; | ||
import jakarta.persistence.Table; | ||
import java.time.LocalDateTime; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
/** | ||
* Represents the OPA Assessment Log. | ||
*/ | ||
@Entity | ||
@Table(name = "XXCCMS_OPA_ASSESSMENT_LOG") | ||
@Getter | ||
@Setter | ||
public class OpaAssessmentLog { | ||
|
||
@Id | ||
@Column(name = "ID") | ||
private Long id; | ||
|
||
@Column(name = "TARGET_ID") | ||
private String targetId; | ||
|
||
@Column(name = "ASSESSMENT") | ||
private String assessment; | ||
|
||
@Column(name = "OWNER_ID") | ||
private String ownerId; | ||
|
||
@Column(name = "ACTION") | ||
private String action; | ||
|
||
@Column(name = "TTL") | ||
private String ttl; | ||
|
||
@Column(name = "CREATED") | ||
private LocalDateTime created; | ||
|
||
@Column(name = "CREATED_BY") | ||
private String createdBy; | ||
|
||
} | ||
|
27 changes: 27 additions & 0 deletions
27
.../src/main/java/uk/gov/laa/ccms/caab/assessment/repository/OpaAssessmentLogRepository.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,27 @@ | ||
package uk.gov.laa.ccms.caab.assessment.repository; | ||
|
||
import java.util.List; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
import org.springframework.stereotype.Repository; | ||
import uk.gov.laa.ccms.caab.assessment.entity.OpaAssessmentLog; | ||
import uk.gov.laa.ccms.caab.assessment.entity.OpaSession; | ||
|
||
/** | ||
* Repository interface for managing {@link uk.gov.laa.ccms.caab.assessment.entity.OpaAssessmentLog} | ||
* entities. | ||
* | ||
*/ | ||
@Repository | ||
public interface OpaAssessmentLogRepository extends JpaRepository<OpaAssessmentLog, Long> { | ||
|
||
/** | ||
* Finds a list of OpaAssessmentLog by the targetId and assessment. | ||
* | ||
* @param targetId the ID of the target | ||
* @param assessment the type of assessment | ||
* @return a list of OpaAssessmentLog matching the targetId and assessment | ||
*/ | ||
List<OpaAssessmentLog> findByTargetIdAndAssessment(String targetId, String assessment); | ||
|
||
} |
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.