Salome HOME
datasource load from gui relies on tui
authorCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 22 Jul 2015 13:33:37 +0000 (15:33 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 22 Jul 2015 13:41:22 +0000 (15:41 +0200)
13 files changed:
idl/MEDDataManager.idl
src/MEDOP/cmp/MEDDataManager_i.cxx
src/MEDOP/cmp/MEDDataManager_i.hxx
src/MEDOP/cmp/MEDPresentationManager_i.cxx
src/MEDOP/cmp/test_medop_components.py
src/MEDOP/doc/sphinx/fr/medop-develguide.rst
src/MEDOP/doc/sphinx/medop-develguide.rst
src/MEDOP/gui/DatasourceController.cxx
src/MEDOP/gui/DatasourceController.hxx
src/MEDOP/gui/WorkspaceController.cxx
src/MEDOP/tui/medpresentation/medpresentation.py
src/MEDOP/tui/xmedpy/fieldtools.py
src/MEDOP/tui/xmedpy/tests/test_xmed_fieldOperations.py

index 26acc5a3e2f8f93580b885607b70b6077f5c0636..a0fa2907e4618b89c04825230218b57610a61c85 100644 (file)
@@ -116,7 +116,8 @@ module MEDOP
     //==========================================================
     // Datasource management
     //==========================================================
-    DatasourceHandler addDatasource(in string filepath);
+    DatasourceHandler loadDatasource(in string filepath);
+    DatasourceHandler getDatasourceHandler(in string filepath);
 
     //==========================================================
     // Mesh data management
index 5db5c996ec9b109e4e27664b2d5e3ad2b86714f6..a2af2f07de24cc729fada7ed60e53122939e723e 100644 (file)
@@ -77,7 +77,7 @@ std::string MEDDataManager_i::source_to_file(const char * source)
  * is a key to retrieve all informations concerning the data (meshes,
  * fields).
  */
-MEDOP::DatasourceHandler * MEDDataManager_i::addDatasource(const char *filepath) {
+MEDOP::DatasourceHandler * MEDDataManager_i::loadDatasource(const char *filepath) {
 
   // We first check that this datasource is not already registered
   long sourceid = getDatasourceId(filepath);
@@ -202,6 +202,20 @@ long MEDDataManager_i::getDatasourceId(const char *filepath) {
   return LONG_UNDEFINED;
 }
 
+MEDOP::DatasourceHandler*
+MEDDataManager_i::getDatasourceHandler(const char *filepath)
+{
+  std::string uri(file_to_source(filepath));
+  DatasourceHandlerMapIterator it = _datasourceHandlerMap.begin();
+  while ( it != _datasourceHandlerMap.end() ) {
+    if ( strcmp(it->second->uri,uri.c_str()) == 0 ) {
+      return it->second;
+    }
+    ++it;
+  }
+  return NULL;
+}
+
 
 MEDOP::MeshHandler * MEDDataManager_i::getMesh(CORBA::Long meshId) {
   if ( _meshHandlerMap.count(meshId) == 0 ) {
@@ -293,7 +307,7 @@ MEDOP::FieldHandlerList * MEDDataManager_i::getFieldListInFieldseries(CORBA::Lon
 
 /*!
  * This returns the whole set of fields handlers for all datasource
- * that have been loaded using addDatasource.
+ * that have been loaded using loadDatasource.
  */
 MEDOP::FieldHandlerList * MEDDataManager_i::getFieldHandlerList() {
   MEDOP::FieldHandlerList_var fieldHandlerSeq = new MEDOP::FieldHandlerList();
@@ -562,15 +576,15 @@ MEDCouplingFieldDouble * MEDDataManager_i::getFieldDouble(const MEDOP::FieldHand
   // At this step, the mesh handler needs a meshid correctly
   // set. Normally, we should arrive at this step only in the case
   // where the field is loaded from a file ==> the meshid is defined
-  // (see the addDatasource function).
+  // (see the loadDatasource function).
   //
   // >>>> __GBO__ TO BE CHECKED AND SERIOUSLY TESTED. There at least
   // one case where we can arrive here with no previous call to
-  // addDataSource: for example the field handler list can be obtained
-  // from a call to addFieldsFromFile instead of addDataSource (see
+  // loadDataSource: for example the field handler list can be obtained
+  // from a call to addFieldsFromFile instead of loadDataSource (see
   // for exemple the getFieldRepresentation service of the
   // dataManager, that comes here and then calls getUMesh where we
-  // need a map initialized only in addDataSource) <<<<
+  // need a map initialized only in loadDataSource) <<<<
   long meshid = fieldHandler->meshid;
 
   // We first have to check if the associated mesh is already loaded
index f950f5be94cde1ce61d2315308e3991153a5dbe6..43eb0fcf026f19c7ff50736311463b5acae1890f 100644 (file)
@@ -69,7 +69,8 @@ public:
   //
   // -----------------------------------------------------------
   // Datasource management
-  MEDOP::DatasourceHandler * addDatasource(const char *filepath);
+  MEDOP::DatasourceHandler * loadDatasource(const char *filepath);
+  MEDOP::DatasourceHandler * getDatasourceHandler(const char *filepath);
 
   // -----------------------------------------------------------
   // Mesh management
index b37e616ad6617d364b2a78551eb3f237abf8d984..4bcd056de278dc94b0d310c86bdae4f21f16dfcc 100644 (file)
@@ -41,6 +41,5 @@ MEDPresentationManager_i::~MEDPresentationManager_i()
 void
 MEDPresentationManager_i::MakeScalarMap(const MEDOP::ScalarMapParameters& params)
 {
-  std::cout << "View mode: " << params.viewMode << std::endl;
   std::cout << "MEDPresentationManager_i::MakeScalarMap: Not implemented yet\n";
 }
index be873629b4c49a56f99280a496e0f7941d022bbf..f332306d4e79479cc16b54633b28a997c9c4b49c 100644 (file)
@@ -106,13 +106,13 @@ testFilePath = getFilePath(testFileName)
 #
 def TEST_getDataManager():
     dataManager = factory.getDataManager()
-    if "addDatasource" not in dir(dataManager):
+    if "loadDatasource" not in dir(dataManager):
         return False
     return True
 
-def TEST_addDatasource():
+def TEST_loadDatasource():
     dataManager = factory.getDataManager()
-    datasource = dataManager.addDatasource(testFilePath)
+    datasource = dataManager.loadDatasource(testFilePath)
     if datasource.name != testFileName:
         print "ERR: datasource.name=%s (should be %s)"%(datasource.name,testFilePath)
         return False
@@ -120,16 +120,16 @@ def TEST_addDatasource():
     # We try to load the file twice. It should not load twice and
     # return the same datasource as previously registered (same id).
     sourceid_ref = datasource.id
-    datasource = dataManager.addDatasource(testFilePath)
+    datasource = dataManager.loadDatasource(testFilePath)
     if datasource.id != sourceid_ref:
         print "ERR: datasource.id=%s (should be %s)"%(datasource.id,sourceid_ref)
         return False
-        
+
     return True
 
 def TEST_getFieldHandlerList():
     dataManager = factory.getDataManager()
-    datasource = dataManager.addDatasource(testFilePath)
+    datasource = dataManager.loadDatasource(testFilePath)
     fieldHandlerList = dataManager.getFieldHandlerList()
     if fieldHandlerList is None or len(fieldHandlerList) == 0:
         return False
@@ -137,7 +137,7 @@ def TEST_getFieldHandlerList():
 
 def TEST_getFieldRepresentation():
     dataManager = factory.getDataManager()
-    datasource = dataManager.addDatasource(testFilePath)
+    datasource = dataManager.loadDatasource(testFilePath)
     fieldHandlerList = dataManager.getFieldHandlerList()
     fieldHandler0 = fieldHandlerList[0]
 
@@ -146,13 +146,13 @@ def TEST_getFieldRepresentation():
 
 def TEST_updateFieldMetadata():
     dataManager = factory.getDataManager()
-    datasource = dataManager.addDatasource(testFilePath)
+    datasource = dataManager.loadDatasource(testFilePath)
     fieldHandlerList = dataManager.getFieldHandlerList()
     fieldHandler0 = fieldHandlerList[0]
 
     fieldid = fieldHandler0.id
     newname = fieldHandler0.fieldname + " modified"
-    
+
     dataManager.updateFieldMetadata(fieldid, newname,
                                     fieldHandler0.iteration,
                                     fieldHandler0.order,
@@ -168,7 +168,7 @@ def TEST_updateFieldMetadata():
 
 def TEST_saveFields():
     dataManager = factory.getDataManager()
-    datasource = dataManager.addDatasource(testFilePath)
+    datasource = dataManager.loadDatasource(testFilePath)
     fieldHandlerList = dataManager.getFieldHandlerList()
     fieldHandler0 = fieldHandlerList[0]
     fieldIdList = [fieldHandler0.id]
@@ -176,7 +176,7 @@ def TEST_saveFields():
 
     print "fieldIdList = %s"%fieldIdList
     print "filepath = %s"%filepath
-    
+
     dataManager.saveFields(filepath,fieldIdList)
     # We just control that the file exists. But we should reload the
     # contents to check the fields
@@ -193,17 +193,17 @@ def TEST_saveFields():
 #
 def TEST_MEDDataManager_getMeshList():
     dataManager = factory.getDataManager()
-    datasourceHandler = dataManager.addDatasource(testFilePath)
+    datasourceHandler = dataManager.loadDatasource(testFilePath)
     meshHandlerList = dataManager.getMeshList(datasourceHandler.id)
     print meshHandlerList
 
     if len(meshHandlerList) == 0:
         return False
     return True
-    
+
 def TEST_MEDDataManager_getMesh():
     dataManager = factory.getDataManager()
-    datasourceHandler = dataManager.addDatasource(testFilePath)
+    datasourceHandler = dataManager.loadDatasource(testFilePath)
     meshHandlerList = dataManager.getMeshList(datasourceHandler.id)
     for mRef in meshHandlerList:
         meshId = mRef.id
@@ -212,10 +212,10 @@ def TEST_MEDDataManager_getMesh():
         if ( mRes.name != mRef.name ) or ( mRes.sourceid != mRef.sourceid):
             return False
     return True
-    
+
 def TEST_MEDDataManager_getFieldseriesListOnMesh():
     dataManager = factory.getDataManager()
-    datasourceHandler = dataManager.addDatasource(testFilePath)
+    datasourceHandler = dataManager.loadDatasource(testFilePath)
 
     meshHandlerList = dataManager.getMeshList(datasourceHandler.id)
     # We look for the fieldseries defined on the first mesh of the list
@@ -232,7 +232,7 @@ def TEST_MEDDataManager_getFieldListInFieldseries():
     testFilePath = os.path.join(RESDIR,testFileName)
 
     testFilePath  = getFilePath("timeseries.med")
-    datasourceHandler = dataManager.addDatasource(testFilePath)
+    datasourceHandler = dataManager.loadDatasource(testFilePath)
 
     meshHandlerList = dataManager.getMeshList(datasourceHandler.id)
     # We look for the fieldseries defined on the first mesh of the list
@@ -255,7 +255,7 @@ def TEST_MEDDataManager_getFieldListInFieldseries():
 #
 def TEST_Calculator_basics():
     dataManager = factory.getDataManager()
-    datasource = dataManager.addDatasource(testFilePath)
+    datasource = dataManager.loadDatasource(testFilePath)
     fieldHandlerList = dataManager.getFieldHandlerList()
 
     # Try to operate on the two first fields
@@ -274,7 +274,7 @@ def TEST_Calculator_basics():
     div = calculator.div(fieldHandler0, fieldHandler1)
     print div
     #power = calculator.pow(fieldHandler0, 2)
-    #print power 
+    #print power
     linear = calculator.lin(fieldHandler0, 3,2)
     print linear
 
@@ -282,7 +282,7 @@ def TEST_Calculator_basics():
 
 def TEST_Calculator_applyFunc():
     dataManager = factory.getDataManager()
-    datasource = dataManager.addDatasource(testFilePath)
+    datasource = dataManager.loadDatasource(testFilePath)
     fieldHandlerList = dataManager.getFieldHandlerList()
     fieldHandler = fieldHandlerList[0]
 
@@ -307,7 +307,7 @@ def TEST_Calculator_applyFunc():
 #
 def TEST_markAsPersistent():
     dataManager = factory.getDataManager()
-    datasource = dataManager.addDatasource(testFilePath)
+    datasource = dataManager.loadDatasource(testFilePath)
     fieldHandlerList = dataManager.getFieldHandlerList()
     fieldHandler0 = fieldHandlerList[0]
     fieldHandler1 = fieldHandlerList[1]
@@ -337,8 +337,8 @@ class MyTestSuite(unittest.TestCase):
     def test_getDataManager(self):
         self.assertTrue(TEST_getDataManager())
 
-    def test_addDatasource(self):
-        self.assertTrue(TEST_addDatasource())
+    def test_loadDatasource(self):
+        self.assertTrue(TEST_loadDatasource())
 
     def test_getFieldHandlerList(self):
         self.assertTrue(TEST_getFieldHandlerList())
index 57f826e1c1fecad5b5c421be44a148a43b44bbb7..444a0a9a6ce7dfacbeb66d904482633064a28a02 100644 (file)
@@ -65,14 +65,14 @@ lancés depuis une session shell SALOME. Dans un nouveau shell, taper::
 
 L'exécution imprime un rapport détaillant le résultat pour chaque
 fonction de test::
+
  test_Calculator_applyFunc (__main__.MyTestSuite) ... ok
  test_Calculator_basics (__main__.MyTestSuite) ... ok
  test_MEDDataManager_getFieldListInFieldseries (__main__.MyTestSuite) ... ok
  test_MEDDataManager_getFieldseriesListOnMesh (__main__.MyTestSuite) ... ok
  test_MEDDataManager_getMesh (__main__.MyTestSuite) ... ok
  test_MEDDataManager_getMeshList (__main__.MyTestSuite) ... ok
- test_addDatasource (__main__.MyTestSuite) ... ok
+ test_loadDatasource (__main__.MyTestSuite) ... ok
  test_getDataManager (__main__.MyTestSuite) ... ok
  test_getFieldHandlerList (__main__.MyTestSuite) ... ok
  test_getFieldRepresentation (__main__.MyTestSuite) ... ok
@@ -150,7 +150,7 @@ valeurs des champs et les maillages support sont chargés au besoin.
 
 Le chargement des métadonnées de description se fait par la méthode::
 
-  addDatasource(const char \*filepath)
+  loadDatasource(const char \*filepath)
 
 
 
@@ -164,16 +164,16 @@ Ecrire un service CORBA qui retourne une sequence de FieldHandler:
   MEDOP::FieldHandlerList * MyFunction(...) {
     vector<MEDOP::FieldHandler*> fieldHandlerList;
     ...
-  
+
     fieldHandlerList.push_back(fieldHandler);
-  
+
     // Map the resulting list to a CORBA sequence for return:
     MEDOP::FieldHandlerList_var fieldHandlerSeq = new MEDOP::FieldHandlerList();
     int nbFieldHandler = fieldHandlerList.size();
     fieldHandlerSeq->length(nbFieldHandler);
     for (int i=0; i<nbFieldHandler; i++) {
       fieldHandlerSeq[i] = *fieldHandlerList[i];
-    } 
+    }
     return fieldHandlerSeq._retn();
   }
 
@@ -245,7 +245,7 @@ moyen de la commande::
 
 Cette commande installe un répertoire ``xsalome`` contenant l'ensemble
 des sources de la bibliothèque XSALOME.
+
 .. note:: La bibliothèque XSALOME n'est pas un module SALOME mais une
    simple bibliothèque de fonctions qui complète ou rend plus facile
    d'utilisation les fonctions de SALOME. Elle NE DOIT EN AUCUN CAS
@@ -281,5 +281,5 @@ manipulation de champs::
 Cette commande génére un répertoire ``appli`` à l'emplacement où elle
 est exécutée. Il reste à lancer l'application SALOME au moyen de la
 commande::
+
  $ ./appli/runAppli -k
index 57f826e1c1fecad5b5c421be44a148a43b44bbb7..444a0a9a6ce7dfacbeb66d904482633064a28a02 100644 (file)
@@ -65,14 +65,14 @@ lancés depuis une session shell SALOME. Dans un nouveau shell, taper::
 
 L'exécution imprime un rapport détaillant le résultat pour chaque
 fonction de test::
+
  test_Calculator_applyFunc (__main__.MyTestSuite) ... ok
  test_Calculator_basics (__main__.MyTestSuite) ... ok
  test_MEDDataManager_getFieldListInFieldseries (__main__.MyTestSuite) ... ok
  test_MEDDataManager_getFieldseriesListOnMesh (__main__.MyTestSuite) ... ok
  test_MEDDataManager_getMesh (__main__.MyTestSuite) ... ok
  test_MEDDataManager_getMeshList (__main__.MyTestSuite) ... ok
- test_addDatasource (__main__.MyTestSuite) ... ok
+ test_loadDatasource (__main__.MyTestSuite) ... ok
  test_getDataManager (__main__.MyTestSuite) ... ok
  test_getFieldHandlerList (__main__.MyTestSuite) ... ok
  test_getFieldRepresentation (__main__.MyTestSuite) ... ok
@@ -150,7 +150,7 @@ valeurs des champs et les maillages support sont chargés au besoin.
 
 Le chargement des métadonnées de description se fait par la méthode::
 
-  addDatasource(const char \*filepath)
+  loadDatasource(const char \*filepath)
 
 
 
@@ -164,16 +164,16 @@ Ecrire un service CORBA qui retourne une sequence de FieldHandler:
   MEDOP::FieldHandlerList * MyFunction(...) {
     vector<MEDOP::FieldHandler*> fieldHandlerList;
     ...
-  
+
     fieldHandlerList.push_back(fieldHandler);
-  
+
     // Map the resulting list to a CORBA sequence for return:
     MEDOP::FieldHandlerList_var fieldHandlerSeq = new MEDOP::FieldHandlerList();
     int nbFieldHandler = fieldHandlerList.size();
     fieldHandlerSeq->length(nbFieldHandler);
     for (int i=0; i<nbFieldHandler; i++) {
       fieldHandlerSeq[i] = *fieldHandlerList[i];
-    } 
+    }
     return fieldHandlerSeq._retn();
   }
 
@@ -245,7 +245,7 @@ moyen de la commande::
 
 Cette commande installe un répertoire ``xsalome`` contenant l'ensemble
 des sources de la bibliothèque XSALOME.
+
 .. note:: La bibliothèque XSALOME n'est pas un module SALOME mais une
    simple bibliothèque de fonctions qui complète ou rend plus facile
    d'utilisation les fonctions de SALOME. Elle NE DOIT EN AUCUN CAS
@@ -281,5 +281,5 @@ manipulation de champs::
 Cette commande génére un répertoire ``appli`` à l'emplacement où elle
 est exécutée. Il reste à lancer l'application SALOME au moyen de la
 commande::
+
  $ ./appli/runAppli -k
index 740677333bfee29905c70b04e02563f22d83bede..e59ebc048120d1d5a4a322f6c7b3214810c6b843 100644 (file)
@@ -123,10 +123,21 @@ void DatasourceController::createActions() {
  * informations to the GUI, and the GUI creates a tree view of these
  * data in the study object browser.
  */
-MEDOP::DatasourceHandler * DatasourceController::addDatasource(const char * filename) {
-
-  MEDOP::DatasourceHandler * datasourceHandler =
-    MEDOPFactoryClient::getDataManager()->addDatasource(filename);
+void
+DatasourceController::addDatasource(const char* filename)
+{
+  DatasourceEvent* event = new DatasourceEvent();
+  event->eventtype = DatasourceEvent::EVENT_ADD_DATASOURCE;
+  event->objectalias = filename;
+  emit datasourceSignal(event);
+}
+// call to this function is trigerred by workspace (itself from python console)
+void
+DatasourceController::updateTreeViewWithNewDatasource(const MEDOP::DatasourceHandler* datasourceHandler)
+{
+  if (!datasourceHandler) {
+    return;
+  }
 
   // We need a studyEditor updated on the active study
   _studyEditor->updateActiveStudy();
@@ -169,8 +180,6 @@ MEDOP::DatasourceHandler * DatasourceController::addDatasource(const char * file
       _studyEditor->setParameterBool(soFieldseries,OBJECT_IS_IN_WORKSPACE,false);
     }
   }
-
-  return datasourceHandler;
 }
 
 
@@ -554,10 +563,11 @@ void DatasourceController::OnInterpolateFieldInputValidated() {
 }
 
 void
-DatasourceController::processWorkspaceEvent(const MEDOP::MedEvent * event)
+DatasourceController::processWorkspaceEvent(const MEDOP::MedEvent* event)
 {
   if ( event->type == MEDOP::EVENT_ADD_DATASOURCE ) {
-    this->addDatasource(event->filename);
+    MEDOP::DatasourceHandler* datasourceHandler = MEDOPFactoryClient::getDataManager()->getDatasourceHandler(event->filename);
+    this->updateTreeViewWithNewDatasource(datasourceHandler);
     _salomeModule->updateObjBrowser(true);
   }
 }
index 9ed1ee0daa4113ebfe409e8b0e0b1880f101c923..63d3fc9605da016166bc60400b21bddf586833d5 100644 (file)
@@ -54,7 +54,8 @@ typedef struct {
     EVENT_IMPORT_OBJECT, // Simply import the object in the workspace
     EVENT_USE_OBJECT,    // Import in the workspace AND define a proxy
                          // variable in the tui console to use it
-    EVENT_VIEW_OBJECT_SCALAR_MAP
+    EVENT_VIEW_OBJECT_SCALAR_MAP,
+    EVENT_ADD_DATASOURCE // to forward action to workspace (and then to python console)
   };
   int eventtype;
   XmedDataObject * objectdata;
@@ -74,7 +75,6 @@ public:
   ~DatasourceController();
 
   void createActions();
-  MEDOP::DatasourceHandler * addDatasource(const char * filename);
 
 public slots:
   // Callback connected to dialog box validation signals
@@ -96,6 +96,8 @@ protected slots:
 
 private:
   void visualize(DatasourceEvent::EventType);
+  void addDatasource(const char* filename);
+  void updateTreeViewWithNewDatasource(const MEDOP::DatasourceHandler*);
 
 private:
   StandardApp_Module * _salomeModule;
index e5ef41345887ad55fe26f24e0bad7064034aadbe..6d28d336dcb3b0de9f8d146832ed0641b1b8715c 100644 (file)
@@ -498,6 +498,12 @@ void WorkspaceController::processDatasourceEvent(const DatasourceEvent * event)
     commands += QString("MakeScalarMap(get(%1), %2)").arg(fieldHandler->id).arg(viewMode);
     _consoleDriver->exec(commands);
   }
+  else if ( event->eventtype == DatasourceEvent::EVENT_ADD_DATASOURCE ) {
+    QStringList commands;
+    commands += QString("from medpresentation import LoadDataSource");
+    commands += QString("LoadDataSource('%1')").arg(event->objectalias);
+    _consoleDriver->exec(commands);
+  }
   else {
     STDLOG("The event "<<event->eventtype<<" is not implemented yet");
   }
index 7e51ad0a0603315fe0da647bef8cf39791f3a1b2..1fb6d8618b06e87d49ebb94fcc83c666a41b314c 100644 (file)
@@ -24,6 +24,7 @@ import SALOME
 __manager = xmed.factory.getPresentationManager()
 
 def LoadDataSource(filename):
+  xmed.dataManager.loadDatasource(filename)
   from xmed.fieldproxy import notifyGui_addsource
   notifyGui_addsource(filename)
 #
@@ -36,7 +37,7 @@ def MakeScalarMap(proxy, viewMode=MEDOP.VIEW_MODE_REPLACE):
 
   print "viewMode:", viewMode, " [", type(viewMode), "]"
 
-  params = MEDOP.ScalarMapParameters(proxy.id, viewMode);
+  params = MEDOP.ScalarMapParameters(proxy.id, viewMode)
   __manager.MakeScalarMap(params)
 
 #
index 33beb86415e46dcc3496b1637b29aa6cbd8ea4b3..13effcd804ec7011bd3f23232150c93deb80de34 100644 (file)
@@ -155,6 +155,8 @@ def load(medFileName=filepath):
     """
     xmed.dataManager.addDatasource(filepath)
     print status(local=False,remote=True)
+    from xmed.fieldproxy import notifyGui_addsource
+    notifyGui_addsource(filename)
 
 def get(fieldHandlerId):
     """
index de911c7a89f75c488d30e92439f999fe77183500..4f7daab0f3ca04284a02614c94d7fae1887b5ddd 100644 (file)
@@ -38,7 +38,7 @@ xmed.setConsoleGlobals(globals())
 
 # Load some test data in the MedDataManager
 filepath  = properties.testFilePath
-xmed.dataManager.addDatasource(filepath)
+xmed.dataManager.loadDatasource(filepath)
 fieldHandlerList = xmed.dataManager.getFieldHandlerList()
 
 def setup():
@@ -63,11 +63,11 @@ def TEST_addition():
     # The addition can be done using field handler directly
     addFieldHandler = xmed.calculator.add(fieldHandler0, fieldHandler1)
     print addFieldHandler
-    
+
     # Or with a field proxy that ease the writing of operations
     fieldProxy0 = FieldProxy(fieldHandler0)
     fieldProxy1 = FieldProxy(fieldHandler1)
-    
+
     res = fieldProxy0 + fieldProxy1
     if res is None: return False
 
@@ -128,7 +128,7 @@ def TEST_composition():
     if res is None: return False
 
     return True
-    
+
 def TEST_litteral_equation():
     fieldProxy0 = FieldProxy(fieldHandlerList[0])
     res = fieldProxy0.ope("abs(u)^2")
@@ -225,7 +225,7 @@ def myusecases():
     #TEST_unary_operations()
     #TEST_update_metadata()
     #TEST_composition()
-    
+
 if __name__ == "__main__":
     #myusecases()
     myunittests()