Skip to content

Commit

Permalink
Warn if Morphia domain is not mapped / ack'd by GORM
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael J Salera committed Jun 27, 2014
1 parent 3998300 commit aab62c4
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class BusinessAuditLogService {
* where their static auditable = true
*
* This method sends an instance of AuditLogEvent to MongoDB
* assumes Morphia classes are mapped
*
* @param eventType
* @param className this.class.simpleName
Expand All @@ -47,15 +48,17 @@ class BusinessAuditLogService {
* @return true on success
*/
def recordLogEvent(String eventType, String className, persistedObjectId, oldeState, newState) {
//magic of the dataStore
def auditEvent = new AuditLogEvent(eventName: eventType, className: className, objectId: persistedObjectId as String)
if (oldeState) { auditEvent.oldState = oldeState }
if (newState) { auditEvent.newState = newState }

println( auditEvent.toString() )
println( "${eventType} for class ${className} Id -> ${persistedObjectId}" )

if (auditEvent.validate()) { return auditEvent.save(flush: true) }
false
if (auditEvent?.validate()) {
println( "${eventType} for class ${className} [Id] -> ${persistedObjectId}" )
return auditEvent.save(flush: true)
}
else {
false
}
}
}

0 comments on commit aab62c4

Please sign in to comment.