]> SALOME platform Git repositories - modules/jobmanager.git/commitdiff
Salome HOME
- Begin of clone
authorribes <ribes>
Mon, 25 Jan 2010 14:51:24 +0000 (14:51 +0000)
committerribes <ribes>
Mon, 25 Jan 2010 14:51:24 +0000 (14:51 +0000)
src/engine/BL_SALOMEServices.cxx
src/genericgui/BL_Buttons.cxx
src/genericgui/BL_Buttons.hxx
src/genericgui/BL_CreateJobWizard.cxx
src/genericgui/BL_CreateJobWizard.hxx
src/genericgui/BL_GenericGui.cxx
src/genericgui/BL_GenericGui.hxx
src/genericgui/BL_JobsManager_QT.cxx
src/genericgui/BL_JobsManager_QT.hxx

index 3060fb764cd075cf4d15c4171b6c234e2af3e353..da485c3002898c7e917865df3814609f67dab176 100644 (file)
@@ -89,7 +89,7 @@ BL::SALOMEServices::getResourceList()
     Engines::ResourceList * resourceList = NULL;
     try
     {
-      Engines::ResourceList * resourceList = _resources_manager->GetFittingResources(params);
+      resourceList = _resources_manager->GetFittingResources(params);
     }
     catch (const SALOME::SALOME_Exception & ex)
     {
index b13f7dfaa4cd376ad0912e8753199c9073fd8512..2e82557fa939a3b936336d3d5f3cd171bf44c813 100644 (file)
@@ -25,14 +25,16 @@ BL::Buttons::Buttons(QWidget * parent) : QGroupBox(parent)
 
   setTitle("Actions");
 
-  _create_button = new QPushButton("Create Job", this);
-  _start_button = new QPushButton("Start Job", this);
-  _delete_button = new QPushButton("Delete Job", this);
+  _create_button = new QPushButton("Create a Job", this);
+  _edit_clone_button = new QPushButton("Edit/Clone a Job", this);
+  _start_button = new QPushButton("Start a Job", this);
+  _delete_button = new QPushButton("Delete a Job", this);
   _get_results_button = new QPushButton("Get Job Results", this);
   _refresh_button = new QPushButton("Refresh Jobs", this);
 
   QHBoxLayout *mainLayout = new QHBoxLayout;
   mainLayout->addWidget(_create_button);
+  mainLayout->addWidget(_edit_clone_button);
   mainLayout->addWidget(_start_button);
   mainLayout->addWidget(_delete_button);
   mainLayout->addWidget(_get_results_button);
@@ -59,6 +61,12 @@ BL::Buttons::setCreateButtonSlot(QObject * receiver, const char * name)
   connect(_create_button, SIGNAL(clicked()), receiver, name);
 }
 
+void
+BL::Buttons::setEditCloneButtonSlot(QObject * receiver, const char * name)
+{
+  connect(_edit_clone_button, SIGNAL(clicked()), receiver, name);
+}
+
 void
 BL::Buttons::setStartButtonSlot(QObject * receiver, const char * name)
 {
@@ -83,6 +91,18 @@ BL::Buttons::setGetResultsButtonSlot(QObject * receiver, const char * name)
   connect(_get_results_button, SIGNAL(clicked()), receiver, name);
 }
 
