Search in sources :

Example 11 with FormTemplate

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

the class FormTemplateMaintenanceTx method load.

// .//GEN-END:_preprocessUpdate_2_be
// .//GEN-BEGIN:_loadUpdate_1_be
/**
 * Retrieve the domain object.
 */
private FormTemplate load(UOW uow, FormTemplateMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    FormTemplate domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(FormTemplateMeta.getName());
    // .//GEN-END:_loadUpdate_1_be
    // Add custom criteria //GEN-FIRST:_loadUpdate_1
    // .//GEN-LAST:_loadUpdate_1
    // .//GEN-BEGIN:_loadUpdate_2_be
    criteria.addCriteria(FormTemplateMeta.FORM_ID, input.getFormId());
    criteria.setLocking(Criteria.LOCKING_PARANOID);
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (FormTemplate) itr.next();
    // .//GEN-BEGIN:_loadUpdate_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 12 with FormTemplate

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

the class FormTemplateMaintenanceTx method create.

// .//GEN-END:_prevalidateCreate_1_be
// .//GEN-BEGIN:_create_1_be
/**
 * Persists 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 FormTemplateMaintenanceRetrieveOutDto create(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, false);
        uow.add(domain);
        // Perform post create processing
        postCreate(uow, input, domain, false);
        // Commit the changes
        uow.commit();
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Successfully created 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 13 with FormTemplate

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

the class FormTemplateFinderTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private FormTemplateFinderOutDto buildDto(UOW uow, Collection results, FormTemplateFinderInDto input) throws UOWException {
    FormTemplateFinderOutDto output = new FormTemplateFinderOutDto();
    int maxRecords = input.getMaxRecords() != null ? input.getMaxRecords().intValue() : 0;
    int counter = 0;
    for (Iterator i = results.iterator(); i.hasNext(); ) {
        if (++counter > maxRecords && maxRecords > 0) {
            output.setMoreRecordsExist(Boolean.TRUE);
            break;
        }
        FormTemplateFinderOutRowDto row = new FormTemplateFinderOutRowDto();
        FormTemplate formTemplate = (FormTemplate) i.next();
        // .//GEN-END:_buildDto_1_be
        // Add custom code before all the setters //GEN-FIRST:_buildDto_1
        // .//GEN-LAST:_buildDto_1
        // .//GEN-BEGIN:_buildDto_FormId_1_be
        row.setFormId(formTemplate.getFormId());
        // .//GEN-END:_buildDto_FormId_1_be
        // .//GEN-BEGIN:_buildDto_TemplateData_1_be
        row.setTemplateData(formTemplate.getTemplateData());
        // .//GEN-END:_buildDto_TemplateData_1_be
        // .//GEN-BEGIN:_buildDto_LayoutData_1_be
        row.setLayoutData(formTemplate.getLayoutData());
        // .//GEN-END:_buildDto_LayoutData_1_be
        // Add custom code to pass values to the dto //GEN-FIRST:_buildDto_2
        // .//GEN-LAST:_buildDto_2
        // .//GEN-BEGIN:_buildDto_3_be
        output.addRows(row);
    }
    return output;
}
Also used : FormTemplateFinderOutRowDto(org.jaffa.modules.printing.components.formtemplatefinder.dto.FormTemplateFinderOutRowDto) FormTemplate(org.jaffa.modules.printing.domain.FormTemplate) FormTemplateFinderOutDto(org.jaffa.modules.printing.components.formtemplatefinder.dto.FormTemplateFinderOutDto)

Example 14 with FormTemplate

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

the class FormTemplateMaintenanceTx method delete.

/**
 * Deletes an existing instance of FormTemplate.
 * @param input The key values for the domain object to be deleted.
 * @param uow The delete will be performed using the input UOW.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 */
public void delete(FormTemplateMaintenanceDeleteInDto input, UOW uow) throws FrameworkException, ApplicationExceptions {
    // Print Debug Information for the input
    if (log.isDebugEnabled())
        log.debug("Input: " + (input != null ? input.toString() : null));
    // Preprocess the input
    preprocess(uow, input);
    // Retrieve the object
    FormTemplate domain = load(uow, input);
    // Delete the domain object
    deleteDomain(uow, input, domain);
    // Print Debug Information for the output
    if (log.isDebugEnabled())
        log.debug("The domain object has been marked for deletion. It will be deleted when the UOW is committed");
}
Also used : FormTemplate(org.jaffa.modules.printing.domain.FormTemplate)

Example 15 with FormTemplate

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

the class FormTemplateMaintenanceTx method load.

// .//GEN-END:_preprocessDelete_2_be
// .//GEN-BEGIN:_loadDelete_1_be
/**
 * Retrieve the domain object.
 */
private FormTemplate load(UOW uow, FormTemplateMaintenanceDeleteInDto input) throws FrameworkException, ApplicationExceptions {
    FormTemplate domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(FormTemplateMeta.getName());
    // .//GEN-END:_loadDelete_1_be
    // Add custom criteria //GEN-FIRST:_loadDelete_1
    // .//GEN-LAST:_loadDelete_1
    // .//GEN-BEGIN:_loadDelete_2_be
    criteria.addCriteria(FormTemplateMeta.FORM_ID, input.getFormId());
    criteria.setLocking(Criteria.LOCKING_PARANOID);
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (FormTemplate) itr.next();
    // .//GEN-BEGIN:_loadDelete_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)

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