Search in sources :

Example 21 with ValidationException

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

the class PrinterDefinitionMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private PrinterDefinition createDomain(UOW uow, PrinterDefinitionMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    PrinterDefinition domain = new PrinterDefinition();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updatePrinterId(input.getPrinterId());
    } 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.updateSiteCode(input.getSiteCode());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateLocationCode(input.getLocationCode());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateRemote(input.getRemote());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateRealPrinterName(input.getRealPrinterName());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updatePrinterOption1(input.getPrinterOption1());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updatePrinterOption2(input.getPrinterOption2());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateOutputType(input.getOutputType());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateScaleToPageSize(input.getScaleToPageSize());
    } 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 : PrinterDefinition(org.jaffa.modules.printing.domain.PrinterDefinition) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException)

Example 22 with ValidationException

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

the class FormDefinitionMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private FormDefinition createDomain(UOW uow, FormDefinitionMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    FormDefinition domain = new FormDefinition();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updateFormId(input.getFormId());
    } 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);
    }
    try {
        domain.updateFormAlternate(input.getFormAlternate());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateFormVariation(input.getFormVariation());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateOutputType(input.getOutputType());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateFormTemplate(input.getFormTemplate());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateFieldLayout(input.getFieldLayout());
    } 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.updateRemarks(input.getRemarks());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateDomFactory(input.getDomFactory());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateDomClass(input.getDomClass());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateDomKey1(input.getDomKey1());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateDomKey2(input.getDomKey2());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateDomKey3(input.getDomKey3());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateDomKey4(input.getDomKey4());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateDomKey5(input.getDomKey5());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateDomKey6(input.getDomKey6());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateAdditionalDataComponent(input.getAdditionalDataComponent());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateFollowOnFormName(input.getFollowOnFormName());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateFollowOnFormAlternate(input.getFollowOnFormAlternate());
    } 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 : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) FormDefinition(org.jaffa.modules.printing.domain.FormDefinition) DateTime(org.jaffa.datatypes.DateTime)

Example 23 with ValidationException

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

the class FormDefinitionMaintenanceTx method createOrLoadFormTemplate.

// .//GEN-END:_domainObjectChangedTest_1_be
// .//GEN-BEGIN:_createOrLoadFormTemplate_1_be
/**
 * Create Or Load an existing instance of FormTemplate which has a 1-to-1 relationship with the domain object.
 */
private FormTemplate createOrLoadFormTemplate(UOW uow, FormDefinitionMaintenanceCreateInDto input, FormDefinition domain, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    FormTemplate formTemplate = null;
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createOrLoadFormTemplate_2_be
    if (domain.getFormId() != null) {
        // load an existing instance
        Criteria criteria = new Criteria();
        criteria.setTable(FormTemplateMeta.getName());
        criteria.addCriteria(FormTemplateMeta.FORM_ID, domain.getFormId());
        // .//GEN-END:_createOrLoadFormTemplate_2_be
        // Add custom code//GEN-FIRST:_createOrLoadFormTemplate_2
        // .//GEN-LAST:_createOrLoadFormTemplate_2
        // .//GEN-BEGIN:_createOrLoadFormTemplate_3_be
        Iterator itrOne = uow.query(criteria).iterator();
        if (itrOne.hasNext())
            formTemplate = (FormTemplate) itrOne.next();
    }
    // create if it doesn't already exist
    if (formTemplate == null)
        formTemplate = new FormTemplate();
    // Update the template if a file has been uploaded
    if (input.getFormTemplate() != null) {
        try {
            formTemplate.setTemplateData(input.getTemplateData());
        } catch (ValidationException e) {
            throw new ApplicationExceptions(new ApplicationException("exception.Jaffa.Printing.FormDefinitionMaintenance.UploadTemplateData") {
            });
        }
    }
    if (input.getFieldLayout() != null) {
        try {
            formTemplate.setLayoutData(input.getLayoutData());
        } catch (ValidationException e) {
            throw new ApplicationExceptions(new ApplicationException("exception.Jaffa.Printing.FormDefinitionMaintenance.UploadLayOutData") {
            });
        }
    }
    if (!formTemplate.isDatabaseOccurence() && formTemplate.isModified()) {
        // Finally set the join-fields
        try {
            formTemplate.updateFormId(domain.getFormId());
        } catch (ValidationException e) {
            if (appExps == null)
                appExps = new ApplicationExceptions();
            appExps.add(e);
        }
    }
    // .//GEN-BEGIN:_createOrLoadFormTemplate_5_be
    if (appExps != null && appExps.size() > 0)
        throw appExps;
    return formTemplate;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) ApplicationException(org.jaffa.exceptions.ApplicationException) FormTemplate(org.jaffa.modules.printing.domain.FormTemplate) Criteria(org.jaffa.persistence.Criteria)

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