@startuml images/morpho_save_new_package_seq.png participant ": OpenPackageCommand " as open_package_command <> participant ": ResultPanel " as result_panel <> participant ": DataStoreController" as data_store_controller <> participant "store: DataStore" as data_store <> participant "scienceMetadata: AbstractScienceMetadata" as abstract_metadata <> participant "entity: Entity" as entity <> participant "dataPackage: DataPackage" as d1_datapackage <> activate open_package_command open_package_command -> result_panel: getSelectId() activate result_panel open_package_command <- result_panel: oreID deactivate result_panel open_package_command -> result_panel: getDataStores() activate result_panel open_package_command <- result_panel: []dataStores deactivate result_panel open_package_command -> data_store_controller: read(oreID, dataStores) activate data_store_controller data_store_controller -> data_store_controller: choose one store data_store_controller -> data_store: get(oreID) activate data_store data_store_controller <- data_store: Output stream of the ore document deactivate data_store data_store_controller -> data_store: getSystemMetadata(oreID) activate data_store data_store_controller <- data_store: systemMetadata object deactivate data_store data_store_controller -> data_store_controller: parse the ORE input stream and get list of ids of the metadata and data objects data_store_controller -> d1_datapackage: new DataPackage(oreID, dataStores) activate d1_datapackage data_store_controller <- d1_datapackage: dataPackage data_store_controller -> d1_datapackage: setSystemMetadata(systemMetadata) deactivate d1_datapackage data_store_controller -> abstract_metadata: create a concrete scienceMetada object activate abstract_metadata data_store_controller <- abstract_metadata: scienceMetadata deactivate abstract_metadata data_store_controller -> d1_datapackage: add(scienceMetadata) loop iterate the entityId list data_store_controller -> entity: new Entity(entityId, dataStores) activate entity data_store_controller <- entity: entity deactivate entity data_store_controller -> d1_datapackage: add(entity) end data_store_controller -> d1_datapackage: addRelationShip() deactivate data_store_controller open_package_command <- d1_datapackage: dataPackage deactivate open_package_command @enduml