@Override public WorkflowInstanceLink addWorkflowInstanceLink( long userId, long companyId, long groupId, String className, long classPK, long workflowInstanceId) throws PortalException { User user = userPersistence.findByPrimaryKey(userId); long classNameId = classNameLocalService.getClassNameId(className); long workflowInstanceLinkId = counterLocalService.increment(); WorkflowInstanceLink workflowInstanceLink = workflowInstanceLinkPersistence.create(workflowInstanceLinkId); workflowInstanceLink.setUserId(userId); workflowInstanceLink.setUserName(user.getFullName()); workflowInstanceLink.setGroupId(groupId); workflowInstanceLink.setCompanyId(companyId); workflowInstanceLink.setClassNameId(classNameId); workflowInstanceLink.setClassPK(classPK); workflowInstanceLink.setWorkflowInstanceId(workflowInstanceId); workflowInstanceLinkPersistence.update(workflowInstanceLink); return workflowInstanceLink; }
@Override public void updateClassPK( long companyId, long groupId, String className, long oldClassPK, long newClassPK) throws PortalException { if (!WorkflowThreadLocal.isEnabled()) { return; } List<WorkflowInstanceLink> workflowInstanceLinks = getWorkflowInstanceLinks(companyId, groupId, className, oldClassPK); for (WorkflowInstanceLink workflowInstanceLink : workflowInstanceLinks) { WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance( workflowInstanceLink.getCompanyId(), workflowInstanceLink.getWorkflowInstanceId()); workflowInstanceLink.setClassPK(newClassPK); workflowInstanceLinkPersistence.update(workflowInstanceLink); Map<String, Serializable> workflowContext = new HashMap<>(workflowInstance.getWorkflowContext()); workflowContext.put(WorkflowConstants.CONTEXT_ENTRY_CLASS_PK, String.valueOf(newClassPK)); WorkflowInstanceManagerUtil.updateWorkflowContext( workflowInstanceLink.getCompanyId(), workflowInstanceLink.getWorkflowInstanceId(), workflowContext); } }