Example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_IN_TRASH

List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_IN_TRASH

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_IN_TRASH.

Prototype

int STATUS_IN_TRASH

To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_IN_TRASH.

Click Source Link

Usage

From source file:br.com.prodevelopment.lapidarios.evento.model.EventoAgendaClp.java

License:Open Source License

@Override
public boolean isInTrash() {
    if (getStatus() == WorkflowConstants.STATUS_IN_TRASH) {
        return true;
    } else {/*from   w w  w .  ja  v a 2  s.co  m*/
        return false;
    }
}

From source file:br.com.prodevelopment.lapidarios.evento.service.impl.EventoAgendaLocalServiceImpl.java

License:Open Source License

public EventoAgenda moveEventoAgendaToTrash(long userId, EventoAgenda eventoAgenda)
        throws PortalException, SystemException {

    eventoAgendaLocalService.updateStatus(userId, eventoAgenda, WorkflowConstants.STATUS_IN_TRASH,
            new ServiceContext());

    // Workflow//from   www. j  a v a2 s.c  o  m
    workflowInstanceLinkLocalService.deleteWorkflowInstanceLinks(eventoAgenda.getCompanyId(),
            eventoAgenda.getGroupId(), EventoAgenda.class.getName(), eventoAgenda.getEventoAgendaId());

    return eventoAgenda;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.impl.EventoAgendaLocalServiceImpl.java

License:Open Source License

public EventoAgenda updateStatus(long userId, EventoAgenda eventoAgenda, int status,
        ServiceContext serviceContext) throws PortalException, SystemException {

    // Type Task/*w w w  .j  av a 2 s .  co m*/

    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();

    int oldStatus = eventoAgenda.getStatus();

    eventoAgenda.setModifiedUserId(userId);
    eventoAgenda.setModifiedDate(serviceContext.getModifiedDate(now));
    eventoAgenda.setStatus(status);
    eventoAgenda.setStatusByUserId(user.getUserId());
    eventoAgenda.setStatusByUserName(user.getFullName());
    eventoAgenda.setStatusDate(serviceContext.getModifiedDate(now));

    eventoAgendaPersistence.update(eventoAgenda);

    // Trash

    if (oldStatus == WorkflowConstants.STATUS_IN_TRASH) {
        trashEntryLocalService.deleteEntry(EventoAgenda.class.getName(), eventoAgenda.getEventoAgendaId());

        // Workflow
        WorkflowHandlerRegistryUtil.startWorkflowInstance(eventoAgenda.getCompanyId(),
                eventoAgenda.getGroupId(), userId, EventoAgenda.class.getName(),
                eventoAgenda.getEventoAgendaId(), eventoAgenda, serviceContext);
    }

    if (status == WorkflowConstants.STATUS_IN_TRASH) {
        int novoStatus = WorkflowConstants.STATUS_APPROVED;
        if (WorkflowDefinitionLinkLocalServiceUtil.hasWorkflowDefinitionLink(eventoAgenda.getCompanyId(),
                eventoAgenda.getGroupId(), EventoAgenda.class.getName())) {
            novoStatus = WorkflowConstants.STATUS_PENDING;
        }

        trashEntryLocalService.addTrashEntry(userId, eventoAgenda.getGroupId(), EventoAgenda.class.getName(),
                eventoAgenda.getEventoAgendaId(), eventoAgenda.getUuid(), null, novoStatus, null, null);
    }

    return eventoAgenda;
}

From source file:br.com.prodevelopment.lapidarios.evento.service.persistence.EventoAgendaExportActionableDynamicQuery.java

License:Open Source License

@Override
protected 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);//from w  w w  . j av a2 s .  co m
    }

    if (getStagedModelType().getReferrerClassNameId() >= 0) {
        Property classNameIdProperty = PropertyFactoryUtil.forName("classNameId");

        dynamicQuery.add(classNameIdProperty.eq(getStagedModelType().getReferrerClassNameId()));
    }

    Property workflowStatusProperty = PropertyFactoryUtil.forName("status");

    if (_portletDataContext.isInitialPublication()) {
        dynamicQuery.add(workflowStatusProperty.ne(WorkflowConstants.STATUS_IN_TRASH));
    } else {
        StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil
                .getStagedModelDataHandler(EventoAgenda.class.getName());

        dynamicQuery.add(workflowStatusProperty.in(stagedModelDataHandler.getExportableStatuses()));
    }
}

