]> SALOME platform Git repositories - tools/eficas.git/blob - Validation/V_JDC.py
Salome HOME
gitignore V1
[tools/eficas.git] / Validation / V_JDC.py
1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013   EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 """
22    Ce module contient la classe mixin JDC qui porte les méthodes
23    nécessaires pour réaliser la validation d'un objet de type JDC
24    dérivé de OBJECT.
25
26    Une classe mixin porte principalement des traitements et est
27    utilisée par héritage multiple pour composer les traitements.
28 """
29 # Modules EFICAS
30 import V_MCCOMPO
31 from Noyau.N_Exception import AsException
32 from Noyau.N_utils import AsType
33 from Noyau.strfunc import ufmt
34
35 class JDC(V_MCCOMPO.MCCOMPO):
36    """
37    """
38
39    def report(self):
40       """
41           Methode pour generation d un rapport de validite
42       """
43       self.cr.purge()
44       self.cr.debut="DEBUT CR validation : "+self.nom
45       self.cr.fin="FIN CR validation :"+self.nom
46       for e in self.etapes :
47         if e.isactif():
48           self.cr.add(e.report())
49       self.state = 'modified'
50       self.isvalid(cr='oui')
51       return self.cr
52
53    def isvalid(self,cr='non'):
54       """
55         Méthode booléenne qui retourne 0 si le JDC est invalide, 1 sinon
56       """
57       # FR : on prend en compte l'état du JDC ('unchanged','modified','undetermined')
58       # afin d'accélérer le test de validité du JDC
59       if self.state == 'unchanged':
60         return self.valid
61       else:
62         valid = 1
63         texte,test = self.verif_regles()
64         if test == 0:
65           if cr == 'oui':
66               self.cr.fatal(' '.strip(texte))
67           valid = 0
68         if valid :
69           for e in self.etapes:
70             if not e.isactif() : continue
71             if not e.isvalid():
72               valid = 0
73               break
74         self.state="unchanged"
75         self.valid = valid
76         return self.valid
77
78    def verif_regles(self):
79       """
80       Effectue la vérification de validité des règles du jeu de commandes
81       """
82       noms_etapes = [etape.nom for etape in self.etapes]
83       texte_global = ''
84       test_global = 1
85       for regle in self.regles:
86         texte, test = regle.verif(noms_etapes)
87         texte_global = texte_global + texte
88         test_global = test_global*test
89       return texte_global, test_global
90