Exemplo n.º 1
0
    def createChatroom(cls, obj, params):
        """ Inserts the object in the database according to all the kind of indexing types, in this case:
        -Chat rooms by conference
        -Chat rooms by user
        -Chat rooms by name (to check if there's already a chat room with that name in our XMPP server)
        -Chat rooms by ID (to access faster to the object when querying)
        """
        room = params['room']

        conference = params['conference']

        # index by conference id
        confIndex = IndexByConf()
        room.setId(DBHelpers.newID())
        confIndex.index(conference.getId(), room)

        # Index by chat room's name
        crNameIndex = IndexByCRName()
        crNameIndex.index(room)

        # Index by id
        idIndex = IndexByID()
        idIndex.index(room)

        # Index by room creator
        userIndex = IndexByUser()
        userIndex.index(room.getOwner().getId(), room)
Exemplo n.º 2
0
    def createChatroom(cls, obj, params):
        """ Inserts the object in the database according to all the kind of indexing types, in this case:
        -Chat rooms by conference
        -Chat rooms by user
        -Chat rooms by name (to check if there's already a chat room with that name in our XMPP server)
        -Chat rooms by ID (to access faster to the object when querying)
        """
        room = params['room']

        conference = params['conference']

        # index by conference id
        confIndex = IndexByConf()
        room.setId(DBHelpers.newID())
        confIndex.index(conference.getId(), room)

        # Index by chat room's name
        crNameIndex = IndexByCRName()
        crNameIndex.index(room)

        # Index by id
        idIndex = IndexByID()
        idIndex.index(room)

        # Index by room creator
        userIndex = IndexByUser()
        userIndex.index(room.getOwner().getId(), room)
Exemplo n.º 3
0
    def getChatroom(cls, id):
        index = IndexByID().get()

        if not index.has_key(id):
            raise ServiceError(
                message=_('Chat room not found in database: %s' % id))
        return index[id]
Exemplo n.º 4
0
    def deleteChatroom(cls, obj, params):
        """ Deletes the chat room in the database according to all kind of indexing types"""

        chatroom = params['room']

        confId = obj._conferenceID
        #if we have the same room used in two or more different conferences, we just delete it from the
        #conferences list in the chat room and from the IndexByConf index
        chatroom.getConferences().pop(confId)
        confIndex = IndexByConf()
        confIndex.unindex(confId, chatroom)

        if len(chatroom.getConferences()) is 0:
            #there are no more references to the chat room, we completely delete it
            crNameIndex = IndexByCRName()
            crNameIndex.unindex(chatroom)

            idIndex = IndexByID()
            idIndex.unindex(chatroom)

            userIndex = IndexByUser()
            userIndex.unindex(chatroom.getOwner().getId(), chatroom)
Exemplo n.º 5
0
    def deleteChatroom(cls, obj, params):
        """ Deletes the chat room in the database according to all kind of indexing types"""

        chatroom = params['room']

        confId = obj._conferenceID
        #if we have the same room used in two or more different conferences, we just delete it from the
        #conferences list in the chat room and from the IndexByConf index
        chatroom.getConferences().pop(confId)
        confIndex = IndexByConf()
        confIndex.unindex(confId, chatroom)

        if len(chatroom.getConferences()) is 0:
            #there are no more references to the chat room, we completely delete it
            crNameIndex = IndexByCRName()
            crNameIndex.unindex(chatroom)

            idIndex = IndexByID()
            idIndex.unindex(chatroom)

            userIndex = IndexByUser()
            userIndex.unindex(chatroom.getOwner().getId(), chatroom)
Exemplo n.º 6
0
    def getChatroom(cls, id):
        index = IndexByID().get()

        if not index.has_key(id):
            raise ServiceError( message=_('Chat room not found in database: %s' %id))
        return index[id]