use of org.jaffa.persistence.Criteria 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;
}
}
use of org.jaffa.persistence.Criteria 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;
}
use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.
the class FormEventViewerTx method addRelatedDtos.
// .//GEN-END:_buildDto_3_be
// .//GEN-BEGIN:_addRelatedDtos_1_be
private void addRelatedDtos(UOW uow, FormEventViewerOutDto output, FormEvent formEvent) throws UOWException {
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_1_be
if (formEvent.getEventName() != null) {
Criteria criteria = new Criteria();
criteria.setTable(FormUsageMeta.getName());
criteria.addCriteria(FormUsageMeta.EVENT_NAME, formEvent.getEventName());
criteria.addOrderBy("FormName", Criteria.ORDER_BY_ASC);
// .//GEN-END:_addRelatedDtos_FormUsage_1_be
// Add custom code to set the criteria before the query //GEN-FIRST:_addRelatedDtos_FormUsage_1
// .//GEN-LAST:_addRelatedDtos_FormUsage_1
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_2_be
Iterator itr = uow.query(criteria).iterator();
while (itr.hasNext()) {
FormUsage formUsage = (FormUsage) itr.next();
FormUsageDto dto = new FormUsageDto();
// .//GEN-END:_addRelatedDtos_FormUsage_2_be
// Add custom code before all the setters //GEN-FIRST:_addRelatedDtos_FormUsage_2
// .//GEN-LAST:_addRelatedDtos_FormUsage_2
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_FormName_1_be
dto.setFormName(formUsage.getFormName());
// .//GEN-END:_addRelatedDtos_FormUsage_FormName_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_EventName_1_be
dto.setEventName(formUsage.getEventName());
// .//GEN-END:_addRelatedDtos_FormUsage_EventName_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_FormAlternate_1_be
dto.setFormAlternate(formUsage.getFormAlternate());
// .//GEN-END:_addRelatedDtos_FormUsage_FormAlternate_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_Copies_1_be
dto.setCopies(formUsage.getCopies());
// .//GEN-END:_addRelatedDtos_FormUsage_Copies_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_CreatedOn_1_be
dto.setCreatedOn(formUsage.getCreatedOn());
// .//GEN-END:_addRelatedDtos_FormUsage_CreatedOn_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_CreatedBy_1_be
dto.setCreatedBy(formUsage.getCreatedBy());
// .//GEN-END:_addRelatedDtos_FormUsage_CreatedBy_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_LastChangedOn_1_be
dto.setLastChangedOn(formUsage.getLastChangedOn());
// .//GEN-END:_addRelatedDtos_FormUsage_LastChangedOn_1_be
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_LastChangedBy_1_be
dto.setLastChangedBy(formUsage.getLastChangedBy());
// .//GEN-END:_addRelatedDtos_FormUsage_LastChangedBy_1_be
// Add custom code to pass values to the dto //GEN-FIRST:_addRelatedDtos_FormUsage_3
// .//GEN-LAST:_addRelatedDtos_FormUsage_3
// .//GEN-BEGIN:_addRelatedDtos_FormUsage_3_be
output.addFormUsage(dto);
}
}
// .//GEN-END:_addRelatedDtos_FormUsage_3_be
// .//GEN-BEGIN:_addRelatedDtos_2_be
}
use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.
the class FormEventViewerTx method read.
// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_read_1_be
/**
* Returns the details for FormEvent.
* @param input The criteria based on which an object will be retrieved.
* @throws ApplicationExceptions This will be thrown if the criteria contains invalid data.
* @throws FrameworkException Indicates some system error.
* @return The object details. A null indicates, the object was not found.
*/
public FormEventViewerOutDto read(FormEventViewerInDto 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();
// Build the Criteria Object
Criteria criteria = buildCriteria(input, uow);
// .//GEN-END:_read_1_be
// Add custom code before the query //GEN-FIRST:_read_1
// .//GEN-LAST:_read_1
// .//GEN-BEGIN:_read_2_be
// Execute The Query
Collection results = uow.query(criteria);
// .//GEN-END:_read_2_be
// Add custom code after the query //GEN-FIRST:_read_2
// .//GEN-LAST:_read_2
// .//GEN-BEGIN:_read_3_be
// Convert the domain objects into the outbound dto
FormEventViewerOutDto output = buildDto(uow, results);
// Print Debug Information for the output
if (log.isDebugEnabled()) {
log.debug("Output: " + (output != null ? output.toString() : null));
}
return output;
} finally {
if (uow != null)
uow.rollback();
}
}
use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.
the class FormGroupFinderTx method find.
// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_find_1_be
/**
* Searches for FormGroup objects.
* @param input The criteria based on which the search will be performed.
* @throws ApplicationExceptions This will be thrown if the criteria contains invalid data.
* @throws FrameworkException Indicates some system error
* @return The search results.
*/
public FormGroupFinderOutDto find(FormGroupFinderInDto 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();
// Build the Criteria Object
Criteria criteria = buildCriteria(input, uow);
// .//GEN-END:_find_1_be
// Add custom code before the query //GEN-FIRST:_find_1
// .//GEN-LAST:_find_1
// .//GEN-BEGIN:_find_2_be
// Execute The Query
Collection results = uow.query(criteria);
// .//GEN-END:_find_2_be
// Add custom code after the query //GEN-FIRST:_find_2
// .//GEN-LAST:_find_2
// .//GEN-BEGIN:_find_3_be
// Convert the domain objects into the outbound dto
FormGroupFinderOutDto output = buildDto(uow, results, input);
// Print Debug Information for the output
if (log.isDebugEnabled()) {
log.debug("Output: " + (output != null ? output.toString() : null));
}
return output;
} finally {
if (uow != null)
uow.rollback();
}
}
Aggregations