Skip to content

Commit 3ad3dab

Browse files
committed
#251 (fix) Transactional issues and local mysql username
1 parent 358caec commit 3ad3dab

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

grails-app/conf/application.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ environments:
312312
dbCreate: update
313313
driverClassName: com.mysql.jdbc.Driver
314314
url: jdbc:mysql://localhost/alerts
315-
username: root
315+
username: alerts_user
316316
password: password
317317
test:
318318
dataSource:

grails-app/services/au/org/ala/alerts/DiffService.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class DiffService {
135135
String previous = "{}"
136136
// If previous result is null, assign an empty Json object
137137
if ( queryResult.previousResult != null) {
138-
revious = decompressZipped(queryResult.previousResult)
138+
previous = decompressZipped(queryResult.previousResult)
139139
}
140140

141141
try {

grails-app/services/au/org/ala/alerts/NotificationService.groovy

+20-13
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ class NotificationService {
813813
}
814814
}
815815

816-
@Transactional
816+
817817
def addAlertForUser(User user, Long queryId) {
818818
log.debug('add my alert : ' + queryId + ' for user : ' + user)
819819
def notificationInstance = new Notification()
@@ -823,25 +823,28 @@ class NotificationService {
823823
def exists = Notification.findByQueryAndUser(notificationInstance.query, notificationInstance.user)
824824
if (!exists) {
825825
log.info("Adding alert for user: " + notificationInstance.user + ", query id: " + queryId)
826-
if (!notificationInstance.save(validate: true, flush: true)) {
827-
notificationInstance.errors.allErrors.each {
828-
log.error(it)
826+
Notification.withTransaction {
827+
if (!notificationInstance.save(validate: true, flush: true)) {
828+
notificationInstance.errors.allErrors.each {
829+
log.error(it)
830+
}
829831
}
830832
}
831833
} else {
832834
log.info("NOT Adding alert for user: " + notificationInstance.user + ", query id: " + queryId + ", already exists...")
833835
}
834836
}
835837

836-
@Transactional
837-
def deleteAlertForUser(User user, Long queryId) {
838+
def deleteAlertForUser(User user, Long queryId) {
838839
log.debug('Deleting my alert : ' + queryId + ' for user : ' + user)
839840
def query = Query.findById(queryId)
840841

841842
def notificationInstance = Notification.findByUserAndQuery(user, query)
842843
if (notificationInstance) {
843844
log.debug('Deleting my notification : ' + queryId)
844-
notificationInstance.each { it.delete(flush: true) }
845+
Notification.withTransaction {
846+
notificationInstance.each { it.delete(flush: true) }
847+
}
845848
} else {
846849
log.error('*** Unable to find my notification - no delete : ' + queryId)
847850
}
@@ -906,17 +909,21 @@ class NotificationService {
906909
QueryResult qr = QueryResult.findByQueryAndFrequency(query, oldFrequency)
907910
if (qr) {
908911
qr.frequency = user.frequency
909-
if (!qr.save(validate: true, flush: true)) {
910-
qr.errors.allErrors.each {
911-
log.error(it)
912+
QueryResult.withTransaction {
913+
if (!qr.save(validate: true, flush: true)) {
914+
qr.errors.allErrors.each {
915+
log.error(it)
916+
}
912917
}
913918
}
914919
}
915920
}
916921

917-
if (!user.save(validate: true, flush: true)) {
918-
user.errors.allErrors.each {
919-
log.error(it)
922+
User.withTransaction {
923+
if (!user.save(validate: true, flush: true)) {
924+
user.errors.allErrors.each {
925+
log.error(it)
926+
}
920927
}
921928
}
922929
}

grails-app/views/admin/biosecurity.gsp

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
77
<meta name="layout" content="${grailsApplication.config.skin.layout}"/>
88
<meta name="breadcrumb" content="BioSecurity alerts"/>
9-
<meta name="breadcrumbParent" content="${request.contextPath}/admin,Alerts admin"/>
9+
<meta name="breadcrumbParent" content="${request.contextPath}/admin, Admin"/>
1010

1111
<title>Admin - Manage BioSecurity alerts</title>
1212
<asset:stylesheet href="alerts.css"/>

0 commit comments

Comments
 (0)