Search in sources :

Example 21 with DynamicQuery

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

the class AdminPortletDataHandler method getKBArticleActionableDynamicQuery.

protected ActionableDynamicQuery getKBArticleActionableDynamicQuery(final PortletDataContext portletDataContext) throws Exception {
    return new KBArticleExportActionableDynamicQuery(portletDataContext) {

        @Override
        protected void addCriteria(DynamicQuery dynamicQuery) {
            super.addCriteria(dynamicQuery);
            OrderFactoryUtil.addOrderByComparator(dynamicQuery, new KBArticleVersionComparator(true));
        }
    };
}
Also used : KBArticleVersionComparator(com.liferay.knowledgebase.util.comparator.KBArticleVersionComparator) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) KBTemplateExportActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBTemplateExportActionableDynamicQuery) KBArticleExportActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBArticleExportActionableDynamicQuery) KBCommentExportActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBCommentExportActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) KBArticleExportActionableDynamicQuery(com.liferay.knowledgebase.service.persistence.KBArticleExportActionableDynamicQuery)

Example 22 with DynamicQuery

use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-blade-samples by liferay.

the class FooLocalServiceBaseImpl method getExportActionableDynamicQuery.

@Override
public ExportActionableDynamicQuery getExportActionableDynamicQuery(final PortletDataContext portletDataContext) {
    final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {

        @Override
        public long performCount() throws PortalException {
            ManifestSummary manifestSummary = portletDataContext.getManifestSummary();
            StagedModelType stagedModelType = getStagedModelType();
            long modelAdditionCount = super.performCount();
            manifestSummary.addModelAdditionCount(stagedModelType, modelAdditionCount);
            long modelDeletionCount = ExportImportHelperUtil.getModelDeletionCount(portletDataContext, stagedModelType);
            manifestSummary.addModelDeletionCount(stagedModelType, modelDeletionCount);
            return modelAdditionCount;
        }
    };
    initActionableDynamicQuery(exportActionableDynamicQuery);
    exportActionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() {

        @Override
        public void addCriteria(DynamicQuery dynamicQuery) {
            portletDataContext.addDateRangeCriteria(dynamicQuery, "modifiedDate");
        }
    });
    exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
    exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Foo>() {

        @Override
        public void performAction(Foo foo) throws PortalException {
            StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, foo);
        }
    });
    exportActionableDynamicQuery.setStagedModelType(new StagedModelType(PortalUtil.getClassNameId(Foo.class.getName())));
    return exportActionableDynamicQuery;
}
Also used : ExportActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery) DefaultActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery) ExportActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery) DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) IndexableActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) ManifestSummary(com.liferay.exportimport.kernel.lar.ManifestSummary) Foo(com.liferay.blade.samples.servicebuilder.model.Foo) StagedModelType(com.liferay.exportimport.kernel.lar.StagedModelType) PortalException(com.liferay.portal.kernel.exception.PortalException) DefaultActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery) ExportActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery) IndexableActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)

Example 23 with DynamicQuery

use of com.liferay.portal.kernel.dao.orm.DynamicQuery in project liferay-blade-samples by liferay.

the class FooPersistenceTest method testDynamicQueryByPrimaryKeyExisting.

@Test
public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    Foo newFoo = addFoo();
    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(Foo.class, _dynamicQueryClassLoader);
    dynamicQuery.add(RestrictionsFactoryUtil.eq("fooId", newFoo.getFooId()));
    List<Foo> result = _persistence.findWithDynamicQuery(dynamicQuery);
    Assert.assertEquals(1, result.size());
    Foo existingFoo = result.get(0);
    Assert.assertEquals(existingFoo, newFoo);
}
Also used : DynamicQuery(com.liferay.portal.kernel.dao.orm.DynamicQuery) ActionableDynamicQuery(com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery) Foo(com.liferay.blade.samples.servicebuilder.model.Foo) Test(org.junit.Test)

Aggregations

DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)23 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)21 Test (org.junit.Test)16 Foo (com.liferay.blade.samples.servicebuilder.model.Foo)4 Property (com.liferay.portal.kernel.dao.orm.Property)3 Document (com.liferay.portal.kernel.search.Document)3 Club (com.liferay.roster.model.Club)3 Roster (com.liferay.roster.model.Roster)3 RosterMember (com.liferay.roster.model.RosterMember)3 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 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ManifestSummary (com.liferay.exportimport.kernel.lar.ManifestSummary)1 StagedModelType (com.liferay.exportimport.kernel.lar.StagedModelType)1 KBArticle (com.liferay.knowledgebase.model.KBArticle)1 KBArticleActionableDynamicQuery (com.liferay.knowledgebase.service.persistence.KBArticleActionableDynamicQuery)1