Created
October 24, 2012 15:27
-
-
Save iggymacd/3946743 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.beans.BeanUtils; | |
import com.datacert.core.notifications.model.impl.EmailTemplate; | |
println entity.medLcrVersion.code | |
if(!"Initial - Draft".equalsIgnoreCase(entity.medLcrVersion.code) && !entityService.isNewInstance(entity)) { | |
println 'about to send email...' | |
def parent = queryService.query("Matter",queryService.and().add(queryService.property("medLcr.id").eq(entity.id))).first(); | |
def customTemplateEngine = applicationContext.getBean("customTemplateEngine"); | |
def configService = applicationContext.getBean("configurationService"); | |
def emailService = applicationContext.getBean("emailService"); | |
//def currentRequestProperties = applicationContext.getBean("currentRequestProperties"); | |
//def currentUser = currentRequestProperties.get("currentUser") | |
// retrieve email template | |
def origEmailMessage = queryService.query("EmailTemplate",queryService.and().add(queryService.property("name").eq("Med LCR Notification Report"))).first(); | |
def person = queryService.query("Person",queryService.and().add(queryService.property("user.ldapUser.username").eq(entity.updatedBy))).first(); | |
def emailMessage = new EmailTemplate(); | |
BeanUtils.copyProperties(origEmailMessage, emailMessage, ["id"] as String[]); | |
customTemplateEngine.evaluate(emailMessage, entity); | |
customTemplateEngine.evaluate(emailMessage, parent); | |
// retrieve "From address" | |
//def fromAddress = configService.getProperties().ClientAdministratorEmailAddress; | |
def fromAddress = "[email protected]" | |
emailMessage.setFromAddress(fromAddress); | |
def toEmailAddress = "[email protected]" | |
//person.emailAddress; | |
emailMessage.setToAddress(toEmailAddress); | |
println 'about to send email...' | |
// send email | |
if (!emailService.sendMail(emailMessage)) { | |
System.out.println("Error while sending Matter LCR Notification Report !!!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment