Search in sources :

Example 11 with ValidationException

use of org.jaffa.datatypes.ValidationException in project jaffa-framework by jaffa-projects.

the class FormUsageMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private FormUsage createDomain(UOW uow, FormUsageMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    FormUsage domain = new FormUsage();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updateFormAlternate(input.getFormAlternate());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateCopies(input.getCopies());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        if (!fromPrevalidate)
            domain.updateCreatedOn(new DateTime());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        if (!fromPrevalidate && input.getHeaderDto() != null && input.getHeaderDto().getUserId() != null)
            domain.updateCreatedBy(input.getHeaderDto().getUserId());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateEventName(input.getEventName());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateFormName(input.getFormName());
    } 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) DateTime(org.jaffa.datatypes.DateTime) FormUsage(org.jaffa.modules.printing.domain.FormUsage)

Example 12 with ValidationException

use of org.jaffa.datatypes.ValidationException in project jaffa-framework by jaffa-projects.

the class PrinterOutputTypeMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private PrinterOutputType createDomain(UOW uow, PrinterOutputTypeMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    PrinterOutputType domain = new PrinterOutputType();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updateOutputType(input.getOutputType());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateDescription(input.getDescription());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateDirectPrinting(input.getDirectPrinting());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        if (!fromPrevalidate)
            domain.updateCreatedOn(new DateTime());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        if (!fromPrevalidate && input.getHeaderDto() != null && input.getHeaderDto().getUserId() != null)
            domain.updateCreatedBy(input.getHeaderDto().getUserId());
    } 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 : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) DateTime(org.jaffa.datatypes.DateTime)

Example 13 with ValidationException

use of org.jaffa.datatypes.ValidationException in project jaffa-framework by jaffa-projects.

the class AuditLogger method createAuditTransactionObject.

/**
 * Creates an AuditTransactionObject instance, adds it to the UOW and returns it's id.
 */
private String createAuditTransactionObject(String objectName, ChangeType changeType) throws ApplicationExceptions, FrameworkException {
    try {
        AuditTransactionObject ato = new AuditTransactionObject();
        ato.generateKey();
        ato.setTransactionId(m_transactionId);
        ato.setObjectName(objectName);
        ato.setChangeType(changeType == ChangeType.INSERT ? "I" : (changeType == ChangeType.UPDATE ? "U" : "D"));
        m_uow.addSpecial(ato);
        if (log.isDebugEnabled())
            log.debug("Created AuditTransactionObject: " + ato);
        return ato.getObjectId();
    } catch (ValidationException e) {
        if (log.isDebugEnabled())
            log.debug("Exception thrown during creation of AuditTransactionObject", e);
        throw new ApplicationExceptions(e);
    }
}
Also used : ValidationException(org.jaffa.datatypes.ValidationException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) AuditTransactionObject(org.jaffa.components.audit.domain.AuditTransactionObject)

Example 14 with ValidationException

use of org.jaffa.datatypes.ValidationException in project jaffa-framework by jaffa-projects.

the class AuditLogger method createAuditTransaction.

/**
 * Creates an AuditTransaction instance, if not already created, and adds it to the UOW.
 */
private void createAuditTransaction() throws ApplicationExceptions, FrameworkException {
    if (m_transactionId == null) {
        try {
            AuditTransaction at = new AuditTransaction();
            at.generateKey();
            at.setProcessName((String) MDC.get(AuditTransactionMeta.PROCESS_NAME));
            at.setSubProcessName((String) MDC.get(AuditTransactionMeta.SUB_PROCESS_NAME));
            at.setReason((String) MDC.get(AuditTransactionMeta.REASON));
            if (SecurityManager.getPrincipal() != null && SecurityManager.getPrincipal().getName() != null)
                at.setCreatedBy(SecurityManager.getPrincipal().getName());
            at.setCreatedOn(new DateTime());
            m_uow.addSpecial(at);
            m_transactionId = at.getTransactionId();
            if (log.isDebugEnabled())
                log.debug("Created AuditTransaction: " + at);
        } catch (ValidationException e) {
            if (log.isDebugEnabled())
                log.debug("Exception thrown during creation of AuditTransaction", e);
            throw new ApplicationExceptions(e);
        }
    }
}
Also used : ValidationException(org.jaffa.datatypes.ValidationException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) AuditTransaction(org.jaffa.components.audit.domain.AuditTransaction) DateTime(org.jaffa.datatypes.DateTime)

Example 15 with ValidationException

use of org.jaffa.datatypes.ValidationException in project jaffa-framework by jaffa-projects.

the class UserTimeEntryMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private UserTimeEntry createDomain(UOW uow, UserTimeEntryMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    UserTimeEntry domain = new UserTimeEntry();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updateUserName(input.getUserName());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateProjectCode(input.getProjectCode());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateActivity(input.getActivity());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateTask(input.getTask());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updatePeriodStart(input.getPeriodStart());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updatePeriodEnd(input.getPeriodEnd());
    } 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) UserTimeEntry(org.jaffa.applications.test.modules.time.domain.UserTimeEntry)

Aggregations

ValidationException (org.jaffa.datatypes.ValidationException)23 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)21 DateTime (org.jaffa.datatypes.DateTime)8 Criteria (org.jaffa.persistence.Criteria)4 UserRole (org.jaffa.applications.jaffa.modules.admin.domain.UserRole)2 UserRequest (org.jaffa.applications.jaffa.modules.user.domain.UserRequest)2 ApplicationException (org.jaffa.exceptions.ApplicationException)2 FrameworkException (org.jaffa.exceptions.FrameworkException)2 FormTemplate (org.jaffa.modules.printing.domain.FormTemplate)2 FormUsage (org.jaffa.modules.printing.domain.FormUsage)2 EmailerBean (org.jaffa.util.EmailerBean)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 MalformedURLException (java.net.MalformedURLException)1 Locale (java.util.Locale)1 User (org.jaffa.applications.jaffa.modules.admin.domain.User)1 UserTimeEntry (org.jaffa.applications.test.modules.time.domain.UserTimeEntry)1 Attachment (org.jaffa.components.attachment.domain.Attachment)1 AuditTransaction (org.jaffa.components.audit.domain.AuditTransaction)1 AuditTransactionObject (org.jaffa.components.audit.domain.AuditTransactionObject)1