001
014
015 package com.liferay.portlet.dynamicdatalists.workflow;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.workflow.BaseWorkflowHandler;
021 import com.liferay.portal.kernel.workflow.WorkflowConstants;
022 import com.liferay.portal.model.WorkflowDefinitionLink;
023 import com.liferay.portal.security.permission.ResourceActionsUtil;
024 import com.liferay.portal.service.ServiceContext;
025 import com.liferay.portal.service.WorkflowDefinitionLinkLocalServiceUtil;
026 import com.liferay.portal.theme.ThemeDisplay;
027 import com.liferay.portlet.dynamicdatalists.model.DDLRecord;
028 import com.liferay.portlet.dynamicdatalists.model.DDLRecordSet;
029 import com.liferay.portlet.dynamicdatalists.model.DDLRecordVersion;
030 import com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalServiceUtil;
031
032 import java.io.Serializable;
033
034 import java.util.Locale;
035 import java.util.Map;
036
037
040 public class DDLRecordWorkflowHandler extends BaseWorkflowHandler {
041
042 public static final String CLASS_NAME = DDLRecord.class.getName();
043
044 public String getClassName() {
045 return CLASS_NAME;
046 }
047
048 public String getType(Locale locale) {
049 return ResourceActionsUtil.getModelResource(locale, CLASS_NAME);
050 }
051
052 @Override
053 public WorkflowDefinitionLink getWorkflowDefinitionLink(
054 long companyId, long groupId, long classPK)
055 throws PortalException, SystemException {
056
057 DDLRecordVersion recordVersion =
058 DDLRecordLocalServiceUtil.getRecordVersion(classPK);
059
060 DDLRecord record = recordVersion.getRecord();
061
062 return WorkflowDefinitionLinkLocalServiceUtil.getWorkflowDefinitionLink(
063 companyId, groupId, DDLRecordSet.class.getName(),
064 record.getRecordSetId(), 0);
065 }
066
067 @Override
068 public boolean isVisible() {
069 return false;
070 }
071
072 public DDLRecord updateStatus(
073 int status, Map<String, Serializable> workflowContext)
074 throws PortalException, SystemException {
075
076 long userId = GetterUtil.getLong(
077 (String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
078 long classPK = GetterUtil.getLong(
079 (String)workflowContext.get(
080 WorkflowConstants.CONTEXT_ENTRY_CLASS_PK));
081
082 ServiceContext serviceContext = (ServiceContext)workflowContext.get(
083 "serviceContext");
084
085 return DDLRecordLocalServiceUtil.updateStatus(
086 userId, classPK, status, serviceContext);
087 }
088
089 @Override
090 protected String getIconPath(ThemeDisplay themeDisplay) {
091 return themeDisplay.getPathThemeImages() + "/common/history.png";
092 }
093
094 }