Class ScenarioManager


  • @OpenApiAll
    public class ScenarioManager
    extends java.lang.Object

    Scenario can be manipulated from Open API.

    • The Scenario class represents a use case scenario. It contains methods for manipulating it.
    • The ScenarioManager class contains utility methods for creating and manipulating scenarios.
    • The scenario management calls should be wrapped with the session management calls.
    See an example of how to create the use case scenario with the basic, alternative, and exceptional flows. Scenario can be opened in a diagram.

    
     // Scenario manipulation should be wrapped with the session management calls.
     SessionManager sessionManager = SessionManager.getInstance();
     sessionManager.createSession("Create scenario");
    
     // Creates a use case scenario.
     Scenario scenario = ScenarioManager.createScenario(useCase);
     // Sets the scenario name.
     scenario.setName("Extract money from ATM.");
    
     // Adds a basic flow step.
     FlowStep flowStep1 = scenario.addFlowStep();
     // Sets a name for the basic flow step.
     flowStep1.setName("Insert card");
    
     FlowStep flowStep2 = scenario.addFlowStep();
     flowStep2.setName("Enter pin");
    
     FlowStep flowStep3 = scenario.addFlowStep();
     flowStep3.setName("Good bye");
    
     // Adds an alternative condition for the basic flow step.
     AlternativeCondition condition = scenario.addAlternativeCondition(flowStep2);
     // Sets a condition guard.
     condition.setIfCondition("Pin correct");
    
     // Sets a name for the alternative flow step.
     FlowStep flowStep = condition.getAlternativeFlowSteps().get(0);
     flowStep.setName("Extract money");
     // Adds an exception type to the basic flow step.
     ExceptionType exceptionType = scenario.addExceptionType(flowStep2);
    
     // Sets a name for the exception type.
     exceptionType.setName("Card expired");
     // Sets a name for the exceptional flow step.
     FlowStep exceptionalFlowStep = exceptionType.getExceptionalFlowSteps().get(0);
     exceptionalFlowStep.setName("Inform customer about expired card");
     sessionManager.closeSession();
    
     // Opens and layouts the scenario diagram.
     ScenarioManager.displayScenario(scenario, true, true, "Open ATM Scenario");
     

    For more information about the use case scenario, see the "Use Case Scenario" section in the "MagicDraw UserManual.pdf".

    See Also:
    Scenario, ScenarioFactory, AlternativeCondition, ExceptionType, FlowStep, ScenarioNode, ScenarioNodeEnd, ScenarioNodeStart, ScenarioReadResult, ScenarioRepresentationTextProvider
    • Constructor Summary

      Constructors 
      Constructor Description
      ScenarioManager()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Scenario createScenario​(UseCase useCase)
      Creates and initializes scenario for a given use case.
      static void displayScenario​(Scenario scenario, boolean openDiagram, boolean layout, java.lang.String sessionName)
      Displays scenario on the diagram.
      static void setScenarioFactory​(ScenarioFactory scenarioFactory)
      Sets scenario factory with which to create scenarios.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ScenarioManager

        public ScenarioManager()
    • Method Detail

      • createScenario

        public static Scenario createScenario​(UseCase useCase)
        Creates and initializes scenario for a given use case.
        Parameters:
        useCase - use case for which to create scenario.
        Returns:
        created scenario.
      • setScenarioFactory

        public static void setScenarioFactory​(ScenarioFactory scenarioFactory)
        Sets scenario factory with which to create scenarios. By setting another scenario factory it is possible to create custom scenarios.
        Parameters:
        scenarioFactory - scenario factory with which to create scenarios.
      • displayScenario

        public static void displayScenario​(Scenario scenario,
                                           boolean openDiagram,
                                           boolean layout,
                                           java.lang.String sessionName)
        Displays scenario on the diagram. Performs necessary preparations and creates scenario symbols on the diagram. Creates its own session, all sessions should be closed before invoking this method. A session name can be passed.
        Parameters:
        scenario - scenario to display.
        openDiagram - indicates whether scenario diagram should be opened.
        layout - indicates whether scenario diagram should be layouted.
        sessionName - name of the session to use in undo/redo history.