Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7,327 changes: 3,907 additions & 3,420 deletions client/wfnews-war/src/main/angular/package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions client/wfnews-war/src/main/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"esri-leaflet": "3.0.12",
"esri-leaflet-vector": "4.2.3",
"exifreader": "4.19.1",
"fnv-plus": "1.3.1",
"karma-viewport": "1.0.9",
"leaflet": "1.3.3",
"lightgallery": "2.7.0",
Expand Down Expand Up @@ -149,6 +150,7 @@
"@storybook/angular": "~8.0.9",
"@storybook/blocks": "~8.0.9",
"@storybook/test": "~8.0.9",
"@types/fnv-plus": "1.3.1",
"@types/jasmine": "3.6.0",
"@types/jasminewd2": "2.0.2",
"@types/jest": "28.1.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,9 @@
<mat-icon *ngIf="!submitting" svgIcon="send"></mat-icon>
<mat-spinner *ngIf="submitting" [diameter]="20" [color]="'accent'"></mat-spinner>
</button>
<div *ngIf="submitting" class="submitting-text">
This may take a few moments.<br>
Please stay on this screen.
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@

.submit-button-row {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
align-items: center;
padding: 12vh 0;
.action-button {
border-radius: 6px;
Expand Down Expand Up @@ -84,6 +85,13 @@
position: relative;
top: -2px;
}

.submitting-text {
margin-top: 16px;
text-align: center;
font-size: 14px;
color: #313132;
}
}

