예제 #1
0
def insert(tag, debug=False):
    res = None
    controller = controllerHandler.get_controller(tag.get('installation'), tag.get('controller_ip'))
    current_tag = tag_dao.get(tag.get('installation'), tag.get('controller_ip'), tag.get('name'))
    if controller and not current_tag:
        res = tag_dao.create_tag(tag)
    if res and not debug:
        print('Inserted new tag with name: ' + tag['name'])
        sync = {}
        sync['installation'] = tag['installation']
        sync['method'] = sync_methods.INSERT
        sync['table'] = 'tags'
        sync['data'] = tag
        sync['prev'] = None
        res = syncHandler.insert(sync)
    return res
예제 #2
0
def get_tag_by_name(serial_number, controller_ip, name):
    res = None
    controller = controllerHandler.get_controller(serial_number, controller_ip)
    if controller:
        res = tag_dao.get(serial_number, controller_ip, name)
    return res
예제 #3
0
def get(id):
    return tag_dao.get(id)