+void 
+BL::Buttons::enable_edit_clone_button()
+{
+  _edit_clone_button->setEnabled(true);
+}
+
+void 
+BL::Buttons::disable_edit_clone_button()
+{
+  _edit_clone_button->setEnabled(false);
+}
+
 void 
 BL::Buttons::enable_start_button()
 {
index 866e96d78a11ae9bd1ccb51ae9b08bbb7232f44f..e364cd7e57954b24a7b60fe1d9ef90585ab35f12 100644 (file)
@@ -35,11 +35,15 @@ namespace BL
       virtual ~Buttons();
 
       void setCreateButtonSlot(QObject * receiver, const char * name);
+      void setEditCloneButtonSlot(QObject * receiver, const char * name);
       void setStartButtonSlot(QObject * receiver, const char * name);
       void setDeleteButtonSlot(QObject * receiver, const char * name);
       void setRefreshButtonSlot(QObject * receiver, const char * name);
       void setGetResultsButtonSlot(QObject * receiver, const char * name);
 
+      void enable_edit_clone_button();
+      void disable_edit_clone_button();
+
       void enable_start_button();
       void disable_start_button();
 
@@ -51,6 +55,7 @@ namespace BL
 
     protected:  
       QPushButton * _create_button;
+      QPushButton * _edit_clone_button;
       QPushButton * _start_button;
       QPushButton * _delete_button;
       QPushButton * _get_results_button;
index 70211a13e1fab33b3685a2d8525e1885245804fc..e247c8708bef979b7c84b62ea0f63b1600a8f9b7 100644 (file)
@@ -46,7 +46,9 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO
   setOptions(QWizard::IndependentPages | QWizard::NoBackButtonOnStartPage);
 
   // Common pages
-  setPage(Page_JobName, new BL::JobNamePage(this, _jobs_manager));
+  _job_name_page = new BL::JobNamePage(this, _jobs_manager);
+
+  setPage(Page_JobName, _job_name_page);
   setPage(Page_BatchParameters, new BL::BatchParametersPage(this));
   setPage(Page_Files, new BL::FilesPage(this));
   setPage(Page_Resource, new BL::ResourcePage(this, salome_services));
@@ -66,6 +68,83 @@ BL::CreateJobWizard::~CreateJobWizard()
   DEBTRACE("Destroying BL::CreateJobWizard");
 }
 
