Share Scenario

This task shares the selected scenario with a different workspace.

    @Bean
    public ScriptedTaskDescription shareScenarioTask() {
        ScriptedTaskDescription task = new ScriptedTaskDescription("ShareScenarioTask", "Share Scenario");
        task.setDescription("Share the selected scenario to a different workspace");
        setI18nKeys(task, "SHARE_SCENARIO");

        var scenario = VariableAccessExpression.ofScenario();
        var workspace = VariableAccessExpression.of("Share to");
        var newScenarioId = VariableAccessExpression.of("newScenarioId");

        task.getScript()
            .addStatement(AskInputStatement.ofVariable(scenario, true, JobInputType.SCENARIO_ID))
            .addStatement(AskInputStatement.ofVariable(workspace, true, JobInputType.workspaceId(JobInputType.WorkspaceOrScenarioFilter.UNIQUE), "The Uuid of the new workspace to share the scenario to"))
            .addStatement(ExecuteRoutineStatement
                .of(StringExpression.of("com.decisionbrain.gene.ShareScenarioRoutine"))
                .withInput(scenario)
                .withInput(workspace)
                .withOutput("new-scenario-id", newScenarioId.getVariableName()))
            .addStatement(SetTaskOutputStatement.of("New Scenario ID", newScenarioId));

        return task;
    }