use of org.jaffa.components.finder.StringCriteriaField in project jaffa-framework by jaffa-projects.
the class GraphCriteriaFlexFieldsTest method testCriteriaClauseDomainMapped.
public void testCriteriaClauseDomainMapped() throws FrameworkException, ApplicationExceptions {
UserCriteria userCriteria = new UserCriteria();
StaticContext.initialize(userCriteria);
assertNotNull(userCriteria.getFlexCriteriaBean());
Criteria c = userCriteria.buildQueryCriteria();
assertNull(c.getCriteriaEntries());
userCriteria.getFlexCriteriaBean().set("remarks", new StringCriteriaField("Equals", "nice guy"));
c = userCriteria.buildQueryCriteria();
assertNotNull(c.getCriteriaEntries());
assertEquals(1, c.getCriteriaEntries().size());
List<Criteria.CriteriaEntry> criteriaEntries = new ArrayList<>(c.getCriteriaEntries());
assertEquals("nice guy", criteriaEntries.get(0).getValue());
assertEquals("UserRef15", criteriaEntries.get(0).getName());
}
use of org.jaffa.components.finder.StringCriteriaField in project jaffa-framework by jaffa-projects.
the class MessageViewerTx method buildBusinessEventLogDto.
/**
* Obtains the related business event logs.
*/
private void buildBusinessEventLogDto(MessageViewerInDto input, MessageViewerOutDto output, Message message) throws FrameworkException, ApplicationExceptions, JMSException {
BusinessEventLogFinderInDto inputDto = new BusinessEventLogFinderInDto();
inputDto.setMessageId(message.getStringProperty(JmsBrowser.HEADER_ORIGINAL_MESSAGE_ID) != null ? new StringCriteriaField(CriteriaField.RELATIONAL_EQUALS, message.getStringProperty(JmsBrowser.HEADER_ORIGINAL_MESSAGE_ID)) : new StringCriteriaField(CriteriaField.RELATIONAL_EQUALS, message.getJMSMessageID()));
inputDto.setMaxRecords(new Integer(10));
inputDto.setOrderByFields(new OrderByField[] { new OrderByField(BusinessEventLogMeta.LOGGED_ON, Boolean.FALSE) });
BusinessEventLogFinderOutDto businessEventLogFinderOutDto = new BusinessEventLogFinderTx().find(inputDto);
output.setBusinessEventLog(businessEventLogFinderOutDto);
}
use of org.jaffa.components.finder.StringCriteriaField in project jaffa-framework by jaffa-projects.
the class JaffaTransactionMessageService method getTransactionByFieldsAndBeginsWithFields.
/**
* Gets the Transaction that has the specified fields-values and also fields that begin with
* the specified values. If multiple beginsWith values are defined for a field, the field will be checked against
* them all.
*
* @param fields the field name/value pairs
* @param beginsWith the field name/begins-with values
* @return the Transaction that contains the specified fields with the input values
* @throws FrameworkException
*/
@Override
public Transaction getTransactionByFieldsAndBeginsWithFields(HashMap<String, String> fields, HashMap<String, String> beginsWith) throws FrameworkException {
UOW uow = null;
Transaction transaction = null;
try {
uow = new UOW();
TransactionCriteria transactionCriteria = new TransactionCriteria();
List<TransactionFieldCriteria> tranFieldCriteriaList = new ArrayList<TransactionFieldCriteria>();
// add all of the field criteria
for (Map.Entry<String, String> field : fields.entrySet()) {
TransactionFieldCriteria fieldCriteria = new TransactionFieldCriteria();
fieldCriteria.setFieldName(field.getKey());
StringCriteriaField stringCriteria = StringCriteriaField.getStringCriteriaField(StringCriteriaField.RELATIONAL_EQUALS, field.getValue(), null);
fieldCriteria.setValue(stringCriteria);
tranFieldCriteriaList.add(fieldCriteria);
}
// add all of the begins with criteria
for (Map.Entry<String, String> beginsWithField : beginsWith.entrySet()) {
TransactionFieldCriteria beginsWithCriteria = new TransactionFieldCriteria();
beginsWithCriteria.setFieldName(beginsWithField.getKey());
StringCriteriaField stringCriteria = StringCriteriaField.getStringCriteriaField(StringCriteriaField.RELATIONAL_BEGINS_WITH, beginsWithField.getValue(), null);
beginsWithCriteria.setValue(stringCriteria);
tranFieldCriteriaList.add(beginsWithCriteria);
}
// set all of the field criteria on the transaction criteria
TransactionFieldCriteria[] criteriaArray = new TransactionFieldCriteria[tranFieldCriteriaList.size()];
criteriaArray = tranFieldCriteriaList.toArray(criteriaArray);
transactionCriteria.setTransactionFields(criteriaArray);
// call the transaction service for a response to the query
TransactionService transactionService = new TransactionService();
TransactionQueryResponse response = transactionService.query(transactionCriteria);
// return a transaction from the response
for (TransactionGraph transactionGraph : response.getGraphs()) {
if ((transactionGraph != null) && (transactionGraph.getId() != null)) {
transaction = getTransaction(transactionGraph.getId());
}
}
} finally {
if (uow != null) {
uow.close();
}
}
return transaction;
}
use of org.jaffa.components.finder.StringCriteriaField in project jaffa-framework by jaffa-projects.
the class JaffaTransactionMessageService method getTransactionsByTypeSubTypeFieldsOrderBy.
/**
* Gets an ordered list of Transaction that match the input type, subType and fields.
* If more than one value is defined for a field, that field will be checked against all values to see if it
* matched any of them (they will be OR-ed).
*
* @param type the type of Transactions to return
* @param subType the subType of Transactions to return
* @param fields the fields to check the Transaction for, if multiple values are defined for a field, the
* field will be checked to see if it matches any of the values (they will be OR-ed)
* @param orderBy the fields to sort the return list by, each field has a boolean value that determines the
* direction. True for ascending and false for descending.
* @return an ordered list of Transactions that match the input type, subType and fields
* @throws FrameworkException
*/
@Override
public List<Transaction> getTransactionsByTypeSubTypeFieldsOrderBy(String type, String subType, HashMap<String, List<String>> fields, LinkedHashMap<String, Boolean> orderBy) throws FrameworkException {
List<Transaction> results = new ArrayList<Transaction>();
UOW uow = null;
try {
uow = new UOW();
Criteria c = new Criteria();
c.setTable(TransactionMeta.getName());
// query on type and subType
StringCriteriaField typeField = StringCriteriaField.getStringCriteriaField(CriteriaField.RELATIONAL_EQUALS, type, null);
StringCriteriaField subTypeField = StringCriteriaField.getStringCriteriaField(CriteriaField.RELATIONAL_EQUALS, subType, null);
FinderTx.addCriteria(typeField, TransactionMeta.TYPE, c);
FinderTx.addCriteria(subTypeField, TransactionMeta.SUB_TYPE, c);
// add the fields
for (Map.Entry<String, List<String>> entry : fields.entrySet()) {
Criteria joinCriteria = new Criteria();
joinCriteria.setTable(TransactionFieldMeta.getName());
joinCriteria.addInnerCriteria(TransactionFieldMeta.TRANSACTION_ID, TransactionMeta.ID);
// the key is the field name
joinCriteria.addCriteria(TransactionFieldMeta.FIELD_NAME, entry.getKey());
// the values are OR-ed together
AtomicCriteria ac = new AtomicCriteria();
for (String value : entry.getValue()) {
if (value == null) {
if ((ac.getCriteriaEntries() == null) || ac.getCriteriaEntries().isEmpty()) {
ac.addCriteria(TransactionFieldMeta.VALUE, Criteria.RELATIONAL_IS_NULL);
} else {
ac.addOrCriteria(TransactionFieldMeta.VALUE, Criteria.RELATIONAL_IS_NULL);
}
} else {
if ((ac.getCriteriaEntries() == null) || ac.getCriteriaEntries().isEmpty()) {
ac.addCriteria(TransactionFieldMeta.VALUE, value);
} else {
ac.addOrCriteria(TransactionFieldMeta.VALUE, value);
}
}
}
joinCriteria.addAtomic(ac);
c.addAggregate(joinCriteria);
}
// add the orderBy
for (Map.Entry<String, Boolean> entry : orderBy.entrySet()) {
int sort = Criteria.ORDER_BY_ASC;
if (entry.getValue() != null && !entry.getValue()) {
sort = Criteria.ORDER_BY_DESC;
}
c.addOrderBy(entry.getKey(), sort);
}
// add the query results to the return list
for (Object o : uow.query(c)) {
results.add((Transaction) o);
}
} finally {
if (uow != null) {
uow.close();
}
}
return results;
}
use of org.jaffa.components.finder.StringCriteriaField in project jaffa-framework by jaffa-projects.
the class AttachmentFinderInDtoTapGenTest method testGetAttachmentType.
/**
* Test method for {@link org.jaffa.components.attachment.components.attachmentfinder.dto.AttachmentFinderInDto#getAttachmentType()}.
*/
@Test
public void testGetAttachmentType() {
AttachmentFinderInDto testObject = new AttachmentFinderInDto();
StringCriteriaField setValue = new StringCriteriaField();
testObject.setAttachmentType(setValue);
StringCriteriaField getValue = testObject.getAttachmentType();
assertEquals(setValue, getValue);
}
Aggregations