예제 #1
0
    def add_attribute(self):
        ''' When add button pressed, open addItem dialog to get new attribute text.
        AddItem dialog checks for duplicate attribute name.
        New attribute is added to the model and database '''

        ui = DialogAddItemName(self.attribute_type, _("New attribute name"))
        ui.exec_()
        newText = ui.get_new_name()
        if newText is None or newText == "":
            return
        Dialog_type = QtWidgets.QDialog()
        ui = Ui_Dialog_attribute_type()
        ui.setupUi(Dialog_type)
        ok = Dialog_type.exec_()
        valuetype = "character"
        if ok and ui.radioButton_numeric.isChecked():
            valuetype = "numeric"
        Dialog_assign = QtWidgets.QDialog()
        ui = Ui_Dialog_assignAttribute()
        ui.setupUi(Dialog_assign)
        ok = Dialog_assign.exec_()
        case_or_file = "case"
        if ok and ui.radioButton_files.isChecked():
            case_or_file = "file"
        # update attribute_type list and database
        now_date = str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
        item = {
            'name': newText,
            'memo': "",
            'owner': self.app.settings['codername'],
            'date': now_date,
            'valuetype': valuetype,
            'caseOrFile': case_or_file
        }
        self.attribute_type.append(item)
        cur = self.app.conn.cursor()
        cur.execute(
            "insert into attribute_type (name,date,owner,memo,caseOrFile, valuetype) values(?,?,?,?,?,?)",
            (item['name'], item['date'], item['owner'], item['memo'],
             item['caseOrFile'], item['valuetype']))
        self.app.conn.commit()
        sql = "select id from source"
        cur.execute(sql)
        ids = cur.fetchall()
        if case_or_file == "case":
            sql = "select caseid from cases"
            cur.execute(sql)
            ids = cur.fetchall()
        for id_ in ids:
            sql = "insert into attribute (name, value, id, attr_type, date, owner) values (?,?,?,?,?,?)"
            cur.execute(sql, (item['name'], "", id_[0], case_or_file, now_date,
                              self.app.settings['codername']))
        self.app.conn.commit()
        self.fill_tableWidget()
        self.parent_textEdit.append(_("Attribute added: ") + item['name'])
예제 #2
0
    def add_attribute(self):
        ''' When add button pressed, opens the addItem dialog to get new attribute text.
        Then get the attribute type through a dialog.
        AddItem dialog checks for duplicate attribute name.
        New attribute is added to the model and database '''

        cur = self.settings['conn'].cursor()
        cur.execute("select name from attribute_type where caseOrFile='case'")
        result = cur.fetchall()
        attribute_names = []
        for a in result:
            attribute_names.append({'name': a[0]})
        check_names = attribute_names + [{
            'name': 'name'
        }, {
            'name': 'memo'
        }, {
            'name': 'caseid'
        }, {
            'name': 'date'
        }]
        ui = DialogAddItemName(check_names, _("New attribute name"))
        ui.exec_()
        name = ui.get_new_name()
        if name is None or name == "":
            return
        Dialog_type = QtWidgets.QDialog()
        ui = Ui_Dialog_attribute_type()
        ui.setupUi(Dialog_type)
        ok = Dialog_type.exec_()
        valuetype = "character"
        if ok and ui.radioButton_numeric.isChecked():
            valuetype = "numeric"
        #self.attribute_names.append({'name': name})
        # update attribute_type list and database
        now_date = str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
        cur = self.settings['conn'].cursor()
        cur.execute(
            "insert into attribute_type (name,date,owner,memo,caseOrFile, valuetype) values(?,?,?,?,?,?)",
            (name, now_date, self.settings['codername'], "", 'case',
             valuetype))
        self.settings['conn'].commit()
        sql = "select caseid from cases"
        cur.execute(sql)
        case_ids = cur.fetchall()
        for id_ in case_ids:
            sql = "insert into attribute (name, value, id, attr_type, date, owner) values (?,?,?,?,?,?)"
            cur.execute(sql, (name, "", id_[0], 'case', now_date,
                              self.settings['codername']))
        self.settings['conn'].commit()
        self.load_cases_and_attributes()
        self.fill_tableWidget()
        self.parent_textEdit.append(
            _("Attribute added to cases: ") + name + ", " + _("type: ") +
            valuetype)
예제 #3
0
    def add_attribute(self):
        """ When add button pressed, opens the addItem dialog to get new attribute text.
        Then get the attribute type through a dialog.
        AddItem dialog checks for duplicate attribute name.
        New attribute is added to the model and database. """

        check_names = self.attribute_names + [{'name': 'name'}, {'name':'memo'}, {'name':'id'}, {'name':'date'}]
        ui = DialogAddItemName(check_names, "New attribute name")
        ui.exec_()
        name = ui.get_new_name()
        if name is None or name == "":
            return
        Dialog_type = QtWidgets.QDialog()
        ui = Ui_Dialog_attribute_type()
        ui.setupUi(Dialog_type)
        ok = Dialog_type.exec_()
        valuetype = "character"
        if ok and ui.radioButton_numeric.isChecked():
            valuetype = "numeric"
        self.attribute_names.append({'name': name})
        # update attribute_type list and database
        now_date = str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
        cur = self.settings['conn'].cursor()
        cur.execute("insert into attribute_type (name,date,owner,memo,caseOrFile, valuetype) values(?,?,?,?,?,?)"
            ,(name, now_date, self.settings['codername'], "", 'file', valuetype))
        self.settings['conn'].commit()
        sql = "select id from source"
        cur.execute(sql)
        ids = cur.fetchall()
        for id_ in ids:
            sql = "insert into attribute (name, value, id, attr_type, date, owner) values (?,?,?,?,?,?)"
            cur.execute(sql, (name, "", id_[0], 'file', now_date, self.settings['codername']))
        self.settings['conn'].commit()
        self.load_file_data()
        self.fill_table()
        self.parent_textEdit.append("Attribute added to files: " + name + ", type: " + valuetype)