Commit 27fc8c9d authored by Cedric Abunar's avatar Cedric Abunar

[evo]new dao for incall

parent 78cc26e6
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012 Avencall
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, XiVO CTI Server is available under other licenses directly
# contracted with Avencall. See the LICENSE file at top of the source tree
# or delivered in the installable package in which XiVO CTI Server is
# distributed for more details.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from xivo_dao.alchemy.base import Base, Type
from sqlalchemy.schema import Column
from sqlalchemy.types import Integer, String, Enum
class Dialaction(Base):
__tablename__ = 'dialaction'
event = Column(Enum('answer',
'noanswer',
'congestion',
'busy',
'chanunavail',
'inschedule',
'outschedule',
'qwaittime',
'qwaitratio',
name='dialaction_event',
metadata=Type.metadata),
nullable=False,
primary_key=True)
category = Column(Enum('callfilter',
'group',
'incall',
'queue',
'schedule',
'user',
'outcall',
name='dialaction_category',
metadata=Type.metadata),
nullable=False,
primary_key=True)
categoryval = Column(String(128), nullable=False, default='', primary_key=True)
action = Column(Enum('none',
'endcall:busy',
'endcall:congestion',
'endcall:hangup',
'user',
'group',
'queue',
'meetme',
'voicemail',
'trunk',
'schedule',
'voicemenu',
'extension',
'outcall',
'application:callbackdisa',
'application:disa',
'application:directory',
'application:faxtomail',
'application:voicemailmain',
'application:password',
'sound',
'custom',
name='dialaction_action',
metadata=Type.metadata),
nullable=False)
actionarg1 = Column(String(255), nullable=False, default='')
actionarg2 = Column(String(255), nullable=False, default='')
linked = Column(Integer, nullable=False, default=0)
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012 Avencall
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, XiVO CTI Server is available under other licenses directly
# contracted with Avencall. See the LICENSE file at top of the source tree
# or delivered in the installable package in which XiVO CTI Server is
# distributed for more details.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from xivo_dao.alchemy.base import Base
from sqlalchemy.schema import Column
from sqlalchemy.types import Integer, String, Text
class Incall(Base):
__tablename__ = 'incall'
id = Column(Integer, primary_key=True)
exten = Column(String(40), nullable=False)
context = Column(String(39), nullable=False)
preprocess_subroutine = Column(String(39))
commented = Column(Integer, nullable=False, default=0)
preprocess_subroutine = Column(Text, nullable=False)
# -*- coding: UTF-8 -*-
# Copyright (C) 2012 Avencall
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, XiVO CTI Server is available under other licenses directly
# contracted with Avencall SAS. See the LICENSE file at top of the
# source tree or delivered in the installable package in which XiVO CTI Server
# is distributed for more details.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from xivo_dao.alchemy.base import Base
from sqlalchemy.schema import Column
from sqlalchemy.types import Integer, String, Text
class Voicemenu(Base):
__tablename__ = 'voicemenu'
id = Column(Integer, primary_key=True, nullable=False)
name = Column(String(29), nullable=False, default='')
number = Column(String(40), nullable=False)
context = Column(String(39), nullable=False)
commented = Column(Integer, nullable=False, default=0)
description = Column(Text, nullable=False)
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012 Avencall
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Alternatively, XiVO CTI Server is available under other licenses directly
# contracted with Avencall. See the LICENSE file at top of the source tree
# or delivered in the installable package in which XiVO CTI Server is
# distributed for more details.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from xivo_dao.alchemy import dbconnection
from xivo_dao.alchemy.incall import Incall
from xivo_dao.alchemy.dialaction import Dialaction
from xivo_dao.alchemy.userfeatures import UserFeatures
from xivo_dao.alchemy.groupfeatures import GroupFeatures
from xivo_dao.alchemy.queuefeatures import QueueFeatures
from xivo_dao.alchemy.meetmefeatures import MeetmeFeatures
from xivo_dao.alchemy.voicemail import Voicemail
from xivo_dao.alchemy.voicemenu import Voicemenu
from sqlalchemy.sql.expression import and_, cast
from sqlalchemy.types import Integer
_DB_NAME = 'asterisk'
def _session():
connection = dbconnection.get_connection(_DB_NAME)
return connection.get_session()
def get(incall_id):
return _session().query(Incall).filter(Incall.id == incall_id).first()
def all():
return (_session().query(Incall, Dialaction, UserFeatures, GroupFeatures, QueueFeatures, MeetmeFeatures, Voicemail, Voicemenu)
.join((Dialaction, Incall.id == cast(Dialaction.categoryval, Integer)))
.outerjoin((UserFeatures, and_(UserFeatures.id == cast(Dialaction.actionarg1, Integer),
Dialaction.action == u'user')))
.outerjoin((GroupFeatures, and_(GroupFeatures.id == cast(Dialaction.actionarg1, Integer),
Dialaction.action == u'group')))
.outerjoin((QueueFeatures, and_(QueueFeatures.id == cast(Dialaction.actionarg1, Integer),
Dialaction.action == u'queue')))
.outerjoin((MeetmeFeatures, and_(MeetmeFeatures.id == cast(Dialaction.actionarg1, Integer),
Dialaction.action == u'meetme')))
.outerjoin((Voicemail, and_(Voicemail.uniqueid == cast(Dialaction.actionarg1, Integer),
Dialaction.action == u'voicemail')))
.outerjoin((Voicemenu, and_(Voicemenu.id == cast(Dialaction.actionarg1, Integer),
Dialaction.action == u'voicemenu')))
.filter(and_(Dialaction.event == u'answer',
Dialaction.category == u'incall'))
.all())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment