Search in sources :

Example 6 with FormTemplate

use of org.jaffa.modules.printing.domain.FormTemplate in project jaffa-framework by jaffa-projects.

the class FormTemplateMaintenanceTx method prevalidateUpdate.

// .//GEN-END:_retrieve_1_be
// .//GEN-BEGIN:_prevalidateUpdate_1_be
/**
 * This method is used to perform prevalidations before updating an existing instance of FormTemplate.
 * @param input The new values for the domain object.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details.
 */
public FormTemplateMaintenancePrevalidateOutDto prevalidateUpdate(FormTemplateMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + (input != null ? input.toString() : null));
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Retrieve the object
        FormTemplate domain = load(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Update the domain object
        updateDomain(uow, input, domain, true);
        // Build the outbound dto
        FormTemplateMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Output: " + (output != null ? output.toString() : null));
        return output;
    } catch (FrameworkException e) {
        // If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
        if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
            throw (ApplicationExceptions) e.getCause();
        } else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            appExps.add((ApplicationException) e.getCause());
            throw appExps;
        } else
            throw e;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) FormTemplate(org.jaffa.modules.printing.domain.FormTemplate) UOW(org.jaffa.persistence.UOW)

Example 7 with FormTemplate

use of org.jaffa.modules.printing.domain.FormTemplate in project jaffa-framework by jaffa-projects.

the class FormTemplateMaintenanceTx method update.

// .//GEN-END:_prevalidateUpdate_1_be
// .//GEN-BEGIN:_update_1_be
/**
 * Updates an existing instance of FormTemplate.
 * @param input The new values for the domain object.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details.
 */
public FormTemplateMaintenanceRetrieveOutDto update(FormTemplateMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + (input != null ? input.toString() : null));
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Retrieve the object
        FormTemplate domain = load(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Update the domain object
        updateDomain(uow, input, domain, false);
        uow.update(domain);
        // Commit the changes
        uow.commit();
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Successfully updated the domain object. Now retrieving the object details.");
        // Build the outbound dto by performing a retrieve
        FormTemplateMaintenanceRetrieveInDto retrieveInDto = new FormTemplateMaintenanceRetrieveInDto();
        retrieveInDto.setHeaderDto(input.getHeaderDto());
        retrieveInDto.setFormId(input.getFormId());
        FormTemplateMaintenanceRetrieveOutDto output = retrieve(retrieveInDto);
        return output;
    } catch (FrameworkException e) {
        // If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
        if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
            throw (ApplicationExceptions) e.getCause();
        } else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            appExps.add((ApplicationException) e.getCause());
            throw appExps;
        } else
            throw e;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) FormTemplate(org.jaffa.modules.printing.domain.FormTemplate) UOW(org.jaffa.persistence.UOW)

Example 8 with FormTemplate

use of org.jaffa.modules.printing.domain.FormTemplate in project jaffa-framework by jaffa-projects.

the class FormTemplateMaintenanceTx method prevalidateCreate.

// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_prevalidateCreate_1_be
/**
 * This method is used to perform prevalidations before creating a new instance of FormTemplate.
 * @param input The new values for the domain object.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details.
 */
public FormTemplateMaintenancePrevalidateOutDto prevalidateCreate(FormTemplateMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + (input != null ? input.toString() : null));
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Do not allow a Duplicate record
        duplicateCheck(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Create the domain object
        FormTemplate domain = createDomain(uow, input, true);
        // Perform post create processing
        postCreate(uow, input, domain, true);
        // Build the outbound dto
        FormTemplateMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Output: " + (output != null ? output.toString() : null));
        return output;
    } catch (FrameworkException e) {
        // If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
        if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
            throw (ApplicationExceptions) e.getCause();
        } else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            appExps.add((ApplicationException) e.getCause());
            throw appExps;
        } else
            throw e;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) FormTemplate(org.jaffa.modules.printing.domain.FormTemplate) UOW(org.jaffa.persistence.UOW)

Example 9 with FormTemplate

use of org.jaffa.modules.printing.domain.FormTemplate in project jaffa-framework by jaffa-projects.

the class FormTemplateMaintenanceTx method load.

// .//GEN-END:_preprocessRetrieve_2_be
// .//GEN-BEGIN:_loadRetrieve_1_be
/**
 * Retrieve the domain object.
 */
private FormTemplate load(UOW uow, FormTemplateMaintenanceRetrieveInDto input) throws FrameworkException, ApplicationExceptions {
    FormTemplate domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(FormTemplateMeta.getName());
    // .//GEN-END:_loadRetrieve_1_be
    // Add custom criteria //GEN-FIRST:_loadRetrieve_1
    // .//GEN-LAST:_loadRetrieve_1
    // .//GEN-BEGIN:_loadRetrieve_2_be
    criteria.addCriteria(FormTemplateMeta.FORM_ID, input.getFormId());
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (FormTemplate) itr.next();
    // .//GEN-BEGIN:_loadRetrieve_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(FormTemplateMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) FormTemplate(org.jaffa.modules.printing.domain.FormTemplate) Criteria(org.jaffa.persistence.Criteria)

Example 10 with FormTemplate

use of org.jaffa.modules.printing.domain.FormTemplate in project jaffa-framework by jaffa-projects.

the class FormTemplateMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private FormTemplate createDomain(UOW uow, FormTemplateMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    FormTemplate domain = new FormTemplate();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updateTemplateData(input.getTemplateData());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateLayoutData(input.getLayoutData());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateFormId(input.getFormId());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    // .//GEN-BEGIN:_createDomain_3_be
    if (appExps != null && appExps.size() > 0)
        throw appExps;
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) FormTemplate(org.jaffa.modules.printing.domain.FormTemplate)

Aggregations

FormTemplate (org.jaffa.modules.printing.domain.FormTemplate)23 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)15 ApplicationException (org.jaffa.exceptions.ApplicationException)11 UOW (org.jaffa.persistence.UOW)10 FrameworkException (org.jaffa.exceptions.FrameworkException)9 Criteria (org.jaffa.persistence.Criteria)7 FormDefinition (org.jaffa.modules.printing.domain.FormDefinition)4 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)3 ValidationException (org.jaffa.datatypes.ValidationException)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 TransformerException (javax.xml.transform.TransformerException)1 FormTemplateFinderOutDto (org.jaffa.modules.printing.components.formtemplatefinder.dto.FormTemplateFinderOutDto)1 FormTemplateFinderOutRowDto (org.jaffa.modules.printing.components.formtemplatefinder.dto.FormTemplateFinderOutRowDto)1 FormTemplateLookupOutDto (org.jaffa.modules.printing.components.formtemplatelookup.dto.FormTemplateLookupOutDto)1 FormTemplateLookupOutRowDto (org.jaffa.modules.printing.components.formtemplatelookup.dto.FormTemplateLookupOutRowDto)1 FormTemplateViewerOutDto (org.jaffa.modules.printing.components.formtemplateviewer.dto.FormTemplateViewerOutDto)1 EngineProcessingException (org.jaffa.modules.printing.services.exceptions.EngineProcessingException)1