22
33import java .io .File ;
44import java .net .URL ;
5- import java .util .ArrayList ;
65import java .util .HashMap ;
7- import java .util .LinkedHashSet ;
86import java .util .List ;
97import java .util .Map ;
108import java .util .Optional ;
119import java .util .ResourceBundle ;
12- import java .util .Set ;
13- import java .util .stream .Collectors ;
1410
1511import org .apache .commons .configuration2 .PropertiesConfiguration ;
1612import org .apache .commons .lang3 .StringUtils ;
1713import org .apache .log4j .Logger ;
1814
1915import com .jfoenix .controls .JFXComboBox ;
20- import com .jfoenix .controls .JFXToggleButton ;
2116
2217import de .jensd .fx .glyphs .fontawesome .FontAwesomeIcon ;
2318import de .jensd .fx .glyphs .fontawesome .FontAwesomeIconView ;
3833import javafx .stage .FileChooser .ExtensionFilter ;
3934import javafx .stage .Stage ;
4035import javafx .util .StringConverter ;
41- import root .core .domain .ASMDiskUsage ;
42- import root .core .domain .AlertLog ;
43- import root .core .domain .ArchiveUsage ;
4436import root .core .domain .JdbcConnectionInfo ;
4537import root .core .domain .JschConnectionInfo ;
4638import root .core .domain .MonitoringYN ;
4739import root .core .domain .MonitoringYN .MonitoringTypeAndYN ;
48- import root .core .domain .OSDiskUsage ;
49- import root .core .domain .TableSpaceUsage ;
5040import root .core .domain .enums .MonitoringType ;
5141import root .core .domain .enums .RoundingDigits ;
5242import root .core .domain .enums .UsageUIType ;
@@ -107,21 +97,13 @@ public class SettingMenuController implements Initializable {
10797 JFXComboBox <UsageUIType > usageUICB ;
10898
10999 /* Common Data */
110- private static final Map <Class <?>, String > DB_MONITORING_CONTENTS = new HashMap <>();
111- private static final Map <Class <?>, String > SERVER_MONITORING_CONTENTS = new HashMap <>();
112- static {
113- DB_MONITORING_CONTENTS .put (ArchiveUsage .class , "Archive Usage" );
114- DB_MONITORING_CONTENTS .put (TableSpaceUsage .class , "TableSpace Usage" );
115- DB_MONITORING_CONTENTS .put (ASMDiskUsage .class , "ASM Disk Usage" );
116- SERVER_MONITORING_CONTENTS .put (OSDiskUsage .class , "OS Disk Usage" );
117- SERVER_MONITORING_CONTENTS .put (AlertLog .class , "Alert Log" );
118- }
119-
120100 List <JdbcConnectionInfo > jdbcConnInfoList ;
121101 List <JschConnectionInfo > jschConnInfoList ;
122102
123103 Map <String , String > monitoringPresetMap = new HashMap <>();
124104
105+ MonitoringYNVBox monitoringYNVBox = new MonitoringYNVBox ();
106+
125107 @ Override
126108 public void initialize (URL location , ResourceBundle resources ) {
127109
@@ -295,21 +277,21 @@ private void loadSelectedConfigFile(String absoluteFilePath) {
295277 int startIdx = absoluteFilePath .lastIndexOf ("\\ config" );
296278 String filePath = startIdx == -1 ? absoluteFilePath : "." + absoluteFilePath .substring (startIdx );
297279
298- // 2. 파일경로에서 접속정보 프로퍼티파일을 읽는다.
280+ // 2. fileChooserText의 텍스트를 현재 선택된 파일경로로 변경한다.
281+ fileChooserText .setText (filePath );
282+
283+ // 3. 파일경로에서 접속정보 프로퍼티파일을 읽는다.
299284 propRepo .loadConnectionInfoConfig (filePath );
300285
301- // 3 . 프로퍼티파일에 작성된 내용에 따라 동적 요소를 생성한다.
286+ // 4 . 프로퍼티파일에 작성된 내용에 따라 동적 요소를 생성한다.
302287 createSettingDynamicElements ();
303288
304289 // TODO move this logic to PropertyService
305- // 4 . remember.properties 파일에 최근 사용된 설정파일 경로를 저장한다.
290+ // 5 . remember.properties 파일에 최근 사용된 설정파일 경로를 저장한다.
306291 PropertiesConfiguration rememberConfig = propRepo .getConfiguration ("rememberConfig" );
307292 rememberConfig .setProperty ("filepath.config.lastuse" , filePath .replace ("\\ " , "/" ));
308293 propRepo .save (rememberConfig .getString ("filepath.config.remember" ), rememberConfig );
309294
310- // 5. fileChooserText의 텍스트를 현재 선택된 파일경로로 변경한다.
311- fileChooserText .setText (filePath );
312-
313295 } catch (Exception e ) {
314296 e .printStackTrace ();
315297 // 6. 파일 load가 실패 시, Alert 메시지를 띄운다.
@@ -327,12 +309,12 @@ private void loadSelectedConfigFile(String absoluteFilePath) {
327309 private void loadMonitoringConfigFile (String filePath ) {
328310 monitoringElementsVBox .getChildren ().clear ();
329311
330- propRepo . loadMonitoringInfoConfig ( filePath );
312+ String presetConfigFileName = monitoringPresetComboBox . getSelectionModel (). getSelectedItem ( );
331313
332- String [] dbNames = propRepo . getMonitoringDBNames ( );
333- String [] serverNames = propRepo . getMonitoringServerNames ( );
314+ List < MonitoringYN > dbYnList = propService . getDBMonitoringYnList ( presetConfigFileName );
315+ List < MonitoringYN > serverYnList = propService . getServerMonitoringYnList ( presetConfigFileName );
334316
335- createMonitoringElements (monitoringElementsVBox );
317+ createMonitoringElements (monitoringElementsVBox , dbYnList , serverYnList );
336318 }
337319
338320 /**
@@ -373,14 +355,20 @@ public void saveConnInfoSettings(ActionEvent e) {
373355 */
374356 public void saveMonitoringSettings (ActionEvent e ) {
375357 // TODO move this logic to PropertyService
376- PropertiesConfiguration config = propRepo . getConfiguration ( "monitoringConfig" );
358+ PropertiesConfiguration config = new PropertiesConfiguration ( );
377359 String presetName = monitoringPresetComboBox .getSelectionModel ().getSelectedItem ();
378360 String monitoringFilePath = monitoringPresetMap .get (presetName );
379361
380362 if (!monitoringFilePath .isEmpty ()) {
381- for (Node n : monitoringElementsVBox .lookupAll ("JFXToggleButton" )) {
382- JFXToggleButton thisToggle = (JFXToggleButton ) n ;
383- config .setProperty (thisToggle .getId (), thisToggle .isSelected ());
363+
364+ Map <MonitoringType , Map <String , Boolean >> selection = monitoringYNVBox .getToggleSelection ();
365+
366+ for (MonitoringType type : selection .keySet ()) {
367+ Map <String , Boolean > aliasMap = selection .get (type );
368+ for (String alias : aliasMap .keySet ()) {
369+ String key = StringUtils .join (type .getName ().replace (" " , "_" ), "." , alias );
370+ config .setProperty (key , aliasMap .get (alias ) ? "Y" : "N" );
371+ }
384372 }
385373 propRepo .save (monitoringFilePath , config );
386374
@@ -396,27 +384,12 @@ public void saveMonitoringSettings(ActionEvent e) {
396384 * 모니터링 여부 설정할 요소들 동적 생성
397385 *
398386 * @param rootVBox
399- * @param monitoringElements
400- * @param monitoringAlias
387+ * @param dbYnList
388+ * @param serverYnList
401389 */
402- private void createMonitoringElements (VBox rootVBox ) {
403-
404- List <MonitoringYN > dbYnList = new ArrayList <>();
405- List <MonitoringTypeAndYN > childList = new ArrayList <>();
406- childList .add (new MonitoringTypeAndYN (MonitoringType .ARCHIVE , false ));
407- childList .add (new MonitoringTypeAndYN (MonitoringType .TABLE_SPACE , true ));
408- childList .add (new MonitoringTypeAndYN (MonitoringType .ASM_DISK , false ));
409- dbYnList .add (new MonitoringYN ("ERP" , childList ));
410- dbYnList .add (new MonitoringYN ("ERP2" , childList ));
411- dbYnList .add (new MonitoringYN ("ERP3" , childList ));
412-
413- List <MonitoringYN > serverYnList = new ArrayList <>();
414- List <MonitoringTypeAndYN > childList2 = new ArrayList <>();
415- childList2 .add (new MonitoringTypeAndYN (MonitoringType .OS_DISK , true ));
416- childList2 .add (new MonitoringTypeAndYN (MonitoringType .ALERT_LOG , true ));
417- serverYnList .add (new MonitoringYN ("DBERP1" , childList2 ));
418-
419- MonitoringYNVBox monitoringYNVBox = new MonitoringYNVBox ();
390+ private void createMonitoringElements (VBox rootVBox , List <MonitoringYN > dbYnList , List <MonitoringYN > serverYnList ) {
391+ monitoringYNVBox = new MonitoringYNVBox ();
392+
420393 for (MonitoringYN dbYn : dbYnList ) {
421394 for (MonitoringTypeAndYN typeAndYn : dbYn .getMonitoringTypeList ()) {
422395 MonitoringType type = typeAndYn .getMonitoringType ();
@@ -425,7 +398,7 @@ private void createMonitoringElements(VBox rootVBox) {
425398 }
426399 }
427400 monitoringYNVBox .initSelection (dbYnList );
428-
401+
429402 for (MonitoringYN serverYn : serverYnList ) {
430403 for (MonitoringTypeAndYN typeAndYn : serverYn .getMonitoringTypeList ()) {
431404 MonitoringType type = typeAndYn .getMonitoringType ();
0 commit comments