Search in sources :

Example 1 with StagedModelDataHandler

use of com.liferay.exportimport.kernel.lar.StagedModelDataHandler in project liferay-blade-samples by liferay.

the class QuxLocalServiceBaseImpl 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) {
            Criterion modifiedDateCriterion = portletDataContext.getDateRangeCriteria("modifiedDate");
            Criterion statusDateCriterion = portletDataContext.getDateRangeCriteria("statusDate");
            if ((modifiedDateCriterion != null) && (statusDateCriterion != null)) {
                Disjunction disjunction = RestrictionsFactoryUtil.disjunction();
                disjunction.add(modifiedDateCriterion);
                disjunction.add(statusDateCriterion);
                dynamicQuery.add(disjunction);
            }
            Property workflowStatusProperty = PropertyFactoryUtil.forName("status");
            if (portletDataContext.isInitialPublication()) {
                dynamicQuery.add(workflowStatusProperty.ne(WorkflowConstants.STATUS_IN_TRASH));
            } else {
                StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil.getStagedModelDataHandler(Qux.class.getName());
                dynamicQuery.add(workflowStatusProperty.in(stagedModelDataHandler.getExportableStatuses()));
            }
        }
    });
    exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
    exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Qux>() {

        @Override
        public void performAction(Qux qux) throws PortalException {
            StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, qux);
        }
    });
    exportActionableDynamicQuery.setStagedModelType(new StagedModelType(PortalUtil.getClassNameId(Qux.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) Disjunction(com.liferay.portal.kernel.dao.orm.Disjunction) Criterion(com.liferay.portal.kernel.dao.orm.Criterion) Qux(com.liferay.blade.workflow.asset.model.Qux) StagedModelDataHandler(com.liferay.exportimport.kernel.lar.StagedModelDataHandler) StagedModelType(com.liferay.exportimport.kernel.lar.StagedModelType) PortalException(com.liferay.portal.kernel.exception.PortalException) Property(com.liferay.portal.kernel.dao.orm.Property) 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 2 with StagedModelDataHandler

use of com.liferay.exportimport.kernel.lar.StagedModelDataHandler in project liferay-blade-samples by liferay.

the class BazLocalServiceBaseImpl 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) {
            Criterion modifiedDateCriterion = portletDataContext.getDateRangeCriteria("modifiedDate");
            Criterion statusDateCriterion = portletDataContext.getDateRangeCriteria("statusDate");
            if ((modifiedDateCriterion != null) && (statusDateCriterion != null)) {
                Disjunction disjunction = RestrictionsFactoryUtil.disjunction();
                disjunction.add(modifiedDateCriterion);
                disjunction.add(statusDateCriterion);
                dynamicQuery.add(disjunction);
            }
            Property workflowStatusProperty = PropertyFactoryUtil.forName("status");
            if (portletDataContext.isInitialPublication()) {
                dynamicQuery.add(workflowStatusProperty.ne(WorkflowConstants.STATUS_IN_TRASH));
            } else {
                StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil.getStagedModelDataHandler(Baz.class.getName());
                dynamicQuery.add(workflowStatusProperty.in(stagedModelDataHandler.getExportableStatuses()));
            }
        }
    });
    exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());
    exportActionableDynamicQuery.setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<Baz>() {

        @Override
        public void performAction(Baz baz) throws PortalException {
            StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, baz);
        }
    });
    exportActionableDynamicQuery.setStagedModelType(new StagedModelType(PortalUtil.getClassNameId(Baz.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) Disjunction(com.liferay.portal.kernel.dao.orm.Disjunction) Criterion(com.liferay.portal.kernel.dao.orm.Criterion) StagedModelDataHandler(com.liferay.exportimport.kernel.lar.StagedModelDataHandler) Baz(com.liferay.blade.workflow.basic.model.Baz) StagedModelType(com.liferay.exportimport.kernel.lar.StagedModelType) PortalException(com.liferay.portal.kernel.exception.PortalException) Property(com.liferay.portal.kernel.dao.orm.Property) 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)

Aggregations

ManifestSummary (com.liferay.exportimport.kernel.lar.ManifestSummary)2 StagedModelDataHandler (com.liferay.exportimport.kernel.lar.StagedModelDataHandler)2 StagedModelType (com.liferay.exportimport.kernel.lar.StagedModelType)2 ActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery)2 Criterion (com.liferay.portal.kernel.dao.orm.Criterion)2 DefaultActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery)2 Disjunction (com.liferay.portal.kernel.dao.orm.Disjunction)2 DynamicQuery (com.liferay.portal.kernel.dao.orm.DynamicQuery)2 ExportActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.ExportActionableDynamicQuery)2 IndexableActionableDynamicQuery (com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery)2 Property (com.liferay.portal.kernel.dao.orm.Property)2 PortalException (com.liferay.portal.kernel.exception.PortalException)2 Qux (com.liferay.blade.workflow.asset.model.Qux)1 Baz (com.liferay.blade.workflow.basic.model.Baz)1