pilot.linkstec 0.0.32__tar.gz → 0.0.91__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/PKG-INFO +1 -1
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/pyproject.toml +1 -1
- pilot_linkstec-0.0.91/src/pilot/base/ai_call.py +38 -0
- pilot_linkstec-0.0.91/src/pilot/base/ai_info.py +20 -0
- pilot_linkstec-0.0.91/src/pilot/base/chage_file_tag_base.py +73 -0
- pilot_linkstec-0.0.91/src/pilot/base/db_operation_base.py +536 -0
- pilot_linkstec-0.0.91/src/pilot/base/delete_commnents_base.py +306 -0
- pilot_linkstec-0.0.91/src/pilot/base/file_operation.py +44 -0
- pilot_linkstec-0.0.91/src/pilot/base/get_file_encoding.py +14 -0
- pilot_linkstec-0.0.91/src/pilot/base/make_parsing_java_file_order_base.py +154 -0
- pilot_linkstec-0.0.91/src/pilot/base/split_file_base.py +256 -0
- pilot_linkstec-0.0.91/src/pilot/client/ai_client.py +75 -0
- pilot_linkstec-0.0.91/src/pilot/config/config_reader.py +133 -0
- pilot_linkstec-0.0.91/src/pilot/create_python/create_python.py +150 -0
- pilot_linkstec-0.0.91/src/pilot/db/create_table.py +34 -0
- pilot_linkstec-0.0.91/src/pilot/db/db_connect.py +49 -0
- pilot_linkstec-0.0.91/src/pilot/db/db_main.py +293 -0
- pilot_linkstec-0.0.91/src/pilot/db/db_util.py +508 -0
- pilot_linkstec-0.0.91/src/pilot/db/ddl/__init__.py +18 -0
- pilot_linkstec-0.0.91/src/pilot/db/dml/__init__.py +18 -0
- pilot_linkstec-0.0.91/src/pilot/db/sql_executor.py +62 -0
- pilot_linkstec-0.0.91/src/pilot/db/sql_loader.py +233 -0
- pilot_linkstec-0.0.91/src/pilot/db/sql_service.py +55 -0
- pilot_linkstec-0.0.91/src/pilot/file_tool/__init__.py +0 -0
- pilot_linkstec-0.0.91/src/pilot/file_tool/create_prompt_file.py +75 -0
- pilot_linkstec-0.0.91/src/pilot/file_tool/json_file_tool.py +103 -0
- pilot_linkstec-0.0.91/src/pilot/generater/__init__.py +0 -0
- pilot_linkstec-0.0.91/src/pilot/job/__init__.py +0 -0
- pilot_linkstec-0.0.91/src/pilot/job/base/__init__.py +0 -0
- pilot_linkstec-0.0.91/src/pilot/job/base/convert/__init__.py +0 -0
- pilot_linkstec-0.0.91/src/pilot/job/base/convert/encodingTransformerJob.py +16 -0
- pilot_linkstec-0.0.91/src/pilot/job/base/convert/tabReplaceJob.py +27 -0
- pilot_linkstec-0.0.91/src/pilot/job/base/generate/__init__.py +0 -0
- pilot_linkstec-0.0.91/src/pilot/job/base/generate/generateJsonBaseJob.py +42 -0
- pilot_linkstec-0.0.91/src/pilot/job/base/generate/generateTextBaseJob.py +40 -0
- pilot_linkstec-0.0.91/src/pilot/job/impl/__init__.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/job/impl/base_job.py +4 -0
- pilot_linkstec-0.0.91/src/pilot/logging/__init__.py +0 -0
- pilot_linkstec-0.0.91/src/pilot/processor/__init__.py +0 -0
- pilot_linkstec-0.0.91/src/pilot/prompt/__init__.py +0 -0
- pilot_linkstec-0.0.91/src/pilot/splitters/__init__.py +0 -0
- pilot_linkstec-0.0.91/src/pilot/unit/__init__.py +0 -0
- pilot_linkstec-0.0.91/src/pilot/unit/impl/__init__.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/unit/impl/base_unit.py +1 -0
- pilot_linkstec-0.0.91/src/pilot/util/__init__.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot.linkstec.egg-info/PKG-INFO +1 -1
- pilot_linkstec-0.0.91/src/pilot.linkstec.egg-info/SOURCES.txt +77 -0
- pilot_linkstec-0.0.32/src/pilot/config/config_reader.py +0 -95
- pilot_linkstec-0.0.32/src/pilot.linkstec.egg-info/SOURCES.txt +0 -37
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/LICENSE +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/README.md +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/setup.cfg +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/__init__.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/config → pilot_linkstec-0.0.91/src/pilot/base}/__init__.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/control → pilot_linkstec-0.0.91/src/pilot/client}/__init__.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/control/impl → pilot_linkstec-0.0.91/src/pilot/config}/__init__.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/conver → pilot_linkstec-0.0.91/src/pilot/control}/__init__.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/control/control_interface.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/generater → pilot_linkstec-0.0.91/src/pilot/control/impl}/__init__.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/control/impl/base_controller.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/job → pilot_linkstec-0.0.91/src/pilot/conver}/__init__.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/conver/commentRemover.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/conver/converfileEncodding.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/conver/nkf_converter.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/job/impl → pilot_linkstec-0.0.91/src/pilot/create_python}/__init__.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/logging → pilot_linkstec-0.0.91/src/pilot/create_python/config}/__init__.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/processor → pilot_linkstec-0.0.91/src/pilot/create_python/sample}/__init__.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/splitters → pilot_linkstec-0.0.91/src/pilot/create_python/sample/child_sample}/__init__.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/unit → pilot_linkstec-0.0.91/src/pilot/create_python/sample/child_sample/job}/__init__.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/unit/impl → pilot_linkstec-0.0.91/src/pilot/create_python/sample/config}/__init__.py +0 -0
- {pilot_linkstec-0.0.32/src/pilot/util → pilot_linkstec-0.0.91/src/pilot/db}/__init__.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/generater/vertexai.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/job/job_interface.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/logging/logger.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/processor/code_processor.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/processor/code_processor_pipeline.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/splitters/cobolsplitter.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/unit/unit_interface.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot/util/files.py +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot.linkstec.egg-info/dependency_links.txt +0 -0
- {pilot_linkstec-0.0.32 → pilot_linkstec-0.0.91}/src/pilot.linkstec.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from base.ai_info import call_ai
|
|
5
|
+
|
|
6
|
+
def call_ai_main(prompt_file_path, out_file_path):
|
|
7
|
+
|
|
8
|
+
lines = read_file_lines_with_path(prompt_file_path)
|
|
9
|
+
|
|
10
|
+
prompt_str = ''.join(lines)
|
|
11
|
+
|
|
12
|
+
result_content = call_ai(prompt_str)
|
|
13
|
+
|
|
14
|
+
file_name = Path(prompt_file_path).name.split('.')[0] + '.json'
|
|
15
|
+
|
|
16
|
+
os.makedirs(out_file_path, exist_ok=True)
|
|
17
|
+
|
|
18
|
+
method_info_file = os.path.join(out_file_path, file_name)
|
|
19
|
+
|
|
20
|
+
with open(method_info_file, 'w', encoding='utf-8') as f:
|
|
21
|
+
f.write(result_content)
|
|
22
|
+
|
|
23
|
+
return method_info_file
|
|
24
|
+
|
|
25
|
+
def read_file_lines_with_path(file_path):
|
|
26
|
+
with open(file_path, 'r', encoding='utf-8') as f:
|
|
27
|
+
_lines = f.readlines()
|
|
28
|
+
return _lines
|
|
29
|
+
|
|
30
|
+
def remove_markdown_code_block(content):
|
|
31
|
+
content = content.strip()
|
|
32
|
+
if content.startswith('```') and content.endswith('```'):
|
|
33
|
+
lines = content.split('\n')
|
|
34
|
+
if len(lines) >= 3:
|
|
35
|
+
return '\n'.join(lines[1:-1])
|
|
36
|
+
else:
|
|
37
|
+
return '\n'.join(lines[1:-1]) if len(lines) > 2 else ''
|
|
38
|
+
return content
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from client.ai_client import LMStudioClient
|
|
2
|
+
|
|
3
|
+
def call_ai(prompt_str):
|
|
4
|
+
|
|
5
|
+
# AIを呼び出し
|
|
6
|
+
ai_client = LMStudioClient()
|
|
7
|
+
#
|
|
8
|
+
result_content = remove_markdown_code_block(ai_client.call(prompt_str))
|
|
9
|
+
|
|
10
|
+
return result_content
|
|
11
|
+
|
|
12
|
+
def remove_markdown_code_block(content):
|
|
13
|
+
content = content.strip()
|
|
14
|
+
if content.startswith('```') and content.endswith('```'):
|
|
15
|
+
lines = content.split('\n')
|
|
16
|
+
if len(lines) >= 3:
|
|
17
|
+
return '\n'.join(lines[1:-1])
|
|
18
|
+
else:
|
|
19
|
+
return '\n'.join(lines[1:-1]) if len(lines) > 2 else ''
|
|
20
|
+
return content
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from pilot.job.impl.base_job import BaseJob
|
|
4
|
+
from base.file_operation import read_file_lines, write_json_file, write_file_line
|
|
5
|
+
|
|
6
|
+
class ChangeFile(BaseJob):
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def escape_sql_text(text):
|
|
10
|
+
"""只转义SQL中的 < 和 >"""
|
|
11
|
+
text = text.replace('<', '<')
|
|
12
|
+
text = text.replace('>', '>')
|
|
13
|
+
return text
|
|
14
|
+
|
|
15
|
+
def change_mybatis_tag(self, content):
|
|
16
|
+
"""处理MyBatis标签内容"""
|
|
17
|
+
# 处理所有动态标签
|
|
18
|
+
tags = ['select', 'update', 'insert', 'delete', 'where', 'if', 'foreach', 'choose', 'otherwise', 'set']
|
|
19
|
+
|
|
20
|
+
for tag in tags:
|
|
21
|
+
pattern = re.compile(rf'<{tag}([^>]*?)>([\s\S]*?)</{tag}>', re.IGNORECASE)
|
|
22
|
+
|
|
23
|
+
def _single(m):
|
|
24
|
+
attrs, body = m.groups()
|
|
25
|
+
body_fixed = self.process_tag_text(body)
|
|
26
|
+
return f'<{tag}{attrs}>{body_fixed}</{tag}>'
|
|
27
|
+
|
|
28
|
+
content = pattern.sub(_single, content)
|
|
29
|
+
|
|
30
|
+
return content
|
|
31
|
+
|
|
32
|
+
def process_tag_text(self, tag_body):
|
|
33
|
+
"""处理标签内容,只转义普通文本中的 < 和 >"""
|
|
34
|
+
parts = re.split(r'(<!--.*?-->|<[^>]+?>)', tag_body, flags=re.DOTALL)
|
|
35
|
+
out = ""
|
|
36
|
+
for i, part in enumerate(parts):
|
|
37
|
+
if i % 2 == 0:
|
|
38
|
+
# 偶数索引是普通文本,需要转义
|
|
39
|
+
out += self.escape_sql_text(part)
|
|
40
|
+
else:
|
|
41
|
+
# 奇数索引是标签,原样保留
|
|
42
|
+
out += part
|
|
43
|
+
return out
|
|
44
|
+
|
|
45
|
+
def backup_file(self):
|
|
46
|
+
|
|
47
|
+
file_name = Path(self.file_path).name
|
|
48
|
+
|
|
49
|
+
file_path = Path(self.file_path)
|
|
50
|
+
|
|
51
|
+
backup_file_path = file_path.with_name(file_name + '.back')
|
|
52
|
+
|
|
53
|
+
file_path.rename(backup_file_path)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def run(self):
|
|
57
|
+
try:
|
|
58
|
+
lines = read_file_lines(self.file_path)
|
|
59
|
+
str_code = ''.join(lines)
|
|
60
|
+
remove_file_type = self.__getattribute__('file_type')
|
|
61
|
+
match remove_file_type:
|
|
62
|
+
case 'mybatis':
|
|
63
|
+
self.backup_file()
|
|
64
|
+
_split_result = self.change_mybatis_tag(str_code)
|
|
65
|
+
write_file_line(self.file_path, _split_result)
|
|
66
|
+
case _:
|
|
67
|
+
_split_result =None
|
|
68
|
+
|
|
69
|
+
except Exception as e:
|
|
70
|
+
self.logger.error(f"{__name__}異常終了. {e}")
|
|
71
|
+
return
|
|
72
|
+
|
|
73
|
+
super().run()
|
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from pilot.job.impl.base_job import BaseJob
|
|
6
|
+
|
|
7
|
+
from base.file_operation import write_file_line, write_java_files, read_json_file_lines, read_file_lines
|
|
8
|
+
from db.sql_service import delete_sql_info, insert_sql_info, select_sql_info, update_sql_info
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class DBOperationBase(BaseJob):
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def _insert_sql_file_info(file_name, file_path, file_out_path_str):
|
|
15
|
+
|
|
16
|
+
params_delete_file_info = {
|
|
17
|
+
"mapper_file_name": file_name.split('.')[0]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
delete_sql_info('delete_sql_file_info', params_delete_file_info)
|
|
21
|
+
|
|
22
|
+
params_file_info = {
|
|
23
|
+
"mapper_file_name": file_name.split('.')[0],
|
|
24
|
+
"original_file_path": file_path,
|
|
25
|
+
"no_comment_file_path": file_out_path_str
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
insert_sql_info('sql_file_info', params_file_info)
|
|
30
|
+
|
|
31
|
+
@staticmethod
|
|
32
|
+
def _insert_sql_content_info(sql_mapper_name, sql_id, sql_content):
|
|
33
|
+
|
|
34
|
+
params_delete_sql_content_info = {
|
|
35
|
+
"sql_mapper_name": sql_mapper_name,
|
|
36
|
+
"sql_id": sql_id
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
delete_sql_info('delete_sql_content_info', params_delete_sql_content_info)
|
|
40
|
+
|
|
41
|
+
params_file_info = {
|
|
42
|
+
"sql_mapper_name": sql_mapper_name,
|
|
43
|
+
"sql_id": sql_id,
|
|
44
|
+
"sql_content": sql_content
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
insert_sql_info('sql_content_info', params_file_info)
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def _update_sql_table_content_info(sql_mapper_name, sql_id, result_info):
|
|
51
|
+
sql_style = result_info.get('SQL_STYLE')
|
|
52
|
+
# SQL CONTENTテーブル情報の更新処理
|
|
53
|
+
params_info = {
|
|
54
|
+
'sql_style': sql_style,
|
|
55
|
+
'sql_mapper_name': sql_mapper_name,
|
|
56
|
+
'sql_id': sql_id
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
update_sql_info('update_sql_table_content_info', params_info)
|
|
60
|
+
|
|
61
|
+
@staticmethod
|
|
62
|
+
def _insert_sql_table_info(sql_mapper_name, sql_id, result_info):
|
|
63
|
+
sql_content = result_info.get('CONTENT')
|
|
64
|
+
|
|
65
|
+
sql_style = result_info.get('SQL_STYLE')
|
|
66
|
+
|
|
67
|
+
if sql_content:
|
|
68
|
+
|
|
69
|
+
params_delete_sql_table_info = {
|
|
70
|
+
"sql_mapper_name": sql_mapper_name,
|
|
71
|
+
"sql_id": sql_id
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
delete_sql_info('delete_sql_table_info', params_delete_sql_table_info)
|
|
75
|
+
|
|
76
|
+
if sql_style.upper() == 'DDL':
|
|
77
|
+
table_name = sql_content.get('OBJECT_NAME')
|
|
78
|
+
params_file_info = {
|
|
79
|
+
"sql_mapper_name": sql_mapper_name,
|
|
80
|
+
"sql_id": sql_id,
|
|
81
|
+
"sql_style": sql_style,
|
|
82
|
+
"mapper_file_name": sql_mapper_name + '.xml',
|
|
83
|
+
"table_name": table_name,
|
|
84
|
+
"table_alias": ''
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
insert_sql_info('sql_table_info', params_file_info)
|
|
88
|
+
|
|
89
|
+
tables_list = sql_content.get('TARGET_TABLES')
|
|
90
|
+
|
|
91
|
+
# SQLのテーブル情報の登録処理
|
|
92
|
+
if tables_list:
|
|
93
|
+
for table_info in tables_list:
|
|
94
|
+
table_name = table_info.get('TABLE_NAME')
|
|
95
|
+
table_alias = table_info.get('ALIAS')
|
|
96
|
+
params_file_info = {
|
|
97
|
+
"sql_mapper_name": sql_mapper_name,
|
|
98
|
+
"sql_id": sql_id,
|
|
99
|
+
"sql_style": sql_style,
|
|
100
|
+
"mapper_file_name": sql_mapper_name + '.xml',
|
|
101
|
+
"table_name": table_name,
|
|
102
|
+
"table_alias": table_alias
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
insert_sql_info('sql_table_info', params_file_info)
|
|
106
|
+
|
|
107
|
+
@staticmethod
|
|
108
|
+
def _insert_sql_condition_info(sql_mapper_name, sql_id, result_info):
|
|
109
|
+
|
|
110
|
+
params_delete_sql_condition_info = {
|
|
111
|
+
"sql_mapper_name": sql_mapper_name,
|
|
112
|
+
"sql_id": sql_id
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
delete_sql_info('delete_sql_condition_info', params_delete_sql_condition_info)
|
|
116
|
+
|
|
117
|
+
sql_content = result_info.get('CONTENT')
|
|
118
|
+
|
|
119
|
+
sql_style = result_info.get('SQL_STYLE')
|
|
120
|
+
|
|
121
|
+
condition_info = sql_content.get('WHERE_CLAUSE')
|
|
122
|
+
if condition_info:
|
|
123
|
+
params_condition_info = {
|
|
124
|
+
"sql_mapper_name": sql_mapper_name,
|
|
125
|
+
"sql_id": sql_id,
|
|
126
|
+
"sql_style": sql_style,
|
|
127
|
+
"mapper_file_name": sql_mapper_name + '.xml',
|
|
128
|
+
"condition_content": condition_info
|
|
129
|
+
}
|
|
130
|
+
insert_sql_info('sql_condition_info', params_condition_info)
|
|
131
|
+
|
|
132
|
+
@staticmethod
|
|
133
|
+
def _insert_sql_column_info(sql_mapper_name, sql_id, result_info):
|
|
134
|
+
|
|
135
|
+
params_delete_sql_column_info_info = {
|
|
136
|
+
"sql_mapper_name": sql_mapper_name,
|
|
137
|
+
"sql_id": sql_id
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
delete_sql_info('delete_sql_column_info_info', params_delete_sql_column_info_info)
|
|
141
|
+
|
|
142
|
+
sql_style = result_info.get('SQL_STYLE')
|
|
143
|
+
sql_content = result_info.get('CONTENT')
|
|
144
|
+
operation_type = sql_content.get('OPERATION_TYPE')
|
|
145
|
+
# SQLのカラム情報の登録処理
|
|
146
|
+
table_name_ddl = ''
|
|
147
|
+
if sql_style.upper() == 'DDL':
|
|
148
|
+
table_name = sql_content.get('OBJECT_NAME')
|
|
149
|
+
table_name_ddl = table_name
|
|
150
|
+
|
|
151
|
+
definition_details_info = sql_content.get('DEFINITION_DETAILS')
|
|
152
|
+
columns_info_list = definition_details_info.get('COLUMNS')
|
|
153
|
+
else:
|
|
154
|
+
columns_info_list = sql_content.get('COLUMNS')
|
|
155
|
+
|
|
156
|
+
if columns_info_list:
|
|
157
|
+
for column_info in columns_info_list:
|
|
158
|
+
if sql_style.upper() == 'DDL':
|
|
159
|
+
table_name = table_name_ddl
|
|
160
|
+
table_alias = ''
|
|
161
|
+
column_name = column_info.get('COLUMN_NAME')
|
|
162
|
+
column_alias = ''
|
|
163
|
+
else:
|
|
164
|
+
table_name = column_info.get('TABLE_NAME')
|
|
165
|
+
table_alias = column_info.get('TABLE_ALIAS')
|
|
166
|
+
column_name = column_info.get('COLUMN_NAME')
|
|
167
|
+
column_alias = column_info.get('COLUMN_ALIAS')
|
|
168
|
+
|
|
169
|
+
params_column_info = {
|
|
170
|
+
"sql_mapper_name": sql_mapper_name,
|
|
171
|
+
"sql_id": sql_id,
|
|
172
|
+
"sql_style": sql_style,
|
|
173
|
+
"mapper_file_name": sql_mapper_name + '.xml',
|
|
174
|
+
"table_name": table_name,
|
|
175
|
+
"table_alias": table_alias,
|
|
176
|
+
"sql_type": operation_type,
|
|
177
|
+
"column_name": column_name,
|
|
178
|
+
"column_alias": column_alias
|
|
179
|
+
}
|
|
180
|
+
insert_sql_info('sql_column_info', params_column_info)
|
|
181
|
+
|
|
182
|
+
@staticmethod
|
|
183
|
+
def _insert_sql_parameter_info(sql_mapper_name, sql_id, result_info):
|
|
184
|
+
|
|
185
|
+
params_delete_sql_parameter_info = {
|
|
186
|
+
"sql_mapper_name": sql_mapper_name,
|
|
187
|
+
"sql_id": sql_id
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
delete_sql_info('delete_sql_parameter_info', params_delete_sql_parameter_info)
|
|
191
|
+
|
|
192
|
+
sql_style = result_info.get('SQL_STYLE')
|
|
193
|
+
sql_content = result_info.get('CONTENT')
|
|
194
|
+
|
|
195
|
+
# SQLのパラメーター条件情報の登録処理
|
|
196
|
+
params_info_list = sql_content.get('PARAMETERS')
|
|
197
|
+
if params_info_list:
|
|
198
|
+
for params_info in params_info_list:
|
|
199
|
+
parameter_name = params_info.get('PARAMETER_NAME')
|
|
200
|
+
parameter_column_name = params_info.get('LINKED_ITEM')
|
|
201
|
+
parameter_table_name = params_info.get('LINKED_TABLE_NAME')
|
|
202
|
+
params_parameter_info = {
|
|
203
|
+
"sql_mapper_name": sql_mapper_name,
|
|
204
|
+
"sql_id": sql_id,
|
|
205
|
+
"sql_style": sql_style,
|
|
206
|
+
"mapper_file_name": sql_mapper_name + '.xml',
|
|
207
|
+
"parameter_name": parameter_name,
|
|
208
|
+
"parameter_column_name": parameter_column_name,
|
|
209
|
+
"parameter_table_name": parameter_table_name
|
|
210
|
+
}
|
|
211
|
+
insert_sql_info('sql_parameter_info', params_parameter_info)
|
|
212
|
+
|
|
213
|
+
@staticmethod
|
|
214
|
+
def _insert_sql_parsing_info(sql_mapper_name, sql_id, result_info, parsing_sql_file_path):
|
|
215
|
+
|
|
216
|
+
params_delete_sql_parameter_info = {
|
|
217
|
+
"sql_mapper_name": sql_mapper_name,
|
|
218
|
+
"sql_id": sql_id
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
delete_sql_info('delete_sql_parsing_info', params_delete_sql_parameter_info)
|
|
222
|
+
|
|
223
|
+
in_parameter_info = result_info.get('IN_DTO')
|
|
224
|
+
output_info = result_info.get('OUT_DTO')
|
|
225
|
+
sql_description = result_info.get('SQL_PURPOSE')
|
|
226
|
+
sql_content = result_info.get('SQL')
|
|
227
|
+
|
|
228
|
+
insert_value = {
|
|
229
|
+
'sql_mapper_name': sql_mapper_name,
|
|
230
|
+
'sql_id': sql_id,
|
|
231
|
+
'in_parameter_info': str(in_parameter_info),
|
|
232
|
+
'output_info': str(output_info),
|
|
233
|
+
'sql_description': sql_description,
|
|
234
|
+
'sql_content': sql_content,
|
|
235
|
+
'parsing_file_path': parsing_sql_file_path
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
insert_sql_info('sql_parsing_info', insert_value)
|
|
239
|
+
|
|
240
|
+
@staticmethod
|
|
241
|
+
def _update_method_info(method_all_info, class_name):
|
|
242
|
+
# パッケージ名
|
|
243
|
+
package_name = method_all_info.get('package')
|
|
244
|
+
# メソッド情報
|
|
245
|
+
methods_info = method_all_info.get('methods')
|
|
246
|
+
|
|
247
|
+
if methods_info:
|
|
248
|
+
for method_info in methods_info:
|
|
249
|
+
method_name = method_info.get('method_name')
|
|
250
|
+
return_type = method_info.get('return_type')
|
|
251
|
+
|
|
252
|
+
params_method_info = {
|
|
253
|
+
"package_name": package_name,
|
|
254
|
+
"class_name": class_name,
|
|
255
|
+
"method_name": method_name,
|
|
256
|
+
"return_type": return_type
|
|
257
|
+
}
|
|
258
|
+
update_sql_info('update_method_info', params_method_info)
|
|
259
|
+
|
|
260
|
+
@staticmethod
|
|
261
|
+
def _insert_method_parameter_info(method_all_info, class_name):
|
|
262
|
+
# パッケージ名
|
|
263
|
+
package_name = method_all_info.get('package')
|
|
264
|
+
# メソッド情報
|
|
265
|
+
methods_info = method_all_info.get('methods')
|
|
266
|
+
if methods_info:
|
|
267
|
+
for method_info in methods_info:
|
|
268
|
+
parameters_info = method_info.get('parameters')
|
|
269
|
+
method_name = method_info.get('method_name')
|
|
270
|
+
if parameters_info:
|
|
271
|
+
|
|
272
|
+
params_delete_parameter_info = {
|
|
273
|
+
"package_name": package_name,
|
|
274
|
+
"class_name": class_name,
|
|
275
|
+
"method_name": method_name
|
|
276
|
+
}
|
|
277
|
+
delete_sql_info('delete_method_parameter_info', params_delete_parameter_info)
|
|
278
|
+
for parameter_info in parameters_info:
|
|
279
|
+
parameter_type = parameter_info.get('parameter_type')
|
|
280
|
+
parameter_name = parameter_info.get('parameter_name')
|
|
281
|
+
|
|
282
|
+
params_parameter_info = {
|
|
283
|
+
"package_name": package_name,
|
|
284
|
+
"class_name": class_name,
|
|
285
|
+
"method_name": method_name,
|
|
286
|
+
"parameter_type": parameter_type,
|
|
287
|
+
"parameter_name": parameter_name
|
|
288
|
+
}
|
|
289
|
+
insert_sql_info('method_parameter_info', params_parameter_info)
|
|
290
|
+
|
|
291
|
+
@staticmethod
|
|
292
|
+
def _insert_method_sub_method_info(method_all_info, class_name):
|
|
293
|
+
# パッケージ名
|
|
294
|
+
package_name = method_all_info.get('package')
|
|
295
|
+
# メソッド情報
|
|
296
|
+
methods_info = method_all_info.get('methods')
|
|
297
|
+
|
|
298
|
+
if methods_info:
|
|
299
|
+
for method_info in methods_info:
|
|
300
|
+
method_name = method_info.get('method_name')
|
|
301
|
+
sub_method_calls = method_info.get('sub_method_calls')
|
|
302
|
+
|
|
303
|
+
if sub_method_calls:
|
|
304
|
+
params_delete_sub_method_calls_info = {
|
|
305
|
+
"package_name": package_name,
|
|
306
|
+
"class_name": class_name,
|
|
307
|
+
"method_name": method_name
|
|
308
|
+
}
|
|
309
|
+
delete_sql_info('delete_method_sub_method_info', params_delete_sub_method_calls_info)
|
|
310
|
+
|
|
311
|
+
for sub_method_call in sub_method_calls:
|
|
312
|
+
sub_method_name = sub_method_call.get('sub_method_name')
|
|
313
|
+
called_method_full_signature = sub_method_call.get('called_method_full_signature')
|
|
314
|
+
called_method_class = sub_method_call.get('called_method_class')
|
|
315
|
+
called_method_class_package = sub_method_call.get('called_method_class_package')
|
|
316
|
+
|
|
317
|
+
params_sub_method_calls_info = {
|
|
318
|
+
"package_name": package_name,
|
|
319
|
+
"class_name": class_name,
|
|
320
|
+
"method_name": method_name,
|
|
321
|
+
"sub_method_name": sub_method_name,
|
|
322
|
+
"called_method_full_signature": called_method_full_signature,
|
|
323
|
+
"called_method_class": called_method_class,
|
|
324
|
+
"called_method_class_package": called_method_class_package
|
|
325
|
+
}
|
|
326
|
+
insert_sql_info('sub_method_info', params_sub_method_calls_info)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
@staticmethod
|
|
331
|
+
def _insert_method_info(file_info_list):
|
|
332
|
+
|
|
333
|
+
if file_info_list:
|
|
334
|
+
for file_info in file_info_list:
|
|
335
|
+
file_name = file_info.get('fileName')
|
|
336
|
+
class_name = file_info.get('className')
|
|
337
|
+
method_name = file_info.get('methodName')
|
|
338
|
+
package_name = file_info.get('package')
|
|
339
|
+
method_code = file_info.get('code')
|
|
340
|
+
remaining_class_code = file_info.get('remainingClassCode')
|
|
341
|
+
|
|
342
|
+
params_delete_method_info = {
|
|
343
|
+
"package_name": package_name,
|
|
344
|
+
"class_name": class_name,
|
|
345
|
+
"method_name": method_name
|
|
346
|
+
}
|
|
347
|
+
delete_sql_info('delete_method_info', params_delete_method_info)
|
|
348
|
+
|
|
349
|
+
params_method_info = {
|
|
350
|
+
"package_name": package_name,
|
|
351
|
+
"class_name": class_name,
|
|
352
|
+
"file_name": file_name,
|
|
353
|
+
"method_name": method_name,
|
|
354
|
+
"full_method_signature": method_code,
|
|
355
|
+
"return_type": '',
|
|
356
|
+
"remaining_class_code": remaining_class_code
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
insert_sql_info('method_info', params_method_info)
|
|
360
|
+
|
|
361
|
+
@staticmethod
|
|
362
|
+
def _insert_method_file_info(package_info, class_name, file_name, file_path):
|
|
363
|
+
|
|
364
|
+
full_class_name = package_info + '.' + class_name
|
|
365
|
+
|
|
366
|
+
params_delete_method_file_info = {
|
|
367
|
+
"package_name": package_info,
|
|
368
|
+
"class_name": class_name
|
|
369
|
+
}
|
|
370
|
+
delete_sql_info('delete_method_file_info', params_delete_method_file_info)
|
|
371
|
+
|
|
372
|
+
# クラス情報
|
|
373
|
+
params_method_file_info = {
|
|
374
|
+
"package_name": package_info,
|
|
375
|
+
"class_name": class_name,
|
|
376
|
+
"file_name": file_name,
|
|
377
|
+
"original_file_path": full_class_name,
|
|
378
|
+
"no_comment_file_path": file_path
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
insert_sql_info('method_file_info', params_method_file_info)
|
|
382
|
+
|
|
383
|
+
@staticmethod
|
|
384
|
+
def _insert_method_class_info(imports_info, package_info, class_name, file_name):
|
|
385
|
+
full_class_name = package_info + '.' + class_name
|
|
386
|
+
|
|
387
|
+
# クラスのimport情報
|
|
388
|
+
if imports_info:
|
|
389
|
+
params_delete_method_class_info = {
|
|
390
|
+
"package_name": package_info,
|
|
391
|
+
"class_name": class_name
|
|
392
|
+
}
|
|
393
|
+
delete_sql_info('delete_method_class_info', params_delete_method_class_info)
|
|
394
|
+
|
|
395
|
+
for import_info in imports_info:
|
|
396
|
+
params_method_class_info = {
|
|
397
|
+
"package_name": package_info,
|
|
398
|
+
"class_name": class_name,
|
|
399
|
+
"file_name": file_name,
|
|
400
|
+
"class_type": '',
|
|
401
|
+
'full_class_name': full_class_name,
|
|
402
|
+
"import_object_name": import_info
|
|
403
|
+
}
|
|
404
|
+
insert_sql_info('method_class_info', params_method_class_info)
|
|
405
|
+
|
|
406
|
+
def create_sub_file(self, file_info_list):
|
|
407
|
+
|
|
408
|
+
output_folder = self.__getattribute__('output_folder')
|
|
409
|
+
|
|
410
|
+
sub_file_path =[]
|
|
411
|
+
if file_info_list:
|
|
412
|
+
for file_info in file_info_list:
|
|
413
|
+
file_name = file_info.get('fileName')
|
|
414
|
+
class_name = file_info.get('className')
|
|
415
|
+
package_name = file_info.get('package')
|
|
416
|
+
method_code = file_info.get('code')
|
|
417
|
+
|
|
418
|
+
# クラス別のimport情報ファイルを作成する
|
|
419
|
+
import_file_path = os.path.join(str(output_folder), class_name + '.json')
|
|
420
|
+
package_info_path = os.path.join(str(output_folder), class_name + '_package.json')
|
|
421
|
+
|
|
422
|
+
write_file_line(package_info_path, package_name)
|
|
423
|
+
self.copy_input_file_to_next_step(package_info_path)
|
|
424
|
+
|
|
425
|
+
if not os.path.exists(import_file_path):
|
|
426
|
+
params_method_class_info = {
|
|
427
|
+
"package_name": package_name,
|
|
428
|
+
"class_name": class_name
|
|
429
|
+
}
|
|
430
|
+
method_class_info_result = select_sql_info('method_class_info', params_method_class_info)
|
|
431
|
+
method_class_info_list = []
|
|
432
|
+
if method_class_info_result:
|
|
433
|
+
for method_class_info in method_class_info_result:
|
|
434
|
+
import_info = method_class_info.get('IMPORT_OBJECT_NAME')
|
|
435
|
+
method_class_info_list.append(import_info)
|
|
436
|
+
|
|
437
|
+
str_method_class_info = '\n'.join(method_class_info_list)
|
|
438
|
+
|
|
439
|
+
write_file_line(import_file_path, str_method_class_info)
|
|
440
|
+
self.copy_input_file_to_next_step(import_file_path)
|
|
441
|
+
|
|
442
|
+
file_path = os.path.join(str(output_folder), file_name)
|
|
443
|
+
write_java_files(Path(file_path), method_code)
|
|
444
|
+
sub_file_path.append(file_path)
|
|
445
|
+
return sub_file_path
|
|
446
|
+
|
|
447
|
+
def run(self):
|
|
448
|
+
try:
|
|
449
|
+
|
|
450
|
+
file_name = Path(self.file_path).name
|
|
451
|
+
|
|
452
|
+
class_name = file_name.split('.')[0]
|
|
453
|
+
|
|
454
|
+
db_operation_type = self.__getattribute__('db_operation_type')
|
|
455
|
+
|
|
456
|
+
match db_operation_type:
|
|
457
|
+
case 'method_base':
|
|
458
|
+
package_info, imports_info = self.extract()
|
|
459
|
+
self._insert_method_file_info(package_info, class_name, file_name, self.file_path)
|
|
460
|
+
self._insert_method_class_info(imports_info, package_info, class_name, file_name)
|
|
461
|
+
case 'method_info':
|
|
462
|
+
_file_info = read_json_file_lines(self.file_path)
|
|
463
|
+
file_info_list = _file_info.get('files')
|
|
464
|
+
self._insert_method_info(file_info_list)
|
|
465
|
+
sub_file_path = self.create_sub_file(file_info_list)
|
|
466
|
+
setattr(self, 'sub_file_path', sub_file_path)
|
|
467
|
+
case 'sub_method_info':
|
|
468
|
+
method_all_info = self.__getattribute__('method_all_info')
|
|
469
|
+
# メソッド情報の取得する
|
|
470
|
+
# クラス名
|
|
471
|
+
class_name = str(Path(Path(self.file_path).parent).name)
|
|
472
|
+
|
|
473
|
+
self._update_method_info(method_all_info, class_name)
|
|
474
|
+
|
|
475
|
+
self._insert_method_parameter_info(method_all_info, class_name)
|
|
476
|
+
|
|
477
|
+
self._insert_method_sub_method_info(method_all_info, class_name)
|
|
478
|
+
|
|
479
|
+
case 'sql_base':
|
|
480
|
+
|
|
481
|
+
sql_content_list = read_file_lines(self.file_path)
|
|
482
|
+
sql_content = ''.join(sql_content_list)
|
|
483
|
+
sql_mapper_name = Path(Path(self.file_path).parent).name
|
|
484
|
+
sql_id = file_name.split('.')[0]
|
|
485
|
+
# SQLの基本情報の登録する
|
|
486
|
+
self._insert_sql_content_info(sql_mapper_name, sql_id, sql_content)
|
|
487
|
+
|
|
488
|
+
case 'sub_sql_info':
|
|
489
|
+
|
|
490
|
+
sql_mapper_name = Path(Path(self.file_path).parent).name
|
|
491
|
+
sql_id = file_name.split('.')[0]
|
|
492
|
+
all_sql_info = self.__getattribute__('all_sql_info')
|
|
493
|
+
# SQL基本情報の更新処理
|
|
494
|
+
self._update_sql_table_content_info(sql_mapper_name, sql_id, all_sql_info)
|
|
495
|
+
# SQL用テーブル情報の登録する
|
|
496
|
+
self._insert_sql_table_info(sql_mapper_name, sql_id, all_sql_info)
|
|
497
|
+
# SQLの条件情報の登録する
|
|
498
|
+
self._insert_sql_condition_info(sql_mapper_name, sql_id, all_sql_info)
|
|
499
|
+
# SQLの条件項目情報の登録する
|
|
500
|
+
self._insert_sql_column_info(sql_mapper_name, sql_id, all_sql_info)
|
|
501
|
+
|
|
502
|
+
case 'parsing_sql':
|
|
503
|
+
# DB登録する
|
|
504
|
+
sql_mapper_name = Path(Path(self.file_path).parent).name
|
|
505
|
+
sql_id = file_name.split('.')[0]
|
|
506
|
+
parsing_result_info = self.__getattribute__('parsing_result_info')
|
|
507
|
+
|
|
508
|
+
# SQLの条件項目情報の登録する
|
|
509
|
+
self._insert_sql_parsing_info(sql_mapper_name, sql_id, parsing_result_info, self.file_path)
|
|
510
|
+
|
|
511
|
+
case _:
|
|
512
|
+
del_comment_code =''
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
except Exception as e:
|
|
516
|
+
self.logger.error(f"{__name__}異常終了. {e}")
|
|
517
|
+
return
|
|
518
|
+
|
|
519
|
+
super().run()
|
|
520
|
+
|
|
521
|
+
def extract(self):
|
|
522
|
+
|
|
523
|
+
package_re = re.compile(r'^\s*package\s+([\w.]+)\s*;', re.MULTILINE)
|
|
524
|
+
import_re = re.compile(r'^\s*import\s+([^\s;]+)\s*;(.*)', re.MULTILINE)
|
|
525
|
+
|
|
526
|
+
file_path = Path(self.file_path)
|
|
527
|
+
src = file_path.read_text(encoding='utf-8')
|
|
528
|
+
|
|
529
|
+
pkg_match = package_re.search(src)
|
|
530
|
+
package_name = pkg_match.group(1) if pkg_match else '(default)'
|
|
531
|
+
|
|
532
|
+
imports = [m.group(1).strip() for m in import_re.finditer(src)]
|
|
533
|
+
|
|
534
|
+
return package_name, imports
|
|
535
|
+
|
|
536
|
+
|