Search in sources :

Example 1 with DuplicateKeyException

use of org.jaffa.exceptions.DuplicateKeyException in project jaffa-framework by jaffa-projects.

the class FormEventMaintenanceTx method duplicateCheck.

// .//GEN-END:_preprocessCreate_2_be
// .//GEN-BEGIN:_duplicateCheck_1_be
/**
 * Ensure that a duplicate record is not created.
 */
private void duplicateCheck(UOW uow, FormEventMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
    // .//GEN-BEGIN:_duplicateCheck_2_be
    if (input.getEventName() == null)
        return;
    Criteria criteria = new Criteria();
    criteria.setTable(FormEventMeta.getName());
    // .//GEN-END:_duplicateCheck_2_be
    // Add custom criteria//GEN-FIRST:_duplicateCheck_2
    // .//GEN-LAST:_duplicateCheck_2
    // .//GEN-BEGIN:_duplicateCheck_3_be
    criteria.addCriteria(FormEventMeta.EVENT_NAME, input.getEventName());
    Collection col = uow.query(criteria);
    // .//GEN-BEGIN:_duplicateCheck_4_be
    if (col != null && !col.isEmpty()) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DuplicateKeyException(FormEventMeta.getLabelToken()));
        throw appExps;
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) Criteria(org.jaffa.persistence.Criteria) DuplicateKeyException(org.jaffa.exceptions.DuplicateKeyException)

Example 2 with DuplicateKeyException

use of org.jaffa.exceptions.DuplicateKeyException in project jaffa-framework by jaffa-projects.

the class UserTimeEntryMaintenanceTx method duplicateCheck.

// .//GEN-END:_preprocessCreate_2_be
// .//GEN-BEGIN:_duplicateCheck_1_be
/**
 * Ensure that a duplicate record is not created.
 */
private void duplicateCheck(UOW uow, UserTimeEntryMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
    // .//GEN-BEGIN:_duplicateCheck_2_be
    if (input.getUserName() == null || input.getProjectCode() == null || input.getTask() == null || input.getPeriodStart() == null || input.getPeriodEnd() == null)
        return;
    Criteria criteria = new Criteria();
    criteria.setTable(UserTimeEntryMeta.getName());
    // .//GEN-END:_duplicateCheck_2_be
    // Add custom criteria //GEN-FIRST:_duplicateCheck_2
    // .//GEN-LAST:_duplicateCheck_2
    // .//GEN-BEGIN:_duplicateCheck_3_be
    criteria.addCriteria(UserTimeEntryMeta.USER_NAME, input.getUserName());
    criteria.addCriteria(UserTimeEntryMeta.PROJECT_CODE, input.getProjectCode());
    criteria.addCriteria(UserTimeEntryMeta.TASK, input.getTask());
    criteria.addCriteria(UserTimeEntryMeta.PERIOD_START, input.getPeriodStart());
    criteria.addCriteria(UserTimeEntryMeta.PERIOD_END, input.getPeriodEnd());
    Collection col = uow.query(criteria);
    // .//GEN-BEGIN:_duplicateCheck_4_be
    if (col != null && !col.isEmpty()) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DuplicateKeyException(UserTimeEntryMeta.getLabelToken()));
        throw appExps;
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) Criteria(org.jaffa.persistence.Criteria) DuplicateKeyException(org.jaffa.exceptions.DuplicateKeyException)

Example 3 with DuplicateKeyException

use of org.jaffa.exceptions.DuplicateKeyException in project jaffa-framework by jaffa-projects.

the class AttachmentMaintenanceTx method duplicateCheck.

// .//GEN-END:_preprocessCreate_2_be
// .//GEN-BEGIN:_duplicateCheck_1_be
/**
 * Ensure that a duplicate record is not created.
 */