From source file:br.com.prodevelopment.lapidarios.loja.service.impl.LojaLocalServiceImpl.java

License:Open Source License

public Loja moveLojaToTrash(long userId, Loja loja) throws PortalException, SystemException {

    lojaLocalService.updateStatus(userId, loja, WorkflowConstants.STATUS_IN_TRASH, new ServiceContext());

    // Social/*from   ww  w .java2 s.  c  o m*/
    socialActivityCounterLocalService.disableActivityCounters(Loja.class.getName(), loja.getLojaId());

    socialActivityLocalService.addActivity(userId, loja.getGroupId(), Loja.class.getName(), loja.getLojaId(),
            SocialActivityConstants.TYPE_MOVE_TO_TRASH, getExtraDataJSON(loja), 0);

    // Workflow
    workflowInstanceLinkLocalService.deleteWorkflowInstanceLinks(loja.getCompanyId(), loja.getGroupId(),
            Loja.class.getName(), loja.getLojaId());

    return loja;
}

From source file:br.com.prodevelopment.lapidarios.loja.service.impl.LojaLocalServiceImpl.java

License:Open Source License

public Loja updateStatus(long userId, Loja loja, int status, ServiceContext serviceContext)
        throws PortalException, SystemException {

    // Type Task/*from   w w  w. j  a v  a2 s .c o m*/

    User user = userPersistence.findByPrimaryKey(userId);
    Date now = new Date();

    int oldStatus = loja.getStatus();

    loja.setModifiedUserId(user.getUserId());
    loja.setModifiedDate(serviceContext.getModifiedDate(now));
    loja.setStatus(status);
    loja.setStatusByUserId(user.getUserId());
    loja.setStatusByUserName(user.getFullName());
    loja.setStatusDate(serviceContext.getModifiedDate(now));

    lojaPersistence.update(loja);

    // Trash

    if (oldStatus == WorkflowConstants.STATUS_IN_TRASH) {
        trashEntryLocalService.deleteEntry(Loja.class.getName(), loja.getLojaId());

        // Workflow
        WorkflowHandlerRegistryUtil.startWorkflowInstance(loja.getCompanyId(), loja.getGroupId(), userId,
                Loja.class.getName(), loja.getLojaId(), loja, serviceContext);
    }

    if (status == WorkflowConstants.STATUS_IN_TRASH) {
        int novoStatus = WorkflowConstants.STATUS_APPROVED;
        if (WorkflowDefinitionLinkLocalServiceUtil.hasWorkflowDefinitionLink(loja.getCompanyId(),
                loja.getGroupId(), Loja.class.getName())) {
            novoStatus = WorkflowConstants.STATUS_PENDING;
        }

        trashEntryLocalService.addTrashEntry(userId, loja.getGroupId(), Loja.class.getName(), loja.getLojaId(),
                loja.getUuid(), null, novoStatus, null, null);
    }

    return loja;
}

From source file:br.com.prodevelopment.lapidarios.loja.service.persistence.LojaExportActionableDynamicQuery.java

License:Open Source License

@Override
protected 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);//from  w  ww  .  ja  v a2 s.c  o m
    }

    if (getStagedModelType().getReferrerClassNameId() >= 0) {
        Property classNameIdProperty = PropertyFactoryUtil.forName("classNameId");

        dynamicQuery.add(classNameIdProperty.eq(getStagedModelType().getReferrerClassNameId()));
    }

    Property workflowStatusProperty = PropertyFactoryUtil.forName("status");

    if (_portletDataContext.isInitialPublication()) {
        dynamicQuery.add(workflowStatusProperty.ne(WorkflowConstants.STATUS_IN_TRASH));
    } else {
        StagedModelDataHandler<?> stagedModelDataHandler = StagedModelDataHandlerRegistryUtil
                .getStagedModelDataHandler(Loja.class.getName());

        dynamicQuery.add(workflowStatusProperty.in(stagedModelDataHandler.getExportableStatuses()));
    }
}

From source file:ca.efendi.datafeeds.service.base.CJProductLocalServiceBaseImpl.java

License:Open Source License

