use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.
the class FormGroupLookupTx 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 FormGroupLookupOutDto find(FormGroupLookupInDto 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
FormGroupLookupOutDto 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();
}
}
use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.
the class FormDefinitionFinderTx method buildCriteria.
// .//GEN-END:_find_3_be
// .//GEN-BEGIN:_buildCriteria_1_be
private Criteria buildCriteria(FormDefinitionFinderInDto input, UOW uow) {
Criteria criteria = new Criteria();
criteria.setTable(FormDefinitionMeta.getName());
// .//GEN-END:_buildCriteria_1_be
// Add custom criteria //GEN-FIRST:_buildCriteria_1
// .//GEN-LAST:_buildCriteria_1
// .//GEN-BEGIN:_buildCriteria_2_be
FinderTx.addCriteria(input.getFormId(), FormDefinitionMeta.FORM_ID, criteria);
FinderTx.addCriteria(input.getFormName(), FormDefinitionMeta.FORM_NAME, criteria);
FinderTx.addCriteria(input.getFormAlternate(), FormDefinitionMeta.FORM_ALTERNATE, criteria);
FinderTx.addCriteria(input.getFormVariation(), FormDefinitionMeta.FORM_VARIATION, criteria);
FinderTx.addCriteria(input.getOutputType(), FormDefinitionMeta.OUTPUT_TYPE, criteria);
FinderTx.addCriteria(input.getFormTemplate(), FormDefinitionMeta.FORM_TEMPLATE, criteria);
// append an orderBy clause to the criteria
OrderByField[] orderByFields = input.getOrderByFields();
if (orderByFields != null) {
for (int i = 0; i < orderByFields.length; i++) {
OrderByField orderByField = orderByFields[i];
int sort = Criteria.ORDER_BY_ASC;
if (orderByField.getSortAscending() != null && !orderByField.getSortAscending().booleanValue())
sort = Criteria.ORDER_BY_DESC;
criteria.addOrderBy(orderByField.getFieldName(), sort);
}
}
// .//GEN-BEGIN:_buildCriteria_3_be
return criteria;
}
use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.
the class FormDefinitionLookupTx method find.
// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_find_1_be
/**
* Searches for FormDefinition 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 FormDefinitionLookupOutDto find(FormDefinitionLookupInDto 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
FormDefinitionLookupOutDto 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();
}
}
use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.
the class FormDefinitionMaintenanceTx method preprocess.
// .//GEN-END:_delete_1_be
// .//GEN-BEGIN:_preprocessCreate_1_be
/**
* Preprocess the input for the create method.
*/
private void preprocess(UOW uow, FormDefinitionMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
// Not allowed to create a form definition without a template
if (input.getFormTemplate() == null)
throw new ApplicationExceptions(new ApplicationException("exception.Jaffa.Printing.FormDefinitionMaintenance.FormTemplateMandatory") {
});
if (input.getFollowOnFormName() != null) {
Criteria criteria = new Criteria();
criteria.setTable(FormGroupMeta.getName());
criteria.addCriteria(FormGroupMeta.FORM_NAME, input.getFollowOnFormName());
Iterator it = uow.query(criteria).iterator();
if (!it.hasNext())
throw new ApplicationExceptions(new ApplicationException("exception.Jaffa.Printing.FormDefinitionMaintenance.ValidFollowOnForm") {
});
}
// .//GEN-LAST:_preprocessCreate_1
// .//GEN-BEGIN:_preprocessCreate_2_be
}
use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.
the class FormDefinitionMaintenanceTx method load.
// .//GEN-END:_preprocessRetrieve_2_be
// .//GEN-BEGIN:_loadRetrieve_1_be
/**
* Retrieve the domain object.
*/
private FormDefinition load(UOW uow, FormDefinitionMaintenanceRetrieveInDto input) throws FrameworkException, ApplicationExceptions {
FormDefinition domain = null;
Criteria criteria = new Criteria();
criteria.setTable(FormDefinitionMeta.getName());
// .//GEN-END:_loadRetrieve_1_be
// Add custom criteria//GEN-FIRST:_loadRetrieve_1
// .//GEN-LAST:_loadRetrieve_1
// .//GEN-BEGIN:_loadRetrieve_2_be
criteria.addCriteria(FormDefinitionMeta.FORM_ID, input.getFormId());
Iterator itr = uow.query(criteria).iterator();
if (itr.hasNext())
domain = (FormDefinition) itr.next();
// .//GEN-BEGIN:_loadRetrieve_3_be
if (domain == null) {
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new DomainObjectNotFoundException(FormDefinitionMeta.getLabelToken()));
throw appExps;
}
return domain;
}
Aggregations