List of usage examples for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_DRAFT
int STATUS_DRAFT
To view the source code for com.liferay.portal.kernel.workflow WorkflowConstants STATUS_DRAFT.
Click Source Link
From source file:at.meduni.liferay.portlet.bbmrieric.model.D2BiobankClp.java
License:Open Source License
@Override public boolean isDraft() { if (getStatus() == WorkflowConstants.STATUS_DRAFT) { return true; } else {//from ww w.j ava 2 s .c o m return false; } }
From source file:com.idetronic.subur.model.impl.SuburItemImpl.java
License:Open Source License
public boolean isDraft() { return (super.getStatus() == WorkflowConstants.STATUS_DRAFT); }
From source file:com.idetronic.subur.service.impl.SuburItemLocalServiceImpl.java
License:Open Source License
public SuburItem addItem(long userId, long groupId, String title, String itemAbstract, long[] itemTypeId, ServiceContext serviceContext) throws PortalException, SystemException { User user = userLocalService.getUserById(userId); Date now = new Date(); long itemId = CounterLocalServiceUtil.increment(SuburItem.class.getName()); SuburItem suburItem = suburItemPersistence.create(itemId); suburItem.setItemId(itemId);//from w ww.j a va 2 s . co m suburItem.setGroupId(groupId); suburItem.setCompanyId(user.getCompanyId()); suburItem.setUserId(userId); suburItem.setCreateDate(now); suburItem.setModifiedDate(now); suburItem.setTitle(title); suburItem.setItemAbstract(itemAbstract); suburItem.setUuid(PortalUUIDUtil.generate()); suburItem.setStatus(WorkflowConstants.STATUS_DRAFT); suburItem.setCompleted(false); suburItem.setStatusDate(now); suburItemPersistence.update(suburItem); ItemItemTypeLocalServiceUtil.addItemItemType(itemId, itemTypeId); /* Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer( SuburItem.class); indexer.reindex(suburItem); */ //only show item with published status boolean visible = (suburItem.getStatus() == SuburConstant.STATUS_PUBLISHED_ITEM); String itemDescription = null; String summary = null; String url = null; String layoutUuid = null; /* resourceLocalService.addResources(suburItem.getCompanyId(), suburItem.getGroupId(), suburItem.getUserId(), SuburItem.class.getName(), suburItem.getItemId(), false, true, true); 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); */ return suburItem; }
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;/*from www . ja v a2s .c o 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 isDraft() { if (getStatus() == WorkflowConstants.STATUS_DRAFT) { return true; } else {//from w ww . j av a 2 s . co m return false; } }
From source file:com.inkwell.internet.slogan.service.impl.SloganLocalServiceImpl.java
License:Open Source License
/** * Adds a new slogan to the database.// www. j av a2 s.c o m * * @param newSlogan * @param userId * @return * @throws SystemException * @throws PortalException */ public Slogan addSlogan(Slogan newSlogan, long userId, ServiceContext serviceContext) throws SystemException, PortalException { Slogan slogan = sloganPersistence.create(counterLocalService.increment(Slogan.class.getName())); slogan.setCompanyId(newSlogan.getCompanyId()); slogan.setGroupId(newSlogan.getGroupId()); slogan.setUserId(serviceContext.getUserId()); slogan.setSloganDate(newSlogan.getSloganDate()); slogan.setSloganText(newSlogan.getSloganText()); slogan.setStatus(WorkflowConstants.STATUS_DRAFT); sloganPersistence.update(slogan, false); resourceLocalService.addResources(newSlogan.getCompanyId(), newSlogan.getGroupId(), userId, Slogan.class.getName(), slogan.getPrimaryKey(), false, true, true); assetEntryLocalService.updateEntry(userId, slogan.getGroupId(), Slogan.class.getName(), slogan.getSloganId(), serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames()); // Workflow WorkflowHandlerRegistryUtil.startWorkflowInstance(slogan.getCompanyId(), slogan.getGroupId(), userId, Slogan.class.getName(), slogan.getPrimaryKey(), slogan, serviceContext); sendMessage(slogan, serviceContext); return slogan; }
From source file:com.library.slayer.service.impl.LMSBookLocalServiceImpl.java
License:Open Source License
public LMSBook addEntry(long userId, long groupId, long companyId, String bookTitle, String author, String description, ServiceContext serviceContext) throws PortalException, SystemException { LMSBook lmsBook = null;/*from w w w . j a v a 2 s . c o m*/ long classPK = 0l; String userName = userLocalService.getUser(userId).getFullName(); //lmsBook = super.addLMSBook(lmsBook); try { classPK = CounterLocalServiceUtil.increment(LMSBook.class.getName()); lmsBook = LMSBookLocalServiceUtil.createLMSBook(classPK); lmsBook.setBookTitle(bookTitle); lmsBook.setAuthor(author); lmsBook.setCreateDate(new Date()); lmsBook.setModifiedDate(new Date()); lmsBook.setCompanyId(companyId); lmsBook.setGroupId(groupId); lmsBook.setUserId(userId); lmsBook.setDescription(description); lmsBook.setUserName(userName); lmsBook.setStatus(WorkflowConstants.STATUS_DRAFT); lmsBook = LMSBookLocalServiceUtil.addLMSBook(lmsBook); WorkflowHandlerRegistryUtil.startWorkflowInstance(lmsBook.getCompanyId(), lmsBook.getUserId(), LMSBook.class.getName(), lmsBook.getBookId(), lmsBook, serviceContext); } catch (SystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Resources if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) { addEntryResources(lmsBook, userId, groupId, companyId, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions()); } else { addEntryResources(lmsBook, userId, groupId, companyId, serviceContext.getGroupPermissions(), serviceContext.getGuestPermissions()); } // Asset updateAsset(userId, groupId, lmsBook, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds()); // Social Activity SocialActivityLocalServiceUtil.addUniqueActivity(userId, groupId, LMSBook.class.getName(), classPK, LibraryActivityKeys.ADD_ENTRY, StringPool.BLANK, 0); return lmsBook; }
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) @Override// w w w . j a v a 2 s .c om public BlogsEntry addEntry(long userId, String title, String subtitle, String urlTitle, String description, String content, Date displayDate, boolean allowPingbacks, boolean allowTrackbacks, String[] trackbacks, String coverImageCaption, ImageSelector coverImageImageSelector, ImageSelector smallImageImageSelector, ServiceContext serviceContext) throws PortalException { // Entry User user = userPersistence.findByPrimaryKey(userId); long groupId = serviceContext.getScopeGroupId(); long entryId = counterLocalService.increment(); validate(title, urlTitle, content); BlogsEntry entry = blogsEntryPersistence.create(entryId); entry.setUuid(serviceContext.getUuid()); entry.setGroupId(groupId); entry.setCompanyId(user.getCompanyId()); entry.setUserId(user.getUserId()); entry.setUserName(user.getFullName()); entry.setTitle(title); entry.setSubtitle(subtitle); if (Validator.isNotNull(urlTitle)) { entry.setUrlTitle(getUniqueUrlTitle(entryId, groupId, urlTitle)); } entry.setDescription(description); entry.setContent(content); entry.setDisplayDate(displayDate); entry.setAllowPingbacks(allowPingbacks); entry.setAllowTrackbacks(allowTrackbacks); entry.setStatus(WorkflowConstants.STATUS_DRAFT); entry.setStatusByUserId(userId); entry.setStatusDate(serviceContext.getModifiedDate(null)); entry.setExpandoBridgeAttributes(serviceContext); blogsEntryPersistence.update(entry); // Resources if (serviceContext.isAddGroupPermissions() || serviceContext.isAddGuestPermissions()) { addEntryResources(entry, serviceContext.isAddGroupPermissions(), serviceContext.isAddGuestPermissions()); } else { addEntryResources(entry, serviceContext.getModelPermissions()); } // Asset updateAsset(userId, entry, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority()); // Images long coverImageFileEntryId = 0; String coverImageURL = null; if (coverImageImageSelector != null) { coverImageURL = coverImageImageSelector.getImageURL(); if (coverImageImageSelector.getImageBytes() != null) { coverImageFileEntryId = addCoverImageFileEntry(userId, groupId, entryId, coverImageImageSelector); } } long smallImageFileEntryId = 0; String smallImageURL = null; if (smallImageImageSelector != null) { smallImageURL = smallImageImageSelector.getImageURL(); if (smallImageImageSelector.getImageBytes() != null) { smallImageFileEntryId = addSmallImageFileEntry(userId, groupId, entryId, smallImageImageSelector); } } validate(smallImageFileEntryId); entry.setCoverImageCaption(coverImageCaption); entry.setCoverImageFileEntryId(coverImageFileEntryId); entry.setCoverImageURL(coverImageURL); if ((smallImageFileEntryId != 0) || Validator.isNotNull(smallImageURL)) { entry.setSmallImage(true); } entry.setSmallImageFileEntryId(smallImageFileEntryId); entry.setSmallImageURL(smallImageURL); blogsEntryPersistence.update(entry); // Workflow if (ArrayUtil.isNotEmpty(trackbacks)) { serviceContext.setAttribute("trackbacks", trackbacks); } else { serviceContext.setAttribute("trackbacks", null); } return startWorkflowInstance(userId, entry, serviceContext); }
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
/** * Moves the blogs entry to the recycle bin. Social activity counters for * this entry get disabled./* w w w . j av a 2 s . c o m*/ * * @param userId the primary key of the user moving the blogs entry * @param entry the blogs entry to be moved * @return the moved blogs entry */ @Indexable(type = IndexableType.REINDEX) @Override public BlogsEntry moveEntryToTrash(long userId, BlogsEntry entry) throws PortalException { // Entry if (entry.isInTrash()) { throw new TrashEntryException(); } int oldStatus = entry.getStatus(); if (oldStatus == WorkflowConstants.STATUS_PENDING) { entry.setStatus(WorkflowConstants.STATUS_DRAFT); blogsEntryPersistence.update(entry); } entry = updateStatus(userId, entry.getEntryId(), WorkflowConstants.STATUS_IN_TRASH, new ServiceContext()); // Social JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject(); extraDataJSONObject.put("title", entry.getTitle()); SocialActivityManagerUtil.addActivity(userId, entry, SocialActivityConstants.TYPE_MOVE_TO_TRASH, extraDataJSONObject.toString(), 0); // Workflow if (oldStatus == WorkflowConstants.STATUS_PENDING) { workflowInstanceLinkLocalService.deleteWorkflowInstanceLink(entry.getCompanyId(), entry.getGroupId(), BlogsEntry.class.getName(), entry.getEntryId()); } return entry; }
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
@Indexable(type = IndexableType.REINDEX) @Override/*from w ww .j a va 2 s . c om*/ public BlogsEntry updateEntry(long userId, long entryId, String title, String subtitle, String urlTitle, String description, String content, Date displayDate, boolean allowPingbacks, boolean allowTrackbacks, String[] trackbacks, String coverImageCaption, ImageSelector coverImageImageSelector, ImageSelector smallImageImageSelector, ServiceContext serviceContext) throws PortalException { // Entry BlogsEntry entry = blogsEntryPersistence.findByPrimaryKey(entryId); validate(title, urlTitle, content); String oldUrlTitle = entry.getUrlTitle(); entry.setTitle(title); entry.setSubtitle(subtitle); if (Validator.isNotNull(urlTitle)) { entry.setUrlTitle(getUniqueUrlTitle(entryId, entry.getGroupId(), urlTitle)); } entry.setDescription(description); entry.setContent(content); entry.setDisplayDate(displayDate); entry.setAllowPingbacks(allowPingbacks); entry.setAllowTrackbacks(allowTrackbacks); if (entry.isPending() || entry.isDraft()) { } else { entry.setStatus(WorkflowConstants.STATUS_DRAFT); } entry.setExpandoBridgeAttributes(serviceContext); blogsEntryPersistence.update(entry); // Asset updateAsset(userId, entry, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(), serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority()); // Images long coverImageFileEntryId = entry.getCoverImageFileEntryId(); String coverImageURL = entry.getCoverImageURL(); long deletePreviousCoverImageFileEntryId = 0; if (coverImageImageSelector != null) { coverImageURL = coverImageImageSelector.getImageURL(); if (coverImageImageSelector.getImageBytes() != null) { coverImageFileEntryId = addCoverImageFileEntry(userId, entry.getGroupId(), entryId, coverImageImageSelector); } else { coverImageFileEntryId = 0; } deletePreviousCoverImageFileEntryId = entry.getCoverImageFileEntryId(); } long smallImageFileEntryId = entry.getSmallImageFileEntryId(); String smallImageURL = entry.getSmallImageURL(); long deletePreviousSmallImageFileEntryId = 0; if (smallImageImageSelector != null) { smallImageURL = smallImageImageSelector.getImageURL(); if (smallImageImageSelector.getImageBytes() != null) { smallImageFileEntryId = addSmallImageFileEntry(userId, entry.getGroupId(), entryId, smallImageImageSelector); } else { smallImageFileEntryId = 0; } deletePreviousSmallImageFileEntryId = entry.getSmallImageFileEntryId(); } validate(smallImageFileEntryId); entry.setCoverImageCaption(coverImageCaption); entry.setCoverImageFileEntryId(coverImageFileEntryId); entry.setCoverImageURL(coverImageURL); if ((smallImageFileEntryId != 0) || Validator.isNotNull(smallImageURL)) { entry.setSmallImage(true); } entry.setSmallImageFileEntryId(smallImageFileEntryId); entry.setSmallImageURL(smallImageURL); blogsEntryPersistence.update(entry); // Workflow boolean pingOldTrackbacks = false; if (!oldUrlTitle.equals(entry.getUrlTitle())) { pingOldTrackbacks = true; } serviceContext.setAttribute("pingOldTrackbacks", String.valueOf(pingOldTrackbacks)); if (ArrayUtil.isNotEmpty(trackbacks)) { serviceContext.setAttribute("trackbacks", trackbacks); } else { serviceContext.setAttribute("trackbacks", null); } entry = startWorkflowInstance(userId, entry, serviceContext); if (deletePreviousCoverImageFileEntryId != 0) { PortletFileRepositoryUtil.deletePortletFileEntry(deletePreviousCoverImageFileEntryId); } if (deletePreviousSmallImageFileEntryId != 0) { PortletFileRepositoryUtil.deletePortletFileEntry(deletePreviousSmallImageFileEntryId); } return entry; }