Skip to content

Commit 42de894

Browse files
authored
Merge pull request #252 from Dokyeongyun/develop
2022.05.15. ~ 2022.05.19. Merge
2 parents d67a41a + 38b7aa8 commit 42de894

File tree

17 files changed

+1036
-597
lines changed

17 files changed

+1036
-597
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package root.core.domain.exceptions;
2+
3+
public class PropertyNotFoundException extends Exception {
4+
private static final long serialVersionUID = 196259383529491976L;
5+
6+
public PropertyNotFoundException(String message) {
7+
super(message);
8+
}
9+
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,32 @@
88
import root.common.database.implement.JdbcConnectionInfo;
99
import root.common.server.implement.AlertLogCommand;
1010
import root.common.server.implement.JschConnectionInfo;
11+
import root.core.domain.exceptions.PropertyNotFoundException;
12+
import root.core.domain.exceptions.PropertyNotLoadedException;
1113

1214
public interface PropertyRepository {
1315

1416
boolean isFileExist(String filePath);
1517

16-
PropertiesConfiguration getConfiguration(String config);
18+
PropertiesConfiguration getConfiguration(String config) throws PropertyNotLoadedException;
1719

1820
void save(String filePath, PropertiesConfiguration config);
1921

2022
void saveDBConnectionInfo(String filePath, Map<String, JdbcConnectionInfo> config);
2123

2224
void saveServerConnectionInfo(String filePath, Map<String, JschConnectionInfo> config);
2325

24-
void saveCommonConfig(Map<String, Object> values);
26+
void saveCommonConfig(Map<String, Object> values) throws PropertyNotLoadedException;
2527

26-
void saveCommonConfig(String key, String value);
28+
void saveCommonConfig(String key, String value) throws PropertyNotLoadedException;
2729

28-
void loadCombinedConfiguration();
30+
void loadCombinedConfiguration() throws PropertyNotFoundException;
2931

3032
void loadConnectionInfoConfig(String filePath);
3133

3234
void loadMonitoringInfoConfig(String filePath);
3335

34-
String[] getConnectionInfoFileNames();
36+
String[] getConnectionInfoFileNames() throws PropertyNotFoundException;
3537

3638
String getCommonResource(String key);
3739

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

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import root.core.domain.enums.MonitoringType;
1111
import root.core.domain.enums.RoundingDigits;
1212
import root.core.domain.enums.UsageUIType;
13+
import root.core.domain.exceptions.PropertyNotFoundException;
14+
import root.core.domain.exceptions.PropertyNotLoadedException;
1315
import root.utils.UnitUtils.FileSize;
1416

1517
public interface PropertyService {
@@ -25,8 +27,9 @@ public interface PropertyService {
2527
* 모니터링 접속정보 설정파일의 경로를 반환한다.
2628
*
2729
* @return
30+
* @throws PropertyNotFoundException
2831
*/
29-
List<String> getConnectionInfoList();
32+
List<String> getConnectionInfoList() throws PropertyNotFoundException;
3033

3134
/**
3235
* 최근 사용된 접속정보 설정파일의 경로를 반환한다.
@@ -65,13 +68,13 @@ public interface PropertyService {
6568
*/
6669
List<MonitoringYN> getServerMonitoringYnList(String presetConfigFileName);
6770

68-
Map<String, String> getMonitoringPresetMap();
71+
Map<String, String> getMonitoringPresetMap() throws PropertyNotLoadedException;
6972

70-
List<String> getMonitoringPresetFilePathList();
73+
List<String> getMonitoringPresetFilePathList() throws PropertyNotLoadedException;
7174

72-
List<String> getMonitoringPresetNameList();
75+
List<String> getMonitoringPresetNameList() throws PropertyNotLoadedException;
7376

74-
String getMonitoringPresetFilePath(String presetName);
77+
String getMonitoringPresetFilePath(String presetName) throws PropertyNotLoadedException;
7578

7679
List<String> getMonitoringDBNameList();
7780

@@ -122,30 +125,32 @@ public interface PropertyService {
122125
* @param key 설정정보 키
123126
* @param value 설정정보 값
124127
*/
125-
void saveCommonConfig(String key, String value);
128+
void saveCommonConfig(String key, String value) throws PropertyNotLoadedException;
126129

127130
/**
128131
* 최근 사용한 접속정보 설정정보를 저장한다.
129132
*
130133
* @param filePath
134+
* @throws PropertyNotLoadedException
131135
*/
132-
void saveLastUseConnectionInfoSetting(String filePath);
136+
void saveLastUseConnectionInfoSetting(String filePath) throws PropertyNotLoadedException;
133137

134138
/**
135139
* 접속정보 설정을 추가한다.
136140
*
137141
* @param filePath
138142
* @return
143+
* @throws PropertyNotLoadedException
139144
*/
140-
String addConnectionInfoSetting(String filePath);
145+
String addConnectionInfoSetting(String filePath) throws PropertyNotLoadedException;
141146

142147
/**
143148
* 모니터링여부 Preset 설정을 추가한다.
144149
*
145150
* @param connInfoSetting
146151
* @param presetName
147152
*/
148-
void addMonitoringPreset(String connInfoSetting, String presetName);
153+
void addMonitoringPreset(String connInfoSetting, String presetName) throws PropertyNotLoadedException;
149154

150155
/**
151156
* 모니터링여부 Preset 설정을 저장한다.

DBMonitoringWindowApp/src/main/java/root/applications/ConsoleApp.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import root.common.server.implement.JschServer;
1818
import root.core.batch.DBCheckBatch;
1919
import root.core.batch.ServerCheckBatch;
20+
import root.core.domain.exceptions.PropertyNotLoadedException;
2021
import root.core.repository.constracts.DBCheckRepository;
2122
import root.core.repository.constracts.PropertyRepository;
2223
import root.core.repository.constracts.ServerMonitoringRepository;
@@ -98,8 +99,13 @@ public static void main(String[] args) throws IOException {
9899
while (true) {
99100
System.out.println(String.format("사용하실 모니터링여부 설정을 선택해주세요."));
100101

101-
List<String> presetNames = propService.getMonitoringPresetNameList();
102-
if (presetNames.size() == 0) {
102+
List<String> presetNames = null;
103+
try {
104+
presetNames = propService.getMonitoringPresetNameList();
105+
} catch (PropertyNotLoadedException e) {
106+
e.printStackTrace();
107+
}
108+
if (presetNames == null || presetNames.size() == 0) {
103109
System.out.println("모니터링여부 설정파일이 존재하지 않습니다. 프로그램을 종료합니다.");
104110
return;
105111
}

DBMonitoringWindowApp/src/main/java/root/applications/Program.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
import javafx.application.Application;
44
import javafx.scene.Parent;
55
import javafx.scene.Scene;
6+
import javafx.scene.control.Alert.AlertType;
67
import javafx.stage.Stage;
78
import lombok.extern.slf4j.Slf4j;
9+
import root.core.domain.exceptions.PropertyNotFoundException;
810
import root.core.repository.constracts.PropertyRepository;
911
import root.javafx.Controller.HomeController;
1012
import root.javafx.Controller.LeftMenuController;
1113
import root.javafx.DI.DependencyInjection;
14+
import root.javafx.utils.AlertUtils;
1215
import root.repository.implement.PropertyRepositoryImpl;
1316

1417
@Slf4j
@@ -26,7 +29,12 @@ public void start(Stage primaryStage) throws Exception {
2629
setUpDependecyInjector();
2730

2831
// configuration load
29-
propRepo.loadCombinedConfiguration();
32+
try {
33+
propRepo.loadCombinedConfiguration();
34+
} catch (PropertyNotFoundException e) {
35+
AlertUtils.showAlert(AlertType.ERROR, "설정 파일 Load", "설정 파일 읽기에 실패했습니다. 설정파일을 확인해주세요.");
36+
return;
37+
}
3038

3139
// fxml load
3240
System.setProperty("prism.lcdtext", "false"); // 안티앨리어싱 (Font 부드럽게)

DBMonitoringWindowApp/src/main/java/root/javafx/Controller/AlertLogMonitoringMenuController.java

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

3+
import java.io.IOException;
34
import java.net.URL;
45
import java.time.LocalDate;
56
import java.util.HashMap;
@@ -20,6 +21,7 @@
2021
import javafx.fxml.Initializable;
2122
import javafx.geometry.Insets;
2223
import javafx.scene.control.Alert.AlertType;
24+
import javafx.scene.control.Button;
2325
import javafx.scene.control.DatePicker;
2426
import javafx.scene.control.ScrollPane;
2527
import javafx.scene.control.ScrollPane.ScrollBarPolicy;
@@ -35,6 +37,7 @@
3537
import root.common.server.implement.ServerOS;
3638
import root.core.domain.AlertLog;
3739
import root.core.domain.Log;
40+
import root.core.domain.exceptions.PropertyNotFoundException;
3841
import root.core.repository.constracts.ServerMonitoringRepository;
3942
import root.core.service.contracts.PropertyService;
4043
import root.core.usecase.constracts.ServerMonitoringUsecase;
@@ -44,7 +47,9 @@
4447
import root.javafx.CustomView.NumberTextFormatter;
4548
import root.javafx.CustomView.TagBar;
4649
import root.javafx.CustomView.dateCell.DisableAfterTodayDateCell;
50+
import root.javafx.DI.DependencyInjection;
4751
import root.javafx.utils.AlertUtils;
52+
import root.javafx.utils.SceneUtils;
4853
import root.repository.implement.LinuxServerMonitoringRepository;
4954
import root.repository.implement.PropertyRepositoryImpl;
5055
import root.repository.implement.ReportFileRepo;
@@ -90,6 +95,15 @@ public class AlertLogMonitoringMenuController implements Initializable {
9095

9196
@FXML
9297
AnchorPane summaryNodataAP;
98+
99+
@FXML
100+
AnchorPane topMenuBar;
101+
102+
@FXML
103+
AnchorPane noPropertyFileAP;
104+
105+
@FXML
106+
Button fileOpenBtn;
93107

94108
TagBar tagBar = new TagBar();
95109

@@ -107,19 +121,34 @@ public AlertLogMonitoringMenuController() {
107121
public void initialize(URL location, ResourceBundle resources) {
108122

109123
// 접속정보 설정 프로퍼티 파일
110-
List<String> connInfoFiles = propService.getConnectionInfoList();
111-
if (connInfoFiles != null && connInfoFiles.size() != 0) {
112-
// Connection Info ComboBox
113-
runConnInfoFileComboBox.getItems().addAll(connInfoFiles);
114-
runConnInfoFileComboBox.getSelectionModel().selectFirst();
115-
116-
// remember.properties 파일에서, 최근 사용된 설정파일 경로가 있다면 해당 설정파일을 불러온다.
117-
String lastUseConnInfoFilePath = propService.getLastUseConnectionInfoFilePath();
118-
if (lastUseConnInfoFilePath != null) {
119-
runConnInfoFileComboBox.getSelectionModel().select(lastUseConnInfoFilePath);
124+
List<String> connInfoFiles;
125+
try {
126+
connInfoFiles = propService.getConnectionInfoList();
127+
if (connInfoFiles != null && connInfoFiles.size() != 0) {
128+
// Connection Info ComboBox
129+
runConnInfoFileComboBox.getItems().addAll(connInfoFiles);
130+
runConnInfoFileComboBox.getSelectionModel().selectFirst();
131+
132+
// remember.properties 파일에서, 최근 사용된 설정파일 경로가 있다면 해당 설정파일을 불러온다.
133+
String lastUseConnInfoFilePath = propService.getLastUseConnectionInfoFilePath();
134+
if (lastUseConnInfoFilePath != null) {
135+
runConnInfoFileComboBox.getSelectionModel().select(lastUseConnInfoFilePath);
136+
}
137+
138+
System.out.println(propService.getMonitoringServerNameList());
139+
if(propService.getMonitoringServerNameList().size() == 0) {
140+
setNoPropertyUIVisible(true);
141+
} else {
142+
setNoPropertyUIVisible(false);
143+
}
144+
145+
} else {
146+
setNoPropertyUIVisible(true);
147+
return;
120148
}
121-
} else {
122-
AlertUtils.showAlert(AlertType.INFORMATION, "접속정보 설정", "설정된 접속정보가 없습니다.\n[설정]메뉴로 이동합니다.");
149+
} catch (PropertyNotFoundException e) {
150+
log.error(e.getMessage());
151+
setNoPropertyUIVisible(true);
123152
return;
124153
}
125154

@@ -387,4 +416,32 @@ private void updateStatusMessage(String message) {
387416
statusTextUpdateThread.setDaemon(true);
388417
statusTextUpdateThread.start();
389418
}
419+
420+
/**
421+
* 설정 메뉴로 이동
422+
*
423+
* @param e
424+
* @throws IOException
425+
*/
426+
public void goSettingMenu(ActionEvent e) throws IOException {
427+
SceneUtils.movePage(DependencyInjection.load("/fxml/SettingMenu.fxml"));
428+
}
429+
430+
/**
431+
* 접속정보 설정파일 열기
432+
*
433+
* @param e
434+
*/
435+
public void openPropertiesFile(ActionEvent e) {
436+
}
437+
438+
/**
439+
* 접속정보 설정 파일이 없을 때 UI Visible 변경
440+
*
441+
* @param isVisible
442+
*/
443+
private void setNoPropertyUIVisible(boolean isVisible) {
444+
noPropertyFileAP.setVisible(isVisible);
445+
topMenuBar.setVisible(!isVisible);
446+
}
390447
}

0 commit comments

Comments
 (0)