本文整理汇总了Java中com.liferay.portal.kernel.dao.orm.Criterion类的典型用法代码示例。如果您正苦于以下问题:Java Criterion类的具体用法?Java Criterion怎么用?Java Criterion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Criterion类属于com.liferay.portal.kernel.dao.orm包,在下文中一共展示了Criterion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeDynamicQuery
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
public static List<?> executeDynamicQuery(
Service service, Criterion criterion, Projection projection,
List<Order> orders)
throws Exception {
DynamicQuery query = service.newDynamicQuery();
if (projection != null) {
query.setProjection(projection);
}
if (orders != null) {
for (Order order : orders) {
query.addOrder(order);
}
}
if (criterion != null) {
query.add(criterion);
}
return service.executeDynamicQuery(query);
}
示例2: count
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
@Override
public long count(Criterion criterion) {
try {
List<?> list = executeDynamicQuery(
criterion, ProjectionFactoryUtil.rowCount());
if (list != null) {
return (Long)list.get(0);
}
}
catch (Exception e) {
_log.error(
"Error executing count for " + getName() + ": " +
e.getMessage());
}
return -1;
}
示例3: getFilteredModel
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
@Override
public Model getFilteredModel(Criterion criterion, String nameSuffix) {
if (criterion == null) {
return this;
}
if (count(criterion)==-1) {
return null;
}
ModelWrapper modelWrapper = new ModelWrapper(this);
modelWrapper.setCriterion(criterion);
if (Validator.isNotNull(nameSuffix)) {
modelWrapper.setNameSuffix(nameSuffix);
}
return modelWrapper;
}
示例4: getMostUsedSearchStringNotNull
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
public List<Logging> getMostUsedSearchStringNotNull() {
try {
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Logging.class);
Criterion criterion = RestrictionsFactoryUtil.not(RestrictionsFactoryUtil.like("searchString", "null"));
dynamicQuery.add(criterion);
Order defaultOrder = OrderFactoryUtil.desc("passel");
dynamicQuery.addOrder(defaultOrder);
return dynamicQuery(dynamicQuery);
} catch (SystemException e) {
e.printStackTrace();
}
return null;
}
示例5: getMostViewdApplications
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
public List<Application> getMostViewdApplications() {
try {
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Application.class);
Criterion criterion = RestrictionsFactoryUtil.gt("detailsViewed", new Long(0));
dynamicQuery.add(criterion);
Order defaultOrder = OrderFactoryUtil.desc("detailsViewed");
dynamicQuery.addOrder(defaultOrder);
return dynamicQuery(dynamicQuery);
} catch (SystemException e) {
e.printStackTrace();
}
return null;
}
示例6: getMostClickedApplications
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
public List<Application> getMostClickedApplications() {
try {
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Application.class);
Criterion criterion = RestrictionsFactoryUtil.gt("linkClicked", new Long(0));
dynamicQuery.add(criterion);
Order defaultOrder = OrderFactoryUtil.desc("linkClicked");
dynamicQuery.addOrder(defaultOrder);
return dynamicQuery(dynamicQuery);
} catch (SystemException e) {
e.printStackTrace();
}
return null;
}
示例7: getRelAppIds
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
public List<Long> getRelAppIds(long appId) throws SystemException {
List<Long> result = new ArrayList<Long>();
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(RelatedApplications.class);
Criterion criterionOr = null;
criterionOr = RestrictionsFactoryUtil.or(RestrictionsFactoryUtil.eq("applicationId", appId), RestrictionsFactoryUtil.eq("applicationId2", appId));
dynamicQuery.add(criterionOr);
List<RelatedApplications> relatedApplicationsList = dynamicQuery(dynamicQuery);
for (RelatedApplications relatedApplications: relatedApplicationsList) {
if (relatedApplications.getApplicationId() == appId && !result.contains(relatedApplications.getApplicationId2() )) {
result.add(relatedApplications.getApplicationId2());
}
if (relatedApplications.getApplicationId2() == appId && !result.contains(relatedApplications.getApplicationId() )) {
result.add(relatedApplications.getApplicationId());
}
}
return result;
}
示例8: getPreviusModule
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
public Module getPreviusModule(Module theModule) throws SystemException {
ClassLoader classLoader = (ClassLoader) PortletBeanLocatorUtil.locate(ClpSerializer.getServletContextName(), "portletClassLoader");
DynamicQuery dq=DynamicQueryFactoryUtil.forClass(Module.class, classLoader);
Criterion criterion=PropertyFactoryUtil.forName("ordern").lt(theModule.getOrdern());
dq.add(criterion);
criterion=PropertyFactoryUtil.forName("groupId").eq(theModule.getGroupId());
dq.add(criterion);
Order createOrder=OrderFactoryUtil.getOrderFactory().desc("ordern");
dq.addOrder(createOrder);
@SuppressWarnings("unchecked")
List<Module> modulesp=(List<Module>)moduleLocalService.dynamicQuery(dq,0,1);
if(modulesp!=null&& modulesp.size()>0)
{
return modulesp.get(0);
}
else
{
return null;
}
}
示例9: getNextModule
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
public Module getNextModule(Module theModule) throws SystemException {
ClassLoader classLoader = (ClassLoader) PortletBeanLocatorUtil.locate(ClpSerializer.getServletContextName(), "portletClassLoader");
DynamicQuery dq=DynamicQueryFactoryUtil.forClass(Module.class, classLoader);
Criterion criterion=PropertyFactoryUtil.forName("ordern").gt(theModule.getOrdern());
dq.add(criterion);
criterion=PropertyFactoryUtil.forName("groupId").eq(theModule.getGroupId());
dq.add(criterion);
Order createOrder=OrderFactoryUtil.getOrderFactory().asc("ordern");
dq.addOrder(createOrder);
@SuppressWarnings("unchecked")
List<Module> modulesp=(List<Module>)moduleLocalService.dynamicQuery(dq,0,1);
if(modulesp!=null&& modulesp.size()>0)
{
return modulesp.get(0);
}
else
{
return null;
}
}
示例10: findByclassName_classPK_filterByActions
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public List<AuditEntry> findByclassName_classPK_filterByActions(String className, long classPK, List<String> actions)
throws SystemException
{
DynamicQuery dq = auditEntryLocalService.dynamicQuery();
Criterion criterion=PropertyFactoryUtil.forName("classname").eq(className);
if(classPK>0)
{
criterion=RestrictionsFactoryUtil.and(criterion, PropertyFactoryUtil.forName("classPK").eq(classPK));
}
Criterion criterionAux = criterion;
for (int i=0; i<actions.size(); i++) {
if(i==0){
criterion = RestrictionsFactoryUtil.and(criterion, PropertyFactoryUtil.forName("action").eq(actions.get(i)));
}else{
Criterion criterionAnd = RestrictionsFactoryUtil.and(criterionAux , PropertyFactoryUtil.forName("action").eq(actions.get(i)));
criterion = RestrictionsFactoryUtil.or(criterion, criterionAnd);
}
}
dq.add(criterion);
return auditEntryLocalService.dynamicQuery(dq);
}
示例11: getDataWithDuplicatesWithCache
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
public Map<Long, List<Data>> getDataWithDuplicatesWithCache(
Map<String, Map<Long, List<Data>>> queryCache, Model relatedModel,
List<String> relatedAttributes, List<String> mappingsRelated,
Criterion relatedCriterion)
throws Exception {
Map<Long, List<Data>> relatedMap;
String attributes = Arrays.toString(relatedAttributes.toArray());
String cacheKey =
relatedModel.getName() + "_" + attributes + "_key_" +
mappingsRelated.get(0);
relatedMap = queryCache.get(cacheKey);
if (relatedMap == null) {
synchronized(relatedModel) {
relatedMap = queryCache.get(cacheKey);
if (relatedMap == null) {
relatedMap = Query.getDataWithDuplicates(
relatedModel, relatedAttributes.toArray(new String[0]),
mappingsRelated.get(0), relatedCriterion);
queryCache.put(cacheKey, relatedMap);
}
}
}
return relatedMap;
}
示例12: getAttributeRangeCriterion
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
protected Criterion getAttributeRangeCriterion(
Model model, String attribute, Object value, boolean isStartValue) {
if (!model.hasAttribute(attribute)) {
return RestrictionsFactoryUtil.disjunction();
}
Property property = model.getProperty(attribute);
if (isStartValue) {
return property.ge(value);
}
return property.lt(value);
}
示例13: generateSQLCriterion
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
public static Criterion generateSQLCriterion(String sql) {
if (Validator.isNull(sql)) {
return null;
}
sql = PortalUtil.transformSQL(sql);
return RestrictionsFactoryUtil.sqlRestriction(sql);
}
示例14: addCriterion
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
public void addCriterion(Criterion criterion) {
if (serviceWrapper == null) {
serviceWrapper = new ServiceWrapper(model.getService());
}
serviceWrapper.addCriterion(criterion);
}
示例15: executeDynamicQuery
import com.liferay.portal.kernel.dao.orm.Criterion; //导入依赖的package包/类
@Override
public List<?> executeDynamicQuery(Criterion criterion, Order order)
throws Exception {
List<Order> orders = Collections.singletonList(order);
return executeDynamicQuery(criterion, null, orders);
}