Search in sources :

Example 6 with FormEvent

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

the class FormEventMaintenanceTx method delete.

/**
 * Deletes an existing instance of FormEvent.
 * @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(FormEventMaintenanceDeleteInDto 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
    FormEvent 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 : FormEvent(org.jaffa.modules.printing.domain.FormEvent)

Example 7 with FormEvent

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

the class FormEventMaintenanceTx method load.

// .//GEN-END:_preprocessDelete_2_be
// .//GEN-BEGIN:_loadDelete_1_be
/**
 * Retrieve the domain object.
 */
private FormEvent load(UOW uow, FormEventMaintenanceDeleteInDto input) throws FrameworkException, ApplicationExceptions {
    FormEvent domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(FormEventMeta.getName());
    // .//GEN-END:_loadDelete_1_be
    // Add custom criteria//GEN-FIRST:_loadDelete_1
    // .//GEN-LAST:_loadDelete_1
    // .//GEN-BEGIN:_loadDelete_2_be
    criteria.addCriteria(FormEventMeta.EVENT_NAME, input.getEventName());
    criteria.setLocking(Criteria.LOCKING_PARANOID);
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (FormEvent) itr.next();
    // .//GEN-BEGIN:_loadDelete_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(FormEventMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FormEvent(org.jaffa.modules.printing.domain.FormEvent) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) Criteria(org.jaffa.persistence.Criteria)

Example 8 with FormEvent

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

the class FormEventViewerTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private FormEventViewerOutDto buildDto(UOW uow, Collection results) throws UOWException {
    FormEventViewerOutDto output = null;
    Iterator itr = results.iterator();
    if (itr.hasNext()) {
        // just return the details for the 1st record retrieved.
        FormEvent formEvent = (FormEvent) itr.next();
        output = new FormEventViewerOutDto();
        // .//GEN-END:_buildDto_1_be
        // Add custom code before all the setters //GEN-FIRST:_buildDto_1
        // .//GEN-LAST:_buildDto_1
        // .//GEN-BEGIN:_buildDto_EventName_1_be
        output.setEventName(formEvent.getEventName());
        // .//GEN-END:_buildDto_EventName_1_be
        // .//GEN-BEGIN:_buildDto_Description_1_be
        output.setDescription(formEvent.getDescription());
        // .//GEN-END:_buildDto_Description_1_be
        // .//GEN-BEGIN:_buildDto_CreatedOn_1_be
        output.setCreatedOn(formEvent.getCreatedOn());
        // .//GEN-END:_buildDto_CreatedOn_1_be
        // .//GEN-BEGIN:_buildDto_CreatedBy_1_be
        output.setCreatedBy(formEvent.getCreatedBy());
        // .//GEN-END:_buildDto_CreatedBy_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedOn_1_be
        output.setLastChangedOn(formEvent.getLastChangedOn());
        // .//GEN-END:_buildDto_LastChangedOn_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedBy_1_be
        output.setLastChangedBy(formEvent.getLastChangedBy());
        // .//GEN-END:_buildDto_LastChangedBy_1_be
        // .//GEN-BEGIN:_buildDto_2_be
        // Add related objects, if required
        addRelatedDtos(uow, output, formEvent);
    // .//GEN-END:_buildDto_2_be
    // Add custom code to pass values to the dto //GEN-FIRST:_buildDto_2
    // .//GEN-LAST:_buildDto_2
    // .//GEN-BEGIN:_buildDto_3_be
    }
    return output;
}
Also used : FormEvent(org.jaffa.modules.printing.domain.FormEvent) FormEventViewerOutDto(org.jaffa.modules.printing.components.formeventviewer.dto.FormEventViewerOutDto)

Example 9 with FormEvent

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

the class FormUsage method findFormEventObject.

/**
 * Finds the related foreign FormEvent object.
 * If checkExistenceOnly is false, then the foreign object will be fetched and assigned to the corresponding member variable of this class.
 * If checkExistenceOnly is true, then a mere existence check is performed for the foreign object, as oppposed to fetching all the values for that object.
 */
private void findFormEventObject(boolean checkExistenceOnly) throws ValidationException, FrameworkException {
    UOW uow = getUOW();
    boolean localUow = false;
    try {
        if (m_formEventObject == null && getEventName() != null) {
            Criteria criteria = new Criteria();
            criteria.setTable(FormEventMeta.getName());
            criteria.addCriteria(FormEventMeta.EVENT_NAME, getEventName());
            if (checkExistenceOnly)
                criteria.addFunction(Criteria.FUNCTION_COUNT, null, Criteria.ID_FUNCTION_COUNT);
            Number count = null;
            if (uow == null || !uow.isActive()) {
                uow = new UOW();
                localUow = true;
            }
            Iterator itr = uow.query(criteria).iterator();
            if (itr.hasNext()) {
                if (checkExistenceOnly)
                    count = (Number) ((Map) itr.next()).get(Criteria.ID_FUNCTION_COUNT);
                else
                    m_formEventObject = (FormEvent) itr.next();
            }
            if (m_formEventObject == null && (count == null || count.intValue() <= 0))
                throw new InvalidForeignKeyException(FormUsageMeta.META_EVENT_NAME.getLabelToken(), new Object[] { FormEventMeta.getLabelToken(), FormEventMeta.META_EVENT_NAME.getLabelToken() });
        }
    } finally {
        if (localUow && uow != null)
            uow.rollback();
    }
}
Also used : FormEvent(org.jaffa.modules.printing.domain.FormEvent) InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException)

