Search in sources :

Example 1 with MADBoilerPlate

use of de.metas.letters.model.MADBoilerPlate in project metasfresh-webui-api by metasfresh.

the class LetterRestController method applyTemplate.

private void applyTemplate(final WebuiLetter letter, final WebuiLetterBuilder newLetterBuilder, final LookupValue templateLookupValue) {
    final Properties ctx = Env.getCtx();
    final int textTemplateId = templateLookupValue.getIdAsInt();
    final MADBoilerPlate boilerPlate = MADBoilerPlate.get(ctx, textTemplateId);
    // 
    // Attributes
    final BoilerPlateContext context = documentCollection.createBoilerPlateContext(letter.getContextDocumentPath());
    // 
    // Content and subject
    newLetterBuilder.textTemplateId(textTemplateId);
    newLetterBuilder.content(boilerPlate.getTextSnippetParsed(context));
    newLetterBuilder.subject(boilerPlate.getSubject());
}
Also used : MADBoilerPlate(de.metas.letters.model.MADBoilerPlate) BoilerPlateContext(de.metas.letters.model.MADBoilerPlate.BoilerPlateContext) Properties(java.util.Properties)

Example 2 with MADBoilerPlate

use of de.metas.letters.model.MADBoilerPlate in project metasfresh-webui-api by metasfresh.

the class MailRestController method applyTemplate.

private void applyTemplate(final WebuiEmail email, final WebuiEmailBuilder newEmailBuilder, final LookupValue templateId) {
    final Properties ctx = Env.getCtx();
    final MADBoilerPlate boilerPlate = MADBoilerPlate.get(ctx, templateId.getIdAsInt());
    // 
    // Attributes
    final BoilerPlateContext attributes = documentCollection.createBoilerPlateContext(email.getContextDocumentPath());
    // 
    // Subject
    final String subject = MADBoilerPlate.parseText(ctx, boilerPlate.getSubject(), true, attributes, ITrx.TRXNAME_None);
    newEmailBuilder.subject(subject);
    // Message
    newEmailBuilder.message(boilerPlate.getTextSnippetParsed(attributes));
}
Also used : MADBoilerPlate(de.metas.letters.model.MADBoilerPlate) BoilerPlateContext(de.metas.letters.model.MADBoilerPlate.BoilerPlateContext) Properties(java.util.Properties)

Aggregations

MADBoilerPlate (de.metas.letters.model.MADBoilerPlate)2 BoilerPlateContext (de.metas.letters.model.MADBoilerPlate.BoilerPlateContext)2 Properties (java.util.Properties)2