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)
コード例 #2
0
    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
コード例 #3
0
    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
コード例 #4
0
    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