2017-01-16 23:32:28 +01:00
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
import cherrypy
|
2017-01-17 19:57:12 +01:00
|
|
|
from .database import KatfehlerDatabase_cl, KatursacheDatabase_cl, FehlerDatabase_cl, KomponenteDatabase_cl, QsMitarbeiterDatabase_cl, SwEntwicklerDatabase_cl
|
2017-01-16 23:32:28 +01:00
|
|
|
# Method-Dispatching!
|
|
|
|
|
|
|
|
# Übersicht Anforderungen / Methoden
|
|
|
|
# (beachte: / relativ zu /navigation, siehe Konfiguration Server!)
|
|
|
|
|
2017-01-17 18:59:39 +01:00
|
|
|
#-------------------------------------------------------
|
|
|
|
def adjustId_p(id_spl, data_opl):
|
|
|
|
#-------------------------------------------------------
|
2017-01-16 23:32:28 +01:00
|
|
|
|
2017-01-17 18:59:39 +01:00
|
|
|
if id_spl == None:
|
|
|
|
data_opl['id'] = ''
|
|
|
|
elif id_spl == '':
|
|
|
|
data_opl['id'] = ''
|
|
|
|
elif id_spl == '0':
|
|
|
|
data_opl['id'] = ''
|
|
|
|
else:
|
|
|
|
data_opl['id'] = id_spl
|
|
|
|
return data_opl
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
Anforderung GET PUT POST DELETE
|
|
|
|
-----------------------------------------------------------------------------------------
|
|
|
|
/katfehler/ alle Fehlerkategorien
|
2017-01-18 18:14:35 +01:00
|
|
|
/katfehler/:katfehlerid
|
2017-01-16 23:32:28 +01:00
|
|
|
einzelne Fehlerkategorien Fehler löschen
|
|
|
|
/katfehler/+Daten neue FK speichern
|
2017-01-18 18:14:35 +01:00
|
|
|
/katfehler/:katfehlerid+Daten Fehler ändern
|
2017-01-16 23:32:28 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
#----------------------------------------------------------
|
|
|
|
class KatFehler_cl(object):
|
|
|
|
#----------------------------------------------------------
|
|
|
|
|
|
|
|
exposed = True # gilt für alle Methoden
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
def __init__(self):
|
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
self.db_o = KatfehlerDatabase_cl()
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
2017-01-18 18:14:35 +01:00
|
|
|
def GET(self, id=None):
|
2017-01-16 23:32:28 +01:00
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
retVal_o = {
|
|
|
|
'data': None
|
|
|
|
}
|
|
|
|
if id == None:
|
|
|
|
# Anforderung der Liste
|
|
|
|
retVal_o['data'] = self.db_o.read_px()
|
|
|
|
else:
|
|
|
|
# Anforderung eines Dokuments
|
|
|
|
data_o = self.db_o.read_px(id)
|
|
|
|
if data_o != None:
|
|
|
|
retVal_o['data'] = adjustId_p(id, data_o)
|
|
|
|
|
|
|
|
return retVal_o
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
2017-01-18 18:14:35 +01:00
|
|
|
def PUT(self, id=None):
|
2017-01-16 23:32:28 +01:00
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
# Sichern der Daten: jetzt wird keine vollständige Seite
|
|
|
|
# zurückgeliefert, sondern nur noch die Information, ob das
|
|
|
|
# Speichern erfolgreich war
|
|
|
|
|
|
|
|
retVal_o = {
|
|
|
|
'id': None
|
|
|
|
}
|
|
|
|
|
|
|
|
# data_opl: Dictionary mit den gelieferten key-value-Paaren
|
|
|
|
# hier müsste man prüfen, ob die Daten korrekt vorliegen!
|
|
|
|
|
|
|
|
id_s = data_opl["id_s"]
|
|
|
|
data_o = {
|
|
|
|
'name': data_opl["name_s"],
|
|
|
|
'id': data_opl["id_s"]
|
|
|
|
}
|
|
|
|
# Update-Operation
|
|
|
|
retVal_o['id'] = id_s
|
|
|
|
if self.db_o.update_px(id_s, data_o):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
retVal_o['id'] = None
|
|
|
|
|
|
|
|
return retVal_o
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
def POST(self, data_opl):
|
2017-01-16 23:32:28 +01:00
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
retVal_o = {
|
|
|
|
'id': None
|
|
|
|
}
|
|
|
|
|
|
|
|
# data_opl: Dictionary mit den gelieferten key-value-Paaren
|
|
|
|
|
|
|
|
# hier müsste man prüfen, ob die Daten korrekt vorliegen!
|
|
|
|
|
|
|
|
data_o = {
|
|
|
|
'name': data_opl["name_s"]
|
|
|
|
}
|
|
|
|
# Create-Operation
|
|
|
|
id_s = self.db_o.create_px(data_o)
|
|
|
|
retVal_o['id'] = id_s
|
|
|
|
|
|
|
|
return retVal_o
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
def DELETE(self, id):
|
2017-01-16 23:32:28 +01:00
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
# Eintrag löschen, nur noch Rückmeldung liefern
|
|
|
|
retVal_o = {
|
|
|
|
'id': id
|
|
|
|
}
|
|
|
|
|
|
|
|
if self.db_o.delete_px(id):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
retVal_o['id'] = None
|
|
|
|
|
|
|
|
return retVal_o
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
Anforderung GET PUT POST DELETE
|
|
|
|
-----------------------------------------------------------------------------------------
|
|
|
|
/katursache/ alle Fehlerkategorien
|
2017-01-18 18:14:35 +01:00
|
|
|
/katursache/:katursacheid
|
2017-01-16 23:32:28 +01:00
|
|
|
einzelne Fehlerkategorien Fehler löschen
|
|
|
|
/katursache/+Daten neue FK speichern
|
2017-01-18 18:14:35 +01:00
|
|
|
/katursache/:katursacheid+Daten Fehler ändern
|
2017-01-16 23:32:28 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
#----------------------------------------------------------
|
|
|
|
class KatUrsache_cl(object):
|
|
|
|
#----------------------------------------------------------
|
|
|
|
|
|
|
|
exposed = True # gilt für alle Methoden
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
def __init__(self):
|
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
self.db_o = KatursacheDatabase_cl()
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
def GET(self, id = None):
|
2017-01-16 23:32:28 +01:00
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
retVal_o = {
|
|
|
|
'data': None
|
|
|
|
}
|
|
|
|
if id == None:
|
|
|
|
# Anforderung der Liste
|
|
|
|
retVal_o['data'] = self.db_o.read_px()
|
|
|
|
else:
|
|
|
|
# Anforderung eines Dokuments
|
|
|
|
data_o = self.db_o.read_px(id)
|
|
|
|
if data_o != None:
|
|
|
|
retVal_o['data'] = adjustId_p(id, data_o)
|
|
|
|
|
|
|
|
return retVal_o
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
def PUT(self, data_opl):
|
2017-01-16 23:32:28 +01:00
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
# Sichern der Daten: jetzt wird keine vollständige Seite
|
|
|
|
# zurückgeliefert, sondern nur noch die Information, ob das
|
|
|
|
# Speichern erfolgreich war
|
|
|
|
|
|
|
|
retVal_o = {
|
|
|
|
'id': None
|
|
|
|
}
|
|
|
|
|
|
|
|
# data_opl: Dictionary mit den gelieferten key-value-Paaren
|
|
|
|
# hier müsste man prüfen, ob die Daten korrekt vorliegen!
|
|
|
|
|
|
|
|
id_s = data_opl["id_s"]
|
|
|
|
data_o = {
|
|
|
|
'name': data_opl["name_s"],
|
|
|
|
'id': data_opl["id_s"]
|
|
|
|
}
|
|
|
|
# Update-Operation
|
|
|
|
retVal_o['id'] = id_s
|
|
|
|
if self.db_o.update_px(id_s, data_o):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
retVal_o['id'] = None
|
|
|
|
|
|
|
|
return retVal_o
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
def POST(self, data_opl):
|
2017-01-16 23:32:28 +01:00
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
retVal_o = {
|
|
|
|
'id': None
|
|
|
|
}
|
|
|
|
|
|
|
|
# data_opl: Dictionary mit den gelieferten key-value-Paaren
|
|
|
|
|
|
|
|
# hier müsste man prüfen, ob die Daten korrekt vorliegen!
|
|
|
|
|
|
|
|
data_o = {
|
|
|
|
'name': data_opl["name_s"]
|
|
|
|
}
|
|
|
|
# Create-Operation
|
|
|
|
id_s = self.db_o.create_px(data_o)
|
|
|
|
retVal_o['id'] = id_s
|
|
|
|
|
|
|
|
return retVal_o
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
def DELETE(self, id):
|
2017-01-16 23:32:28 +01:00
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
# Eintrag löschen, nur noch Rückmeldung liefern
|
|
|
|
retVal_o = {
|
|
|
|
'id': id
|
|
|
|
}
|
|
|
|
|
|
|
|
if self.db_o.delete_px(id):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
retVal_o['id'] = None
|
|
|
|
|
|
|
|
return retVal_o
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
Anforderung GET PUT POST DELETE
|
|
|
|
-----------------------------------------------------------------------------------------
|
|
|
|
/fehler/ alle Fehler
|
|
|
|
/fehler/?type=erkannt alle erkannten Fehler
|
|
|
|
/fehler/?type=behoben alle behobenen Fehler
|
2017-01-18 18:14:35 +01:00
|
|
|
/fehler/:fehlerid einzelner Fehler
|
2017-01-16 23:32:28 +01:00
|
|
|
/fehler/+Daten Fehler speichern
|
|
|
|
Rückgabe Id
|
2017-01-18 18:14:35 +01:00
|
|
|
/fehler/:fehlerid+Daten Fehler ändern
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
#----------------------------------------------------------
|
|
|
|
class Fehler_cl(object):
|
|
|
|
#----------------------------------------------------------
|
|
|
|
|
|
|
|
exposed = True # gilt für alle Methoden
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
def __init__(self):
|
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
self.db_o = FehlerDatabase_cl()
|
2017-01-17 19:57:12 +01:00
|
|
|
self.dbKomponente_o = KomponenteDatabase_cl()
|
|
|
|
self.dbQsMitarbeiter_o = QsMitarbeiterDatabase_cl()
|
|
|
|
self.dbSwEntwickler_o = SwEntwicklerDatabase_cl()
|
|
|
|
self.dbKatFehler_o = KatfehlerDatabase_cl()
|
|
|
|
self.dbKatUrsache_o = KatursacheDatabase_cl()
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
2017-01-18 18:14:35 +01:00
|
|
|
def GET(self, id=None, type=None):
|
2017-01-16 23:32:28 +01:00
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
retVal_o = {
|
|
|
|
'data': None
|
|
|
|
}
|
|
|
|
if id == None:
|
|
|
|
# Anforderung der Liste
|
2017-01-18 18:14:35 +01:00
|
|
|
print('true')
|
|
|
|
if type == 'erkannt':
|
|
|
|
retVal_o['data'] = self.db_o.readErkannt_px()
|
|
|
|
elif type == 'behoben':
|
|
|
|
retVal_o['data'] = self.db_o.readBehoben_px()
|
|
|
|
else:
|
|
|
|
retVal_o['data'] = self.db_o.read_px()
|
2017-01-17 18:59:39 +01:00
|
|
|
else:
|
|
|
|
# Anforderung eines Dokuments
|
|
|
|
data_o = self.db_o.read_px(id)
|
|
|
|
if data_o != None:
|
|
|
|
retVal_o['data'] = adjustId_p(id, data_o)
|
2017-01-18 18:14:35 +01:00
|
|
|
retVal_o['komponente'] = self.dbKomponente_o.read_px()
|
|
|
|
retVal_o['qsmitarbeiter'] = self.dbQsMitarbeiter_o.read_px()
|
|
|
|
retVal_o['swentwickler'] = self.dbSwEntwickler_o.read_px()
|
|
|
|
retVal_o['katfehler'] = self.dbKatFehler_o.read_px()
|
|
|
|
retVal_o['katursache'] = self.dbKatUrsache_o.read_px()
|
2017-01-17 18:59:39 +01:00
|
|
|
|
|
|
|
return retVal_o
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
def PUT(self, data_opl):
|
|
|
|
#-------------------------------------------------------
|
|
|
|
# Sichern der Daten: jetzt wird keine vollständige Seite
|
|
|
|
# zurückgeliefert, sondern nur noch die Information, ob das
|
|
|
|
# Speichern erfolgreich war
|
|
|
|
|
|
|
|
retVal_o = {
|
|
|
|
'id': None
|
|
|
|
}
|
|
|
|
|
|
|
|
# data_opl: Dictionary mit den gelieferten key-value-Paaren
|
|
|
|
# hier müsste man prüfen, ob die Daten korrekt vorliegen!
|
|
|
|
|
|
|
|
id_s = data_opl["id_s"]
|
|
|
|
data_o = {
|
|
|
|
'name': data_opl["name_s"],
|
2017-01-17 19:57:12 +01:00
|
|
|
'id': data_opl["id_s"],
|
2017-01-18 18:14:35 +01:00
|
|
|
'komponenteid': data_opl["komponenteid_s"],
|
|
|
|
'katfehlerid': data_opl["katfehlerid_s"],
|
|
|
|
'katursacheid': data_opl["katursacheid_s"],
|
|
|
|
'qsmitarbeiterid': data_opl["qsmitarbeiterid_s"],
|
|
|
|
'swentwicklerid': data_opl["swentwicklerid_s"],
|
2017-01-17 19:57:12 +01:00
|
|
|
'status': data_opl["status_s"]
|
2017-01-17 18:59:39 +01:00
|
|
|
}
|
|
|
|
# Update-Operation
|
|
|
|
retVal_o['id'] = id_s
|
|
|
|
if self.db_o.update_px(id_s, data_o):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
retVal_o['id'] = None
|
|
|
|
|
|
|
|
return retVal_o
|
|
|
|
|
2017-01-16 23:32:28 +01:00
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
def POST(self, data_opl):
|
|
|
|
#-------------------------------------------------------
|
|
|
|
retVal_o = {
|
|
|
|
'id': None
|
|
|
|
}
|
|
|
|
|
|
|
|
# data_opl: Dictionary mit den gelieferten key-value-Paaren
|
|
|
|
|
|
|
|
# hier müsste man prüfen, ob die Daten korrekt vorliegen!
|
|
|
|
|
|
|
|
data_o = {
|
2017-01-17 19:57:12 +01:00
|
|
|
'name': data_opl["name_s"],
|
|
|
|
'id': data_opl["id_s"],
|
2017-01-18 18:14:35 +01:00
|
|
|
'komponenteid': data_opl["komponenteid_s"],
|
|
|
|
'katfehlerid': data_opl["katfehlerid_s"],
|
|
|
|
'katursacheid': data_opl["katursacheid_s"],
|
|
|
|
'qsmitarbeiterid': data_opl["qsmitarbeiterid_s"],
|
|
|
|
'swentwicklerid': data_opl["swentwicklerid_s"],
|
2017-01-17 19:57:12 +01:00
|
|
|
'status': data_opl["status_s"]
|
2017-01-17 18:59:39 +01:00
|
|
|
}
|
|
|
|
# Create-Operation
|
|
|
|
id_s = self.db_o.create_px(data_o)
|
|
|
|
retVal_o['id'] = id_s
|
|
|
|
|
|
|
|
return retVal_o
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
def DELETE(self, id):
|
2017-01-16 23:32:28 +01:00
|
|
|
#-------------------------------------------------------
|
2017-01-17 18:59:39 +01:00
|
|
|
# Eintrag löschen, nur noch Rückmeldung liefern
|
|
|
|
retVal_o = {
|
|
|
|
'id': id
|
|
|
|
}
|
|
|
|
|
|
|
|
if self.db_o.delete_px(id):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
retVal_o['id'] = None
|
|
|
|
|
|
|
|
return retVal_o
|
2017-01-16 23:32:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
# EOF
|