Skip to content

Commit

Permalink
feat(area): rename move_area command to update_area_ui
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoPascoli committed Feb 6, 2025
1 parent d6b94a6 commit a91fb01
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions antarest/study/business/area_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
from antarest.study.storage.storage_service import StudyStorageService
from antarest.study.storage.variantstudy.model.command.create_area import CreateArea
from antarest.study.storage.variantstudy.model.command.icommand import ICommand
from antarest.study.storage.variantstudy.model.command.move_area import MoveArea
from antarest.study.storage.variantstudy.model.command.remove_area import RemoveArea
from antarest.study.storage.variantstudy.model.command.update_area_ui import UpdateAreaUI
from antarest.study.storage.variantstudy.model.command.update_config import UpdateConfig

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -507,7 +507,7 @@ def update_area_metadata(
def update_area_ui(self, study: Study, area_id: str, area_ui: UpdateAreaUi, layer: str = "0") -> None:
file_study = self.storage_service.get_storage(study).get_raw(study)

command = MoveArea(
command = UpdateAreaUI(
area_id=area_id,
area_ui=area_ui,
layer=layer,
Expand Down
4 changes: 2 additions & 2 deletions antarest/study/storage/variantstudy/command_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
GenerateThermalClusterTimeSeries,
)
from antarest.study.storage.variantstudy.model.command.icommand import ICommand
from antarest.study.storage.variantstudy.model.command.move_area import MoveArea
from antarest.study.storage.variantstudy.model.command.remove_area import RemoveArea
from antarest.study.storage.variantstudy.model.command.remove_binding_constraint import RemoveBindingConstraint
from antarest.study.storage.variantstudy.model.command.remove_cluster import RemoveCluster
Expand All @@ -45,6 +44,7 @@
from antarest.study.storage.variantstudy.model.command.remove_st_storage import RemoveSTStorage
from antarest.study.storage.variantstudy.model.command.remove_user_resource import RemoveUserResource
from antarest.study.storage.variantstudy.model.command.replace_matrix import ReplaceMatrix
from antarest.study.storage.variantstudy.model.command.update_area_ui import UpdateAreaUI
from antarest.study.storage.variantstudy.model.command.update_binding_constraint import UpdateBindingConstraint
from antarest.study.storage.variantstudy.model.command.update_comments import UpdateComments
from antarest.study.storage.variantstudy.model.command.update_config import UpdateConfig
Expand All @@ -58,7 +58,7 @@

COMMAND_MAPPING = {
CommandName.CREATE_AREA.value: CreateArea,
CommandName.MOVE_AREA.value: MoveArea,
CommandName.UPDATE_AREA_UI.value: UpdateAreaUI,
CommandName.REMOVE_AREA.value: RemoveArea,
CommandName.CREATE_DISTRICT.value: CreateDistrict,
CommandName.REMOVE_DISTRICT.value: RemoveDistrict,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FilteringOptions:

class CommandName(Enum):
CREATE_AREA = "create_area"
MOVE_AREA = "move_area"
UPDATE_AREA_UI = "update_area_ui"
REMOVE_AREA = "remove_area"
CREATE_DISTRICT = "create_district"
REMOVE_DISTRICT = "remove_district"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
from antarest.study.storage.variantstudy.model.model import CommandDTO


class MoveArea(ICommand):
class UpdateAreaUI(ICommand):
"""
Command used to move an area inside the map and to update its UI.
"""

# Overloaded metadata
# ===================

command_name: CommandName = CommandName.MOVE_AREA
command_name: CommandName = CommandName.UPDATE_AREA_UI
version: int = 1

# Command parameters
Expand Down Expand Up @@ -67,7 +67,7 @@ def _apply(self, study_data: FileStudy, listener: t.Optional[ICommandListener] =
@override
def to_dto(self) -> CommandDTO:
return CommandDTO(
action=CommandName.MOVE_AREA.value,
action=CommandName.UPDATE_AREA_UI.value,
args={"area_id": self.area_id, "area_ui": self.area_ui, "layer": self.layer},
study_version=self.study_version,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/storage/business/test_arealink_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def test_area_crud(empty_study: FileStudy, matrix_service: SimpleMatrixService):
[
CommandDTO(
id=None,
action=CommandName.MOVE_AREA.value,
action=CommandName.UPDATE_AREA_UI.value,
args={
"area_id": "test",
"area_ui": UpdateAreaUi(
Expand Down
2 changes: 1 addition & 1 deletion tests/variantstudy/test_command_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
CommandDTO(action=CommandName.REMOVE_AREA.value, args={"id": "id"}, study_version=STUDY_VERSION_8_8),
CommandDTO(action=CommandName.REMOVE_AREA.value, args=[{"id": "id"}], study_version=STUDY_VERSION_8_8),
CommandDTO(
action=CommandName.MOVE_AREA.value,
action=CommandName.UPDATE_AREA_UI.value,
args={
"area_id": "id",
"area_ui": UpdateAreaUi(x=100, y=100, color_rgb=(100, 100, 100), layer_x={}, layer_y={}, layer_color={}),
Expand Down

0 comments on commit a91fb01

Please sign in to comment.