Search in sources :

Example 16 with FormUsage

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

the class FormUsageFinderTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private FormUsageFinderOutDto buildDto(UOW uow, Collection results, FormUsageFinderInDto input) throws UOWException {
    FormUsageFinderOutDto output = new FormUsageFinderOutDto();
    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;
        }
        FormUsageFinderOutRowDto row = new FormUsageFinderOutRowDto();
        FormUsage formUsage = (FormUsage) 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_FormName_1_be
        row.setFormName(formUsage.getFormName());
        // .//GEN-END:_buildDto_FormName_1_be
        // .//GEN-BEGIN:_buildDto_EventName_1_be
        row.setEventName(formUsage.getEventName());
        // .//GEN-END:_buildDto_EventName_1_be
        // .//GEN-BEGIN:_buildDto_FormAlternate_1_be
        row.setFormAlternate(formUsage.getFormAlternate());
        // .//GEN-END:_buildDto_FormAlternate_1_be
        // .//GEN-BEGIN:_buildDto_Copies_1_be
        row.setCopies(formUsage.getCopies());
        // .//GEN-END:_buildDto_Copies_1_be
        // .//GEN-BEGIN:_buildDto_CreatedOn_1_be
        row.setCreatedOn(formUsage.getCreatedOn());
        // .//GEN-END:_buildDto_CreatedOn_1_be
        // .//GEN-BEGIN:_buildDto_CreatedBy_1_be
        row.setCreatedBy(formUsage.getCreatedBy());
        // .//GEN-END:_buildDto_CreatedBy_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedOn_1_be
        row.setLastChangedOn(formUsage.getLastChangedOn());
        // .//GEN-END:_buildDto_LastChangedOn_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedBy_1_be
        row.setLastChangedBy(formUsage.getLastChangedBy());
        // .//GEN-END:_buildDto_LastChangedBy_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 : FormUsageFinderOutRowDto(org.jaffa.modules.printing.components.formusagefinder.dto.FormUsageFinderOutRowDto) FormUsageFinderOutDto(org.jaffa.modules.printing.components.formusagefinder.dto.FormUsageFinderOutDto) FormUsage(org.jaffa.modules.printing.domain.FormUsage)

Example 17 with FormUsage

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

the class FormUsageLookupTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private FormUsageLookupOutDto buildDto(UOW uow, Collection results, FormUsageLookupInDto input) throws UOWException {
    FormUsageLookupOutDto output = new FormUsageLookupOutDto();
    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;
        }
        FormUsageLookupOutRowDto row = new FormUsageLookupOutRowDto();
        FormUsage formUsage = (FormUsage) 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_FormName_1_be
        row.setFormName(formUsage.getFormName());
        // .//GEN-END:_buildDto_FormName_1_be
        // .//GEN-BEGIN:_buildDto_EventName_1_be
        row.setEventName(formUsage.getEventName());
        // .//GEN-END:_buildDto_EventName_1_be
        // .//GEN-BEGIN:_buildDto_FormAlternate_1_be
        row.setFormAlternate(formUsage.getFormAlternate());
        // .//GEN-END:_buildDto_FormAlternate_1_be
        // .//GEN-BEGIN:_buildDto_Copies_1_be
        row.setCopies(formUsage.getCopies());
        // .//GEN-END:_buildDto_Copies_1_be
        // .//GEN-BEGIN:_buildDto_CreatedOn_1_be
        row.setCreatedOn(formUsage.getCreatedOn());
        // .//GEN-END:_buildDto_CreatedOn_1_be
        // .//GEN-BEGIN:_buildDto_CreatedBy_1_be
        row.setCreatedBy(formUsage.getCreatedBy());
        // .//GEN-END:_buildDto_CreatedBy_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedOn_1_be
        row.setLastChangedOn(formUsage.getLastChangedOn());
        // .//GEN-END:_buildDto_LastChangedOn_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedBy_1_be
        row.setLastChangedBy(formUsage.getLastChangedBy());
        // .//GEN-END:_buildDto_LastChangedBy_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 : FormUsageLookupOutRowDto(org.jaffa.modules.printing.components.formusagelookup.dto.FormUsageLookupOutRowDto) FormUsageLookupOutDto(org.jaffa.modules.printing.components.formusagelookup.dto.FormUsageLookupOutDto) FormUsage(org.jaffa.modules.printing.domain.FormUsage)

Example 18 with FormUsage

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

the class FormUsageMaintenanceTx method delete.

/**
 * Deletes an existing instance of FormUsage.
 * @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(FormUsageMaintenanceDeleteInDto 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
    FormUsage domain = load(uow, input);
    // Ensure the domain object has not been modified
    domainObjectChangedTest(input.getPerformDirtyReadCheck(), domain, input.getLastChangedOn());
    // 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 : FormUsage(org.jaffa.modules.printing.domain.FormUsage)

Example 19 with FormUsage

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

the class FormUsageMaintenanceTx method load.

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

Example 20 with FormUsage

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

the class FormUsageMaintenanceTx method create.

// .//GEN-END:_prevalidateCreate_1_be
// .//GEN-BEGIN:_create_1_be
/**
 * Persists a new instance of FormUsage.
 * @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 FormUsageMaintenanceRetrieveOutDto create(FormUsageMaintenanceCreateInDto 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
        FormUsage 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
        FormUsageMaintenanceRetrieveInDto retrieveInDto = new FormUsageMaintenanceRetrieveInDto();
        retrieveInDto.setHeaderDto(input.getHeaderDto());
        retrieveInDto.setFormName(input.getFormName());
        FormUsageMaintenanceRetrieveOutDto 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) UOW(org.jaffa.persistence.UOW) FormUsage(org.jaffa.modules.printing.domain.FormUsage)

Aggregations

FormUsage (org.jaffa.modules.printing.domain.FormUsage)23 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)10 Criteria (org.jaffa.persistence.Criteria)9 FrameworkException (org.jaffa.exceptions.FrameworkException)6 ApplicationException (org.jaffa.exceptions.ApplicationException)5 UOW (org.jaffa.persistence.UOW)5 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)3 ValidationException (org.jaffa.datatypes.ValidationException)2 FormSelectionMaintenanceOutDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto)2 FormSelectionMaintenanceOutRowDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto)2 FormDefinition (org.jaffa.modules.printing.domain.FormDefinition)2 FormEvent (org.jaffa.modules.printing.domain.FormEvent)2 DateTime (org.jaffa.datatypes.DateTime)1 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)1 DuplicateKeyException (org.jaffa.exceptions.DuplicateKeyException)1 RelatedDomainObjectFoundException (org.jaffa.exceptions.RelatedDomainObjectFoundException)1 FormUsageDto (org.jaffa.modules.printing.components.formeventviewer.dto.FormUsageDto)1 FormUsageDto (org.jaffa.modules.printing.components.formgroupviewer.dto.FormUsageDto)1 FormUsageFinderOutDto (org.jaffa.modules.printing.components.formusagefinder.dto.FormUsageFinderOutDto)1 FormUsageFinderOutRowDto (org.jaffa.modules.printing.components.formusagefinder.dto.FormUsageFinderOutRowDto)1