本文整理汇总了Java中org.apache.ojb.broker.query.Criteria.addLike方法的典型用法代码示例。如果您正苦于以下问题:Java Criteria.addLike方法的具体用法?Java Criteria.addLike怎么用?Java Criteria.addLike使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ojb.broker.query.Criteria
的用法示例。
在下文中一共展示了Criteria.addLike方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInvoicesToExtractForVendor
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
/**
* @see org.kuali.ole.module.purap.document.dataaccess.InvoiceDao#getInvoicesToExtractForVendor(String,
* org.kuali.ole.module.purap.util.VendorGroupingHelper, Date)
*/
public Collection<InvoiceDocument> getInvoicesToExtractForVendor(String campusCode, VendorGroupingHelper vendor, Date onOrBeforeInvoicePayDate) {
LOG.debug("getInvoicesToExtract() started");
Criteria criteria = new Criteria();
criteria.addEqualTo("processingCampusCode", campusCode);
//criteria.addIn(PurapPropertyConstants.STATUS_CODE, statuses);
criteria.addIsNull("extractedTimestamp");
criteria.addEqualTo("holdIndicator", Boolean.FALSE);
Criteria c1 = new Criteria();
c1.addLessOrEqualThan("invoicePayDate", onOrBeforeInvoicePayDate);
Criteria c2 = new Criteria();
c2.addEqualTo("immediatePaymentIndicator", Boolean.TRUE);
c1.addOrCriteria(c2);
criteria.addAndCriteria(c1);
criteria.addEqualTo("vendorHeaderGeneratedIdentifier", vendor.getVendorHeaderGeneratedIdentifier());
criteria.addEqualTo("vendorDetailAssignedIdentifier", vendor.getVendorDetailAssignedIdentifier());
criteria.addEqualTo("vendorCountryCode", vendor.getVendorCountry());
criteria.addLike("vendorPostalCode", vendor.getVendorPostalCode() + "%");
return getPersistenceBrokerTemplate().getCollectionByQuery(new QueryByCriteria(InvoiceDocument.class, criteria));
}
示例2: testMultipleClassPath_2b
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
public void testMultipleClassPath_2b()
{
Criteria criteria = new Criteria();
criteria.addLike("headline", "SAL%");
criteria.addEqualTo("qualifiers.importance", "unimportant");
criteria.addEqualTo("qualifiers.name", "Sellers");
//criteria.addPathClass("qualifiers", Qualifier.class);
criteria.addPathClass("qualifiers", TopicExt.class);
criteria.addPathClass("qualifiers", Topic.class);
QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
List content = (List) broker.getCollectionByQuery(query);
assertEquals(1, content.size());
assertEquals(11, ((Paper)content.get(0)).getId());
assertNotNull(((Paper)content.get(0)).getQualifiers());
assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
}
示例3: testQueryMN_Alias1
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
public void testQueryMN_Alias1() throws Exception
{
Criteria crit1 = new Criteria();
Criteria crit2 = new Criteria();
QueryByCriteria q;
Collection result;
broker.clearCache();
// get persons working for projects OJB and SODA
crit1.addLike("projects.title", "OJB%");
crit1.setAlias("alias1");
crit2.addLike("projects.title", "SODA%");
crit2.setAlias("alias2");
crit1.addAndCriteria(crit2);
q = QueryFactory.newQuery(Person.class, crit1, true);
result = broker.getCollectionByQuery(q);
assertNotNull(result);
assertTrue(result.size() == 2); // bob, tom
}
示例4: testSubQuery1
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
/**
* test Subquery get all articles with price > avg(price) PROBLEM:
* avg(price) is NOT extent aware !!
* <p/>
* test may fail if db does not support sub queries
*/
public void testSubQuery1()
{
ReportQueryByCriteria subQuery;
Criteria subCrit = new Criteria();
Criteria crit = new Criteria();
subCrit.addLike("articleName", "A%");
subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
subQuery.setAttributes(new String[]{"avg(price)"});
crit.addGreaterOrEqualThan("price", subQuery);
Query q = QueryFactory.newQuery(Article.class, crit);
Collection results = broker.getCollectionByQuery(q);
assertNotNull(results);
assertTrue(results.size() > 0);
}
示例5: testNullCriteria
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
/**
* test Null Criteria
*/
public void testNullCriteria()
{
String name = "testNullCriteria_" + System.currentTimeMillis();
Person p = new Person();
p.setLastname(name);
broker.beginTransaction();
broker.store(p);
broker.commitTransaction();
Criteria crit = new Criteria();
crit.addIsNull("firstname");
Criteria crit2 = new Criteria();
crit2.addLike("lastname", name);
crit.addAndCriteria(crit2);
Query q = QueryFactory.newQuery(Person.class, crit);
Collection results = broker.getCollectionByQuery(q);
assertNotNull(results);
assertEquals(1, results.size());
}
示例6: testMultipleClassPath_1a
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
public void testMultipleClassPath_1a()
{
Criteria criteria = new Criteria();
criteria.addLike("headline", "SAL%");
criteria.addEqualTo("qualifiers.importance", "unimportant");
criteria.addEqualTo("qualifiers.name", "Sellers");
QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
query.addPathClass("qualifiers", Qualifier.class);
query.addPathClass("qualifiers", Topic.class);
query.addPathClass("qualifiers", TopicExt.class);
List content = (List) broker.getCollectionByQuery(query);
assertEquals(1, content.size());
assertEquals(11, ((Paper)content.get(0)).getId());
assertNotNull(((Paper)content.get(0)).getQualifiers());
assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
}
示例7: processRootCriteria
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
protected void processRootCriteria(Criteria rootCriteria, Class<? extends HrBusinessObjectContract> businessObjectClass, Map formProps, Map<String, String> removedProperties) {
// call super class method
super.processRootCriteria(rootCriteria, businessObjectClass, formProps, removedProperties);
// inject subquery for group key based on user-entered location and institution
String institutionVal = removedProperties.get(INSTITUTION_PARAM_NAME);
String locationVal = removedProperties.get(LOCATION_PARAM_NAME);
if(StringUtils.isNotBlank(institutionVal) || StringUtils.isNotBlank(locationVal)) {
// create the subquery criteria and conditionally add 'like' checks for institution and location
Criteria subQueryCriteria = new Criteria();
if(StringUtils.isNotBlank(institutionVal)) {
String institutionName = getDbPlatform().getUpperCaseFunction() + "(" + INSTITUTION_PARAM_NAME + ")";
subQueryCriteria.addLike(institutionName, institutionVal.toUpperCase());
}
if(StringUtils.isNotBlank(locationVal)) {
String locationName = getDbPlatform().getUpperCaseFunction() + "(" + LOCATION_PARAM_NAME + ")";
subQueryCriteria.addLike(locationName, locationVal.toUpperCase());
}
// create the subquery for the grp key BO's table using the above criteria, and set the 'select' to be the grp key code column
ReportQueryByCriteria subQuery = QueryFactory.newReportQuery(HrGroupKeyBo.class, subQueryCriteria);
subQuery.setAttributes(new String[]{GRP_KEY_PARAM_NAME});
// finally constrain the root criteria to grp key codes only within those found by the subquery
rootCriteria.addIn(GRP_KEY_PARAM_NAME, subQuery);
}
}
示例8: addSingleValuePredicate
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
/** adds a single valued predicate to a Criteria. */
private void addSingleValuePredicate(SingleValuedPredicate p, Criteria parent) {
final Object value = getVal(p.getValue());
final String pp = p.getPropertyPath();
if (p instanceof EqualPredicate) {
parent.addEqualTo(pp, value);
} else if (p instanceof EqualIgnoreCasePredicate) {
parent.addEqualTo(genUpperFunc(pp), ((String) value).toUpperCase());
} else if (p instanceof GreaterThanOrEqualPredicate) {
parent.addGreaterOrEqualThan(pp, value);
} else if (p instanceof GreaterThanPredicate) {
parent.addGreaterThan(pp, value);
} else if (p instanceof LessThanOrEqualPredicate) {
parent.addLessOrEqualThan(pp, value);
} else if (p instanceof LessThanPredicate) {
parent.addLessThan(pp, value);
} else if (p instanceof LikePredicate) {
//no need to convert * or ? since ojb handles the conversion/escaping
parent.addLike(genUpperFunc(pp), ((String) value).toUpperCase());
} else if (p instanceof NotEqualPredicate) {
parent.addNotEqualTo(pp, value);
} else if (p instanceof NotEqualIgnoreCasePredicate) {
parent.addNotEqualTo(genUpperFunc(pp), ((String) value).toUpperCase());
} else if (p instanceof NotLikePredicate) {
parent.addNotLike(pp, value);
} else {
throw new UnsupportedPredicateException(p);
}
}
示例9: getSearchResults
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
public List<CalendarEntryBo> getSearchResults(String calendarName, String calendarTypes, LocalDate fromBeginDate, LocalDate toBeginDate, LocalDate fromEndDate, LocalDate toEndDate) {
Criteria crit = new Criteria();
List<CalendarEntryBo> results = new ArrayList<CalendarEntryBo>();
// for either pay or leave (not both!) get all the calendars that match
if (!StringUtils.equals(calendarTypes,"")) {
List<Calendar> calendars = HrServiceLocator.getCalendarService().getCalendars(calendarName, calendarTypes, null, null);
List<String> hrCalendarIdList = new ArrayList<String>();
for (Calendar cal : calendars) {
hrCalendarIdList.add(cal.getHrCalendarId());
}
if (hrCalendarIdList.isEmpty()) { //no calendar with that combination of name and type
return results;
} else {
crit.addIn("hrCalendarId", hrCalendarIdList);
}
}
if (!StringUtils.equals(calendarName,"")){
crit.addLike("UPPER(calendarName)", calendarName.toUpperCase());
}
if (fromBeginDate != null) {
crit.addGreaterOrEqualThan("beginPeriodDateTime", fromBeginDate.toDate());
}
if (toBeginDate != null) {
crit.addLessOrEqualThan("beginPeriodDateTime", toBeginDate.toDate());
}
if (fromEndDate != null) {
crit.addGreaterOrEqualThan("endPeriodDateTime", fromEndDate.toDate());
}
if (toEndDate != null){
crit.addLessOrEqualThan("endPeriodDateTime", toEndDate.toDate());
}
Query query = QueryFactory.newQuery(CalendarEntryBo.class, crit);
results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query));
return results;
}
示例10: testAutoRefreshTrue
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
public void testAutoRefreshTrue()
{
String pkSuffix = "_" + System.currentTimeMillis();
ObjectReferenceDescriptor ord_A = null;
ObjectReferenceDescriptor ord_B = null;
ClassDescriptor cld_A = broker.getClassDescriptor(BidirectionalAssociationObjectA.class);
ord_A = cld_A.getObjectReferenceDescriptorByName("relatedB");
ClassDescriptor cld_B = broker.getClassDescriptor(BidirectionalAssociationObjectB.class);
ord_B = cld_B.getObjectReferenceDescriptorByName("relatedA");
boolean oldA = ord_A.isRefresh();
boolean oldB = ord_B.isRefresh();
try
{
ord_A.setRefresh(true);
ord_B.setRefresh(true);
createWithUpdate(pkSuffix);
Criteria crit = new Criteria();
crit.addLike("pk", "%" + pkSuffix);
Query query = QueryFactory.newQuery(BidirectionalAssociationObjectB.class, crit);
Collection result = broker.getCollectionByQuery(query);
assertEquals(1, result.size());
}
finally
{
if(ord_A != null) ord_A.setRefresh(oldA);
if(ord_B != null) ord_B.setRefresh(oldB);
}
}
示例11: testQueryMN_Alias2
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
public void testQueryMN_Alias2() throws Exception
{
Criteria crit1 = new Criteria();
Criteria crit2 = new Criteria();
QueryByCriteria q;
Collection result1;
Collection result2;
broker.clearCache();
// get persons working for projects OJB (alias should have no effect)
crit1.setAlias("myAlias");
crit1.addLike("firstname", "%o%");
crit1.addLike("projects.title", "OJB%");
q = QueryFactory.newQuery(Person.class, crit1, true);
result1 = broker.getCollectionByQuery(q);
assertNotNull(result1);
assertTrue(result1.size() == 2); // bob, tom
// WITHOUT ALIAS
// get persons working for projects OJB
crit2.addLike("firstname", "%o%");
crit2.addLike("projects.title", "OJB%");
q = QueryFactory.newQuery(Person.class, crit2, true);
result2 = broker.getCollectionByQuery(q);
assertNotNull(result2);
assertTrue(result2.size() == 2); // bob, tom
}
示例12: testReportQueryAlias
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
/**
* Test ReportQuery and Alias
*/
public void testReportQueryAlias()
{
ArrayList list = new java.util.ArrayList();
Criteria crit1 = new Criteria();
crit1.setAlias("NAMES");
crit1.addLike("upper(allArticlesInGroup.articleName)", "F%");
Criteria crit2 = new Criteria();
crit2.setAlias("STOCKS");
crit2.addGreaterOrEqualThan("allArticlesInGroup.stock", new Integer(110));
crit1.addAndCriteria(crit2);
ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroup.class, crit1);
q.setAttributes(new String[]{"groupId", "groupName", "STOCKS.allArticlesInGroup.articleName",
"NAMES.allArticlesInGroup.articleName", "NAMES.allArticlesInGroup.stock"});
// Due to AliasPrefixes ArticleName is taken from A2 and A1, Stock from A1,
// SELECT A0.Kategorie_Nr,A0.KategorieName,A2.Artikelname,A1.Artikelname,A1.Lagerbestand FROM
Iterator iter = broker.getReportQueryIteratorByQuery(q);
while(iter.hasNext())
{
list.add(iter.next());
}
// ProductGroup 4 with it's Articles
assertEquals("check size", 1, list.size());
}
示例13: addCriteria
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
/**
* Adds to the criteria object based on the property type and any query characters given.
*/
private void addCriteria(String propertyName, String propertyValue, Class propertyType, boolean caseInsensitive, boolean treatWildcardsAndOperatorsAsLiteral, Criteria criteria) {
if (!treatWildcardsAndOperatorsAsLiteral && StringUtils.contains(propertyValue, SearchOperator.OR.op())) {
addOrCriteria(propertyName, propertyValue, propertyType, caseInsensitive, criteria);
return;
}
if (!treatWildcardsAndOperatorsAsLiteral && StringUtils.contains(propertyValue, SearchOperator.AND.op())) {
addAndCriteria(propertyName, propertyValue, propertyType, caseInsensitive, criteria);
return;
}
if (StringUtils.equalsIgnoreCase(propertyValue, SearchOperator.NULL.op()) || StringUtils.equalsIgnoreCase(propertyValue, SearchOperator.NOT_NULL.op())) {
// KULRICE-6846 null Lookup criteria causes sql exception
if (StringUtils.contains(propertyValue, SearchOperator.NOT.op())) {
criteria.addNotNull(propertyName);
}
else {
criteria.addIsNull(propertyName);
}
}
else if (TypeUtils.isStringClass(propertyType)) {
// KULRICE-85 : made string searches case insensitive - used new DBPlatform function to force strings to upper case
if ( caseInsensitive ) {
propertyName = getDbPlatform().getUpperCaseFunction() + "(" + propertyName + ")";
propertyValue = propertyValue.toUpperCase();
}
if (!treatWildcardsAndOperatorsAsLiteral && StringUtils.contains(propertyValue, SearchOperator.NOT.op())) {
addNotCriteria(propertyName, propertyValue, propertyType, caseInsensitive, criteria);
} else if (
!treatWildcardsAndOperatorsAsLiteral && propertyValue != null && (
StringUtils.contains(propertyValue, SearchOperator.BETWEEN.op())
|| propertyValue.startsWith(">")
|| propertyValue.startsWith("<") ) ) {
addStringRangeCriteria(propertyName, propertyValue, criteria);
} else {
if (treatWildcardsAndOperatorsAsLiteral) {
propertyValue = StringUtils.replace(propertyValue, "*", "\\*");
}
criteria.addLike(propertyName, propertyValue);
}
} else if (TypeUtils.isIntegralClass(propertyType) || TypeUtils.isDecimalClass(propertyType) ) {
addNumericRangeCriteria(propertyName, propertyValue, treatWildcardsAndOperatorsAsLiteral, criteria);
} else if (TypeUtils.isTemporalClass(propertyType)) {
addDateRangeCriteria(propertyName, propertyValue, treatWildcardsAndOperatorsAsLiteral, criteria);
} else if (TypeUtils.isBooleanClass(propertyType)) {
criteria.addEqualTo(propertyName, ObjectUtils.clean(propertyValue));
} else {
LOG.error("not adding criterion for: " + propertyName + "," + propertyType + "," + propertyValue);
}
}
示例14: getJobs
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public List<JobBo> getJobs(String principalId, String jobNumber, String dept, String positionNumber, String hrPayType, LocalDate fromEffdt, LocalDate toEffdt,
String active, String showHistory) {
List<JobBo> results = new ArrayList<JobBo>();
Criteria root = new Criteria();
if (StringUtils.isNotBlank(principalId)) {
root.addLike("UPPER(principalId)", principalId.toUpperCase()); // KPME-2695 in case principal id is not a number
}
if (StringUtils.isNotBlank(jobNumber)) {
root.addLike("jobNumber", jobNumber);
}
if (StringUtils.isNotBlank(dept)) {
root.addLike("dept", dept);
}
if (StringUtils.isNotBlank(positionNumber)) {
root.addLike("positionNumber", positionNumber);
}
if (StringUtils.isNotBlank(hrPayType)) {
root.addLike("UPPER(hrPayType)", hrPayType.toUpperCase()); // KPME-2695
}
Criteria effectiveDateFilter = new Criteria();
if (fromEffdt != null) {
effectiveDateFilter.addGreaterOrEqualThan("effectiveDate", fromEffdt.toDate());
}
if (toEffdt != null) {
effectiveDateFilter.addLessOrEqualThan("effectiveDate", toEffdt.toDate());
}
if (fromEffdt == null && toEffdt == null) {
effectiveDateFilter.addLessOrEqualThan("effectiveDate", LocalDate.now().toDate());
}
root.addAndCriteria(effectiveDateFilter);
if (StringUtils.isNotBlank(active)) {
Criteria activeFilter = new Criteria();
if (StringUtils.equals(active, "Y")) {
activeFilter.addEqualTo("active", true);
} else if (StringUtils.equals(active, "N")) {
activeFilter.addEqualTo("active", false);
}
root.addAndCriteria(activeFilter);
}
if (StringUtils.equals(showHistory, "N")) {
ImmutableList<String> fields = new ImmutableList.Builder<String>()
.add("principalId")
.add("jobNumber")
.add("dept")
.add("positionNumber")
.add("hrPayType")
.build();
root.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQueryWithFilter(JobBo.class, effectiveDateFilter, JobBo.BUSINESS_KEYS, false));
root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(JobBo.class, JobBo.BUSINESS_KEYS, false));
}
Query query = QueryFactory.newQuery(JobBo.class, root);
results.addAll(getPersistenceBrokerTemplate().getCollectionByQuery(query));
return results;
}
示例15: getEdoCandidateList
import org.apache.ojb.broker.query.Criteria; //导入方法依赖的package包/类
public List<EdoCandidateBo> getEdoCandidateList(String principalName, String groupKeyCode, LocalDate fromEffdt, LocalDate toEffdt, String active, String showHistory){
List<EdoCandidateBo> candidateLists = new LinkedList<EdoCandidateBo>();
Criteria root = new Criteria();
if (StringUtils.isNotEmpty(principalName)
&& !ValidationUtils.isWildCard(principalName)) {
root.addLike("UPPER(principalName)", principalName.toUpperCase());
}
if (StringUtils.isNotEmpty(groupKeyCode)) {
root.addLike("UPPER(groupKeyCode)", groupKeyCode.toUpperCase());
}
Criteria effectiveDateFilter = new Criteria();
if (fromEffdt != null) {
effectiveDateFilter.addGreaterOrEqualThan("effectiveDate", fromEffdt.toDate());
}
if (toEffdt != null) {
effectiveDateFilter.addLessOrEqualThan("effectiveDate", toEffdt.toDate());
}
if (fromEffdt == null && toEffdt == null) {
effectiveDateFilter.addLessOrEqualThan("effectiveDate", LocalDate.now().toDate());
}
root.addAndCriteria(effectiveDateFilter);
if (StringUtils.isNotBlank(active)) {
Criteria activeFilter = new Criteria();
if (StringUtils.equals(active, "Y")) {
activeFilter.addEqualTo("active", true);
} else if (StringUtils.equals(active, "N")) {
activeFilter.addEqualTo("active", false);
}
root.addAndCriteria(activeFilter);
}
if (StringUtils.equals(showHistory, "N")) {
root.addEqualTo("effectiveDate", OjbSubQueryUtil.getEffectiveDateSubQueryWithFilter(EdoCandidateBo.class, effectiveDateFilter, EdoCandidateBo.BUSINESS_KEYS , false));
root.addEqualTo("timestamp", OjbSubQueryUtil.getTimestampSubQuery(EdoCandidateBo.class, EdoCandidateBo.BUSINESS_KEYS , false));
}
Query query = QueryFactory.newQuery(EdoCandidateBo.class, root);
Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
if (!c.isEmpty())
candidateLists.addAll(c);
return candidateLists;
}