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;
}
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;
}
Aggregations