From f18d663c044d3f26aaef0db447cfd89ec2b99590 Mon Sep 17 00:00:00 2001 From: himeshr Date: Wed, 15 Nov 2023 18:57:11 +0530 Subject: [PATCH] avniproject/avni-client#1172 | Introduce new fields in RuleFailureTelemetry --- .../server/domain/RuleFailureTelemetry.java | 72 +++++++++++++++++-- .../domain/enums/ruleFailure/AppType.java | 5 ++ .../domain/enums/ruleFailure/EntityType.java | 5 ++ .../domain/enums/ruleFailure/SourceType.java | 5 ++ .../web/RuleFailureTelemetryController.java | 7 +- .../request/RuleFailureTelemetryRequest.java | 48 +++++++++++++ ..._320__AddColumnsToRuleFailureTelemetry.sql | 12 ++++ 7 files changed, 148 insertions(+), 6 deletions(-) create mode 100644 avni-server-api/src/main/java/org/avni/server/domain/enums/ruleFailure/AppType.java create mode 100644 avni-server-api/src/main/java/org/avni/server/domain/enums/ruleFailure/EntityType.java create mode 100644 avni-server-api/src/main/java/org/avni/server/domain/enums/ruleFailure/SourceType.java create mode 100644 avni-server-api/src/main/resources/db/migration/V1_320__AddColumnsToRuleFailureTelemetry.sql diff --git a/avni-server-api/src/main/java/org/avni/server/domain/RuleFailureTelemetry.java b/avni-server-api/src/main/java/org/avni/server/domain/RuleFailureTelemetry.java index 96cf537c1..d3662491f 100644 --- a/avni-server-api/src/main/java/org/avni/server/domain/RuleFailureTelemetry.java +++ b/avni-server-api/src/main/java/org/avni/server/domain/RuleFailureTelemetry.java @@ -1,6 +1,9 @@ package org.avni.server.domain; import com.fasterxml.jackson.annotation.JsonIgnore; +import org.avni.server.domain.enums.ruleFailure.AppType; +import org.avni.server.domain.enums.ruleFailure.EntityType; +import org.avni.server.domain.enums.ruleFailure.SourceType; import org.hibernate.annotations.BatchSize; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; @@ -36,6 +39,24 @@ public class RuleFailureTelemetry { @Column private String ruleUuid; + @Column + @Enumerated(EnumType.STRING) + private SourceType sourceType; + + @Column + private String sourceId; + + @Column + @Enumerated(EnumType.STRING) + private EntityType entityType; + + @Column + private String entityId; + + @Column + @Enumerated(EnumType.STRING) + private AppType appType; + @Column private String individualUuid; @@ -46,13 +67,14 @@ public class RuleFailureTelemetry { private String stacktrace; @Column - private DateTime closeDateTime; + private DateTime closedDateTime; @Column private DateTime errorDateTime; @Column private Boolean isClosed; + @Column private Long organisationId; @@ -157,6 +179,46 @@ public void setRuleUuid(String ruleUuid) { this.ruleUuid = ruleUuid; } + public SourceType getSourceType() { + return sourceType; + } + + public void setSourceType(SourceType sourceType) { + this.sourceType = sourceType; + } + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public EntityType getEntityType() { + return entityType; + } + + public void setEntityType(EntityType entityType) { + this.entityType = entityType; + } + + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + public AppType getAppType() { + return appType; + } + + public void setAppType(AppType appType) { + this.appType = appType; + } + public String getIndividualUuid() { return individualUuid; } @@ -181,12 +243,12 @@ public void setStacktrace(String stacktrace) { this.stacktrace = stacktrace; } - public DateTime getCloseDateTime() { - return closeDateTime; + public DateTime getClosedDateTime() { + return closedDateTime; } - public void setCloseDateTime(DateTime closeDateTime) { - this.closeDateTime = closeDateTime; + public void setClosedDateTime(DateTime closedDateTime) { + this.closedDateTime = closedDateTime; } public DateTime getErrorDateTime() { diff --git a/avni-server-api/src/main/java/org/avni/server/domain/enums/ruleFailure/AppType.java b/avni-server-api/src/main/java/org/avni/server/domain/enums/ruleFailure/AppType.java new file mode 100644 index 000000000..37a7fedf6 --- /dev/null +++ b/avni-server-api/src/main/java/org/avni/server/domain/enums/ruleFailure/AppType.java @@ -0,0 +1,5 @@ +package org.avni.server.domain.enums.ruleFailure; + +public enum AppType { + Android, Web +} \ No newline at end of file diff --git a/avni-server-api/src/main/java/org/avni/server/domain/enums/ruleFailure/EntityType.java b/avni-server-api/src/main/java/org/avni/server/domain/enums/ruleFailure/EntityType.java new file mode 100644 index 000000000..c74696d89 --- /dev/null +++ b/avni-server-api/src/main/java/org/avni/server/domain/enums/ruleFailure/EntityType.java @@ -0,0 +1,5 @@ +package org.avni.server.domain.enums.ruleFailure; + +public enum EntityType { + Individual, ProgramEnrolment, ProgramEncounter, Encounter, WorkList, Checklist, ReportCard; +} \ No newline at end of file diff --git a/avni-server-api/src/main/java/org/avni/server/domain/enums/ruleFailure/SourceType.java b/avni-server-api/src/main/java/org/avni/server/domain/enums/ruleFailure/SourceType.java new file mode 100644 index 000000000..2ada039c4 --- /dev/null +++ b/avni-server-api/src/main/java/org/avni/server/domain/enums/ruleFailure/SourceType.java @@ -0,0 +1,5 @@ +package org.avni.server.domain.enums.ruleFailure; + +public enum SourceType { + Decision, VisitSchedule, Validation, EnrolmentSummary, SubjectSummary, WorkListUpdation, ManualEnrolmentEligibilityCheckRule, EnrolmentEligibilityCheck, EncounterEligibilityCheck, Checklist, FormElement, FormElementGroup, OldRule, ReportCard +} \ No newline at end of file diff --git a/avni-server-api/src/main/java/org/avni/server/web/RuleFailureTelemetryController.java b/avni-server-api/src/main/java/org/avni/server/web/RuleFailureTelemetryController.java index 4b3a8b85a..40cb933f5 100644 --- a/avni-server-api/src/main/java/org/avni/server/web/RuleFailureTelemetryController.java +++ b/avni-server-api/src/main/java/org/avni/server/web/RuleFailureTelemetryController.java @@ -60,6 +60,11 @@ public void save(@RequestBody RuleFailureTelemetryRequest request) { ruleFailureTelemetry.setStacktrace(request.getStacktrace()); ruleFailureTelemetry.setRuleUuid(request.getRuleUuid()); ruleFailureTelemetry.setErrorDateTime(request.getErrorDateTime()); + ruleFailureTelemetry.setSourceType(request.getSourceType()); + ruleFailureTelemetry.setSourceId(request.getSourceId()); + ruleFailureTelemetry.setEntityType(request.getEntityType()); + ruleFailureTelemetry.setEntityId(request.getEntityId()); + ruleFailureTelemetry.setAppType(request.getAppType()); ruleFailureTelemetry.setClosed(request.getClosed()); ruleFailureTelemetryRepository.save(ruleFailureTelemetry); } @@ -85,7 +90,7 @@ public ResponseEntity> updateStatus(@RequestParam("id List ruleFailureTelemetries = ruleFailureTelemetryRepository.findAllById(ids); ruleFailureTelemetries.forEach(ruleFailureTelemetry -> { ruleFailureTelemetry.setClosed(isClosed); - ruleFailureTelemetry.setCloseDateTime(isClosed ? DateTime.now() : null); + ruleFailureTelemetry.setClosedDateTime(isClosed ? DateTime.now() : null); }); ruleFailureTelemetryRepository.saveAll(ruleFailureTelemetries); return new ResponseEntity<>(ruleFailureTelemetries, HttpStatus.CREATED); diff --git a/avni-server-api/src/main/java/org/avni/server/web/request/RuleFailureTelemetryRequest.java b/avni-server-api/src/main/java/org/avni/server/web/request/RuleFailureTelemetryRequest.java index 9cf726536..5579bf988 100644 --- a/avni-server-api/src/main/java/org/avni/server/web/request/RuleFailureTelemetryRequest.java +++ b/avni-server-api/src/main/java/org/avni/server/web/request/RuleFailureTelemetryRequest.java @@ -1,5 +1,8 @@ package org.avni.server.web.request; +import org.avni.server.domain.enums.ruleFailure.AppType; +import org.avni.server.domain.enums.ruleFailure.EntityType; +import org.avni.server.domain.enums.ruleFailure.SourceType; import org.joda.time.DateTime; public class RuleFailureTelemetryRequest { @@ -8,6 +11,11 @@ public class RuleFailureTelemetryRequest { private String individualUuid; private String ruleUuid; private String errorMessage; + private SourceType sourceType; + private String sourceId; + private EntityType entityType; + private String entityId; + private AppType appType; private String stacktrace; private DateTime errorDateTime; @@ -68,4 +76,44 @@ public DateTime getErrorDateTime() { public void setErrorDateTime(DateTime errorDateTime) { this.errorDateTime = errorDateTime; } + + public SourceType getSourceType() { + return sourceType; + } + + public void setSourceType(SourceType sourceType) { + this.sourceType = sourceType; + } + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public EntityType getEntityType() { + return entityType; + } + + public void setEntityType(EntityType entityType) { + this.entityType = entityType; + } + + public String getEntityId() { + return entityId; + } + + public void setEntityId(String entityId) { + this.entityId = entityId; + } + + public AppType getAppType() { + return appType; + } + + public void setAppType(AppType appType) { + this.appType = appType; + } } diff --git a/avni-server-api/src/main/resources/db/migration/V1_320__AddColumnsToRuleFailureTelemetry.sql b/avni-server-api/src/main/resources/db/migration/V1_320__AddColumnsToRuleFailureTelemetry.sql new file mode 100644 index 000000000..978c7bf71 --- /dev/null +++ b/avni-server-api/src/main/resources/db/migration/V1_320__AddColumnsToRuleFailureTelemetry.sql @@ -0,0 +1,12 @@ +ALTER TABLE public.rule_failure_telemetry + ADD COLUMN IF NOT EXISTS source_type VARCHAR(255), + ADD COLUMN IF NOT EXISTS source_id VARCHAR(255), + ADD COLUMN IF NOT EXISTS entity_type VARCHAR(255), + ADD COLUMN IF NOT EXISTS entity_id VARCHAR(255), + ADD COLUMN IF NOT EXISTS app_type VARCHAR(255); + +ALTER TABLE public.rule_failure_telemetry + RENAME COLUMN close_date_time TO closed_date_time; + +ALTER TABLE public.rule_failure_telemetry + ALTER COLUMN rule_uuid DROP NOT NULL;