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

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

Introduction

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

Prototype

int STATUS_PENDING

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

Click Source Link

Usage

From source file:at.meduni.liferay.portlet.bbmrieric.model.D2BiobankClp.java

License:Open Source License

@Override
public boolean isPending() {
    if (getStatus() == WorkflowConstants.STATUS_PENDING) {
        return true;
    } else {/* ww w. j a  v  a  2s. c o m*/
        return false;
    }
}

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

License:Open Source License

public EventoAgenda addEventoAgenda(long companyId, long groupId, long userIdCreate, String sDataEvento,
        String sHoraEvento, int qtdeVagas, boolean gratuito, double valor, long userResponsavelId,
        long eventoId, long localId, Map<Locale, String> observacaoMap, long classNameId,
        ServiceContext serviceContext) throws SystemException, PortalException {

    Locale locale = LocaleUtil.getSiteDefault();

    Date now = new Date();

    validate(0, eventoId, localId, sDataEvento, sHoraEvento, DateUtil.dateToString(now), userIdCreate,
            qtdeVagas, 1);//from   w  w w  . j a  va2s  .c o  m

    User userCreate = userPersistence.findByPrimaryKey(userIdCreate);

    // Recuperar responsvel
    String userResponsavelNome = StringPool.BLANK;
    if (userResponsavelId > 0) {
        User userResponsavel = userPersistence.findByPrimaryKey(userResponsavelId);
        userResponsavelNome = userResponsavel.getFullName();
    }

    // Recuperar evento
    String eventoNome = StringPool.BLANK;
    if (eventoId > 0) {
        Evento evento = eventoPersistence.findByPrimaryKey(eventoId);
        eventoNome = evento.getNome(locale);
    }

    // Recuperar local
    String localNome = StringPool.BLANK;
    if (localId > 0) {
        Local local = localPersistence.findByPrimaryKey(localId);
        localNome = local.getNome();
    }

    // Criar objeto incrementando um novo ID
    long eventoAgendaId = counterLocalService.increment();
    EventoAgenda eventoAgenda = eventoAgendaPersistence.create(eventoAgendaId);

    // Atribui novos valores
    eventoAgenda.setCompanyId(companyId);
    eventoAgenda.setGroupId(groupId);
    eventoAgenda.setCreateUserId(userIdCreate);
    eventoAgenda.setCreateDate(now);
    try {
        Date dataEvento = DateUtil.stringToDate("dd/MM/yyyy", sDataEvento);
        eventoAgenda.setDataEvento(dataEvento);
    } catch (ParseException e) {
        _log.error(e, e);
    }
    eventoAgenda.setHoraEvento(sHoraEvento);
    eventoAgenda.setQtdeVagas(qtdeVagas);
    eventoAgenda.setQtdeVagasPreenchida(0);
    eventoAgenda.setValor(valor);
    eventoAgenda.setUserResponsavelId(userResponsavelId);
    eventoAgenda.setUserResponsavelNome(userResponsavelNome);
    eventoAgenda.setEventoId(eventoId);
    eventoAgenda.setEventoNome(eventoNome);
    eventoAgenda.setLocalId(localId);
    eventoAgenda.setLocalNome(localNome);
    eventoAgenda.setClassNameId(classNameId);
    String className = PortalUtil.getClassName(classNameId);
    eventoAgenda.setClassName(className);
    eventoAgenda.setStatusDate(serviceContext.getModifiedDate(now));
    eventoAgenda.setStatusByUserId(userCreate.getUserId());
    eventoAgenda.setStatusByUserName(userCreate.getFullName());
    if (WorkflowDefinitionLinkLocalServiceUtil.hasWorkflowDefinitionLink(companyId, groupId,
            EventoAgenda.class.getName())) {
        eventoAgenda.setStatus(WorkflowConstants.STATUS_PENDING);
    } else {
        eventoAgenda.setStatus(WorkflowConstants.STATUS_APPROVED);
    }
    eventoAgenda.setObservacaoMap(observacaoMap);
    eventoAgenda.setVersao(Constantes.VERSAO_INICIAL);
    eventoAgenda.setGratuito(gratuito);

    eventoAgendaPersistence.update(eventoAgenda);

    // Workflow
    WorkflowHandlerRegistryUtil.startWorkflowInstance(companyId, groupId, userCreate.getUserId(),
            EventoAgenda.class.getName(), eventoAgendaId, eventoAgenda, serviceContext);

    return eventoAgenda;
}

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

