Exemplo n.º 1
0
def save_current_status_message(component_id, component_type, message_code, data=""):
    result = True
    try:
        db.session.begin()
        message = get_current_status_message(component_id,message_code)
        if message is not None:
            message_data = message
            message_data.creation_time = datetime.now()
            db.session.merge(message_data)
        else:
            message_data = Current_Status()
            message_data.component_id = component_id
            message_data.component_type = component_type
            message_data.creation_time = datetime.now()
            message_data.message_id = message_code
            message_data.additional_info = data
            message_data.supressed = 0
            message_data.viewed = 'false'
            db.session.add(message_data)
        db.session.commit()
    except:
        db.session.rollback()
        result = False

    return result
Exemplo n.º 2
0
 def append_trigger_message(self,
                            component_id,
                            component_type,
                            message_code,
                            data=""):
     """
     Creates a current status message and saves it in the database
     :param component_id: The component id - uuid canonical string
     :param message_code: Message type
     :param data: Current Status Message Additional Info
     :return: True is successful, False otherwise
     """
     rt = True
     try:
         message_data = Current_Status()
         message_data.component_id = component_id
         message_data.component_type = component_type
         message_data.creation_time = datetime.now()
         message_data.message_id = message_code
         message_data.additional_info = data
         message_data.supressed = 0
         message_data.viewed = 'false'
         self.__trigger_messages.append(message_data)
     except Exception, e:
         rt = False
Exemplo n.º 3
0
def save_current_status_message(component_id, component_type, message_code, data=""):
    """Saves or merges the status_message
    Args:
        component_id(uuid canonical string)
        message_code(uuid cannonical string):Message id
        data (str): Message data
        component_type(str): Component tyep
    """
    result = True
    try:
        message = get_current_status_message(component_id, message_code)
        db.session.begin()
        if message is not None:

            message_data = message
            #message_data.creation_time = datetime.now()
            message_data.additional_info = data
            db.session.merge(message_data)
        else:
            message_data = Current_Status()
            message_data.id = uuid.uuid4().bytes
            message_data.component_id = get_bytes_from_uuid(component_id)
            message_data.component_type = component_type
            message_data.creation_time = datetime.utcnow()
            message_data.message_id = get_bytes_from_uuid(message_code)
            message_data.additional_info = data
            message_data.supressed = 0
            message_data.viewed = 0
            db.session.add(message_data)
        db.session.commit()
    except Exception as error:
        db.session.rollback()
        result = False

    return result
Exemplo n.º 4
0
def save_current_status_message(component_id, component_type, message_code, data=""):
    """Saves or merges the status_message
    Args:
        component_id(uuid canonical string)
        message_code(uuid cannonical string):Message id
        data (str): Message data
        component_type(str): Component tyep
    """
    result = True
    try:
        message = get_current_status_message(component_id, message_code)
        db.session.begin()
        if message is not None:

            message_data = message
            #message_data.creation_time = datetime.now()
            message_data.additional_info = data
            db.session.merge(message_data)
        else:
            message_data = Current_Status()
            message_data.id = uuid.uuid4().bytes
            message_data.component_id = get_bytes_from_uuid(component_id)
            message_data.component_type = component_type
            message_data.creation_time = datetime.utcnow()
            message_data.message_id = get_bytes_from_uuid(message_code)
            message_data.additional_info = data
            message_data.supressed = 0
            message_data.viewed = 0
            db.session.add(message_data)
        db.session.commit()
    except Exception as error:
        db.session.rollback()
        result = False

    return result
Exemplo n.º 5
0
 def append_trigger_message(self, component_id, component_type, message_code, data=""):
     """
     Creates a current status message and saves it in the database
     :param component_id: The component id - uuid canonical string
     :param message_code: Message type
     :param data: Current Status Message Additional Info
     :return: True is successful, False otherwise
     """
     rt = True
     try:
         message_data = Current_Status()
         message_data.component_id = component_id
         message_data.component_type = component_type
         message_data.creation_time = datetime.now()
         message_data.message_id = message_code
         message_data.additional_info = data
         message_data.supressed = 0
         message_data.viewed = 'false'
         self.__trigger_messages.append(message_data)
     except Exception, e:
         rt = False