Skip to content

Commit 401ac4c

Browse files
committed
Added check for deleted protocols #823
1 parent c33d603 commit 401ac4c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

grails-app/services/au/org/ala/ecodata/ParatooService.groovy

+14
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,11 @@ class ParatooService {
276276
private Map syncParatooProtocols(List<Map> protocols) {
277277

278278
Map result = [errors:[], messages:[]]
279+
List guids = []
279280
protocols.each { Map protocol ->
280281
String id = protocol.id
281282
String guid = protocol.attributes.identifier
283+
guids << guid
282284
String name = protocol.attributes.name
283285
ActivityForm form = ActivityForm.findByExternalId(guid)
284286
if (!form) {
@@ -318,6 +320,18 @@ class ParatooService {
318320
log.warn "Error saving form with id: "+id+", name: "+name
319321
}
320322
}
323+
324+
List allProtocolForms = ActivityForm.findAll {
325+
externalIds {
326+
idType == ExternalId.IdType.MONITOR_PROTOCOL_GUID
327+
}
328+
status != Status.DELETED
329+
}
330+
331+
List deletions = allProtocolForms.findAll{it.externalIds.find{it.idType == ExternalId.IdType.MONITOR_PROTOCOL_GUID && !(it.externalId in guids)}}
332+
deletions.each { ActivityForm activityForm ->
333+
result.messages << "Form ${activityForm.name} with guid: ${activityForm.externalIds.find{it.idType == ExternalId.IdType.MONITOR_PROTOCOL_GUID}.externalId} has been deleted"
334+
}
321335
result
322336

323337
}

0 commit comments

Comments
 (0)