License:Open Source License

public EventoAgenda updateEventoAgenda(long eventoAgendaId, long companyId, long groupId, long modifiedUserId,
        String sDataEvento, String sHoraEvento, int qtdeVagas, boolean gratuito, double valor,
        long userResponsavelId, long eventoId, long localId, Map<Locale, String> observacaoMap,
        long classNameId, ServiceContext serviceContext) throws PortalException, SystemException {

    Locale locale = LocaleUtil.getSiteDefault();

    Date now = new Date();

    // Recuperar evento agenda
    EventoAgenda eventoAgenda = eventoAgendaPersistence.fetchByPrimaryKey(eventoAgendaId);
    double versao = eventoAgenda.getVersao() + 1;

    validate(eventoAgendaId, eventoId, localId, sDataEvento, sHoraEvento, DateUtil.dateToString(now),
            modifiedUserId, qtdeVagas, versao);

    User userModified = userPersistence.findByPrimaryKey(modifiedUserId);

    // Recuperar responsvel
    String userResponsavelNome = StringPool.BLANK;
    if (userResponsavelId > 0) {
        User userResponsavel = userPersistence.findByPrimaryKey(userResponsavelId);
        userResponsavelNome = userResponsavel.getFullName();
    }//from www. j av  a  2  s .c  om

    // Recuperar evento
    String eventoNome = StringPool.BLANK;
    if (eventoId > 0) {
        Evento evento = eventoPersistence.findByPrimaryKey(eventoId);
        eventoNome = evento.getNome(locale);
    }

    // Recuperar local
    String localNome = StringPool.BLANK;
    if (localId > 0) {
        Local local = localPersistence.findByPrimaryKey(localId);
        localNome = local.getNome();
    }

    // Atribui novos valores
    eventoAgenda.setCompanyId(companyId);
    eventoAgenda.setGroupId(groupId);
    eventoAgenda.setModifiedUserId(modifiedUserId);
    eventoAgenda.setModifiedDate(now);
    try {
        Date dataEvento = DateUtil.stringToDate("dd/MM/yyyy", sDataEvento);
        eventoAgenda.setDataEvento(dataEvento);
    } catch (ParseException e) {
        _log.error(e, e);
    }
    eventoAgenda.setHoraEvento(sHoraEvento);
    eventoAgenda.setQtdeVagas(qtdeVagas);
    eventoAgenda.setQtdeVagasPreenchida(0);
    eventoAgenda.setValor(valor);
    eventoAgenda.setUserResponsavelId(userResponsavelId);
    eventoAgenda.setUserResponsavelNome(userResponsavelNome);
    eventoAgenda.setEventoId(eventoId);
    eventoAgenda.setEventoNome(eventoNome);
    eventoAgenda.setLocalId(localId);
    eventoAgenda.setLocalNome(localNome);
    eventoAgenda.setClassNameId(classNameId);
    String className = PortalUtil.getClassName(classNameId);
    eventoAgenda.setClassName(className);
    eventoAgenda.setStatusDate(serviceContext.getModifiedDate(now));
    eventoAgenda.setStatusByUserId(userModified.getUserId());
    eventoAgenda.setStatusByUserName(userModified.getFullName());
    if (WorkflowDefinitionLinkLocalServiceUtil.hasWorkflowDefinitionLink(companyId, groupId,
            EventoAgenda.class.getName())) {
        eventoAgenda.setStatus(WorkflowConstants.STATUS_PENDING);
    } else {
        eventoAgenda.setStatus(WorkflowConstants.STATUS_APPROVED);
    }
    eventoAgenda.setObservacaoMap(observacaoMap);
    eventoAgenda.setVersao(versao);
    eventoAgenda.setGratuito(gratuito);

    eventoAgendaPersistence.update(eventoAgenda);

    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  .  ja  v a 2s  .c  om

    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.loja.service.impl.LojaLocalServiceImpl.java

License:Open Source License

public Loja addLoja(long companyId, long groupId, long userIdCreate, String razaoSocial, String nomeFantasia,
        Map<Locale, String> observacaoMap, String cnpj, String endLogradouro, String endNumero,
        String endComplemento, String endCep, String endBairro, String endCidade, String endUf, String endPais,
        double versao, List<EnderecoEmail> enderecosEmail, List<Telefone> telefones, long classNameId,
        ServiceContext serviceContext) throws SystemException, PortalException {

    validate(0, razaoSocial, nomeFantasia, cnpj, userIdCreate, versao);

    User userCreate = userPersistence.findByPrimaryKey(userIdCreate);

    // Criar objeto incrementando um novo ID
    long lojaId = counterLocalService.increment();
    Loja loja = lojaPersistence.create(lojaId);

    Date now = new Date();

    // Atribui novos valores
    loja.setCompanyId(companyId);//  w  w w  . jav  a2 s . co  m
    loja.setGroupId(groupId);
    loja.setCreateUserId(userIdCreate);
    loja.setCreateDate(now);
    loja.setRazaoSocial(razaoSocial);
    loja.setNomeFantasia(nomeFantasia);
    loja.setObservacaoMap(observacaoMap);
    loja.setCnpj(cnpj);
    loja.setEndLogradouro(endLogradouro);
    loja.setEndNumero(endNumero);
    loja.setEndComplemento(endComplemento);
    loja.setEndCep(endCep);
    loja.setEndBairro(endBairro);
    loja.setEndCidade(endCidade);
    loja.setEndUf(endUf);
    loja.setEndPais(endPais);
    loja.setClassNameId(classNameId);
    String className = PortalUtil.getClassName(classNameId);
    loja.setClassName(className);
    loja.setStatusDate(serviceContext.getModifiedDate(now));
    loja.setStatusByUserId(userCreate.getUserId());
    loja.setStatusByUserName(userCreate.getFullName());
    if (WorkflowDefinitionLinkLocalServiceUtil.hasWorkflowDefinitionLink(companyId, groupId,
            Loja.class.getName())) {
        loja.setStatus(WorkflowConstants.STATUS_PENDING);
    } else {
        loja.setStatus(WorkflowConstants.STATUS_APPROVED);
    }
    loja.setVersao(versao);

    lojaPersistence.update(loja);

    // Contato
    Contato contato = ContatoLocalServiceUtil.addContato(companyId, groupId, userIdCreate, Loja.class.getName(),
            loja.getLojaId(), nomeFantasia, null, null, null, 0, null, null, null);

    // Telefones
    TelefoneLocalServiceUtil.updateTelefones(companyId, groupId, userIdCreate, Contato.class.getName(),
            contato.getContatoId(), telefones);

    // Enderecos de email
    EnderecoEmailLocalServiceUtil.updateEnderecosEmail(companyId, groupId, userIdCreate,
            Contato.class.getName(), contato.getContatoId(), enderecosEmail);

    // Asset
    updateAsset(loja.getCreateUserId(), loja, serviceContext.getAssetCategoryIds(),
            serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds());

    // Social
    socialActivityLocalService.addActivity(userIdCreate, loja.getGroupId(), Loja.class.getName(), lojaId,
            CadastroLojaActivityKeys.ADD_LOJA, getExtraDataJSON(loja), 0);

    // Workflow
    WorkflowHandlerRegistryUtil.startWorkflowInstance(companyId, groupId, userCreate.getUserId(),
            Loja.class.getName(), lojaId, loja, serviceContext);
    Loja lojaAtiva = lojaPersistence.fetchByCG_OrdemIndicadaAtual(companyId, groupId, true,
            WorkflowConstants.STATUS_APPROVED);
    if (Validator.isNull(lojaAtiva)) {
        loja.setOrdemIndicadaAtual(true);
        lojaPersistence.update(loja);
    }

    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 a2s .  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:com.idetronic.subur.model.impl.SuburItemImpl.java

License:Open Source License

public boolean isPending() {
    return (super.getStatus() == WorkflowConstants.STATUS_PENDING);

}

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

License:Open Source License

@Override
public SuburItem updateSuburItem(SuburItem suburItem, long userId, int newStatus, long[] itemTypeIds,
        long[] authorIds, ServiceContext serviceContext) throws PortalException, SystemException {

    long groupId = serviceContext.getScopeGroupId();
    suburItem.setStatusDate(new Date());
    if (Validator.isNull(suburItem.getPublishedDate())
            && suburItem.getStatus() == SuburConstant.STATUS_PUBLISHED_ITEM)
        suburItem.setPublishedDate(new Date());

    //only show item with published status
    boolean visible = false;
    String itemDescription = null;
    String summary = null;/*  w  w  w . jav  a  2 s  .  co m*/
    String url = null;
    String layoutUuid = null;
    Date publishedDate = suburItem.getPublishedDate();
    suburItem.getMetadataValue();

    itemDescription = suburItem.getTitle();
    AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, groupId, suburItem.getCreateDate(),
            suburItem.getModifiedDate(), SuburItem.class.getName(), suburItem.getItemId(), suburItem.getUuid(),
            0, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), visible, null, null,
            null, ContentTypes.TEXT_HTML, suburItem.getTitle(), itemDescription, summary, url, layoutUuid, 0, 0,
            null, false);

    if (suburItem.isDraft() || suburItem.isPending()) {

    } else {
        suburItem.setStatus(WorkflowConstants.STATUS_DRAFT);
    }

    //if status is published, ensure to update asset entry published date
    if (Validator.isNull(assetEntry.getPublishDate())
            && suburItem.getStatus() == WorkflowConstants.STATUS_APPROVED)
        assetEntryLocalService.updateEntry(SuburItem.class.getName(), suburItem.getItemId(),
                suburItem.getPublishedDate(), true);

    assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), serviceContext.getAssetLinkEntryIds(),
            AssetLinkConstants.TYPE_RELATED);

    ItemAuthorLocalServiceUtil.setItemAuthor(suburItem.getItemId(), authorIds, suburItem.getStatus());
    //AuthorLocalServiceUtil.updateAuthorPosting(suburItem);

    resourceLocalService.addResources(serviceContext.getCompanyId(), groupId, userId, SuburItem.class.getName(),
            suburItem.getItemId(), false, true, true);

    ItemItemTypeLocalServiceUtil.updateItemItemType(suburItem.getItemId(), itemTypeIds);

    //workflow

    boolean workFlowEnable = SuburUtil.isWorkflowEnabled(serviceContext);

    serviceContext.setAttribute("trackbacks", null);

    if (workFlowEnable) {
        WorkflowHandlerRegistryUtil.startWorkflowInstance(suburItem.getCompanyId(), suburItem.getGroupId(),
                userId, SuburItem.class.getName(), suburItem.getItemId(), suburItem, serviceContext);

    }

    Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(SuburItem.class);

    if (serviceContext.getWorkflowAction() == WorkflowConstants.ACTION_PUBLISH) {
        suburItem.setStatus(WorkflowConstants.STATUS_PENDING);
        JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();

        extraDataJSONObject.put("title", suburItem.getTitle());
        if (suburItem.getCompleted()) {
            SocialActivityLocalServiceUtil.addActivity(userId, suburItem.getGroupId(),
                    SuburItem.class.getName(), suburItem.getItemId(),
                    SuburActivityKeys.UPDATE_SUBUR_PUBLICATION, extraDataJSONObject.toString(), 0);

        } else {
            SocialActivityLocalServiceUtil.addActivity(userId, suburItem.getGroupId(),
                    SuburItem.class.getName(), suburItem.getItemId(), SuburActivityKeys.ADD_SUBUR_PUBLICATION,
                    extraDataJSONObject.toString(), 0);

            suburItem.setCompleted(true);
        }
    }

    indexer.reindex(suburItem);
    suburItem.setExpandoBridgeAttributes(serviceContext);

    //updateStatus(suburItem.getItemId(),userId,newStatus,serviceContext);
    return suburItemPersistence.update(suburItem);

}

From source file:com.inkwell.internet.slogan.model.impl.SloganModelImpl.java

License:Open Source License

public boolean isPending() {
    if (getStatus() == WorkflowConstants.STATUS_PENDING) {
        return true;
    } else {/*from ww w.  j ava 2  s. co m*/
        return false;
    }
}

From source file:com.liferay.asset.tags.admin.web.internal.display.context.AssetTagsDisplayContext.java

License:Open Source License

public long getFullTagsCount(AssetTag tag) {
    int[] statuses = { WorkflowConstants.STATUS_APPROVED, WorkflowConstants.STATUS_PENDING,
            WorkflowConstants.STATUS_SCHEDULED };

    ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY);

    return AssetEntryLocalServiceUtil.searchCount(tag.getCompanyId(), null, themeDisplay.getUserId(), null, 0,
            null, null, null, null, tag.getName(), true, true, statuses, false);
}