private void duplicateCheck(UOW uow, AttachmentMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
    // .//GEN-BEGIN:_duplicateCheck_2_be
    if (input.getAttachmentId() == null)
        return;
    Criteria criteria = new Criteria();
    criteria.setTable(AttachmentMeta.getName());
    // .//GEN-END:_duplicateCheck_2_be
    // Add custom criteria //GEN-FIRST:_duplicateCheck_2
    // .//GEN-LAST:_duplicateCheck_2
    // .//GEN-BEGIN:_duplicateCheck_3_be
    criteria.addCriteria(AttachmentMeta.ATTACHMENT_ID, input.getAttachmentId());
    Collection col = uow.query(criteria);
    // .//GEN-BEGIN:_duplicateCheck_4_be
    if (col != null && !col.isEmpty()) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DuplicateKeyException(AttachmentMeta.getLabelToken()));
        throw appExps;
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) Criteria(org.jaffa.persistence.Criteria) DuplicateKeyException(org.jaffa.exceptions.DuplicateKeyException)

Example 4 with DuplicateKeyException

use of org.jaffa.exceptions.DuplicateKeyException in project jaffa-framework by jaffa-projects.

the class UserMaintenanceTx method duplicateCheck.

// .//GEN-END:_preprocessCreate_2_be
// .//GEN-BEGIN:_duplicateCheck_1_be
/**
 * Ensure that a duplicate record is not created.
 */
private void duplicateCheck(UOW uow, UserMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
    // .//GEN-BEGIN:_duplicateCheck_2_be
    if (input.getUserName() == null)
        return;
    Criteria criteria = new Criteria();
    criteria.setTable(UserMeta.getName());
    // .//GEN-END:_duplicateCheck_2_be
    // Add custom criteria //GEN-FIRST:_duplicateCheck_2
    // .//GEN-LAST:_duplicateCheck_2
    // .//GEN-BEGIN:_duplicateCheck_3_be
    criteria.addCriteria(UserMeta.USER_NAME, input.getUserName());
    Collection col = uow.query(criteria);
    // .//GEN-BEGIN:_duplicateCheck_4_be
    if (col != null && !col.isEmpty()) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DuplicateKeyException(UserMeta.getLabelToken()));
        throw appExps;
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) Criteria(org.jaffa.persistence.Criteria) DuplicateKeyException(org.jaffa.exceptions.DuplicateKeyException)

Example 5 with DuplicateKeyException

use of org.jaffa.exceptions.DuplicateKeyException in project jaffa-framework by jaffa-projects.

the class UserRequestMaintenanceTx method duplicateCheck.

// .//GEN-END:_preprocessCreate_2_be
// .//GEN-BEGIN:_duplicateCheck_1_be
/**
 * Ensure that a duplicate record is not created.
 */
private void duplicateCheck(UOW uow, UserRequestMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
    // .//GEN-BEGIN:_duplicateCheck_2_be
    if (input.getRequestId() == null)
        return;
    Criteria criteria = new Criteria();
    criteria.setTable(UserRequestMeta.getName());
    // .//GEN-END:_duplicateCheck_2_be
    // Add custom criteria //GEN-FIRST:_duplicateCheck_2
    // .//GEN-LAST:_duplicateCheck_2
    // .//GEN-BEGIN:_duplicateCheck_3_be
    criteria.addCriteria(UserRequestMeta.REQUEST_ID, input.getRequestId());
    Collection col = uow.query(criteria);
    // .//GEN-BEGIN:_duplicateCheck_4_be
    if (col != null && !col.isEmpty()) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DuplicateKeyException(UserRequestMeta.getLabelToken()));
        throw appExps;
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) Criteria(org.jaffa.persistence.Criteria) DuplicateKeyException(org.jaffa.exceptions.DuplicateKeyException)

Aggregations

DuplicateKeyException (org.jaffa.exceptions.DuplicateKeyException)15 Criteria (org.jaffa.persistence.Criteria)13 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)12 IPersistent (org.jaffa.persistence.IPersistent)2 SQLIntegrityConstraintViolationException (java.sql.SQLIntegrityConstraintViolationException)1 ValidationException (org.jaffa.datatypes.ValidationException)1 ApplicationException (org.jaffa.exceptions.ApplicationException)1 FrameworkException (org.jaffa.exceptions.FrameworkException)1 AddFailedException (org.jaffa.persistence.exceptions.AddFailedException)1 PreAddFailedException (org.jaffa.persistence.exceptions.PreAddFailedException)1 UOWException (org.jaffa.persistence.exceptions.UOWException)1 RuleMetaData (org.jaffa.rules.meta.RuleMetaData)1