Skip to content

Commit edf9031

Browse files
committed
Remove propRepo dependency in HistoryMenuController
1 parent b70e5c0 commit edf9031

File tree

3 files changed

+26
-86
lines changed

3 files changed

+26
-86
lines changed

src/main/java/root/javafx/Controller/HistoryMenuController.java

Lines changed: 24 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import java.util.Map;
88
import java.util.ResourceBundle;
99

10-
import org.apache.commons.configuration2.PropertiesConfiguration;
11-
1210
import com.jfoenix.controls.JFXComboBox;
1311
import com.jfoenix.controls.JFXListView;
1412

@@ -22,8 +20,6 @@
2220
import root.common.server.implement.JschServer;
2321
import root.core.domain.ASMDiskUsage;
2422
import root.core.domain.AlertLog;
25-
import root.core.domain.AlertLogCommand;
26-
import root.core.domain.AlertLogCommandPeriod;
2723
import root.core.domain.ArchiveUsage;
2824
import root.core.domain.JdbcConnectionInfo;
2925
import root.core.domain.JschConnectionInfo;
@@ -32,8 +28,6 @@
3228
import root.core.domain.OSDiskUsage;
3329
import root.core.domain.TableSpaceUsage;
3430
import root.core.repository.constracts.DBCheckRepository;
35-
import root.core.repository.constracts.PropertyRepository;
36-
import root.core.repository.constracts.ReportRepository;
3731
import root.core.repository.constracts.ServerCheckRepository;
3832
import root.core.repository.implement.DBCheckRepositoryImpl;
3933
import root.core.repository.implement.PropertyRepositoryImpl;
@@ -52,31 +46,33 @@
5246
public class HistoryMenuController implements Initializable {
5347

5448
/* Dependency Injection */
55-
PropertyRepository propRepo = PropertyRepositoryImpl.getInstance();
56-
ReportRepository reportRepository = ReportFileRepo.getInstance();
57-
PropertyService propService = new FilePropertyService(propRepo);
49+
PropertyService propService = new FilePropertyService(PropertyRepositoryImpl.getInstance());
5850

5951
/* View Binding */
6052
@FXML
6153
JFXComboBox<String> runConnInfoFileComboBox;
62-
@FXML
63-
JFXComboBox<String> runMonitoringPresetComboBox;
54+
6455
@FXML
6556
JFXComboBox<String> alertLogServerComboBox;
6657

6758
@FXML
6859
DatePicker alertLogStartDayDP;
60+
6961
@FXML
7062
DatePicker alertLogEndDayDP;
7163

7264
@FXML
7365
AnchorPane archiveUsageTabAP;
66+
7467
@FXML
7568
AnchorPane tableSpaceUsageTabAP;
69+
7670
@FXML
7771
AnchorPane asmDiskUsageTabAP;
72+
7873
@FXML
7974
AnchorPane osDiskUsageTabAP;
75+
8076
@FXML
8177
AnchorPane alertLogUsageTabAP;
8278

@@ -90,14 +86,6 @@ public class HistoryMenuController implements Initializable {
9086
MonitoringAPController<OSDiskUsage> osDiskUsageMAP;
9187
Map<String, AlertLog> alertLogMonitoringResultMap;
9288

93-
/* Common Data */
94-
String lastUseConnInfoFilePath = null;
95-
String lastUseMonitoringPresetName = null;
96-
String[] dbNames = null;
97-
String[] serverNames = null;
98-
String[] connInfoFiles = null;
99-
List<String> presetList = null;
100-
10189
public HistoryMenuController() {
10290
archiveUsageMAP = new MonitoringAPController<>(ArchiveUsage.class);
10391
tableSpaceUsageMAP = new MonitoringAPController<>(TableSpaceUsage.class);
@@ -111,26 +99,18 @@ public HistoryMenuController() {
11199
*/
112100
@Override
113101
public void initialize(URL location, ResourceBundle resources) {
114-
/*
115-
* 1. 접속정보 프로퍼티 파일 ComboBox를 설정한다.
116-
* 2. 접속정보 프로퍼티 파일 유무를 확인한다.
117-
* 2-1. 있으면 [3]으로 이동
118-
* 2-2. 한개도 없으면 설정 메뉴로 이동하여 접속정보를 설정하도록 한다. [END]
119-
* 3. 최근 사용한 접속정보 프로퍼티 파일이 있는지 확인한다.
120-
* 3-1. 있으면 해당 파일을 Load한다.
121-
* 3-2. 없으면 첫 번째 파일을 Load한다.
122-
*/
102+
123103
// 접속정보 설정 프로퍼티 파일
124-
connInfoFiles = propRepo.getConnectionInfoFileNames();
125-
if (connInfoFiles != null && connInfoFiles.length != 0) {
104+
List<String> connInfoFiles = propService.getConnectionInfoList();
105+
if (connInfoFiles != null && connInfoFiles.size() != 0) {
126106
// Connection Info ComboBox
127107
runConnInfoFileComboBox.getItems().addAll(connInfoFiles);
128108
runConnInfoFileComboBox.getSelectionModel().selectFirst();
109+
129110
// remember.properties 파일에서, 최근 사용된 설정파일 경로가 있다면 해당 설정파일을 불러온다.
130-
lastUseConnInfoFilePath = propRepo.getLastUseConnInfoFilePath();
131-
if (propRepo.isFileExist(lastUseConnInfoFilePath)) {
111+
String lastUseConnInfoFilePath = propService.getLastUseConnectionInfoFilePath();
112+
if (lastUseConnInfoFilePath != null) {
132113
runConnInfoFileComboBox.getSelectionModel().select(lastUseConnInfoFilePath);
133-
loadConnectionInfoProperties(lastUseConnInfoFilePath);
134114
}
135115
} else {
136116
AlertUtils.showAlert(AlertType.INFORMATION, "접속정보 설정", "설정된 DB/Server 접속정보가 없습니다.\n[설정]메뉴로 이동합니다.");
@@ -140,23 +120,19 @@ public void initialize(URL location, ResourceBundle resources) {
140120
// ComboBox 변경 이벤트
141121
runConnInfoFileComboBox.getSelectionModel().selectedItemProperty()
142122
.addListener((options, oldValue, newValue) -> {
143-
loadConnectionInfoProperties(newValue);
123+
// TODO 각 Tab별 콤보박스 아이템 변경
144124
});
145125

146126
String dbComboBoxLabel = "DB 선택";
147-
String[] dbComboBoxItems = dbNames;
127+
List<String> dbComboBoxItems = propService.getMonitoringDBNameList();
148128
String serverComboBoxLabel = "Server 선택";
149-
String[] serverComboBoxItems = serverNames;
129+
List<String> serverComboBoxItems = propService.getMonitoringServerNameList();
150130

151-
// Archive Usage TableView Setting
152131
initAndAddMonitoringAnchorPane(archiveUsageMAP, archiveUsageTabAP, dbComboBoxLabel, dbComboBoxItems);
153132
initAndAddMonitoringAnchorPane(tableSpaceUsageMAP, tableSpaceUsageTabAP, dbComboBoxLabel, dbComboBoxItems);
154133
initAndAddMonitoringAnchorPane(asmDiskUsageMAP, asmDiskUsageTabAP, dbComboBoxLabel, dbComboBoxItems);
155134
initAndAddMonitoringAnchorPane(osDiskUsageMAP, osDiskUsageTabAP, serverComboBoxLabel, serverComboBoxItems);
156135

157-
// TODO TableColumn 속성을 설정하는 메서드를 따로 구분해보자. 객체를 생성해서 전달하는 방법도 고려하기
158-
// ex) TableColumnHeaderText, Width, Align
159-
160136
// AlertLog 화면의 UI 요소를 초기화한다.
161137
initAlertLogMonitoringElements();
162138
}
@@ -172,7 +148,7 @@ public void initialize(URL location, ResourceBundle resources) {
172148
* @param tableColumns
173149
*/
174150
private <T extends MonitoringResult> void initAndAddMonitoringAnchorPane(MonitoringAPController<T> monitoringAP,
175-
AnchorPane parentAP, String labelText, String[] comboBoxItems) {
151+
AnchorPane parentAP, String labelText, List<String> comboBoxItems) {
176152

177153
monitoringAP.setAliasComboBoxLabelText(labelText); // ComboBox 좌측 Lebel Text 설정
178154
monitoringAP.setAliasComboBoxItems(comboBoxItems); // ComboBox Items 설정
@@ -195,7 +171,7 @@ private void initAlertLogMonitoringElements() {
195171
alertLogServerComboBox.getSelectionModel().selectedItemProperty().addListener((options, oldValue, newValue) -> {
196172
changeAlertLogListViewData(newValue);
197173
});
198-
alertLogServerComboBox.getItems().addAll(serverNames);
174+
alertLogServerComboBox.getItems().addAll(propService.getMonitoringServerNameList());
199175
alertLogServerComboBox.getSelectionModel().selectFirst();
200176

201177
// AlertLog 조회기간 기본값 설정
@@ -222,49 +198,25 @@ private void initAlertLogMonitoringElements() {
222198
alertLogLV.setCellFactory(categoryList -> new AlertLogListViewCell());
223199
}
224200

225-
/**
226-
* [실행] - 접속정보 설정파일을 읽고, 모니터링설정 Preset을 읽는다.
227-
*
228-
* @param connInfoConfigFilePath
229-
*/
230-
private void loadConnectionInfoProperties(String connInfoConfigFilePath) {
231-
// 접속정보 프로퍼티 파일 Load
232-
propRepo.loadConnectionInfoConfig(connInfoConfigFilePath);
233-
// 모니터링여부 설정 Preset
234-
presetList = propRepo.getMonitoringPresetNameList();
235-
lastUseMonitoringPresetName = propRepo.getLastUseMonitoringPresetName();
236-
// DB/Server Names
237-
dbNames = propRepo.getMonitoringDBNames();
238-
serverNames = propRepo.getMonitoringServerNames();
239-
// Monitoring Preset ComboBox
240-
runMonitoringPresetComboBox.getItems().clear();
241-
runMonitoringPresetComboBox.getItems().addAll(presetList);
242-
runMonitoringPresetComboBox.getSelectionModel().selectFirst();
243-
if (lastUseMonitoringPresetName != null) {
244-
runMonitoringPresetComboBox.getSelectionModel().select(lastUseMonitoringPresetName);
245-
}
246-
}
247-
248201
/**
249202
* [실행] - 모니터링을 시작한다.
250203
*
251204
* @param e
252205
*/
206+
@SuppressWarnings("unused")
253207
public void runMonitoring(ActionEvent e) {
254208
if (!validateInput()) {
255209
return;
256210
}
257-
258211

259212
// DB Usage Check
260213
List<JdbcConnectionInfo> jdbcConnectionList = propService
261214
.getJdbcConnInfoList(propService.getMonitoringDBNameList());
262215
for (JdbcConnectionInfo jdbc : jdbcConnectionList) {
263-
System.out.println("■ [ " + jdbc.getJdbcDBName() + " Monitoring Start ]\n");
264216
JdbcDatabase db = new JdbcDatabase(jdbc);
265217
db.init();
266218
DBCheckRepository repo = new DBCheckRepositoryImpl(db);
267-
DBCheckUsecase usecase = new DBCheckUsecaseImpl(repo, reportRepository);
219+
DBCheckUsecase usecase = new DBCheckUsecaseImpl(repo, ReportFileRepo.getInstance());
268220
archiveUsageMAP.addTableData(jdbc.getJdbcDBName(), usecase.getCurrentArchiveUsage());
269221
tableSpaceUsageMAP.addTableData(jdbc.getJdbcDBName(), usecase.getCurrentTableSpaceUsage());
270222
asmDiskUsageMAP.addTableData(jdbc.getJdbcDBName(), usecase.getCurrentASMDiskUsage());
@@ -276,27 +228,16 @@ public void runMonitoring(ActionEvent e) {
276228
List<JschConnectionInfo> jschConnectionList = propService
277229
.getJschConnInfoList(propService.getMonitoringServerNameList());
278230
for (JschConnectionInfo jsch : jschConnectionList) {
279-
System.out.println("■ [ " + jsch.getServerName() + " Monitoring Start ]\n");
280231
JschServer server = new JschServer(jsch);
281232
server.init();
282233
ServerCheckRepository repo = new ServerCheckRepositoryImpl(server);
283234
ServerCheckUsecase usecase = new ServerCheckUsecaseImpl(repo, ReportFileRepo.getInstance());
284235

285-
PropertiesConfiguration config = propRepo.getConfiguration("connInfoConfig");
286-
String alertLogFilePath = config
287-
.getString(jsch.getServerName().toLowerCase() + ".server.alertlog.filepath");
288-
String alertLogReadLine = config
289-
.getString(jsch.getServerName().toLowerCase() + ".server.alertlog.readline");
290-
String alertLogDateFormat = config
291-
.getString(jsch.getServerName().toLowerCase() + ".server.alertlog.dateformat");
292-
String alertLogDateFormatRegex = config
293-
.getString(jsch.getServerName().toLowerCase() + ".server.alertlog.dateformatregex");
294-
AlertLogCommand alc = new AlertLogCommand("tail", alertLogReadLine, alertLogFilePath, alertLogDateFormat,
295-
alertLogDateFormatRegex);
296-
AlertLogCommandPeriod alcp = new AlertLogCommandPeriod(alc, alertLogStartDay, alertLogEndDay);
297-
298236
osDiskUsageMAP.addTableData(server.getServerName(), usecase.getCurrentOSDiskUsage());
299-
alertLogMonitoringResultMap.put(server.getServerName(), usecase.getAlertLogDuringPeriod(alcp));
237+
238+
// TODO AlertLog 조회
239+
// alertLogMonitoringResultMap.put(server.getServerName(),
240+
// usecase.getAlertLogDuringPeriod(alcp));
300241
}
301242

302243
archiveUsageMAP.syncTableData(archiveUsageMAP.getSelectedAliasComboBoxItem(), 0);

src/main/java/root/javafx/Controller/MonitoringAPController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public void setAliasComboBoxLabelText(String text) {
354354
this.label.setText(text);
355355
}
356356

357-
public void setAliasComboBoxItems(String[] items) {
357+
public void setAliasComboBoxItems(List<String> items) {
358358
this.aliasComboBox.getItems().addAll(items);
359359
this.aliasComboBox.getSelectionModel().selectFirst();
360360
}

src/main/resources/fxml/HistoryMenu.fxml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@
5454
</Label>
5555
<AnchorPane layoutX="217.0" layoutY="5.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="250.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
5656
<children>
57-
<JFXComboBox fx:id="runConnInfoFileComboBox" minWidth="300.0" styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="280.0" AnchorPane.topAnchor="5.0" />
58-
<JFXComboBox fx:id="runMonitoringPresetComboBox" layoutX="330.8000183105469" minWidth="200.0" styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="60.0" AnchorPane.topAnchor="5.0" />
57+
<JFXComboBox fx:id="runConnInfoFileComboBox" minWidth="300.0" styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="60.0" AnchorPane.topAnchor="5.0" />
5958
<Button fx:id="monitoringRunBtn" layoutX="540.6000061035156" mnemonicParsing="false" onAction="#runMonitoring" style="-fx-background-color: transparent;" AnchorPane.bottomAnchor="5.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="5.0">
6059
<cursor>
6160
<Cursor fx:constant="HAND" />

0 commit comments

Comments
 (0)