Search in sources :

Example 6 with StringCriteriaField

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;
}
Also used : GraphCriteria(org.jaffa.soa.graph.GraphCriteria) Criteria(org.jaffa.persistence.Criteria) StringCriteriaField(org.jaffa.components.finder.StringCriteriaField)

Example 7 with StringCriteriaField

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;
}
Also used : Transaction(org.jaffa.transaction.domain.Transaction) StringCriteriaField(org.jaffa.components.finder.StringCriteriaField)

Aggregations

StringCriteriaField (org.jaffa.components.finder.StringCriteriaField)7 ArrayList (java.util.ArrayList)3 Criteria (org.jaffa.persistence.Criteria)3 Transaction (org.jaffa.transaction.domain.Transaction)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 OrderByField (org.jaffa.components.finder.OrderByField)2 BusinessEventLogFinderInDto (org.jaffa.modules.messaging.components.businesseventlogfinder.dto.BusinessEventLogFinderInDto)2 BusinessEventLogFinderTx (org.jaffa.modules.messaging.components.businesseventlogfinder.tx.BusinessEventLogFinderTx)2 UOW (org.jaffa.persistence.UOW)2 TransactionCriteria (org.jaffa.transaction.apis.data.TransactionCriteria)2 TransactionFieldCriteria (org.jaffa.transaction.apis.data.TransactionFieldCriteria)2 LinkedList (java.util.LinkedList)1 List (java.util.List)1 BusinessEventLogFinderOutDto (org.jaffa.modules.messaging.components.businesseventlogfinder.dto.BusinessEventLogFinderOutDto)1 AtomicCriteria (org.jaffa.persistence.AtomicCriteria)1 UserCriteria (org.jaffa.rules.testmodels.UserCriteria)1 GraphCriteria (org.jaffa.soa.graph.GraphCriteria)1 TransactionService (org.jaffa.transaction.apis.TransactionService)1