Search in sources :

Example 1 with Property

use of com.liferay.portal.kernel.dao.orm.Property in project liferay-ide by liferay.

the class KBCommentExportActionableDynamicQuery method addCriteria.

@Override
protected void addCriteria(DynamicQuery dynamicQuery) {
    _portletDataContext.addDateRangeCriteria(dynamicQuery, "modifiedDate");
    if (getStagedModelType().getReferrerClassNameId() >= 0) {
        Property classNameIdProperty = PropertyFactoryUtil.forName("classNameId");
        dynamicQuery.add(classNameIdProperty.eq(getStagedModelType().getReferrerClassNameId()));
    }
}
Also used : Property(com.liferay.portal.kernel.dao.orm.Property)

Example 2 with Property

use of com.liferay.portal.kernel.dao.orm.Property in project liferay-ide by liferay.

the class KBArticleLocalServiceImpl method buildDynamicQuery.

protected DynamicQuery buildDynamicQuery(long groupId, String title, String content, int status, Date startDate, Date endDate, boolean andOperator) {
    Junction junction = null;
    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);
}
Also used : Disjunction(com.liferay.portal.kernel.dao.orm.Disjunction) HashMap(java.util.HashMap) Criterion(com.liferay.portal.kernel.dao.orm.Criterion) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) Conjunction(com.liferay.portal.kernel.dao.orm.Conjunction) Junction(com.liferay.portal.kernel.dao.orm.Junction) Map(java.util.Map) HashMap(java.util.HashMap) Property(com.liferay.portal.kernel.dao.orm.Property)

Example 3 with Property

use of com.liferay.portal.kernel.dao.orm.Property in project liferay-ide by liferay.

the class KBTemplateLocalServiceImpl method buildDynamicQuery.

protected DynamicQuery buildDynamicQuery(long groupId, String title, String content, Date startDate, Date endDate, boolean andOperator) {
    Junction junction = null;
    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);
}
Also used : Disjunction(com.liferay.portal.kernel.dao.orm.Disjunction) HashMap(java.util.HashMap) Criterion(com.liferay.portal.kernel.dao.orm.Criterion) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) Conjunction(com.liferay.portal.kernel.dao.orm.Conjunction) Junction(com.liferay.portal.kernel.dao.orm.Junction) HashMap(java.util.HashMap) Map(java.util.Map) Property(com.liferay.portal.kernel.dao.orm.Property)

Example 4 with Property

use of com.liferay.portal.kernel.dao.orm.Property in project liferay-ide by liferay.

the class AlbumExportActionableDynamicQuery method addCriteria.

@Override
protected void addCriteria(DynamicQuery dynamicQuery) {
    _portletDataContext.addDateRangeCriteria(dynamicQuery, "modifiedDate");
    StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil.getStagedModelDataHandler(Album.class.getName());
    Property workflowStatusProperty = PropertyFactoryUtil.forName("status");
    dynamicQuery.add(workflowStatusProperty.in(stagedModelDataHandler.getExportableStatuses()));
}
Also used : Album(org.liferay.jukebox.model.Album) Property(com.liferay.portal.kernel.dao.orm.Property)

Example 5 with Property

use of com.liferay.portal.kernel.dao.orm.Property in project liferay-ide by liferay.

the class AdminIndexer method reindexKBArticles.

protected void reindexKBArticles(long companyId) throws Exception {
    ActionableDynamicQuery actionableDynamicQuery = new KBArticleActionableDynamicQuery() {

        @Override
        protected void addCriteria(DynamicQuery dynamicQuery) {
            Property property = PropertyFactoryUtil.forName("status");
            dynamicQuery.add(property.eq(WorkflowConstants.STATUS_APPROVED));
        }

        @Override
        protected void performAction(Object object) throws PortalException {
            KBArticle kbArticle = (KBArticle) object;
            Document document = getDocument(kbArticle);
            addDocument(document);
        }
    };
    actionableDynamicQuery.setCompanyId(companyId);
    actionableDynamicQuery.setSearchEngineId(getSearchEngineId());
    actionableDynamicQuery.performActions();
}
Also used : KBArticle(com.liferay.knowledgebase.model.KBArticle) KBArticleActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBArticleActionableDynamicQuery) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) KBArticleActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBArticleActionableDynamicQuery) Document(com.liferay.portal.kernel.search.Document) Property(com.liferay.portal.kernel.dao.orm.Property) KBArticleActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBArticleActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)

Aggregations

Property (com.liferay.portal.kernel.dao.orm.Property)8 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)3 KBArticle (com.liferay.knowledgebase.model.KBArticle)2 Conjunction (com.liferay.portal.kernel.dao.orm.Conjunction)2 Criterion (com.liferay.portal.kernel.dao.orm.Criterion)2 Disjunction (com.liferay.portal.kernel.dao.orm.Disjunction)2 Junction (com.liferay.portal.kernel.dao.orm.Junction)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 KBArticleActionableDynamicQuery (com.liferay.knowledgebase.service.persistence.KBArticleActionableDynamicQuery)1 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)1 Document (com.liferay.portal.kernel.search.Document)1 Album (org.liferay.jukebox.model.Album)1 Artist (org.liferay.jukebox.model.Artist)1 Song (org.liferay.jukebox.model.Song)1