Class GenerateEmailWithAttachmentAction
- java.lang.Object
-
- de.hybris.platform.processengine.action.AbstractAction<T>
-
- de.hybris.platform.processengine.action.AbstractSimpleDecisionAction
-
- de.hybris.platform.yacceleratorordermanagement.actions.email.GenerateEmailWithAttachmentAction
-
- All Implemented Interfaces:
Action
public class GenerateEmailWithAttachmentAction extends AbstractSimpleDecisionAction
A process action which generates email with attachment.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.processengine.action.AbstractSimpleDecisionAction
AbstractSimpleDecisionAction.Transition
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.processengine.action.AbstractAction
modelService, processParameterHelper
-
Fields inherited from interface de.hybris.platform.processengine.spring.Action
ERROR_RETURN_CODE, RETRY_RETURN_CODE
-
-
Constructor Summary
Constructors Constructor Description GenerateEmailWithAttachmentAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected EmailAttachmentModelcastMedialModelToEmailAttachmentModel(MediaModel mediaModel, java.lang.String attachmentName)CreatesEmailAttachmentModelwith proper name andMediaModelprotected EmailAttachmentModelcreateReturnMediaAttachment(BusinessProcessModel businessProcessModel, java.lang.String propertyName)CreatesEmailAttachmentModel.AbstractSimpleDecisionAction.TransitionexecuteAction(BusinessProcessModel businessProcessModel)Executes thisAction's business logic working on the givenBusinessProcessModel.protected booleangenerateEmail(BusinessProcessModel businessProcessModel, EmailMessageModel emailMessageModel)Generates the email or sends warning to the consoleprotected AbstractSimpleDecisionAction.TransitiongenerateEmailContent(BusinessProcessModel businessProcessModel, CatalogVersionModel contentCatalogVersion)Checks whether or not the email content is to be generatedprotected CMSEmailPageServicegetCmsEmailPageService()protected ProcessContextResolutionStrategygetContextResolutionStrategy()protected java.lang.StringgetEmailAttachmentName(java.lang.String propertyName)Gets proper attachment name depending on givenReturnRequestModelstatic field.protected EmailGenerationServicegetEmailGenerationService()protected EmailServicegetEmailService()protected java.lang.StringgetFrontendTemplateName()protected KeyGeneratorgetGuidKeyGenerator()protected MediaServicegetMediaService()protected MediaModelgetOrCreateMediaModelForProcessModel(ReturnProcessModel returnProcessModel, java.lang.String propertyName)RetrievesMediaModelfromReturnRequestModel.RETURNFORMorReturnRequestModel.RETURNLABELfor the givenReturnProcessModel
Or generates one if property is empty.protected PrintMediaServicegetPrintMediaService()protected java.lang.StringgetProperDocumentTemplateName(java.lang.String documentTemplateName)Gets proper document template name depends on given parameter.protected java.lang.StringgetReturnFormAttachmentName()protected java.lang.StringgetReturnFormDocumentTemplateName()protected java.lang.StringgetReturnLabelAttachmentName()protected java.lang.StringgetReturnLabelDocumentTemplateName()protected voidsaveReturnLabelAndReturnFormAttachments(EmailAttachmentModel returnLabelAttachmentModel, EmailAttachmentModel returnFormAttachmentModel, EmailMessageModel emailMessageModel, BusinessProcessModel businessProcessModel)Saves for givenBusinessProcessModel.voidsetCmsEmailPageService(CMSEmailPageService cmsEmailPageService)voidsetContextResolutionStrategy(ProcessContextResolutionStrategy contextResolutionStrategy)voidsetEmailGenerationService(EmailGenerationService emailGenerationService)voidsetEmailService(EmailService emailService)voidsetFrontendTemplateName(java.lang.String frontendTemplateName)voidsetGuidKeyGenerator(KeyGenerator guidKeyGenerator)voidsetMediaService(MediaService mediaService)voidsetPrintMediaService(PrintMediaService printMediaService)voidsetReturnFormAttachmentName(java.lang.String returnFormAttachmentName)voidsetReturnFormDocumentTemplateName(java.lang.String returnFormDocumentTemplateName)voidsetReturnLabelAttachmentName(java.lang.String returnLabelAttachmentName)voidsetReturnLabelDocumentTemplateName(java.lang.String returnLabelDocumentTemplateName)protected voidvalidatePropertyName(java.lang.String propertyName)Validates if passed parameter is either returnLabel or returnForm property.-
Methods inherited from class de.hybris.platform.processengine.action.AbstractSimpleDecisionAction
execute, getTransitions
-
Methods inherited from class de.hybris.platform.processengine.action.AbstractAction
createTransitions, getModelService, getProcessParameterHelper, getProcessParameterValue, refresh, save, setModelService, setOrderStatus, setProcessParameterHelper
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.processengine.spring.Action
getCurrentActionDefinitionContext
-
-
-
-
Method Detail
-
executeAction
public AbstractSimpleDecisionAction.Transition executeAction(BusinessProcessModel businessProcessModel) throws RetryLaterException
Description copied from class:AbstractSimpleDecisionActionExecutes thisAction's business logic working on the givenBusinessProcessModel.- Specified by:
executeActionin classAbstractSimpleDecisionAction- Parameters:
businessProcessModel- The process context to work on.- Returns:
- OK; NOK
- Throws:
RetryLaterException
-
generateEmailContent
protected AbstractSimpleDecisionAction.Transition generateEmailContent(BusinessProcessModel businessProcessModel, CatalogVersionModel contentCatalogVersion)
Checks whether or not the email content is to be generated- Parameters:
businessProcessModel- theBusinessProcessModelfor which to check if an email has to be generatedcontentCatalogVersion- theCatalogVersionModelfor which to check if an email has to be generated- Returns:
- transition for the business process action
-
generateEmail
protected boolean generateEmail(BusinessProcessModel businessProcessModel, EmailMessageModel emailMessageModel)
Generates the email or sends warning to the console- Parameters:
businessProcessModel- theBusinessProcessModelto interact withemailMessageModel- theEmailMessageModelto be generated- Returns:
- true if the email has been generated. False otherwise.
-
createReturnMediaAttachment
protected EmailAttachmentModel createReturnMediaAttachment(BusinessProcessModel businessProcessModel, java.lang.String propertyName)
CreatesEmailAttachmentModel.- Parameters:
businessProcessModel-BusinessProcessModel, for which attachment will be created and savedpropertyName- property ofReturnRequestModel, for whichMediaModelneeds to be found- Returns:
EmailAttachmentModelwith with proper media saved
-
saveReturnLabelAndReturnFormAttachments
protected void saveReturnLabelAndReturnFormAttachments(EmailAttachmentModel returnLabelAttachmentModel, EmailAttachmentModel returnFormAttachmentModel, EmailMessageModel emailMessageModel, BusinessProcessModel businessProcessModel)
Saves for givenBusinessProcessModel.- Parameters:
returnLabelAttachmentModel- generated asReturnRequestModel.RETURNLABEL, with proper media filereturnFormAttachmentModel- generated asReturnRequestModel.RETURNFORMwith proper media fileemailMessageModel-EmailMessageModelwhich will be used to send email to userbusinessProcessModel-BusinessProcessModelfor which attachments should be saved
-
getOrCreateMediaModelForProcessModel
protected MediaModel getOrCreateMediaModelForProcessModel(ReturnProcessModel returnProcessModel, java.lang.String propertyName)
RetrievesMediaModelfromReturnRequestModel.RETURNFORMorReturnRequestModel.RETURNLABELfor the givenReturnProcessModel
Or generates one if property is empty.- Parameters:
returnProcessModel-ReturnProcessModelpropertyName- Describes whichMediaModelshould be found. Must be eitherReturnRequestModel.RETURNFORMorReturnRequestModel.RETURNLABEL- Returns:
MediaModelproperty if exists, generate one otherwise
-
getProperDocumentTemplateName
protected java.lang.String getProperDocumentTemplateName(java.lang.String documentTemplateName)
Gets proper document template name depends on given parameter.- Parameters:
documentTemplateName- should be returnLabel or returnForm - static fields ofReturnRequestModelclass- Returns:
- returnLabelDocumentTemplateName or returnFormDocumentTemplateName field of
GenerateEmailWithAttachmentActionclass
-
validatePropertyName
protected void validatePropertyName(java.lang.String propertyName)
Validates if passed parameter is either returnLabel or returnForm property.- Parameters:
propertyName- should be returnLabel or returnForm - static field ofReturnRequestModelclass
-
castMedialModelToEmailAttachmentModel
protected EmailAttachmentModel castMedialModelToEmailAttachmentModel(MediaModel mediaModel, java.lang.String attachmentName)
CreatesEmailAttachmentModelwith proper name andMediaModel- Parameters:
mediaModel-MediaModelwhich will be attachedattachmentName- the name for the attachedMediaModel- Returns:
- created
EmailAttachmentModelwith proper media file and name
-
getEmailAttachmentName
protected java.lang.String getEmailAttachmentName(java.lang.String propertyName)
Gets proper attachment name depending on givenReturnRequestModelstatic field.- Parameters:
propertyName- should be one ofReturnRequestModelstatic field - returnLabel or returnForm- Returns:
- proper name for attachment
-
getCmsEmailPageService
protected CMSEmailPageService getCmsEmailPageService()
-
setCmsEmailPageService
public void setCmsEmailPageService(CMSEmailPageService cmsEmailPageService)
-
getFrontendTemplateName
protected java.lang.String getFrontendTemplateName()
-
setFrontendTemplateName
public void setFrontendTemplateName(java.lang.String frontendTemplateName)
-
getContextResolutionStrategy
protected ProcessContextResolutionStrategy getContextResolutionStrategy()
-
setContextResolutionStrategy
public void setContextResolutionStrategy(ProcessContextResolutionStrategy contextResolutionStrategy)
-
getEmailGenerationService
protected EmailGenerationService getEmailGenerationService()
-
setEmailGenerationService
public void setEmailGenerationService(EmailGenerationService emailGenerationService)
-
getEmailService
protected EmailService getEmailService()
-
setEmailService
public void setEmailService(EmailService emailService)
-
getPrintMediaService
protected PrintMediaService getPrintMediaService()
-
setPrintMediaService
public void setPrintMediaService(PrintMediaService printMediaService)
-
getMediaService
protected MediaService getMediaService()
-
setMediaService
public void setMediaService(MediaService mediaService)
-
getReturnLabelDocumentTemplateName
protected java.lang.String getReturnLabelDocumentTemplateName()
-
setReturnLabelDocumentTemplateName
public void setReturnLabelDocumentTemplateName(java.lang.String returnLabelDocumentTemplateName)
-
getReturnFormDocumentTemplateName
protected java.lang.String getReturnFormDocumentTemplateName()
-
setReturnFormDocumentTemplateName
public void setReturnFormDocumentTemplateName(java.lang.String returnFormDocumentTemplateName)
-
getGuidKeyGenerator
protected KeyGenerator getGuidKeyGenerator()
-
setGuidKeyGenerator
public void setGuidKeyGenerator(KeyGenerator guidKeyGenerator)
-
getReturnFormAttachmentName
protected java.lang.String getReturnFormAttachmentName()
-
setReturnFormAttachmentName
public void setReturnFormAttachmentName(java.lang.String returnFormAttachmentName)
-
getReturnLabelAttachmentName
protected java.lang.String getReturnLabelAttachmentName()
-
setReturnLabelAttachmentName
public void setReturnLabelAttachmentName(java.lang.String returnLabelAttachmentName)
-
-