use of org.jaffa.components.finder.StringCriteriaField in project jaffa-framework by jaffa-projects.
the class TransactionCriteria method returnQueryClause.
/**
* Returns the criteria object used for retrieving domain objects.
* @param nestedClause Minimal criteria used to retreive 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(TransactionMeta.getName());
FinderTx.addCriteria(getId(), TransactionMeta.ID, c);
FinderTx.addCriteria(getDirection(), TransactionMeta.DIRECTION, c);
FinderTx.addCriteria(getSubType(), TransactionMeta.SUB_TYPE, c);
FinderTx.addCriteria(getStatus(), TransactionMeta.STATUS, c);
FinderTx.addCriteria(getErrorMessage(), TransactionMeta.ERROR_MESSAGE, c);
FinderTx.addCriteria(getCreatedOn(), TransactionMeta.CREATED_ON, c);
FinderTx.addCriteria(getCreatedBy(), TransactionMeta.CREATED_BY, c);
FinderTx.addCriteria(getLastChangedOn(), TransactionMeta.LAST_CHANGED_ON, c);
FinderTx.addCriteria(getLastChangedBy(), TransactionMeta.LAST_CHANGED_BY, c);
FinderTx.addCriteria(getType(), TransactionMeta.TYPE, c);
String[] types = TransactionEngine.getInstance().getAccessibleTypeNames();
StringCriteriaField strCrit = new StringCriteriaField();
strCrit.setOperator(CriteriaField.RELATIONAL_IN);
if (types != null && types.length > 0) {
strCrit.setValues(types);
} else {
strCrit.setValues(new String[] { null });
}
FinderTx.addCriteria(strCrit, TransactionMeta.TYPE, c);
// Include TransactionField criteria
if (getTransactionFields() != null) {
for (TransactionFieldCriteria tfc : getTransactionFields()) {
if (tfc.getFieldName() != null) {
// SELECT
// J_TRANSACTIONS.*
// FROM
// J_TRANSACTIONS, J_TRANSACTION_FIELDS T1, J_TRANSACTION_FIELDS T2, ...
// WHERE
// J_TRANSACTIONS.SOME_FIELD='SOME_VALUE'...
// AND T1.TRANSACTION_ID = J_TRANSACTIONS.ID AND (T1.FIELD_NAME='F1') AND (T1.VALUE='V1')
// AND T2.TRANSACTION_ID = J_TRANSACTIONS.ID AND (T2.FIELD_NAME='F2') AND (T2.VALUE='V2')
// AND ...
Criteria joinCriteria = new Criteria();
joinCriteria.setTable(TransactionFieldMeta.getName());
joinCriteria.addInnerCriteria(TransactionFieldMeta.TRANSACTION_ID, TransactionMeta.ID);
joinCriteria.addCriteria(TransactionFieldMeta.FIELD_NAME, tfc.getFieldName());
FinderTx.addCriteria(tfc.getValue(), TransactionFieldMeta.VALUE, joinCriteria);
c.addAggregate(joinCriteria);
}
}
}
return c;
}
use of org.jaffa.components.finder.StringCriteriaField in project jaffa-framework by jaffa-projects.
the class TransactionAdmin method messageToTransactionStatusCriteriaField.
/**
* Converts the input CriteriaField containing Message.Status values to a new CriteriaField containing the corresponding Transaction.Status values.
*/
private static StringCriteriaField messageToTransactionStatusCriteriaField(StringCriteriaField messageStatusCriteriaField) {
StringCriteriaField transactionStatusCriteriaField = null;
if (messageStatusCriteriaField != null && messageStatusCriteriaField.getValues() != null && messageStatusCriteriaField.getValues().length > 0) {
String[] values = new String[messageStatusCriteriaField.getValues().length];
for (int i = 0; i < values.length; i++) {
Transaction.Status value = messageToTransactionStatus(messageStatusCriteriaField.getValues()[i]);
values[i] = value != null ? value.toString() : null;
}
transactionStatusCriteriaField = new StringCriteriaField(messageStatusCriteriaField.getOperator(), values);
} else {
transactionStatusCriteriaField = messageStatusCriteriaField;
}
return transactionStatusCriteriaField;
}
Aggregations