Search in sources :

Example 1 with FormDefinitionViewerInDto

use of org.jaffa.modules.printing.components.formdefinitionviewer.dto.FormDefinitionViewerInDto in project jaffa-framework by jaffa-projects.

the class FormDefinitionViewerComponent method loadFormTemplate.

// .//GEN-END:_addListeners_1_be
// All the custom code goes here//GEN-FIRST:_custom
public File loadFormTemplate() throws FrameworkException, ApplicationExceptions, IOException {
    String formTemplate = getFormDefinitionViewerOutDto().getFormTemplate();
    if (formTemplate != null) {
        FormDefinitionViewerInDto inputDto = new FormDefinitionViewerInDto();
        inputDto.setFormId(m_formId);
        if (m_tx == null)
            m_tx = (IFormDefinitionViewer) Factory.createObject(IFormDefinitionViewer.class);
        byte[] formTemplateContents = m_tx.loadFormTemplate(inputDto);
        // int i = formTemplate.lastIndexOf(".pdf");
        // String prifix = i>0 ? formTemplate : formTemplate.substring(0,i);
        // File formTemplateFile=File.createTempFile(prifix,"pdf");
        SplitString ss = new SplitString(formTemplate, ".", false);
        String suffix = ss.getSuffix() != null ? "." + ss.getSuffix() : null;
        File formTemplateFile = File.createTempFile("jaffa", suffix);
        OutputStream outputStream = null;
        try {
            outputStream = new BufferedOutputStream(new FileOutputStream(formTemplateFile));
            outputStream.write(formTemplateContents);
            outputStream.flush();
        } finally {
            if (outputStream != null)
                outputStream.close();
        }
        return formTemplateFile;
    }
    return null;
}
Also used : SplitString(org.jaffa.util.SplitString) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) FileOutputStream(java.io.FileOutputStream) FormDefinitionViewerInDto(org.jaffa.modules.printing.components.formdefinitionviewer.dto.FormDefinitionViewerInDto) IFormDefinitionViewer(org.jaffa.modules.printing.components.formdefinitionviewer.IFormDefinitionViewer) SplitString(org.jaffa.util.SplitString) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 2 with FormDefinitionViewerInDto

use of org.jaffa.modules.printing.components.formdefinitionviewer.dto.FormDefinitionViewerInDto in project jaffa-framework by jaffa-projects.

the class FormDefinitionViewerComponent method doInquiry.

// .//GEN-END:_display_2_be
// .//GEN-BEGIN:_inquiry_1_be
private void doInquiry() throws ApplicationExceptions, FrameworkException {
    FormDefinitionViewerInDto inputDto = new FormDefinitionViewerInDto();
    // .//GEN-END:_inquiry_1_be
    // Add custom code before building the input dto//GEN-FIRST:_inquiry_1
    // .//GEN-LAST:_inquiry_1
    // .//GEN-BEGIN:_inquiry_2_be
    inputDto.setFormId(m_formId);
    inputDto.setHeaderDto(createHeaderDto());
    // create the Tx
    if (m_tx == null)
        m_tx = (IFormDefinitionViewer) Factory.createObject(IFormDefinitionViewer.class);
    // .//GEN-END:_inquiry_2_be
    // Add custom code before invoking the Tx//GEN-FIRST:_inquiry_2
    // .//GEN-LAST:_inquiry_2
    // .//GEN-BEGIN:_inquiry_3_be
    // now get the details
    m_outputDto = m_tx.read(inputDto);
    // uncache the widgets
    getUserSession().getWidgetCache(getComponentId()).clear();
    // throw an exception if the output is null
    if (m_outputDto == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(FormDefinitionMeta.getLabelToken()));
        throw appExps;
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) FormDefinitionViewerInDto(org.jaffa.modules.printing.components.formdefinitionviewer.dto.FormDefinitionViewerInDto) IFormDefinitionViewer(org.jaffa.modules.printing.components.formdefinitionviewer.IFormDefinitionViewer)

Aggregations

IFormDefinitionViewer (org.jaffa.modules.printing.components.formdefinitionviewer.IFormDefinitionViewer)2 FormDefinitionViewerInDto (org.jaffa.modules.printing.components.formdefinitionviewer.dto.FormDefinitionViewerInDto)2 BufferedOutputStream (java.io.BufferedOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)1 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)1 SplitString (org.jaffa.util.SplitString)1