Class AutomationProjectManager
AutomationProjectManager serves as the central repository for project-level configuration, maintaining the currently active Project and providing mechanisms to load new projects from JSON definitions. A Project in Brobot encapsulates all the configuration, states, transitions, and settings needed for a complete automation solution.
Key responsibilities:
- Project Loading: Deserializes project definitions from JSON format
- Active Project Management: Maintains reference to the current project
- Configuration Parsing: Leverages JsonParser for robust JSON handling
- Project Switching: Supports changing active projects at runtime
Project lifecycle:
- Load project configuration from JSON string or file
- Parse and validate the project structure
- Set as active project for the automation framework
- All services access configuration through this manager
JSON project format:
- States and their configurations
- State transitions and navigation paths
- Project-specific settings and parameters
- Image resources and recognition patterns
Common usage patterns:
- Load project at application startup
- Switch projects for different automation tasks
- Access project configuration from various services
- Reload project after external modifications
Error handling:
- Throws ConfigurationException for invalid JSON
- Validates project structure during loading
- Maintains previous project on load failure
In the model-based approach, AutomationProjectManager is the gateway to the automation model. It transforms declarative project definitions into the runtime configuration that drives all automation behavior. This separation of configuration from code enables non-programmers to create and modify automation projects through visual tools or direct JSON editing.
- Since:
- 1.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAutomationProjectManager
(ConfigurationParser jsonParser) Constructs an AutomationProjectManager with required JSON parsing capability. -
Method Summary
Modifier and TypeMethodDescriptionThe currently active project configuration.Gets the list of available projects.Gets the currently active project.Parser for deserializing JSON project definitions.void
loadProject
(String json) Loads a project from a JSON string representation.void
Refreshes the list of available projects.void
setActiveProject
(AutomationProject activeProject) The currently active project configuration.
-
Constructor Details
-
AutomationProjectManager
Constructs an AutomationProjectManager with required JSON parsing capability.- Parameters:
jsonParser
- Parser for handling project JSON deserialization
-
-
Method Details
-
loadProject
Loads a project from a JSON string representation.Deserializes the JSON into a Project object and sets it as the active project. The JSON must conform to the Project schema with all required fields properly defined.
Side effects:
- Replaces the current active project
- Does not backup previous project
- May leave activeProject unchanged on parse failure
Example JSON structure:
{ "name": "MyAutomation", "states": [...], "transitions": [...], "settings": {...} }
- Parameters:
json
- JSON string containing project definition- Throws:
ConfigurationException
- if JSON is invalid or missing required fields- See Also:
-
getAvailableProjects
Gets the list of available projects. For now, returns a simple list with a default project.- Returns:
- List of available project names
-
getCurrentProject
Gets the currently active project.- Returns:
- The current AutomationProject or null if none is loaded
-
refreshProjects
public void refreshProjects()Refreshes the list of available projects. For now, this is a no-op. -
getJsonParser
Parser for deserializing JSON project definitions. Handles complex project structures with polymorphic types. -
getActiveProject
The currently active project configuration.Contains all states, transitions, and settings for the current automation task. May be null before initial project loading.
-
setActiveProject
The currently active project configuration.Contains all states, transitions, and settings for the current automation task. May be null before initial project loading.
-