use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.
the class AttachmentCriteria method returnQueryClause.
/**
* Returns the criteria object used for retrieving domain objects.
* @param nestedClause Minimal criteria used to retrieve the nested object. Will be null for the root query.
* @return the criteria object used for retrieving domain objects.
*/
@Override
public Criteria returnQueryClause(Criteria nestedClause) {
Criteria c = super.returnQueryClause(nestedClause);
c.setTable(AttachmentMeta.getName());
FinderTx.addCriteria(getAttachmentId(), AttachmentMeta.ATTACHMENT_ID, c);
FinderTx.addCriteria(getSerializedKey(), AttachmentMeta.SERIALIZED_KEY, c);
FinderTx.addCriteria(getOriginalFileName(), AttachmentMeta.ORIGINAL_FILE_NAME, c);
FinderTx.addCriteria(getAttachmentType(), AttachmentMeta.ATTACHMENT_TYPE, c);
FinderTx.addCriteria(getContentType(), AttachmentMeta.CONTENT_TYPE, c);
FinderTx.addCriteria(getDescription(), AttachmentMeta.DESCRIPTION, c);
FinderTx.addCriteria(getRemarks(), AttachmentMeta.REMARKS, c);
FinderTx.addCriteria(getSupercededBy(), AttachmentMeta.SUPERCEDED_BY, c);
FinderTx.addCriteria(getCreatedOn(), AttachmentMeta.CREATED_ON, c);
FinderTx.addCriteria(getCreatedBy(), AttachmentMeta.CREATED_BY, c);
FinderTx.addCriteria(getLastChangedOn(), AttachmentMeta.LAST_CHANGED_ON, c);
FinderTx.addCriteria(getLastChangedBy(), AttachmentMeta.LAST_CHANGED_BY, c);
return c;
}
use of org.jaffa.persistence.Criteria in project jaffa-framework by jaffa-projects.
the class AttachmentFinderTx method buildCriteria.
// .//GEN-END:_find_3_be
// .//GEN-BEGIN:_buildCriteria_1_be
private Criteria buildCriteria(AttachmentFinderInDto input, UOW uow) {
Criteria criteria = new Criteria();
criteria.setTable(AttachmentMeta.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.getAttachmentId(), AttachmentMeta.ATTACHMENT_ID, criteria);
FinderTx.addCriteria(input.getSerializedKey(), AttachmentMeta.SERIALIZED_KEY, criteria);
FinderTx.addCriteria(input.getOriginalFileName(), AttachmentMeta.ORIGINAL_FILE_NAME, criteria);
FinderTx.addCriteria(input.getAttachmentType(), AttachmentMeta.ATTACHMENT_TYPE, criteria);
FinderTx.addCriteria(input.getContentType(), AttachmentMeta.CONTENT_TYPE, criteria);
FinderTx.addCriteria(input.getDescription(), AttachmentMeta.DESCRIPTION, criteria);
FinderTx.addCriteria(input.getRemarks(), AttachmentMeta.REMARKS, criteria);
FinderTx.addCriteria(input.getSupercededBy(), AttachmentMeta.SUPERCEDED_BY, criteria);
FinderTx.addCriteria(input.getCreatedOn(), AttachmentMeta.CREATED_ON, criteria);
FinderTx.addCriteria(input.getCreatedBy(), AttachmentMeta.CREATED_BY, criteria);
FinderTx.addCriteria(input.getLastChangedOn(), AttachmentMeta.LAST_CHANGED_ON, criteria);
FinderTx.addCriteria(input.getLastChangedBy(), AttachmentMeta.LAST_CHANGED_BY, 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 AttachmentLookupTx method find.
// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_find_1_be
/**
* Searches for Attachment 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 AttachmentLookupOutDto find(AttachmentLookupInDto 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
AttachmentLookupOutDto 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 AttachmentLookupTx method buildCriteria.
// .//GEN-END:_find_3_be
// .//GEN-BEGIN:_buildCriteria_1_be
private Criteria buildCriteria(AttachmentLookupInDto input, UOW uow) {
Criteria criteria = new Criteria();
criteria.setTable(AttachmentMeta.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.getAttachmentId(), AttachmentMeta.ATTACHMENT_ID, criteria);
FinderTx.addCriteria(input.getSerializedKey(), AttachmentMeta.SERIALIZED_KEY, criteria);
FinderTx.addCriteria(input.getOriginalFileName(), AttachmentMeta.ORIGINAL_FILE_NAME, criteria);
FinderTx.addCriteria(input.getAttachmentType(), AttachmentMeta.ATTACHMENT_TYPE, criteria);
FinderTx.addCriteria(input.getContentType(), AttachmentMeta.CONTENT_TYPE, criteria);
FinderTx.addCriteria(input.getDescription(), AttachmentMeta.DESCRIPTION, criteria);
FinderTx.addCriteria(input.getRemarks(), AttachmentMeta.REMARKS, criteria);
FinderTx.addCriteria(input.getSupercededBy(), AttachmentMeta.SUPERCEDED_BY, criteria);
FinderTx.addCriteria(input.getCreatedOn(), AttachmentMeta.CREATED_ON, criteria);
FinderTx.addCriteria(input.getCreatedBy(), AttachmentMeta.CREATED_BY, criteria);
FinderTx.addCriteria(input.getLastChangedOn(), AttachmentMeta.LAST_CHANGED_ON, criteria);
FinderTx.addCriteria(input.getLastChangedBy(), AttachmentMeta.LAST_CHANGED_BY, 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 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;
}
}
Aggregations