@Override
public ExportActionableDynamicQuery getExportActionableDynamicQuery(
        final PortletDataContext portletDataContext) {
    final ExportActionableDynamicQuery exportActionableDynamicQuery = new ExportActionableDynamicQuery() {
        @Override/*from   w w  w.j  ava2s .c  om*/
        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(CJProduct.class.getName());

                dynamicQuery.add(workflowStatusProperty.in(stagedModelDataHandler.getExportableStatuses()));
            }
        }
    });

    exportActionableDynamicQuery.setCompanyId(portletDataContext.getCompanyId());

    exportActionableDynamicQuery
            .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<CJProduct>() {
                @Override
                public void performAction(CJProduct cjProduct) throws PortalException {
                    StagedModelDataHandlerUtil.exportStagedModel(portletDataContext, cjProduct);
                }
            });
    exportActionableDynamicQuery
            .setStagedModelType(new StagedModelType(PortalUtil.getClassNameId(CJProduct.class.getName())));

    return exportActionableDynamicQuery;
}

From source file:com.idetronic.subur.service.impl.SuburItemLocalServiceImpl.java

License:Open Source License

/**
 * /*from   www. j av  a  2  s .co m*/
 */
public SuburItem updateStatus(long userId, long itemId, int status, ServiceContext serviceContext)
        throws SystemException, PortalException {
    Date now = new Date();
    SuburItem item = suburItemPersistence.findByPrimaryKey(itemId);

    int oldStatus = item.getStatus();
    if (oldStatus == status)
        return item;

    item.setStatus(status);
    item.setStatusByUserId(userId);
    item.setStatusDate(now);
    item.setModifiedDate(now);

    AssetEntry assetEntry = assetEntryLocalService.fetchEntry(SuburItem.class.getName(), itemId);

    JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();

    extraDataJSONObject.put("title", item.getTitle());

    if (status == WorkflowConstants.STATUS_APPROVED) {
        // Asset
        item.setPublishedDate(now);
        assetEntryLocalService.updateEntry(SuburItem.class.getName(), itemId, now, true);

        //increment approved item type count
        if (!item.getCounted()) {
            List<ItemType> itemItemTypes = getItemTypes(item.getItemId());

            for (ItemType iType : itemItemTypes) {
                itemTypeLocalService.incrementApprovedCount(iType.getItemTypeId());
            }
            item.setCounted(true);

        }

        if (oldStatus != WorkflowConstants.STATUS_IN_TRASH) {

            //social activity
            if (serviceContext.isCommandUpdate()) {
                SocialActivityLocalServiceUtil.addActivity(userId, item.getGroupId(), SuburItem.class.getName(),
                        itemId, SuburActivityKeys.UPDATE_SUBUR_PUBLICATION, extraDataJSONObject.toString(), 0);
            } else {
                SocialActivityLocalServiceUtil.addUniqueActivity(userId, item.getGroupId(),
                        SuburItem.class.getName(), itemId, SuburActivityKeys.ADD_SUBUR_PUBLICATION,
                        extraDataJSONObject.toString(), 0);
            }

            // Subscriptions

            notifySubscribers(item, serviceContext);

            // Ping

        }

    } else //not approved
    {
        //asset
        assetEntryLocalService.updateVisible(SuburItem.class.getName(), itemId, false);

        item.setPublishedDate(null);

    }

    //update author posting
    AuthorLocalServiceUtil.updateAuthorPosting(item, oldStatus, status);

    suburItemPersistence.update(item);
    return item;

}

From source file:com.liferay.adaptive.media.document.library.web.internal.counter.DLAMImageCounter.java

License:Open Source License

private int _getTrashedFileEntriesCount(long companyId) {
    DynamicQuery dlFileVersionDynamicQuery = _dlFileVersionLocalService.dynamicQuery();

    dlFileVersionDynamicQuery.setProjection(ProjectionFactoryUtil.countDistinct("fileEntryId"));

    Property companyIdProperty = PropertyFactoryUtil.forName("companyId");

    dlFileVersionDynamicQuery.add(companyIdProperty.eq(companyId));

    Property groupIdProperty = PropertyFactoryUtil.forName("groupId");
    Property repositoryIdProperty = PropertyFactoryUtil.forName("repositoryId");

    dlFileVersionDynamicQuery.add(groupIdProperty.eqProperty(repositoryIdProperty));

    Property mimeTypeProperty = PropertyFactoryUtil.forName("mimeType");

    dlFileVersionDynamicQuery.add(mimeTypeProperty.in(_amImageMimeTypeProvider.getSupportedMimeTypes()));

    Property statusProperty = PropertyFactoryUtil.forName("status");

    dlFileVersionDynamicQuery.add(statusProperty.eq(WorkflowConstants.STATUS_IN_TRASH));

    return (int) _dlFileEntryLocalService.dynamicQueryCount(dlFileVersionDynamicQuery);
}