.map-container {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
ReportOfFireType,
} from '@app/services/report-of-fire-service';
import { SmkApi } from '@app/utils/smk';
import * as fnv from 'fnv-plus';
import * as L from 'leaflet';
import { LatLng } from 'leaflet';
import { v5 as uuidv5 } from 'uuid';
import offlineMapJson from '../../../../assets/maps/british-columbia.json';
import { equalsIgnoreCase } from '../../../utils';
import ConfigJson from '../report-of-fire.config.json';
Expand Down Expand Up @@ -387,16 +387,6 @@ export class RoFReviewPage extends RoFPage implements AfterViewInit {
this.submitting = true;

try {
await this.commonUtilityService.checkOnline().then(async (result) => {
if (!result) {
await this.useMyCurrentLocation();
this.reportOfFire.fireLocation = [
this.currentLocation.coords.latitude,
this.currentLocation.coords.longitude,
];
}
});

const rofResource: ReportOfFireType = {
fullName: this.nullEmptyStrings(this.reportOfFire.fullName),
phoneNumber: this.nullEmptyStrings(this.reportOfFire.phoneNumber),
Expand All @@ -417,22 +407,30 @@ export class RoFReviewPage extends RoFPage implements AfterViewInit {
visibleFlame: new Array<string>(this.reportOfFire.visibleFlame)
};

// seed string to create submission UUID
// use the resource object as the checksum seed to create a unique ID based on content
let seedString = JSON.stringify(rofResource);
// use a modified resource object as the checksum seed to create a unique ID based on content
// Round fireLocation coordinates to 4 decimals (approx 11m accuracy) so minor GPS drifts don't break deduplication
const seedResource = { ...rofResource };
if (seedResource.fireLocation && seedResource.fireLocation.length === 2) {
seedResource.fireLocation = [
Number(seedResource.fireLocation[0].toFixed(4)),
Number(seedResource.fireLocation[1].toFixed(4))
];
}

let seedString = JSON.stringify(seedResource);

if (this.reportOfFire.image1) {
seedString += (this.reportOfFire.image1.webPath || this.reportOfFire.image1.path || (this.reportOfFire.image1 as any).dataUrl);
if (this.reportOfFire.image1 && this.reportOfFire.image1.path) {
seedString += this.reportOfFire.image1.path;
}
if (this.reportOfFire.image2) {
seedString += (this.reportOfFire.image2.webPath || this.reportOfFire.image2.path || (this.reportOfFire.image2 as any).dataUrl);
if (this.reportOfFire.image2 && this.reportOfFire.image2.path) {
seedString += this.reportOfFire.image2.path;
}
if (this.reportOfFire.image3) {
seedString += (this.reportOfFire.image3.webPath || this.reportOfFire.image3.path || (this.reportOfFire.image3 as any).dataUrl);
if (this.reportOfFire.image3 && this.reportOfFire.image3.path) {
seedString += this.reportOfFire.image3.path;
}

// uuid library requires custom namespace GUID e.g. 7f7c68e7-8eab-4281-9c1f-4fe3d3e56e62
const uniqueID = uuidv5(seedString, "7f7c68e7-8eab-4281-9c1f-4fe3d3e56e62");
// Generate a fast 64-bit FNV-1a hash to use as the submissionID
const uniqueID = fnv.hash(seedString, 64).hex();

rofResource.submissionID = uniqueID;
rofResource.submittedTimestamp = new Date().getTime().toString();
Expand Down
15 changes: 15 additions & 0 deletions database/main-changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,21 @@
}
]
}
},
{
"changeSet": {
"id": "01_01_00_00",
"author": "sparmar",
"changes": [
{
"sqlFile": {
"dbms": "postgresql",
"endDelimiter": ";",
"path": "scripts/01_01_00/00/ddl/wfone.ddl.add_submission_id_to_rof_cache.sql"
}
}
]
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE "public"."report_of_fire_cache"
ADD COLUMN "submission_id" TEXT UNIQUE;
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public interface RoFFormDao {

RoFFormDto fetch(String guid) throws DaoException;

RoFFormDto fetchBySubmissionId(String submissionId) throws DaoException;

int delete(RoFFormDto dto) throws DaoException;

List<RoFFormDto> selectOldForms() throws DaoException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,23 @@ public RoFFormDto fetch(String guid) throws DaoException {
return dto;
}

@Override
public RoFFormDto fetchBySubmissionId(String submissionId) throws DaoException {
logger.debug("<fetchBySubmissionId");
RoFFormDto dto = null;

try {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("submissionId", submissionId);
dto = this.mapper.fetchBySubmissionId(parameters);
} catch (RuntimeException e) {
handleException(e);
}

logger.debug(">fetchBySubmissionId");
return dto;
}

@Override
public List<RoFFormDto> duplicateSelect() throws DaoException {
logger.debug("duplicateSelect >>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public interface RoFFormMapper {

RoFFormDto fetch(Map<String, Object> parameters);

RoFFormDto fetchBySubmissionId(Map<String, Object> parameters);

int delete(Map<String, Object> parameters);

int update(Map<String, Object> parameters);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,97 +1,107 @@
package ca.bc.gov.nrs.wfone.persistence.v1.dto;

import java.time.LocalDateTime;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ca.bc.gov.nrs.wfone.common.persistence.dto.BaseDto;
import ca.bc.gov.nrs.wfone.common.persistence.utils.DtoUtils;

import java.time.LocalDateTime;

public class RoFFormDto extends BaseDto<RoFFormDto> {

private static final long serialVersionUID = 8046437433239434771L;
private static final Logger logger = LoggerFactory.getLogger(RoFImageDto.class);

private String reportOfFireCacheGuid;
private String reportOfFire;
private LocalDateTime submittedTimestamp;

public RoFFormDto() {

}

public RoFFormDto(RoFFormDto dto) {
this.reportOfFireCacheGuid = dto.reportOfFireCacheGuid;
this.reportOfFire = dto.reportOfFire;
this.submittedTimestamp = dto.submittedTimestamp;

private static final long serialVersionUID = 8046437433239434771L;
private static final Logger logger = LoggerFactory.getLogger(RoFImageDto.class);

private String reportOfFireCacheGuid;
private String reportOfFire;
private LocalDateTime submittedTimestamp;
private String submissionId;

public RoFFormDto() {

}

public String getReportOfFireCacheGuid() {
return this.reportOfFireCacheGuid;
}
public RoFFormDto(RoFFormDto dto) {
this.reportOfFireCacheGuid = dto.reportOfFireCacheGuid;
this.reportOfFire = dto.reportOfFire;
this.submittedTimestamp = dto.submittedTimestamp;
this.submissionId = dto.submissionId;
}

public void setReportOfFireCacheGuid(String reportOfFireCacheGuid) {
this.reportOfFireCacheGuid = reportOfFireCacheGuid;
}
public String getReportOfFireCacheGuid() {
return this.reportOfFireCacheGuid;
}

public String getReportOfFire() {
return this.reportOfFire;
}
public void setReportOfFireCacheGuid(String reportOfFireCacheGuid) {
this.reportOfFireCacheGuid = reportOfFireCacheGuid;
}

public String getReportOfFire() {
return this.reportOfFire;
}

public LocalDateTime getSubmittedTimestamp() {
return this.submittedTimestamp;
}
public LocalDateTime getSubmittedTimestamp() {
return this.submittedTimestamp;
}

public void setSubmittedTimestamp(LocalDateTime submittedTimestamp) {
this.submittedTimestamp = submittedTimestamp;
}
public void setSubmittedTimestamp(LocalDateTime submittedTimestamp) {
this.submittedTimestamp = submittedTimestamp;
}

public void setReportOfFire(String reportOfFire) {
this.reportOfFire = reportOfFire;
}

@Override
public RoFFormDto copy() {
return new RoFFormDto(this);
}

@Override
public Logger getLogger() {
return logger;
}


public String getSubmissionId() {
return this.submissionId;
}

public void setSubmissionId(String submissionId) {
this.submissionId = submissionId;
}

@Override
public boolean equalsBK(RoFFormDto other) {
boolean result = false;

if(other!=null) {

result = true;
DtoUtils dtoUtils = new DtoUtils(getLogger());
result = result&&dtoUtils.equals("reportOfFireCacheGuid", reportOfFireCacheGuid, other.reportOfFireCacheGuid);
public RoFFormDto copy() {
return new RoFFormDto(this);
}

@Override
public Logger getLogger() {
return logger;
}

return result;

@Override
public boolean equalsBK(RoFFormDto other) {
boolean result = false;

if (other != null) {

result = true;
DtoUtils dtoUtils = new DtoUtils(getLogger());
result = result && dtoUtils.equals("reportOfFireCacheGuid", reportOfFireCacheGuid, other.reportOfFireCacheGuid);

}

return result;

}

@Override
public boolean equalsAll(RoFFormDto other) {
boolean result = false;

if(other!=null) {

result = true;
DtoUtils dtoUtils = new DtoUtils(getLogger());
result = result&&dtoUtils.equals("reportOfFireCacheGuid", reportOfFireCacheGuid, other.reportOfFireCacheGuid);
result = result&&dtoUtils.equals("reportOfFire", reportOfFire, other.reportOfFire);
result = result&&dtoUtils.equals("submittedTimestamp", submittedTimestamp, other.submittedTimestamp);

}

boolean result = false;

if (other != null) {

result = true;
DtoUtils dtoUtils = new DtoUtils(getLogger());
result = result && dtoUtils.equals("reportOfFireCacheGuid", reportOfFireCacheGuid, other.reportOfFireCacheGuid);
result = result && dtoUtils.equals("reportOfFire", reportOfFire, other.reportOfFire);
result = result && dtoUtils.equals("submittedTimestamp", submittedTimestamp, other.submittedTimestamp);
result = result && dtoUtils.equals("submissionId", submissionId, other.submissionId);

}

return result;
}
}
}
}
Loading
Loading