Salome HOME
prise en compte modif EF
authorpascale.noyret <pascale.noyret@edf.fr>
Thu, 28 May 2020 13:48:13 +0000 (15:48 +0200)
committerpascale.noyret <pascale.noyret@edf.fr>
Thu, 28 May 2020 13:48:13 +0000 (15:48 +0200)
Editeur/session.py
InterfaceQT4/editor.py
InterfaceQT4/editorSsIhm.py
InterfaceQT4/eficas_go.py
InterfaceQT4/qtEficasSsIhm.py
Tools/validateDataSet.py [new file with mode: 0755]
docCataWriter/mdm_presentation.rst

index 5dbd1483985592cef1f7b3df664336c629c2bd81..a43312a8825c0b7b84fd3cd83c247bf350302e25 100644 (file)
@@ -307,7 +307,7 @@ def parse(args):
             options.comm.append(file)
             options.studies.append({"comm":file})
             #print options.studies
-         elif len(args)==1 and (re.search('.comm',file) or re.search('.map',file) or re.search('.cas',file)):
+         elif len(args)==1 and (re.search('.comm',file) or re.search('.map',file) or re.search('.cas',file) or re.search('.xml',file)):
             try :
                 f=open(file,'w')
                 f.close()
index b19a4a6983d5c7bded2f45295631a4daddcc9005..e9ab3864f9d4754a3d7e64fa826aaff162ce6b05 100755 (executable)
@@ -850,7 +850,12 @@ class JDCEditor(JDCEditorSsIhm,Ui_baseWidget,QWidget):
            self.tree.racine.item.getObject().nom=os.path.basename(newName)
            self.tree.racine.updateNodeLabel()
 
-        if  self.jdc.cata.modeleMetier : self.jdc.toXml(self.fichier)
+        if  self.jdc.cata.modeleMetier:self.jdc.toXml(self.fichier)
+        if  self.jdc.cata.modeleMetier and self.jdc.isValid():
+            if self.generator != self.XMLgenerator :
+               self.XMLgenerator.gener(self.jdc)
+               self.XMLgenerator.writeDefault(fn)
 
         if self.jdc.isValid() != 0 and hasattr(self.generator, "writeDefault"):
         #if hasattr(self.generator, "writeDefault"):
index fec2294353e4930ac5d521ef623b6c45fd02be2c..746bb94392f387eec8924708887e0d7368b6c79e 100755 (executable)
@@ -60,7 +60,8 @@ class JDCEditorSsIhm :
         if debug : print ('dans le init de JDCEditorSsIhm')
         self.appliEficas = appliEficas
         self.fichier     = fichier
-        self.fichierComplet  = fichier
+        self.fichierComplet   = fichier
+        self.extensionFichier = os.path.splitext(fichier)[1]
         self.jdc         = jdc
         self.first      = True
         self.jdc_item    = None
@@ -119,10 +120,11 @@ class JDCEditorSsIhm :
 
         self.maConfiguration.mesGenerators     = generator
         self.maConfiguration.mesconvertisseurs = convert
-        try :
-           self.XMLGenerateur=generator.plugins['xml']()
-        except :
-           self.XMLGenerateur=None
+        try    : self.XMLReader=convert.plugins['xml']()
+        except : self.XMLReader=None
+        try    : self.XMLgenerator=generator.plugins['xml']()
+        except : self.XMLgenerator=None
+        
 
         if self.formatFichierOut in generator.plugins.keys():
            self.generator = generator.plugins[self.formatFichierOut]()
@@ -147,10 +149,8 @@ class JDCEditorSsIhm :
                except :
                    print ("mauvaise lecture du fichier")
                if self.salome :
-                  try :
-                     self.appliEficas.addJdcInSalome( self.fichier)
-                  except :
-                     print ("mauvais enregistrement dans Salome")
+                  try    : self.appliEficas.addJdcInSalome( self.fichier)
+                  except : print ("mauvais enregistrement dans Salome")
             else :
                self.jdc=jdc
 