+void
+BL::CreateJobWizard::clone(const std::string & name)
+{
+  if (_jobs_manager->job_already_exist(name) == true)
+  {
+    BL::Job * job = _jobs_manager->getJob(name);
+
+    // We can only edit a job in CREATED, ERROR or FINISHED
+    if (job->getState() == BL::Job::CREATED or BL::Job::FINISHED or BL::Job::ERROR)
+    { 
+      setField("job_name", QString(name.c_str()));
+    }
+
+    if (job->getType() == BL::Job::YACS_SCHEMA)
+    {
+      setField("yacs_file", QString(job->getJobFile().c_str()));
+      _job_name_page->_yacs_schema_button->click();
+      setField("env_yacs_file", QString(job->getEnvFile().c_str()));
+    }
+    else if (job->getType() == BL::Job::COMMAND)
+    {
+      setField("command", QString(job->getJobFile().c_str()));
+      _job_name_page->_command_button->click();
+      setField("env_command_file", QString(job->getEnvFile().c_str()));
+    }
+    else if (job->getType() == BL::Job::PYTHON_SALOME)
+    {
+      setField("PythonSalome", QString(job->getJobFile().c_str()));
+      _job_name_page->_yacs_schema_button->click();
+      setField("env_PythonSalome_file", QString(job->getEnvFile().c_str()));
+    }
+
+    BL::Job::BatchParam batch_params = job->getBatchParameters();
+    setField("batch_directory", QString(batch_params.batch_directory.c_str()));
+    QString proc_value;
+    proc_value.setNum(batch_params.nb_proc);
+    setField("proc_value", proc_value);
+
+    std::size_t pos = batch_params.maximum_duration.find(":");
+    std::string hour_str = batch_params.maximum_duration.substr(0, pos);
+    int hour; 
+    std::istringstream iss_hour(hour_str);
+    iss_hour >> hour;
+    setField("duration_hour", hour);
+
+    std::string min_str = batch_params.maximum_duration.substr(pos + 1, batch_params.maximum_duration.npos);
+    int min; 
+    std::istringstream iss_min(min_str);
+    iss_min >> min;
+    setField("duration_min", min);
+
+    std::string mem_type = batch_params.expected_memory.substr(batch_params.expected_memory.size() - 2, 2);
+    if (mem_type == "mb")
+      setField("mem_type", 0);
+    else
+      setField("mem_type", 1);
+    std::string mem_value = batch_params.expected_memory.substr(0, batch_params.expected_memory.find(mem_type));
+    int mem_val; 
+    std::istringstream iss_mem(mem_value);
+    iss_mem >> mem_val;
+    setField("mem_value", mem_val);
+
+    BL::Job::FilesParam files_params = job->getFilesParameters();
+
+    std::list<std::string>::iterator it = files_params.input_files_list.begin();
+    for (; it != files_params.input_files_list.end(); it++)
+      _input_files_list->addItem(QString((*it).c_str()));
+    it = files_params.output_files_list.begin();
+    for (; it != files_params.output_files_list.end(); it++)
+      _output_files_list->addItem(QString((*it).c_str()));
+
+    setField("result_directory", QString(files_params.result_directory.c_str()));
+    setField("resource_choosed", QString(job->getResource().c_str()));
+    setField("batch_queue", QString(job->getBatchQueue().c_str()));
+  }
+}
+
 void
 BL::CreateJobWizard::setFilesList(QListWidget * input_files_list, QListWidget * output_files_list)
 {
@@ -118,7 +197,7 @@ BL::CreateJobWizard::end(int result)
       time_min = "0" + field("duration_min").toString();
     else
       time_min = field("duration_min").toString();
-    maximum_duration = time_hour.toStdString() + ":" + time_min.toStdString() + ":00";
+    maximum_duration = time_hour.toStdString() + ":" + time_min.toStdString();
 
     QString mem = field("mem_value").toString();
     int mem_type_i = field("mem_type").toInt();
index 78bd2509209c9021aa99801385419e09e590ee93..9ee578911e651718f8ee61ca64d39ad10238db94 100644 (file)
@@ -33,6 +33,7 @@
 namespace BL{
 
   class JobsManager_QT;
+  class JobNamePage;
   class CreateJobWizard: virtual public QWizard
   {
     Q_OBJECT
@@ -43,6 +44,8 @@ namespace BL{
 
       void setFilesList(QListWidget * input_files_list, QListWidget * output_files_list);
 
+      void clone(const std::string & name);
+
     public slots:
       void end(int result);
 
@@ -53,6 +56,8 @@ namespace BL{
       QListWidget * _input_files_list;
       QListWidget * _output_files_list;
 
+      BL::JobNamePage * _job_name_page;
+
     public:
       // Results
       std::string job_name;
@@ -106,10 +111,12 @@ namespace BL{
 
     private:     
       BL::JobsManager_QT * _jobs_manager;
+      QLabel * _explanation;
+
+    public:
       QRadioButton * _yacs_schema_button;
       QRadioButton * _command_button;
       QRadioButton * _python_salome_button;
-      QLabel * _explanation;
   };
 
   class ConclusionPage: virtual public QWizardPage
index 66aae0de2aaf4da751340a469956a1e52f56ecaf..66e912a37131579f3a8f7634eb41b8ac6190d009 100644 (file)
@@ -43,6 +43,7 @@ BL::GenericGui::GenericGui(BL::MainWindows_Wrap * wrapper) : QObject(wrapper->ge
   /* Buttons */
   _buttons = new BL::Buttons(_tab_parent);
   _buttons->setCreateButtonSlot(this, SLOT(create_job()));
+  _buttons->setEditCloneButtonSlot(this, SLOT(edit_clone_job()));
   _buttons->setStartButtonSlot(this, SLOT(start_job()));
   _buttons->setDeleteButtonSlot(this, SLOT(delete_job()));
   _buttons->setRefreshButtonSlot(this, SLOT(refresh_job()));
@@ -137,10 +138,11 @@ void
 BL::GenericGui::createActions()
 {
   DEBTRACE("CreateActions BL::GenericGui");
-  _create_job_action = _wrapper->createAction("Create Job", QIcon(), "Create Job", "Create Job", 0, _dock_parent, false, this, SLOT(create_job()));
-  _start_job_action = _wrapper->createAction("Start Job", QIcon(), "Start Job", "Start Job", 0, _dock_parent, false, this, SLOT(start_job()));
-  _delete_job_action = _wrapper->createAction("Delete Job", QIcon(), "Delete Job", "Delete Job", 0, _dock_parent, false, this, SLOT(delete_job()));
-  _refresh_job_action = _wrapper->createAction("Refresh Job", QIcon(), "Refresh Job", "Refresh Job", 0, _dock_parent, false, this, SLOT(refresh_job()));
+  _create_job_action = _wrapper->createAction("Create a Job", QIcon(), "Create a Job", "Create a Job", 0, _dock_parent, false, this, SLOT(create_job()));
+  _edit_clone_job_action = _wrapper->createAction("Edit/Clone a Job", QIcon(), "Edit/Clone a Job", "Edit/Clone a Job", 0, _dock_parent, false, this, SLOT(edit_clone_job()));
+  _start_job_action = _wrapper->createAction("Start a Job", QIcon(), "Start a Job", "Start a Job", 0, _dock_parent, false, this, SLOT(start_job()));
+  _delete_job_action = _wrapper->createAction("Delete a Job", QIcon(), "Delete a Job", "Delete a Job", 0, _dock_parent, false, this, SLOT(delete_job()));
+  _refresh_job_action = _wrapper->createAction("Refresh Jobs", QIcon(), "Refresh Jobs", "Refresh Jobs", 0, _dock_parent, false, this, SLOT(refresh_job()));
   _get_results_job_action = _wrapper->createAction("Get Job Results", QIcon(), "Get Job Results", "Get Job Results", 0, _dock_parent, false, this, SLOT(refresh_job()));
 }
 
@@ -150,6 +152,7 @@ BL::GenericGui::createMenus()
   DEBTRACE("CreateMenus BL::GenericGui");
   int menu_id = _wrapper->createTopMenu("JobManager");
   _wrapper->addActionToMenu(_create_job_action, menu_id);
+  _wrapper->addActionToMenu(_edit_clone_job_action, menu_id);
   _wrapper->addActionToMenu(_start_job_action, menu_id);
   _wrapper->addActionToMenu(_delete_job_action, menu_id);
   _wrapper->addActionToMenu(_get_results_job_action, menu_id);
@@ -163,6 +166,13 @@ BL::GenericGui::create_job()
   _jobs_manager->create_job_wizard();
 }
 
+void
+BL::GenericGui::edit_clone_job()
+{
+  DEBTRACE("Edit/Clone Job Slot BL::GenericGui");
+  _jobs_manager->create_job_wizard(_job_name_selected.toStdString());
+}
+
 void
 BL::GenericGui::start_job()
 {
@@ -234,12 +244,16 @@ BL::GenericGui::updateButtonsStates()
     _buttons->disable_start_button();
     _buttons->disable_delete_button();
     _buttons->disable_get_results_button();
+    _edit_clone_job_action->setEnabled(false);
+    _buttons->disable_edit_clone_button();
   }
   else if (_job_name_selected != "" and _row_selected != -1)
   {
     BL::Job * job = _jobs_manager->getJob(_job_name_selected.toStdString());
     BL::Job::State job_state = job->getState();
 
+    _edit_clone_job_action->setEnabled(true);
+    _buttons->enable_edit_clone_button();
     switch (job_state)
     {
       case BL::Job::CREATED:
index 5a80e5e747683d3730f102dac17fc630a40470b4..0d0c03d2c87c7e87da7eb35a1b7a5b8ba29be95d 100644 (file)
@@ -52,6 +52,7 @@ namespace BL
 
     public slots:
       void create_job();
+      void edit_clone_job();
       void start_job();
       void delete_job();
       void refresh_job();
@@ -80,6 +81,7 @@ namespace BL
       BL::Summary * _summary;
 
       QAction * _create_job_action;
+      QAction * _edit_clone_job_action;
       QAction * _start_job_action;
       QAction * _delete_job_action;
       QAction * _get_results_job_action;
index f6c9627fb39faa5817370379e4336fde5741aec1..db22286fc89e74321f5bd1275f39f4b25da7882a 100644 (file)
@@ -150,9 +150,11 @@ BL::JobsManager_QT::one_hour_refresh()
 }
 
 void
-BL::JobsManager_QT::create_job_wizard()
+BL::JobsManager_QT::create_job_wizard(const std::string & name)
 {
     BL::CreateJobWizard wizard(this, _salome_services);
+    if (name != "")
+      wizard.clone(name);
     wizard.exec();
 
     if (wizard.job_name != "")
index b1b09802df08feb0eeeaac241e2fb6854b91481c..86cfb1a82bf0561d97a68e43933304c616044132 100644 (file)
@@ -57,7 +57,7 @@ namespace BL{
       virtual ~JobsManager_QT();
 
       void delete_job(QString job_name);
-      void create_job_wizard();
+      void create_job_wizard(const std::string & name = "");
 
       virtual void sendEvent(const std::string & action, 
                             const std::string & event_name,