Skip to content

Commit 9246c08

Browse files
committed
Implements Monitoring Execution Step2: Set monitoring preset file and preview
1 parent f7a3d9b commit 9246c08

File tree

6 files changed

+129
-48
lines changed

6 files changed

+129
-48
lines changed

src/main/java/root/core/repository/constracts/PropertyRepository.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public interface PropertyRepository {
5151

5252
String getLastUseMonitoringPresetName();
5353

54+
String getLastUseMonitoringPresetName(String filePath);
55+
5456
String[] getMonitoringDBNames();
5557

5658
String[] getMonitoringServerNames();
@@ -64,4 +66,6 @@ public interface PropertyRepository {
6466
JschConnectionInfo getJschConnectionInfo(String serverName);
6567

6668
AlertLogCommand getAlertLogCommand(String serverName);
69+
70+
String getMonitoringConfigResource(String key);
6771
}

src/main/java/root/core/repository/implement/PropertyRepositoryImpl.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,17 @@ public Map<String, String> getMonitoringPresetMap() {
424424
public String getLastUseMonitoringPresetName() {
425425
return connInfoConfig.subset("monitoring.setting.preset.lastuse").getString("");
426426
}
427+
428+
/**
429+
* 최근 사용한 Monitoring Preset 이름을 반환한다. 단, 최근 사용한 Preset이 없을 때, NULL을 반환한다.
430+
*
431+
* @return
432+
*/
433+
@Override
434+
public String getLastUseMonitoringPresetName(String filePath) {
435+
load(filePath);
436+
return connInfoConfig.subset("monitoring.setting.preset.lastuse").getString("");
437+
}
427438

428439
/**
429440
* 모니터링할 DB명 배열을 반환한다.
@@ -535,4 +546,9 @@ public AlertLogCommand getAlertLogCommand(String serverName) {
535546
alertLogDateFormatRegex);
536547
return alc;
537548
}
549+
550+
@Override
551+
public String getMonitoringConfigResource(String key) {
552+
return monitoringConfig.getString(key);
553+
}
538554
}

src/main/java/root/core/service/contracts/PropertyService.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,40 @@
88

99
public interface PropertyService {
1010

11+
/**
12+
* 접속정보 설정파일을 Load 한다.
13+
*
14+
* @param filePath
15+
*/
16+
void loadConnectionInfoConfig(String filePath);
17+
1118
/**
1219
* 모니터링 접속정보 설정파일의 경로를 반환한다.
1320
*
1421
* @return
1522
*/
1623
List<String> getConnectionInfoList();
17-
24+
1825
/**
19-
* 최근 사용된 접속정보 설정파일을 경로를 반환한다.
26+
* 최근 사용된 접속정보 설정파일의 경로를 반환한다.
2027
*
2128
* @return
2229
*/
23-
String getLastUseConnectionInfo();
30+
String getLastUseConnectionInfoFilePath();
31+
32+
/**
33+
* 모니터링 여부 설정파일을 Load 한다.
34+
*
35+
* @param filePath
36+
*/
37+
void loadMonitoringInfoConfig(String filePath);
2438

25-
void loadConnectionInfoConfig(String filePath);
39+
/**
40+
* 최근 사용된 모니터링 여부 Preset 설정파일의 Preset명을 반환한다.
41+
*
42+
* @return
43+
*/
44+
String getLastUsePresetFileName(String filePath);
2645

2746
Map<String, String> getMonitoringPresetMap();
2847

@@ -31,11 +50,11 @@ public interface PropertyService {
3150
List<String> getMonitoringPresetNameList();
3251

3352
String getMonitoringPresetFilePath(String presetName);
34-
53+
3554
List<String> getMonitoringDBNameList();
3655

3756
List<String> getMonitoringServerNameList();
38-
57+
3958
List<JdbcConnectionInfo> getJdbcConnInfoList(List<String> dbNames);
4059

4160
List<JschConnectionInfo> getJschConnInfoList(List<String> serverNames);

src/main/java/root/core/service/implement/FilePropertyService.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,41 @@ public FilePropertyService(PropertyRepository propRepo) {
2727
this.propRepo = propRepo;
2828
}
2929

30+
/**
31+
* 접속정보 설정파일을 Load 한다.
32+
*/
33+
@Override
34+
public void loadConnectionInfoConfig(String filePath) {
35+
propRepo.loadConnectionInfoConfig(filePath);
36+
}
37+
3038
/**
3139
* ./config/connectioninfo/ 디렉터리 하위에 있는 접속정보 설정파일 리스트를 반환한다.
3240
*/
3341
@Override
3442
public List<String> getConnectionInfoList() {
3543
return new ArrayList<>(Arrays.asList(propRepo.getConnectionInfoFileNames()));
3644
}
37-
45+
3846
/**
3947
* 최근 사용된 접속정보 설정파일 경로를 반환한다.
4048
*/
4149
@Override
42-
public String getLastUseConnectionInfo() {
50+
public String getLastUseConnectionInfoFilePath() {
4351
return propRepo.getLastUseConnInfoFilePath();
4452
}
4553

4654
/**
47-
* 접속정보 설정파일을 Load 한다.
55+
* 모니터링 여부 설정파일을 Load 한다.
4856
*/
4957
@Override
50-
public void loadConnectionInfoConfig(String filePath) {
51-
propRepo.loadConnectionInfoConfig(filePath);
58+
public void loadMonitoringInfoConfig(String filePath) {
59+
propRepo.loadMonitoringInfoConfig(filePath);
60+
}
61+
62+
@Override
63+
public String getLastUsePresetFileName(String filePath) {
64+
return propRepo.getLastUseMonitoringPresetName(filePath);
5265
}
5366

5467
@Override
@@ -59,7 +72,7 @@ public Map<String, String> getMonitoringPresetMap() {
5972
.filter(key -> key.matches(MONITORING_PRESET_KEY)).collect(Collectors.toUnmodifiableMap(key -> {
6073
Matcher m = MONITORING_PRESET_KEY_PATTERN.matcher(key);
6174
return m.matches() ? m.group(1) : null;
62-
}, key -> key));
75+
}, key -> propRepo.getMonitoringConfigResource(key)));
6376
}
6477

6578
@Override

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

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package root.javafx.Controller;
22

33
import java.net.URL;
4-
import java.sql.SQLException;
54
import java.util.ArrayList;
65
import java.util.List;
76
import java.util.ResourceBundle;
@@ -12,8 +11,6 @@
1211
import com.jfoenix.controls.JFXComboBox;
1312

1413
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
15-
import javafx.beans.value.ChangeListener;
16-
import javafx.beans.value.ObservableValue;
1714
import javafx.fxml.FXML;
1815
import javafx.fxml.Initializable;
1916
import javafx.scene.Node;
@@ -50,6 +47,9 @@ public class RunMenuController implements Initializable {
5047
@FXML
5148
AnchorPane presetSettingAP;
5249

50+
@FXML
51+
JFXComboBox<String> presetFileListComboBox;
52+
5353
@FXML
5454
AnchorPane dbPresetAP;
5555

@@ -95,7 +95,7 @@ public void initialize(URL location, ResourceBundle resources) {
9595
} else {
9696
connInfoFileListComboBox.getItems().addAll(connInfoFileList);
9797
}
98-
98+
9999
// 1-2. 모니터링 접속정보 설정파일 콤보박스 아이템 변경 리스너 설정
100100
connInfoFileListComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
101101
propService.loadConnectionInfoConfig(newValue);
@@ -105,42 +105,43 @@ public void initialize(URL location, ResourceBundle resources) {
105105
});
106106

107107
// 1-3. 모니터링 접속정보 설정파일 콤보박스 초기값 설정
108-
String lastUseConnInfoFile = propService.getLastUseConnectionInfo();
108+
String lastUseConnInfoFile = propService.getLastUseConnectionInfoFilePath();
109109
if (StringUtils.isEmpty(lastUseConnInfoFile) || !connInfoFileList.contains(lastUseConnInfoFile)) {
110110
// 최근 사용된 접속정보 설정파일이 없거나 현재 존재하지 않는 경우, 첫 번째 설정파일 선택
111111
connInfoFileListComboBox.getSelectionModel().selectFirst();
112112
} else {
113113
connInfoFileListComboBox.getSelectionModel().select(lastUseConnInfoFile);
114114
}
115115

116-
// 모니터링 여부 리스트 TreeTableView
117-
List<DBMonitoringYN> list1 = new ArrayList<>();
118-
list1.add(new DBMonitoringYN("DB1", "N", "N", "N"));
119-
list1.add(new DBMonitoringYN("DB2", "N", "N", "N"));
120-
list1.add(new DBMonitoringYN("DB3", "N", "N", "N"));
121-
122-
CustomTreeTableView<DBMonitoringYN> presetCtv1 = new CustomTreeTableView<>("모니터링 여부 리스트", FontAwesomeIcon.LIST);
123-
presetCtv1.addMonitoringInstanceColumn("Instance", "alias");
124-
presetCtv1.addMonitoringYNTableColumn("Archive", "archiveUsageYN");
125-
presetCtv1.addMonitoringYNTableColumn("Table Space", "tableSpaceUsageYN");
126-
presetCtv1.addMonitoringYNTableColumn("ASM Disk", "asmDiskUsageYN");
127-
presetCtv1.addTreeTableItem(new DBMonitoringYN("DB"), list1, FontAwesomeIcon.DATABASE);
128-
setAnchorPaneAnchor(presetCtv1, 0, 0, 0, 0);
129-
dbPresetAP.getChildren().add(presetCtv1);
130-
131-
List<ServerMonitoringYN> list2 = new ArrayList<>();
132-
list2.add(new ServerMonitoringYN("Server1", "Y"));
133-
list2.add(new ServerMonitoringYN("Server2", "Y"));
134-
list2.add(new ServerMonitoringYN("Server3", "Y"));
135-
list2.add(new ServerMonitoringYN("Server4", "Y"));
136-
137-
CustomTreeTableView<ServerMonitoringYN> presetCtv2 = new CustomTreeTableView<>("모니터링 여부 리스트",
138-
FontAwesomeIcon.LIST);
139-
presetCtv2.addMonitoringInstanceColumn("Instance", "alias");
140-
presetCtv2.addMonitoringYNTableColumn("OS Disk", "osDiskUsageYN");
141-
presetCtv2.addTreeTableItem(new ServerMonitoringYN("Server"), list2, FontAwesomeIcon.SERVER);
142-
setAnchorPaneAnchor(presetCtv2, 0, 0, 0, 0);
143-
serverPresetAP.getChildren().add(presetCtv2);
116+
/* 2. 모니터링 여부 설정 */
117+
// 2-1. 모니터링 여부 Preset 콤보박스 아이템 설정
118+
String curConnInfoFile = connInfoFileListComboBox.getSelectionModel().getSelectedItem();
119+
propService.loadMonitoringInfoConfig(curConnInfoFile);
120+
List<String> presetFileList = propService.getMonitoringPresetNameList();
121+
if (presetFileList == null || presetFileList.size() == 0) {
122+
// TODO 모니터링 여부 Preset 설정파일이 없는 경우
123+
// addMonitoringPresetPreview();
124+
} else {
125+
presetFileListComboBox.getItems().addAll(presetFileList);
126+
}
127+
128+
// 2-2. 모니터링 여부 Preset 콤보박스 아이템 변경 리스너 설정
129+
presetFileListComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
130+
System.out.println(newValue);
131+
System.out.println(propService.getMonitoringPresetFilePath(newValue));
132+
// List<DBMonitoringYN> dbPresets = propService.getMonitoringDBNameList();
133+
// List<ServerMonitoringYN> serverPresets = propService.getMonitoringServerNameList();
134+
// addMonitoringPresetPreview(dbPresets, serverPresets);
135+
});
136+
137+
// 2-3. 모니터링 여부 Preset 콤보박스 초기값 설정
138+
String lastUsePresetFileName = propService.getLastUsePresetFileName(curConnInfoFile);
139+
if (StringUtils.isEmpty(lastUsePresetFileName) || !presetFileList.contains(lastUsePresetFileName)) {
140+
// 최근 사용된 모니터링 여부 Preset 설정파일이 없거나 현재 존재하지 않는 경우, 첫 번째 설정파일 선택
141+
presetFileListComboBox.getSelectionModel().selectFirst();
142+
} else {
143+
presetFileListComboBox.getSelectionModel().select(lastUsePresetFileName);
144+
}
144145

