コード例 #1
0
ファイル: login.py プロジェクト: bbcf/biorepo
 def build_None_attribut_value(self, att_id):
     '''
     build a None value Attribut value
     @param principal = Attributs.id
     @return an Attribut value
     '''
     att_val = Attributs_values()
     att_val.attribut_id = att_id
     att_val.value = None
     att_val.deprecated = False
     return att_val
コード例 #2
0
ファイル: login.py プロジェクト: bbcf/biorepo
    def check_value_addition(self, list_type_att, dict_att_values_type,
                             dict_att_values_db, lab_id):
        '''
        Checking for value(s) addition
        @param principal
        @return an updated db
        '''
        for key_type in list_type_att:
            for i in dict_att_values_type[key_type]:
                #get the attribut and its value(s)
                i_att = DBSession.query(Attributs).filter(
                    and_(Attributs.lab_id == lab_id,
                         Attributs.key == key_type)).first()
                #warning : i_att_value is a list !
                i_att_value = DBSession.query(Attributs_values).filter(
                    and_(Attributs_values.attribut_id == i_att.id,
                         Attributs_values.value == i)).all()
                try:
                    flag = False
                    if i not in dict_att_values_db[key_type] and i != "None":
                        for existant in i_att_value:
                            if existant.value == i and existant.deprecated == True:
                                existant.deprecated = False
                                DBSession.flush()
                                flag = True
                            if existant.value is None:
                                existant.deprecated = True
                                DBSession.flush()
                        if flag == False:
                            new_value = Attributs_values()
                            new_value.attribut_id = i_att.id
                            new_value.value = i
                            new_value.deprecated = False
                            DBSession.add(new_value)
                            DBSession.flush()

                except Exception as e:
                    import sys, traceback
                    a, b, c = sys.exc_info()
                    traceback.print_exception(a, b, c)
                    print "--- error login.py check_value_addition() ---"
                    print "i --->", i
                    print "key_type --->", key_type
                    print "list_type_att --->", list_type_att
                    print "dict_att_values_type[key_type] -->", dict_att_values_type[
                        key_type]
                    print "i_att --> ", i_att
                    print "i_att_value", i_att_value
コード例 #3
0
ファイル: login.py プロジェクト: bbcf/biorepo
    def build_attribut_value(self, s, lab_id, dict_fixed_values_type,
                             list_fixed_values_type, config):
        '''
        build Attribut values
        @return a list of Attribut values
        '''
        list_objects_value = []
        for att in list_fixed_values_type:
            #build a dictionnary of fixed values : {'key':'[value1, value2, value3, ...}'}
            list_values = []
            list_values = (config.get(s + att, att)).split(',')
            dict_fixed_values_type[att] = list_values

        for k, list_values in dict_fixed_values_type.iteritems():
            att_tmp = DBSession.query(Attributs).filter(
                and_(Attributs.key == k), Attributs.lab_id == lab_id).first()
            for v in list_values:
                attributs_v = Attributs_values()
                attributs_v.attribut_id = att_tmp.id
                attributs_v.value = v
                attributs_v.deprecated = False
                list_objects_value.append(attributs_v)

        return list_objects_value