Пример #1
0
 def __init__(self, session=None):
     if session is None:
         session = EngineFactory.create_session()
     self.session = session
     self.candidate_generator = APICandidateGenerator(session)
     self.scorer_list = []
     self.scorer_list.append(APITypeScorer(weight=35, api_linker=None))
     self.scorer_list.append(
         MethodParametersScorer(weight=50, api_linker=None))
     self.scorer_list.append(ParentAPIScorer(weight=100.0, api_linker=self))
     self.scorer_list.append(DeclarationScorer(weight=60.0,
                                               api_linker=self))
Пример #2
0
    def start_import(self):
        self.logger = Logger(self.logger_file_name).get_log()
        if not self.session:
            self.session = EngineFactory.create_session()
        self.init_knowledge_table()

        cur = ConnectionFactory.create_cursor_by_knowledge_table(
            self.data_source_knowledge_table)

        select_sql = "select {primary_key_name},{html_column} from {table}".format(
            primary_key_name=self.primary_key_name,
            html_column=self.html_column,
            table=self.table)
        cur.execute(select_sql)
        data_list = cur.fetchall()
        result_tuples = []
        for i in range(0, len(data_list)):
            row_data = data_list[i]
            primary_key = row_data[0]
            html_text = row_data[1]

            if KnowledgeTableColumnMapRecord.exist_import_record(
                    session=self.session,
                    start_knowledge_table=self.data_source_knowledge_table,
                    end_knowledge_table=self.api_html_table,
                    start_row_id=primary_key,
                    start_row_name=self.html_column):
                self.logger.info("%d has been import to new table",
                                 primary_key)
                continue
            api_html_text = self.create_from_one_row_data(
                primary_key, html_text)

            if api_html_text:
                api_html_text = api_html_text.create(self.session,
                                                     autocommit=False)
                result_tuples.append((api_html_text, primary_key))
            else:
                self.logger.warn("None api_html_text fot %s", str(row_data))
                continue

            if len(result_tuples) > self.commit_step:
                self.commit_to_server_for_column_map(map_tuples=result_tuples)
                result_tuples = []
        self.commit_to_server_for_column_map(map_tuples=result_tuples)
        self.logger.info("import api html completed!")
        cur.close()
Пример #3
0
            className = dic['className: ']
            param = dic['param: ']
            javadocComment = dic['javadocComment: ']
            blockComment = dic['blockComment: ']

            update_by_className_methodName_param(className, methodName, param,
                                                 code, javadocComment,
                                                 blockComment)
            counter += 1
            if counter > step:
                counter = 0
                session.commit()
        session.commit()


if __name__ == "__main__":
    schema_name = 'domainkg'
    engine = EngineFactory.create_engine_by_schema_name(schema_name)
    session = EngineFactory.create_session(engine=engine, autocommit=False)
    read_json_by_line('traces.json')

    # trace_list = session.query(Traces).filter_by()
    # for trace in trace_list:
    #     try:
    #         className = trace.className
    #         methodName = trace.methodName
    #         param = trace.param
    #         trace.code = 'code'
    #     except Exception:
    #         print("error")
Пример #4
0
 def __init__(self, session=None):
     if session is None:
         session = EngineFactory.create_session()
     self.session = session
Пример #5
0
    def get_session(self):
        if not self.session:
            self.session = EngineFactory.create_session()

        return self.session