def create_project(self, name, user_id, project_type_id, semester_id,
                       assignment_id, project_description, partners, capacity,
                       preferred_room, b_days_pre_schedule, b_days_finale,
                       b_days_saturdays, preferred_b_days, additional_lecturer,
                       weekly):
        """Neues Projekt anlegen"""

        project = Project()
        project.set_name(name)
        project.set_user_id(user_id)
        project.set_project_type_id(project_type_id)
        project.set_semester_id(semester_id)
        project.set_assignment_id(assignment_id)
        project.set_project_description(project_description)
        project.set_partners(partners)
        project.set_capacity(capacity)
        project.set_preferred_room(preferred_room)
        project.set_b_days_pre_schedule(b_days_pre_schedule)
        project.set_b_days_finale(b_days_finale)
        project.set_b_days_saturdays(b_days_saturdays)
        project.set_preferred_b_days(preferred_b_days)
        project.set_additional_lecturer(additional_lecturer)
        project.set_weekly(weekly)
        project.set_id(1)

        with ProjectMapper() as mapper:
            return mapper.insert(project)
    def create_project(self, id, creation_time, semester, module,
                       short_description, external_partner_list, capacity,
                       bd_during_exam_period, bd_before_lecture_period,
                       bd_during_lecture_period,
                       preferred_bd_during_lecture_period, language, room,
                       special_room, flag, name, status, project_type, owner):
        """Ein Projekt anlegen"""
        project = Project()
        project.set_id(id)
        project.set_creation_time(creation_time)
        project.set_semester(semester)
        project.set_module(module)
        project.set_short_description(short_description)
        project.set_external_partner_list(external_partner_list)
        project.set_capacity(capacity)
        project.set_bd_during_exam_period(bd_during_exam_period)
        project.set_bd_before_lecture_period(bd_before_lecture_period)
        project.set_bd_during_lecture_period(bd_during_lecture_period)
        project.set_preferred_bd_during_lecture_period(
            preferred_bd_during_lecture_period)
        project.set_language(language)
        project.set_room(room)
        project.set_special_room(special_room)
        project.set_flag(flag)
        project.set_name(name)
        project.set_status(status)
        project.set_project_type(project_type)
        project.set_owner(owner)
        project.set_id(1)

        with ProjectMapper() as mapper:
            return mapper.insert(project)
    def find_by_name(self, name):

        result = []

        cursor = self._cnx.cursor()
        command = "SELECT id, creation_time, semester, module, short_description, external_partner_list, capacity, bd_during_exam_period, bd_before_lecture_period, bd_during_lecture_period, preferred_bd_during_lecture_period, language, room, special_room, flag, name, status, project_type, owner FROM project WHERE name LIKE '%{}%'".format(name)
        cursor.execute(command)
        tuples = cursor.fetchall()

        try:
            (id, creation_time, semester, module, short_description, external_partner_list, capacity,
             bd_during_exam_period, bd_before_lecture_period, bd_during_lecture_period,
             preferred_bd_during_lecture_period, language, room, special_room, flag, name,
             status, project_type, owner) = tuples[0]

            project = Project()
            project.set_id(id)
            project.set_creation_time(creation_time)
            project.set_semester(semester)
            project.set_module(module)
            project.set_short_description(short_description)
            project.set_external_partner_list(external_partner_list)
            project.set_capacity(capacity)
            project.set_bd_during_exam_period(bd_during_exam_period)
            project.set_bd_before_lecture_period(bd_before_lecture_period)
            project.set_bd_during_lecture_period(bd_during_lecture_period)
            project.set_preferred_bd_during_lecture_period(preferred_bd_during_lecture_period)
            project.set_language(language)
            project.set_room(room)
            project.set_special_room(special_room)
            project.set_flag(flag)
            project.set_name(name)
            project.set_status(status)
            project.set_project_type(project_type)
            project.set_owner(owner)
            result.append(project)


        except IndexError:
            """Der IndexError wird oben beim Zugriff auf tuples[0] auftreten, wenn der vorherige SELECT-Aufruf
            keine Tupel liefert, sondern tuples = cursor.fetchall() eine leere Sequenz zurück gibt."""
            result = None

        self._cnx.commit()
        cursor.close()

        return result
    def find_projects_by_student(self, student):

        result = []

        cursor = self._cnx.cursor()
        command = "SELECT project.id, project.creation_time, semester, module, short_description, external_partner_list, capacity, " \
                  "bd_during_exam_period, bd_before_lecture_period, bd_during_lecture_period, " \
                  "preferred_bd_during_lecture_period, language, room, special_room, flag, name, status, " \
                  "project_type, owner FROM project INNER JOIN participation ON participation.project = project.id " \
                  "WHERE participation.student = {}".format(student)

        print(command)
        cursor.execute(command)

        tuples = cursor.fetchall()

        for (id, creation_time, semester, module, short_description, external_partner_list, capacity,
             bd_during_exam_period, bd_before_lecture_period, bd_during_lecture_period,
             preferred_bd_during_lecture_period, language, room, special_room, flag, name,
             status, project_type, owner) in tuples:

            project = Project()
            project.set_id(id)
            project.set_creation_time(creation_time)
            project.set_semester(semester)
            project.set_module(module)
            project.set_short_description(short_description)
            project.set_external_partner_list(external_partner_list)
            project.set_capacity(capacity)
            project.set_bd_during_exam_period(bd_during_exam_period)
            project.set_bd_before_lecture_period(bd_before_lecture_period)
            project.set_bd_during_lecture_period(bd_during_lecture_period)
            project.set_preferred_bd_during_lecture_period(preferred_bd_during_lecture_period)
            project.set_language(language)
            project.set_room(room)
            project.set_special_room(special_room)
            project.set_flag(flag)
            project.set_name(name)
            project.set_status(status)
            project.set_project_type(project_type)
            project.set_owner(owner)
            result.append(project)

        self._cnx.commit()
        cursor.close()
        return result
    def find_by_key(self, id):
        """Suchen eines Projektes mit vorgegebener user ID"""

        result = []
        cursor = self._cnx.cursor()
        command = "SELECT * FROM project WHERE id like '{}'".format(id)
        cursor.execute(command)
        tuples = cursor.fetchall()

        if len(tuples) != 0:

            for (id, name, user_id, project_type_id, state_id, semester_id,
                 assignment_id, project_description, partners, capacity,
                 preferred_room, b_days_pre_schedule, b_days_finale,
                 b_days_saturdays, preferred_b_days, additional_lecturer,
                 weekly, create_time) in tuples:
                project = Project()
                project.set_id(id)
                project.set_name(name)
                project.set_user_id(user_id)
                project.set_project_type_id(project_type_id)
                project.set_state_id(state_id)
                project.set_semester_id(semester_id)
                project.set_assignment_id(assignment_id)
                project.set_project_description(project_description)
                project.set_partners(partners)
                project.set_capacity(capacity)
                project.set_preferred_room(preferred_room)
                project.set_b_days_pre_schedule(b_days_pre_schedule)
                project.set_b_days_finale(b_days_finale)
                project.set_b_days_saturdays(b_days_saturdays)
                project.set_preferred_b_days(preferred_b_days)
                project.set_additional_lecturer(additional_lecturer)
                project.set_weekly(weekly)
                project.set_create_time(create_time)
                result.append(project)
                result = project

        else:

            result = None

        self._cnx.commit()
        cursor.close()

        return result
    def find_by_id(self, id):

        result = []

        cursor = self._cnx.cursor()
        command = "SELECT id, creation_time, semester, module, short_description, external_partner_list, capacity, bd_during_exam_period, bd_before_lecture_period, bd_during_lecture_period, preferred_bd_during_lecture_period, language, room, special_room, flag, name, status, project_type, owner FROM project WHERE id={}".format(id)
        cursor.execute(command)
        tuples = cursor.fetchall()

        if tuples[0] is not None:
            (id, creation_time, semester, module, short_description, external_partner_list, capacity,
             bd_during_exam_period, bd_before_lecture_period, bd_during_lecture_period,
             preferred_bd_during_lecture_period, language, room, special_room, flag, name,
             status, project_type, owner) = tuples[0]
            project = Project()
            project.set_id(id)
            project.set_creation_time(creation_time)
            project.set_name(name)
            project.set_owner(owner)
            project.set_module(module)
            project.set_language(language)
            project.set_project_type(project_type)
            project.set_semester(semester)
            project.set_capacity(capacity)
            project.set_external_partner_list(external_partner_list)
            project.set_short_description(short_description)
            project.set_flag(flag)
            project.set_bd_before_lecture_period(bd_before_lecture_period)
            project.set_bd_during_lecture_period(bd_during_lecture_period)
            project.set_bd_during_exam_period(bd_during_exam_period)
            project.set_preferred_bd_during_lecture_period(preferred_bd_during_lecture_period)
            project.set_status(status)
            project.set_room(room)
            project.set_special_room(special_room)
            result.append(project)

        self._cnx.commit()
        cursor.close()

        return result
    def find_all(self):
        """Auslesen aller Projekte"""

        result = []
        cursor = self._cnx.cursor()
        command = "SELECT * FROM project"
        cursor.execute(command)
        tuples = cursor.fetchall()

        for (id, name, user_id, project_type_id, state_id, semester_id,
             assignment_id, project_description, partners, capacity,
             preferred_room, b_days_pre_schedule, b_days_finale,
             b_days_saturdays, preferred_b_days, additional_lecturer, weekly,
             create_time) in tuples:
            project = Project()
            project.set_id(id)
            project.set_name(name)
            project.set_user_id(user_id)
            project.set_project_type_id(project_type_id)
            project.set_state_id(state_id)
            project.set_semester_id(semester_id)
            project.set_assignment_id(assignment_id)
            project.set_project_description(project_description)
            project.set_partners(partners)
            project.set_capacity(capacity)
            project.set_preferred_room(preferred_room)
            project.set_b_days_pre_schedule(b_days_pre_schedule)
            project.set_b_days_finale(b_days_finale)
            project.set_b_days_saturdays(b_days_saturdays)
            project.set_preferred_b_days(preferred_b_days)
            project.set_additional_lecturer(additional_lecturer)
            project.set_weekly(weekly)
            project.set_create_time(create_time)
            result.append(project)

        self._cnx.commit()
        cursor.close()

        return result