145146
// 실행결과 TableView 생성 및 Column 추가
146147
MonitoringTableView<ArchiveUsage> archiveTable = addMonitoringTableView(archiveAP, ArchiveUsage.class);
@@ -211,7 +212,7 @@ private <T> MonitoringTableView<T> addMonitoringTableView(AnchorPane parent,
211212
}
212213

213214
/**
214-
* 모니터링 접속정보를 보여주는 TreeView를 생성 및 추가한다.
215+
* 설정된 모니터링 접속정보를 보여주는 TreeView를 생성 및 추가한다.
215216
*
216217
* @param dbNameList
217218
* @param serverNameList
@@ -224,4 +225,32 @@ private void addMonitoringConnInfoPreview(List<String> dbNameList, List<String>
224225
setAnchorPaneAnchor(connInfoCtv, 80, 0, 0, 0);
225226
connInfoSettingAP.getChildren().add(connInfoCtv);
226227
}
228+
229+
/**
230+
* 설정된 모니터링 여부 Preset을 보여주는 TreeTableView를 생성 및 추가한다.
231+
*
232+
* @param dbPresetList
233+
* @param serverPresetList
234+
*/
235+
private void addMonitoringPresetPreview(List<DBMonitoringYN> dbPresetList,
236+
List<ServerMonitoringYN> serverPresetList) {
237+
238+
// 모니터링 여부 리스트 TreeTableView - DB
239+
CustomTreeTableView<DBMonitoringYN> dbCtv = new CustomTreeTableView<>("", FontAwesomeIcon.LIST);
240+
dbCtv.addMonitoringInstanceColumn("Instance", "alias");
241+
dbCtv.addMonitoringYNTableColumn("Archive", "archiveUsageYN");
242+
dbCtv.addMonitoringYNTableColumn("Table Space", "tableSpaceUsageYN");
243+
dbCtv.addMonitoringYNTableColumn("ASM Disk", "asmDiskUsageYN");
244+
dbCtv.addTreeTableItem(new DBMonitoringYN("DB"), dbPresetList, FontAwesomeIcon.DATABASE);
245+
setAnchorPaneAnchor(dbCtv, 0, 0, 0, 0);
246+
dbPresetAP.getChildren().add(dbCtv);
247+
248+
// 모니터링 여부 리스트 TreeTableView - Server
249+
CustomTreeTableView<ServerMonitoringYN> serverCtv = new CustomTreeTableView<>("", FontAwesomeIcon.LIST);
250+
serverCtv.addMonitoringInstanceColumn("Instance", "alias");
251+
serverCtv.addMonitoringYNTableColumn("OS Disk", "osDiskUsageYN");
252+
serverCtv.addTreeTableItem(new ServerMonitoringYN("Server"), serverPresetList, FontAwesomeIcon.SERVER);
253+
setAnchorPaneAnchor(serverCtv, 0, 0, 0, 0);
254+
serverPresetAP.getChildren().add(serverCtv);
255+
}
227256
}

src/main/resources/fxml/RunMenu.fxml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
<Font name="Noto Sans Korean Regular" size="12.0" />
8181
</font>
8282
</Label>
83-
<JFXComboBox fx:id="connInfoFileListComboBox" minHeight="22.0" promptText="모니터링 접속정보 설정파일을 선택해주세요." styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0">
83+
<JFXComboBox fx:id="connInfoFileListComboBox" maxWidth="230.0" minHeight="22.0" promptText="모니터링 접속정보 설정파일을 선택해주세요." styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0">
8484
<padding>
8585
<Insets left="5.0" />
8686
</padding></JFXComboBox>
@@ -137,7 +137,7 @@
137137
<Font name="Noto Sans Korean Regular" size="12.0" />
138138
</font>
139139
</Label>
140-
<JFXComboBox minHeight="22.0" minWidth="200.0" styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0">
140+
<JFXComboBox fx:id="presetFileListComboBox" maxWidth="230.0" minHeight="22.0" styleClass="basic-font" stylesheets="@../css/javaFx.css" unFocusColor="#ececec" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0">
141141
<padding>
142142
<Insets left="5.0" />
143143
</padding></JFXComboBox>

0 commit comments

Comments
 (0)