/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.portal.workflow.kaleo.runtime.scripting.internal.assignment; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.workflow.kaleo.model.KaleoTaskAssignment; import com.liferay.portal.workflow.kaleo.runtime.ExecutionContext; import com.liferay.portal.workflow.kaleo.runtime.assignment.BaseTaskAssignmentSelector; import com.liferay.portal.workflow.kaleo.runtime.assignment.TaskAssignmentSelector; import com.liferay.portal.workflow.kaleo.runtime.scripting.internal.util.KaleoScriptingEvaluator; import com.liferay.portal.workflow.kaleo.runtime.util.WorkflowContextUtil; import java.util.Collection; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; /** * @author Michael C. Han */ @Component( immediate = true, property = { "scripting.language=beanshell", "scripting.language=groovy", "scripting.language=javascript", "scripting.language=python", "scripting.language=ruby" }, service = TaskAssignmentSelector.class ) public class ScriptingLanguagesTaskAssignmentSelector extends BaseTaskAssignmentSelector { @Override public Collection<KaleoTaskAssignment> calculateTaskAssignments( KaleoTaskAssignment kaleoTaskAssignment, ExecutionContext executionContext) throws PortalException { String assigneeScript = kaleoTaskAssignment.getAssigneeScript(); String assigneeScriptingLanguage = kaleoTaskAssignment.getAssigneeScriptLanguage(); Map<String, Object> results = _kaleoScriptingEvaluator.execute( executionContext, _outputNames, assigneeScriptingLanguage, assigneeScript); return getKaleoTaskAssignments(results); } private static final Set<String> _outputNames = new HashSet<>(); static { _outputNames.add(ROLES_ASSIGNMENT); _outputNames.add(USER_ASSIGNMENT); _outputNames.add(WorkflowContextUtil.WORKFLOW_CONTEXT_NAME); } @Reference private KaleoScriptingEvaluator _kaleoScriptingEvaluator; }