Example 10 with FormEvent

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

the class FormEventFinderTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private FormEventFinderOutDto buildDto(UOW uow, Collection results, FormEventFinderInDto input) throws UOWException {
    FormEventFinderOutDto output = new FormEventFinderOutDto();
    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;
        }
        FormEventFinderOutRowDto row = new FormEventFinderOutRowDto();
        FormEvent formEvent = (FormEvent) 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_EventName_1_be
        row.setEventName(formEvent.getEventName());
        // .//GEN-END:_buildDto_EventName_1_be
        // .//GEN-BEGIN:_buildDto_Description_1_be
        row.setDescription(formEvent.getDescription());
        // .//GEN-END:_buildDto_Description_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 : FormEvent(org.jaffa.modules.printing.domain.FormEvent) FormEventFinderOutDto(org.jaffa.modules.printing.components.formeventfinder.dto.FormEventFinderOutDto) FormEventFinderOutRowDto(org.jaffa.modules.printing.components.formeventfinder.dto.FormEventFinderOutRowDto)

Aggregations

FormEvent (org.jaffa.modules.printing.domain.FormEvent)16 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)9 ApplicationException (org.jaffa.exceptions.ApplicationException)5 FrameworkException (org.jaffa.exceptions.FrameworkException)5 Criteria (org.jaffa.persistence.Criteria)5 UOW (org.jaffa.persistence.UOW)5 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)3 FormUsage (org.jaffa.modules.printing.domain.FormUsage)2 ValidationException (org.jaffa.datatypes.ValidationException)1 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)1 FormEventFinderOutDto (org.jaffa.modules.printing.components.formeventfinder.dto.FormEventFinderOutDto)1 FormEventFinderOutRowDto (org.jaffa.modules.printing.components.formeventfinder.dto.FormEventFinderOutRowDto)1 FormEventLookupOutDto (org.jaffa.modules.printing.components.formeventlookup.dto.FormEventLookupOutDto)1 FormEventLookupOutRowDto (org.jaffa.modules.printing.components.formeventlookup.dto.FormEventLookupOutRowDto)1 FormEventViewerOutDto (org.jaffa.modules.printing.components.formeventviewer.dto.FormEventViewerOutDto)1 FormUsageDto (org.jaffa.modules.printing.components.formgroupviewer.dto.FormUsageDto)1