@@ -160,10 +160,8 @@ class JDCEditorSsIhm :
 
         else:
             if not self.jdc:                   #  nouveau jdc
-                if not include :
-                   self.jdc = self._newJDC(units=units)
-                else :
-                   self.jdc = self._newJDCInclude(units=units)
+                if not include : self.jdc = self._newJDC(units=units)
+                else : self.jdc = self._newJDCInclude(units=units)
                 self.nouveau=1
 
         if self.jdc:
@@ -171,8 +169,11 @@ class JDCEditorSsIhm :
             self.jdc.lang    = self.appliEficas.langue
             self.jdc.aReafficher=False
             txt_exception  = None
-            if not jdc:
-                self.jdc.analyse()
+            if not jdc:            
+                if self.extensionFichier == '.xml' :
+                   if self.appliEficas.maConfiguration.withXSD: self.jdc.analyseXML()
+                   else : print ('run MDM with -x option  (MDM for XML)'); exit()
+                else : self.jdc.analyse()
                 txt_exception = self.jdc.cr.getMessException()
             if txt_exception :
                 self.jdc = None
@@ -589,6 +590,10 @@ class JDCEditorSsIhm :
         """
 
 
+        if  self.jdc.cata.modeleMetier and self.jdc.isValid():
+            if self.generator != self.XMLgenerator :
+               self.XMLgenerator.gener(self.jdc)
+               self.XMLgenerator.writeDefault(fichier)
         if not (self.writeFile(fichier,formatLigne=formatLigne)): return (0, None)
         self.fichierOut = fichier
 
index 405b74669d4dd3c2e51c9bdcce4235be55ee3d08..50321305439f3e3da5cda91ad02f8da9c1879a13 100755 (executable)
@@ -120,6 +120,26 @@ def genereXML(code=None):
     monEditeur.XMLGenerateur.gener(monEditeur.jdc)
     monEditeur.XMLGenerateur.writeDefault(fichierXML)
 
+def validateDataSet(code=None):
+#------------------------------
+    from Editeur  import session
+    options=session.parse(sys.argv)
+    if code != None : options.code = code
+    if options.fichierCata == None : 
+       print ('Use -c cata_name.py')
+       return
+    fichier=options.comm[0]
+    if fichier==None : 
+       print ('comm file is needed')
+       return
+    from .editorSsIhm import JDCEditorSsIhm
+    monEficasSsIhm = getEficasSsIhm(code=options.code)
+    monEditeur=JDCEditorSsIhm(monEficasSsIhm,fichier)
+    if not (monEditeur.jdc.isValid()) : print (monEditeur.getJdcRapport())
+    else : print ('Jdc is valid')
+    return monEditeur.jdc.isValid()
+
+   
 
 
 # --------------------------- toutes les fonctions après sont obseletes
index f204ecbf1eb5833b9898ad433bb49761f958e3d6..7e2eb6aa368da338045f85dcfd1ad592e9ce6b97 100755 (executable)
@@ -124,6 +124,7 @@ class AppliSsIhm:
         if hasattr (self,'maConfiguration') and self.maConfiguration.translatorFichier :
            from Extensions import localisation
            localisation.localise(None,self.langue,translatorFichier=self.maConfiguration.translatorFichier)
+        if self.withXSD : self.maConfiguration.withXSD=True
 
 
     def getSource(self,file):
diff --git a/Tools/validateDataSet.py b/Tools/validateDataSet.py
new file mode 100755 (executable)
index 0000000..0ba4043
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Copyright (C) 2007-2013   EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+"""
+""
+  cree le .xml associe au .comm
+  generateXML.py -c leCatalogue le.comm
+  23 avril
+
+"""
+# Modules Python
+# Modules Eficas
+
+import sys
+import os
+sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)),'../'))
+
+from InterfaceQT4 import eficas_go
+eficas_go.validateDataSet(code='NonConnu')
index 744be5c15fc7f80728c1bf56f21ade3e7fa51b77..95c347806df1fa801499614a2164dcd6e0ef63d6 100644 (file)
@@ -6,34 +6,36 @@ ____________________
 
 MDM is designed to help code developpers. It allows to:
 
-        * simplify the writing of data models and have both a description in the MDM grammar end  a corresponding unambiguous XSD description
-        * validate datasets against these data models
-        * automatically generate XML drivers (in C++ and Python) for input/output parameters.
-        * automatically generate an GUI which allows end users to write a specific code parameter file in xml or python format. This GUI frees the user from syntax and semantic issues and guarantees data integrity
-        * provide help to define the calculation scheme in Salome environment.
+        * simplify the writing of data models thanks to MDM definition specific langage (DSL) in python.
+        * automatically generate a corresponding unambiguous XSD description.
+        * offer dynamic validation which allows to take into account the value of certain parameters to activate specific parts of the model.
+        * maintain consistency between the  version of the model expressed in the MDM grammar and the corresponding XSD version.
+        * validate datasets against these data models (one of them or both)
+        * use directly the produced XSDs (thanks to their unambiguity) in automatic driver generation tools (such as pyxb) and  thus easely generate XML drivers (in C++ and Python) for input/output parameters.
+        * automatically generate an GUI which allows end users to write a specific code parameter file / dataset in xml or python format. This GUI frees the user from syntax and semantic issues and guarantees data integrity
+        * provide help to define the calculation scheme / calculation workflows in Salome environment.
 
-
-MDM format is XML Schema Definition (XSD).
 The dataset format is either python or XML, or both.
-A valid dataset conforms to the structure and the rules  of the data model.
-MDM is python code. For Gui Part, QT5 is needed. 
+A valid dataset conforms to the structure and the rules  of the data model against both XSD and DSL python format.
+MDM is developped in python. For Gui Part, QT5 is needed. 
 
 General Behaviour
 _________________
 
  * Models
  Most automatic driver generation tools require an XSD definition of the data model.  However, writing  a  data model directly into XSD is often painful and time consuming.
- the MDM grammar is used to express a data model faster in a python-like format (called catalog).  MDM provides  an .xsd mapping and Translation from this grammar to XSD is done automatically. Resulting XSD are unambiguous and can also be used easely with automatic drivers generating tools. MDM allows to manages dynamic validation rules (a simple way to activate part of the XSD description according to the values of certain parameters,). It  also provides a graphical (model-compliant) interface to create valid sets of documents / user data.
+ the MDM grammar is used to express a data model faster in a python-like format (called catalog).  MDM provides  an .xsd mapping able to transcribe level of validation  made in MDM.  Translation from this grammar to XSD is done automatically. Resulting XSD are unambiguous and can also be used easely with automatic drivers generating tools. MDM allows to manages dynamic validation rules (a simple way to activate part of the XSD description according to the values of certain parameters,). It  also provides a graphical (model-compliant) interface to create valid sets of documents / user data. In addition, this generated graphical representation allows a virtuous cycle between the design of the model and the visual representation.
 
  An MDM catalog can contain other MDM catalogs.  This means that others catalogs can be used to supplement the structure of another catalog through inclusion/import mechanisms.
 
  * Data Sets
  The available commands are defined in the data model.
- In order to create a new valid data set, the end user can use the GUI and choose commands (parts of the XSD schema) from those available. He defines valid values for mandatory parameters (cardinality, type...) and adds optional parameters if necessary.
+ In order to create a new valid data set, the end user can use the GUI and choose parameters/commands  (parts of the XSD schema) from those available. He defines valid values for mandatory parameters (cardinality, type...) and adds optional parameters if necessary.
 
  Data sets can be built/modified/validated by command line (TUI).
 
- The python/dataset duality in XML allows the dataset to be executed in a proper python context, in addition to being able to be used as a set of input parameters for code. 
+refaire la phrase
+ The python/XML  duality of the dataset expression  allows on  the one hand to execute the dataset in a proper python context, and/or, on the other hand to use it as a set of input parameters for code. 
 
  * Workflows
  Workflows managed by an orchestrator such as the YACS module of the SALOME project manipulate the parameters to launch codes.