List of usage examples for com.liferay.portal.kernel.dao.orm Property lt
public Criterion lt(Object value);
From source file:com.liferay.akismet.moderation.messaging.DeleteMBMessagesListener.java
License:Open Source License
protected void deleteSpam(long companyId) throws PortalException { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(MBMessage.class, PortalClassLoaderUtil.getClassLoader()); Property statusProperty = PropertyFactoryUtil.forName("status"); dynamicQuery.add(statusProperty.eq(WorkflowConstants.STATUS_DENIED)); Property statusDateProperty = PropertyFactoryUtil.forName("statusDate"); dynamicQuery.add(statusDateProperty.lt(AkismetUtil.getRetainSpamTime())); List<MBMessage> mbMessages = MBMessageLocalServiceUtil.dynamicQuery(dynamicQuery); for (MBMessage mbMessage : mbMessages) { try {/*from w w w. j av a 2 s . co m*/ MBMessageLocalServiceUtil.deleteMBMessage(mbMessage.getMessageId()); } catch (NoSuchMessageException nsme) { } } }
From source file:com.liferay.akismet.moderation.messaging.DeleteSpamListener.java
License:Open Source License
protected void deleteSpamMessages(long companyId) throws PortalException, SystemException { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(MBMessage.class, PortalClassLoaderUtil.getClassLoader()); Property statusProperty = PropertyFactoryUtil.forName("status"); dynamicQuery.add(statusProperty.eq(WorkflowConstants.STATUS_DENIED)); Property statusDateProperty = PropertyFactoryUtil.forName("statusDate"); dynamicQuery.add(statusDateProperty.lt(AkismetUtil.getRetainSpamTime())); List<MBMessage> mbMessages = MBMessageLocalServiceUtil.dynamicQuery(dynamicQuery); for (MBMessage mbMessage : mbMessages) { try {//from w w w .ja v a 2s.c o m MBMessageLocalServiceUtil.deleteMBMessage(mbMessage.getMessageId()); } catch (NoSuchMessageException nsme) { } } }
From source file:com.liferay.akismet.moderation.messaging.UpdateWikiPagesListener.java
License:Open Source License
protected void updateWikiPages(long companyId) { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(WikiPage.class, PortalClassLoaderUtil.getClassLoader()); Property summaryProperty = PropertyFactoryUtil.forName("summary"); dynamicQuery.add(summaryProperty.eq(AkismetConstants.WIKI_PAGE_PENDING_APPROVAL)); Property modifiedDateProperty = PropertyFactoryUtil.forName("modifiedDate"); dynamicQuery.add(modifiedDateProperty.lt(AkismetUtil.getRetainSpamTime())); List<WikiPage> wikiPages = WikiPageLocalServiceUtil.dynamicQuery(dynamicQuery); for (WikiPage wikiPage : wikiPages) { wikiPage.setSummary(AkismetConstants.WIKI_PAGE_MARKED_AS_SPAM); WikiPageLocalServiceUtil.updateWikiPage(wikiPage); }//from w ww . ja va2s .c o m }
From source file:com.liferay.akismet.util.AkismetUtil.java
License:Open Source License
public static WikiPage getWikiPage(long nodeId, String title, double version, boolean previous) { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(WikiPage.class); Property summaryProperty = PropertyFactoryUtil.forName("summary"); dynamicQuery.add(summaryProperty.ne(AkismetConstants.WIKI_PAGE_MARKED_AS_SPAM)); dynamicQuery.add(summaryProperty.ne(AkismetConstants.WIKI_PAGE_PENDING_APPROVAL)); Property nodeIdProperty = PropertyFactoryUtil.forName("nodeId"); dynamicQuery.add(nodeIdProperty.eq(nodeId)); Property titleProperty = PropertyFactoryUtil.forName("title"); dynamicQuery.add(titleProperty.eq(title)); Property statusProperty = PropertyFactoryUtil.forName("status"); dynamicQuery.add(statusProperty.eq(WorkflowConstants.STATUS_APPROVED)); Property versionProperty = PropertyFactoryUtil.forName("version"); if (previous) { dynamicQuery.add(versionProperty.lt(version)); } else {/*from w ww . j a v a 2 s . co m*/ dynamicQuery.add(versionProperty.ge(version)); } OrderFactoryUtil.addOrderByComparator(dynamicQuery, new PageVersionComparator()); List<WikiPage> wikiPages = WikiPageLocalServiceUtil.dynamicQuery(dynamicQuery, 0, 1); if (wikiPages.isEmpty()) { return null; } return wikiPages.get(0); }
From source file:com.liferay.blogs.internal.search.BlogsEntryIndexer.java
License:Open Source License
protected void reindexEntries(long companyId) throws PortalException { final IndexableActionableDynamicQuery indexableActionableDynamicQuery = _blogsEntryLocalService .getIndexableActionableDynamicQuery(); indexableActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() { @Override/*from w w w .j a va 2 s . co m*/ public void addCriteria(DynamicQuery dynamicQuery) { Property displayDateProperty = PropertyFactoryUtil.forName("displayDate"); dynamicQuery.add(displayDateProperty.lt(new Date())); Property statusProperty = PropertyFactoryUtil.forName("status"); Integer[] statuses = { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_IN_TRASH }; dynamicQuery.add(statusProperty.in(statuses)); } }); indexableActionableDynamicQuery.setCompanyId(companyId); indexableActionableDynamicQuery .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<BlogsEntry>() { @Override public void performAction(BlogsEntry entry) { try { Document document = getDocument(entry); indexableActionableDynamicQuery.addDocuments(document); } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn("Unable to index blogs entry " + entry.getEntryId(), pe); } } } }); indexableActionableDynamicQuery.setSearchEngineId(getSearchEngineId()); indexableActionableDynamicQuery.performActions(); }
From source file:com.liferay.calendar.service.impl.CalendarBookingLocalServiceImpl.java
License:Open Source License
@Override public List<CalendarBooking> getCalendarBookings(long calendarId, long startTime, long endTime, int max) { DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(CalendarBooking.class, getClassLoader()); Property property = PropertyFactoryUtil.forName("calendarId"); dynamicQuery.add(property.eq(calendarId)); if (startTime >= 0) { Property propertyStartTime = PropertyFactoryUtil.forName("startTime"); dynamicQuery.add(propertyStartTime.gt(startTime)); }/* w w w . j av a2 s .co m*/ if (endTime >= 0) { Property propertyEndTime = PropertyFactoryUtil.forName("endTime"); dynamicQuery.add(propertyEndTime.lt(endTime)); } if (max > 0) { dynamicQuery.setLimit(0, max); } return dynamicQuery(dynamicQuery); }
From source file:com.liferay.exportimport.web.internal.messaging.DraftExportImportConfigurationMessageListener.java
License:Open Source License
@Override protected void doReceive(Message message) throws PortalException { if (ExportImportWebConfigurationValues.DRAFT_EXPORT_IMPORT_CONFIGURATION_CLEAN_UP_COUNT == -1) { return;/*from w w w .ja v a2s.co m*/ } final Date lastCreateDate; if (ExportImportWebConfigurationValues.DRAFT_EXPORT_IMPORT_CONFIGURATION_CLEAN_UP_COUNT == 0) { lastCreateDate = new Date(); } else { DynamicQuery dynamicQuery = _exportImportConfigurationLocalService.dynamicQuery(); addCommonCriterions(dynamicQuery); Order order = OrderFactoryUtil.desc("createDate"); dynamicQuery.addOrder(order); dynamicQuery.setLimit(QueryUtil.ALL_POS, ExportImportWebConfigurationValues.DRAFT_EXPORT_IMPORT_CONFIGURATION_CLEAN_UP_COUNT); dynamicQuery.setProjection(ProjectionFactoryUtil.property("createDate")); List<Date> createDates = _exportImportConfigurationLocalService.dynamicQuery(dynamicQuery); if (ListUtil.isEmpty(createDates)) { return; } lastCreateDate = createDates.get(createDates.size() - 1); } ActionableDynamicQuery actionableDynamicQuery = _exportImportConfigurationLocalService .getActionableDynamicQuery(); final Property createDate = PropertyFactoryUtil.forName("createDate"); actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() { @Override public void addCriteria(DynamicQuery dynamicQuery) { addCommonCriterions(dynamicQuery); dynamicQuery.add(createDate.lt(lastCreateDate)); } }); actionableDynamicQuery.setPerformActionMethod( new ActionableDynamicQuery.PerformActionMethod<ExportImportConfiguration>() { @Override public void performAction(ExportImportConfiguration exportImportConfiguration) throws PortalException { List<BackgroundTask> backgroundTasks = getParentBackgroundTasks(exportImportConfiguration); if (ListUtil.isEmpty(backgroundTasks)) { _exportImportConfigurationLocalService .deleteExportImportConfiguration(exportImportConfiguration); return; } // BackgroundTaskModelListener deletes the linked // configuration automatically for (BackgroundTask backgroundTask : backgroundTasks) { if (isLiveGroup(backgroundTask.getGroupId())) { continue; } _backgroundTaskLocalService.deleteBackgroundTask(backgroundTask.getBackgroundTaskId()); } } }); actionableDynamicQuery.performActions(); }
From source file:com.liferay.knowledgebase.service.impl.KBArticleLocalServiceImpl.java
License:Open Source License
protected DynamicQuery buildDynamicQuery(long groupId, String title, String content, int status, Date startDate, Date endDate, boolean andOperator) { Junction junction = null;//from w ww .ja v a2s .com if (andOperator) { junction = RestrictionsFactoryUtil.conjunction(); } else { junction = RestrictionsFactoryUtil.disjunction(); } Map<String, String> terms = new HashMap<String, String>(); if (Validator.isNotNull(title)) { terms.put("title", title); } if (Validator.isNotNull(content)) { terms.put("content", content); } for (Map.Entry<String, String> entry : terms.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); Disjunction disjunction = RestrictionsFactoryUtil.disjunction(); for (String keyword : KnowledgeBaseUtil.splitKeywords(value)) { Criterion criterion = RestrictionsFactoryUtil.ilike(key, StringUtil.quote(keyword, StringPool.PERCENT)); disjunction.add(criterion); } junction.add(disjunction); } if (status != WorkflowConstants.STATUS_ANY) { Property property = PropertyFactoryUtil.forName("status"); junction.add(property.eq(status)); } if ((endDate != null) && (startDate != null)) { Disjunction disjunction = RestrictionsFactoryUtil.disjunction(); String[] propertyNames = { "createDate", "modifiedDate" }; for (String propertyName : propertyNames) { Property property = PropertyFactoryUtil.forName(propertyName); Conjunction conjunction = RestrictionsFactoryUtil.conjunction(); conjunction.add(property.gt(startDate)); conjunction.add(property.lt(endDate)); disjunction.add(conjunction); } junction.add(disjunction); } DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(KBArticle.class, getClassLoader()); if (status == WorkflowConstants.STATUS_ANY) { Property property = PropertyFactoryUtil.forName("latest"); dynamicQuery.add(property.eq(Boolean.TRUE)); } else if (status == WorkflowConstants.STATUS_APPROVED) { Property property = PropertyFactoryUtil.forName("main"); dynamicQuery.add(property.eq(Boolean.TRUE)); } if (groupId > 0) { Property property = PropertyFactoryUtil.forName("groupId"); dynamicQuery.add(property.eq(groupId)); } return dynamicQuery.add(junction); }
From source file:com.liferay.knowledgebase.service.impl.KBStructureLocalServiceImpl.java
License:Open Source License
protected DynamicQuery buildDynamicQuery(long groupId, String title, String content, Date startDate, Date endDate, boolean andOperator) { Junction junction = null;/* w w w. j a v a2 s .c o m*/ if (andOperator) { junction = RestrictionsFactoryUtil.conjunction(); } else { junction = RestrictionsFactoryUtil.disjunction(); } Map<String, String> terms = new HashMap<String, String>(); if (Validator.isNotNull(title)) { terms.put("title", title); } if (Validator.isNotNull(content)) { String escapedContent = StringEscapeUtils.escapeXml(content); terms.put("content", content + StringPool.SPACE + escapedContent); } for (Map.Entry<String, String> entry : terms.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); Disjunction disjunction = RestrictionsFactoryUtil.disjunction(); for (String keyword : KnowledgeBaseUtil.parseKeywords(value)) { Criterion criterion = RestrictionsFactoryUtil.ilike(key, StringUtil.quote(keyword, StringPool.PERCENT)); disjunction.add(criterion); } junction.add(disjunction); } if ((endDate != null) && (startDate != null)) { Disjunction disjunction = RestrictionsFactoryUtil.disjunction(); String[] propertyNames = { "createDate", "modifiedDate" }; for (String propertyName : propertyNames) { Property property = PropertyFactoryUtil.forName(propertyName); Conjunction conjunction = RestrictionsFactoryUtil.conjunction(); conjunction.add(property.gt(startDate)); conjunction.add(property.lt(endDate)); disjunction.add(conjunction); } junction.add(disjunction); } DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(KBStructure.class, getClass().getClassLoader()); if (groupId > 0) { Property property = PropertyFactoryUtil.forName("groupId"); dynamicQuery.add(property.eq(groupId)); } return dynamicQuery.add(junction); }
From source file:com.liferay.knowledgebase.service.impl.KBTemplateLocalServiceImpl.java
License:Open Source License
protected DynamicQuery buildDynamicQuery(long groupId, String title, String content, Date startDate, Date endDate, boolean andOperator) { Junction junction = null;//from w ww .j a va 2 s.c o m if (andOperator) { junction = RestrictionsFactoryUtil.conjunction(); } else { junction = RestrictionsFactoryUtil.disjunction(); } Map<String, String> terms = new HashMap<String, String>(); if (Validator.isNotNull(title)) { terms.put("title", title); } if (Validator.isNotNull(content)) { terms.put("content", content); } for (Map.Entry<String, String> entry : terms.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); Disjunction disjunction = RestrictionsFactoryUtil.disjunction(); for (String keyword : KnowledgeBaseUtil.splitKeywords(value)) { Criterion criterion = RestrictionsFactoryUtil.ilike(key, StringUtil.quote(keyword, StringPool.PERCENT)); disjunction.add(criterion); } junction.add(disjunction); } if ((endDate != null) && (startDate != null)) { Disjunction disjunction = RestrictionsFactoryUtil.disjunction(); String[] propertyNames = { "createDate", "modifiedDate" }; for (String propertyName : propertyNames) { Property property = PropertyFactoryUtil.forName(propertyName); Conjunction conjunction = RestrictionsFactoryUtil.conjunction(); conjunction.add(property.gt(startDate)); conjunction.add(property.lt(endDate)); disjunction.add(conjunction); } junction.add(disjunction); } DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(KBTemplate.class, getClassLoader()); if (groupId > 0) { Property property = PropertyFactoryUtil.forName("groupId"); dynamicQuery.add(property.eq(groupId)); } return dynamicQuery.add(junction); }