本文整理匯總了Java中org.kuali.rice.core.api.criteria.OrderByField類的典型用法代碼示例。如果您正苦於以下問題:Java OrderByField類的具體用法?Java OrderByField怎麽用?Java OrderByField使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OrderByField類屬於org.kuali.rice.core.api.criteria包,在下文中一共展示了OrderByField類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: historyQuery
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
public static QueryByCriteria historyQuery(String id, DateTime asOfDate) {
Timestamp asOfTimestamp = new Timestamp(asOfDate.getMillis());
Predicate predicate =
and(
equal("id", id),
and(
or(isNull("activeFromDateValue"), lessThanOrEqual("activeFromDateValue", asOfTimestamp)),
or(isNull("activeToDateValue"), greaterThan("activeToDateValue", asOfTimestamp))
)
);
QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
criteria.setMaxResults(Integer.valueOf(1));
criteria.setPredicates(predicate);
List<OrderByField> orderByFields = new ArrayList<OrderByField>();
orderByFields.add(OrderByField.Builder.create("activeFromDateValue", OrderDirection.DESCENDING).build());
orderByFields.add(OrderByField.Builder.create("historyId", OrderDirection.DESCENDING).build());
criteria.setOrderByFields(orderByFields);
return criteria.build();
}
示例2: futureRecordQuery
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
public static QueryByCriteria futureRecordQuery(String id, DateTime asOfDate) {
Timestamp asOfTimestamp = new Timestamp(asOfDate.getMillis());
Predicate predicate =
and(
equal("id", id),
or(isNull("activeFromDateValue"), greaterThan("activeFromDateValue", asOfTimestamp))
);
QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
criteria.setMaxResults(Integer.valueOf(1));
criteria.setPredicates(predicate);
List<OrderByField> orderByFields = new ArrayList<OrderByField>();
orderByFields.add(OrderByField.Builder.create("activeFromDateValue", OrderDirection.DESCENDING).build());
orderByFields.add(OrderByField.Builder.create("historyId", OrderDirection.DESCENDING).build());
criteria.setOrderByFields(orderByFields);
return criteria.build();
}
示例3: findByRuleTemplateName
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
public RuleTemplateBo findByRuleTemplateName(String ruleTemplateName) {
if (StringUtils.isBlank(ruleTemplateName)) {
return null;
}
org.kuali.rice.core.api.criteria.QueryByCriteria.Builder builder =
org.kuali.rice.core.api.criteria.QueryByCriteria.Builder.create();
builder.setPredicates(equal("name",ruleTemplateName));
builder.setOrderByFields(OrderByField.Builder.create("name", OrderDirection.DESCENDING).build());
QueryResults<RuleTemplateBo> ruleTemplates = getDataObjectService().findMatching(RuleTemplateBo.class,builder.build());
if(ruleTemplates==null || ruleTemplates.getResults() == null || ruleTemplates.getResults().isEmpty()){
return null;
}
return (RuleTemplateBo) ruleTemplates.getResults().get(0);
}
示例4: findMatchingOrderBy
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
@Override
public <T> Collection<T> findMatchingOrderBy(Class<T> clazz, Map<String, ?> fieldValues, String sortField,
boolean sortAscending) {
OrderDirection direction = sortAscending ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
OrderByField orderBy = OrderByField.Builder.create(sortField, direction).build();
QueryResults<T> result = dataObjectService.findMatching(clazz, QueryByCriteria.Builder.andAttributes(
fieldValues).setOrderByFields(orderBy).build());
return result.getResults();
}
示例5: getByRemoteObjectId
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
/**
* @see org.kuali.rice.krad.service.NoteService#getByRemoteObjectId(java.lang.String)
*/
@Override
public List<Note> getByRemoteObjectId(String remoteObjectId) {
if (StringUtils.isBlank(remoteObjectId)) {
throw new IllegalArgumentException("The remoteObjectId must not be null or blank.");
}
QueryResults<Note> result = dataObjectService.findMatching(Note.class,
QueryByCriteria.Builder.forAttribute("remoteObjectIdentifier", remoteObjectId)
.setOrderByFields(OrderByField.Builder.create("notePostedTimestamp", OrderDirection.ASCENDING).build()
).build());
return result.getResults();
}
示例6: findByDocumentId
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
@Override
public Collection<ActionTakenValue> findByDocumentId(String documentId) {
LOG.debug("finding Action Takens by documentId " + documentId);
QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create().setPredicates(equal(DOCUMENT_ID,
documentId), equal(CURRENT_INDICATOR, Boolean.TRUE));
criteria.setOrderByFields(OrderByField.Builder.create(ACTION_DATE, OrderDirection.ASCENDING).build());
return getDataObjectService().findMatching(ActionTakenValue.class, criteria.build()).getResults();
}
示例7: findByDocumentIdIgnoreCurrentInd
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
@Override
public List<ActionTakenValue> findByDocumentIdIgnoreCurrentInd(String documentId) {
LOG.debug("finding ActionsTaken ignoring currentInd by documentId:" + documentId);
QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create().setPredicates(equal(DOCUMENT_ID,
documentId));
criteria.setOrderByFields(OrderByField.Builder.create(ACTION_DATE, OrderDirection.ASCENDING).build());
return getDataObjectService().findMatching(ActionTakenValue.class, criteria.build()).getResults();
}
示例8: fetchAllRules
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
@Override
public List<RuleBaseValues> fetchAllRules(boolean currentRules) {
org.kuali.rice.core.api.criteria.QueryByCriteria.Builder builder =
org.kuali.rice.core.api.criteria.QueryByCriteria.Builder.create();
builder.setPredicates(equal("currentInd",new Boolean(currentRules)),
equal("templateRuleInd",Boolean.FALSE));
builder.setOrderByFields(OrderByField.Builder.create("activationDate", OrderDirection.DESCENDING).build()) ;
return getDataObjectService().findMatching(RuleBaseValues.class,builder.build()).getResults();
}
示例9: findMatchingOrderBy
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
/**
* Adapts BusinessObjectService.findMatchingOrderBy calls to use the DataObjectService.
*
* @param dos the DataObjectService instance
* @param entityClass
* @param queryAttrs attribute:value pairs that will be ANDed together in the query
* @param orderByField
* @param sortAscending
* @param <T> the type of the entity class
* @return the matching entities
*/
public static <T> List<T> findMatchingOrderBy(DataObjectService dos, Class<T> entityClass, Map<String,?> queryAttrs, String orderByField, boolean sortAscending) {
QueryByCriteria.Builder critBuilder = QueryByCriteria.Builder.andAttributes(queryAttrs);
OrderDirection sortDirection = sortAscending ? OrderDirection.ASCENDING : OrderDirection.DESCENDING;
critBuilder.setOrderByFields(OrderByField.Builder.create(orderByField, sortDirection).build());
QueryResults<T> queryResults = dos.findMatching(entityClass, critBuilder.build());
if (queryResults.getResults() != null) {
return queryResults.getResults();
}
return new ArrayList<T>();
}
示例10: testFindMatchingOrderBy
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
@Test
public void testFindMatchingOrderBy() {
// create our sample data
Map.Entry<List<Object>, QueryByCriteria.Builder> fixture = createForQuery(10);
List<Object> objects = fixture.getKey();
for (Object a: objects) {
provider.save(a);
}
// get the query for our created sample data
QueryByCriteria.Builder query = fixture.getValue();
// specify the order
OrderByField.Builder nameOrderBy = OrderByField.Builder.create();
OrderByField.Builder amIdOrderBy = OrderByField.Builder.create();
nameOrderBy.setFieldName("number");
nameOrderBy.setOrderDirection(OrderDirection.ASCENDING);
amIdOrderBy.setFieldName("amId");
amIdOrderBy.setOrderDirection(OrderDirection.ASCENDING);
query.setOrderByFields(nameOrderBy.build(), amIdOrderBy.build());
// get all created objects, ordered by number column ascending order
List<SimpleAccount> ascOrder = provider.findMatching(SimpleAccount.class, query.build()).getResults();
// get all created objects, ordered by number column descending order
nameOrderBy.setOrderDirection(OrderDirection.DESCENDING);
amIdOrderBy.setOrderDirection(OrderDirection.DESCENDING);
query.setOrderByFields(nameOrderBy.build(), amIdOrderBy.build());
List<SimpleAccount> descOrder = provider.findMatching(SimpleAccount.class, query.build()).getResults();
assertEquals(ascOrder.size(), descOrder.size());
// ensure the two lists are exact opposites
if (!CollectionUtils.isEmpty(ascOrder)) {
for (int idx = 0; idx<ascOrder.size();idx++) {
assertTestObjectIdentityEquals(ascOrder.get(idx), descOrder.get((ascOrder.size() - 1) - idx));
}
}
}
示例11: testFindWithResultsWindow
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
@Test
public void testFindWithResultsWindow() {
// get all existing Simple Accounts and delete them so we have a fresh start
List<SimpleAccount> acctList = provider.findMatching(SimpleAccount.class, QueryByCriteria.Builder.create().build()).getResults();
if (CollectionUtils.isEmpty(acctList)) {
for (SimpleAccount acct : acctList) {
provider.delete(acct);
}
}
// now create our sample data
Map.Entry<List<Object>, QueryByCriteria.Builder> fixture = createForQuery(10);
List<Object> objects = fixture.getKey();
for (Object a: objects) {
provider.save(a);
}
// get the query for our created sample data
QueryByCriteria.Builder query = fixture.getValue();
// specify the order
OrderByField.Builder orderBy = OrderByField.Builder.create();
orderBy.setFieldName("number");
orderBy.setOrderDirection(OrderDirection.ASCENDING);
query.setOrderByFields(orderBy.build());
// get all created objects, ordered by number column
List<SimpleAccount> resultsAll = provider.findMatching(SimpleAccount.class, query.build()).getResults();
// now create the window, also ordered by number column
query.setStartAtIndex(2);
query.setMaxResults(5);
List<SimpleAccount> results = provider.findMatching(SimpleAccount.class, query.build()).getResults();
assertEquals(5, results.size());
assertTestObjectIdentityEquals(resultsAll.get(2), results.get(0));
assertTestObjectIdentityEquals(resultsAll.get(3), results.get(1));
assertTestObjectIdentityEquals(resultsAll.get(4), results.get(2));
assertTestObjectIdentityEquals(resultsAll.get(5), results.get(3));
assertTestObjectIdentityEquals(resultsAll.get(6), results.get(4));
}
示例12: forRowResults
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
/** gets results where the actual rows are requested. */
private <T> GenericQueryResults<T> forRowResults(final Class<T> queryClass, final QueryByCriteria criteria, final Criteria ojbCriteria, CountFlag flag, LookupCustomizer.Transform<T, T> transform) {
final org.apache.ojb.broker.query.QueryByCriteria ojbQuery = QueryFactory.newQuery(queryClass, ojbCriteria);
final GenericQueryResults.Builder<T> results = GenericQueryResults.Builder.<T>create();
if (flag == CountFlag.INCLUDE) {
results.setTotalRowCount(getPersistenceBrokerTemplate().getCount(ojbQuery));
}
//ojb's is 1 based, our query api is zero based
final int startAtIndex = criteria.getStartAtIndex() != null ? criteria.getStartAtIndex() + 1 : 1;
ojbQuery.setStartAtIndex(startAtIndex);
if (criteria.getMaxResults() != null) {
//not subtracting one from MaxResults in order to retrieve
//one extra row so that the MoreResultsAvailable field can be set
ojbQuery.setEndAtIndex(criteria.getMaxResults() + startAtIndex);
}
if (CollectionUtils.isNotEmpty(criteria.getOrderByFields())) {
for (OrderByField orderByField : criteria.getOrderByFields()) {
if (OrderDirection.ASCENDING.equals(orderByField.getOrderDirection())) {
ojbQuery.addOrderBy(orderByField.getFieldName(), true);
} else if (OrderDirection.DESCENDING.equals(orderByField.getOrderDirection())) {
ojbQuery.addOrderBy(orderByField.getFieldName(), false);
}
}
}
@SuppressWarnings("unchecked")
final List<T> rows = new ArrayList<T>(getPersistenceBrokerTemplate().getCollectionByQuery(ojbQuery));
if (criteria.getMaxResults() != null && rows.size() > criteria.getMaxResults()) {
results.setMoreResultsAvailable(true);
//remove the extra row that was returned
rows.remove(criteria.getMaxResults().intValue());
}
results.setResults(transformResults(rows, transform));
return results.build();
}
示例13: addOrderBy
import org.kuali.rice.core.api.criteria.OrderByField; //導入依賴的package包/類
/**
* Adds one or more order by clauses to the criteria
*
* @param orderByFields
* @param parent the pareent criteria to add to
*/
protected void addOrderBy(List<OrderByField> orderByFields, C parent) {
for (OrderByField field : orderByFields) {
addOrderBy(parent, field.getFieldName(), OrderDirection.ASCENDING.equals(field.getOrderDirection()));
}
}