Salome HOME
Copyright update 2021
[modules/smesh.git] / src / Tools / Verima / Base / tableGroupes.py
1 # Copyright (C) 2013-2021  EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from qtsalome import QSqlQuery
21 from Base.tableDeBase import TableDeBase
22
23 class TableGroupes (TableDeBase):
24       def __init__(self):
25           TableDeBase.__init__(self,"Groupes")
26           self.setField(('Groupe','Maillage','Version','Entite','NbEntite'))
27           self.setTypeField(('str','int','int','str','int'),('nomGroupe','idMaillage','idVersion','Entite'))
28
29
30       def createSqlTable(self):
31           query=QSqlQuery()
32
33
34           texteQuery ="create table Groupes( nomGroupe varchar(40),idMaillage int, idVersion int,"
35           texteQuery+="Entite var(40), NbEntite int,"
36           texteQuery+="foreign key (idMaillage) references Maillages(id)," 
37           texteQuery+="foreign key (idVersion) references Versions(id)," 
38           texteQuery+="primary key (nomGroupe,idMaillage,idVersion,Entite));"
39
40           print("Creation de TableGroupes : ", query.exec_(texteQuery))
41
42
43       def getVal(self,nomGroupe,idMaillage,idVersion,typeMaille):
44           val=0                          # Valeur si l enregistrement n existe pas
45           query=QSqlQuery()
46           texteQuery ='select NbEntite from Groupes  where nomGroupe ="' + nomGroupe +'"'
47           texteQuery +=' and idMaillage=' + str(idMaillage)
48           texteQuery +=' and idVersion = ' + str(idVersion)
49           texteQuery +=' and Entite ="'  + str(typeMaille)   + '";' 
50           query.exec_(texteQuery)
51           while (query.next()) :
52               val=query.value(0).toInt()[0]
53           while (query.next()) :
54               print("plusieurs enregistrements dans groupe pour ", nomGroupe," ",str(idMaillage)," ",str(idVersion),"\n")
55           return val
56
57
58       def getAllEntity(self):
59             query=QSqlQuery()
60             texteQuery ="select distinct Entite from Groupes;"
61             query.exec_(texteQuery)
62             maListe=[]
63             while (query.next()) :
64                 maListe.append(str(query.value(0).toString()))
65             return maListe