Salome HOME
Update copyrights
[modules/smesh.git] / src / Tools / Verima / Base / tableMailles.py
1 # Copyright (C) 2013-2019  CEA/DEN, 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 TableMailles (TableDeBase):
24       def __init__(self):
25          TableDeBase.__init__(self,"Mailles")
26          self.setField(('Maillage','Version','Entite','NbEntite'))
27          self.setTypeField(('int','int','str','int'),('idMaillage','idVersion','Entite'))
28
29
30       def createSqlTable(self):
31           query=QSqlQuery()
32
33
34           texteQuery ="create table Mailles(idMaillage int, idVersion int,  Entite var(40), NbEntite int, "
35           texteQuery+="foreign key (idMaillage) references Maillages(id)," 
36           texteQuery+="foreign key (idVersion) references Versions(id)," 
37           texteQuery+="primary key (idMaillage,idVersion,Entite));"
38
39           print("Creation de TableMailles : " , query.exec_(texteQuery))
40
41  
42       def getVal(self,idMaillage, idVersion,  Entite):
43             query=QSqlQuery()
44             texteQuery ='select NbEntite from Mailles where idMaillage='+str(idMaillage) 
45             texteQuery+=' and  idVersion='+str(idVersion) 
46             texteQuery+=" and Entite='" + str(Entite)  +"';"
47             query.exec_(texteQuery)
48             nb=0
49             val=0                          # Valeur si l enregistrement n existe pas
50             while (query.next()) :
51                val=query.value(0).toInt()[0]
52                nb=nb+1
53             if nb > 1 : print("Double valeur de Reference dans la table des mailles")
54             return val
55
56
57       def getAllEntity(self):
58             query=QSqlQuery()
59             texteQuery ="select distinct Entite from Mailles;"
60             query.exec_(texteQuery)
61             maListe=[]
62             while (query.next()) :
63                 maListe.append(str(query.value(0).toString()))
64             return maListe