Skip to content

Commit de89c8e

Browse files
authored
Merge pull request #180 from Dokyeongyun/ft-220225-runMenu
Ft 220225 run menu
2 parents d1aa29f + a065399 commit de89c8e

File tree

5 files changed

+379
-125
lines changed

5 files changed

+379
-125
lines changed

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import root.core.domain.JdbcConnectionInfo;
77
import root.core.domain.JschConnectionInfo;
88
import root.core.domain.MonitoringYN;
9+
import root.core.domain.enums.RoundingDigits;
10+
import root.core.domain.enums.UsageUIType;
11+
import root.utils.UnitUtils.FileSize;
912

1013
public interface PropertyService {
1114

@@ -15,7 +18,7 @@ public interface PropertyService {
1518
* @param filePath
1619
*/
1720
void loadConnectionInfoConfig(String filePath);
18-
21+
1922
/**
2023
* 모니터링 접속정보 설정파일의 경로를 반환한다.
2124
*
@@ -36,7 +39,7 @@ public interface PropertyService {
3639
* @param filePath
3740
*/
3841
void loadMonitoringInfoConfig(String filePath);
39-
42+
4043
/**
4144
* 최근 사용된 모니터링 여부 Preset 설정파일의 Preset명을 반환한다.
4245
*
@@ -51,7 +54,7 @@ public interface PropertyService {
5154
* @return
5255
*/
5356
List<MonitoringYN> getDBMonitoringYnList(String presetConfigFileName);
54-
57+
5558
/**
5659
* 모니터링여부 Preset 설정파일을 읽어 Server 모니터링 여부 리스트를 반환한다.
5760
*
@@ -75,4 +78,25 @@ public interface PropertyService {
7578
List<JdbcConnectionInfo> getJdbcConnInfoList(List<String> dbNames);
7679

7780
List<JschConnectionInfo> getJschConnInfoList(List<String> serverNames);
81+
82+
/**
83+
* 기본값으로 설정된 FileSize 단위를 반환한다.
84+
*
85+
* @return
86+
*/
87+
FileSize getDefaultFileSizeUnit();
88+
89+
/**
90+
* 기본값으로 설정된 반올림 자릿수를 반환한다.
91+
*
92+
* @return
93+
*/
94+
RoundingDigits getDefaultRoundingDigits();
95+
96+
/**
97+
* 기본값으로 설정된 사용량 컬럼 UI 타입을 반환한다.
98+
*
99+
* @return
100+
*/
101+
UsageUIType getDefaultUsageUIType();
78102
}

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

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22

33
import java.util.ArrayList;
44
import java.util.Arrays;
5+
import java.util.HashMap;
56
import java.util.List;
67
import java.util.Map;
7-
import java.util.Spliterator;
8-
import java.util.Spliterators;
98
import java.util.regex.Matcher;
109
import java.util.regex.Pattern;
1110
import java.util.stream.Collectors;
12-
import java.util.stream.StreamSupport;
1311

12+
import org.apache.commons.configuration2.PropertiesConfiguration;
1413
import org.apache.commons.lang3.StringUtils;
1514

1615
import root.core.domain.JdbcConnectionInfo;
1716
import root.core.domain.JschConnectionInfo;
1817
import root.core.domain.MonitoringYN;
1918
import root.core.domain.MonitoringYN.MonitoringTypeAndYN;
2019
import root.core.domain.enums.MonitoringType;
20+
import root.core.domain.enums.RoundingDigits;
21+
import root.core.domain.enums.UsageUIType;
2122
import root.core.repository.constracts.PropertyRepository;
2223
import root.core.service.contracts.PropertyService;
24+
import root.utils.UnitUtils.FileSize;
2325

2426
public class FilePropertyService implements PropertyService {
2527

@@ -124,13 +126,20 @@ private List<MonitoringYN> getMonitoringYNList(List<String> aliasList, List<Moni
124126

125127
@Override
126128
public Map<String, String> getMonitoringPresetMap() {
127-
return StreamSupport
128-
.stream(Spliterators.spliteratorUnknownSize(propRepo.getConfiguration("connInfoConfig").getKeys(),
129-
Spliterator.ORDERED), false)
130-
.filter(key -> key.matches(MONITORING_PRESET_KEY)).collect(Collectors.toUnmodifiableMap(key -> {
131-
Matcher m = MONITORING_PRESET_KEY_PATTERN.matcher(key);
132-
return m.matches() ? m.group(1) : "";
133-
}, key -> propRepo.getMonitoringConfigResource(key)));
129+
Map<String, String> result = new HashMap<>();
130+
131+
PropertiesConfiguration config = propRepo.getConfiguration("connInfoConfig");
132+
133+
config.getKeys().forEachRemaining(key -> {
134+
if (key.matches(MONITORING_PRESET_KEY)) {
135+
Matcher m = MONITORING_PRESET_KEY_PATTERN.matcher(key);
136+
if (m.matches()) {
137+
String presetName = m.group(1);
138+
result.put(presetName, config.getString(key));
139+
}
140+
}
141+
});
142+
return result;
134143
}
135144

136145
@Override
@@ -170,4 +179,27 @@ public List<JschConnectionInfo> getJschConnInfoList(List<String> serverNames) {
170179
Collectors.mapping(serverName -> propRepo.getJschConnectionInfo(serverName), Collectors.toList()));
171180
}
172181

182+
/**
183+
* 기본값으로 설정된 FileSize 단위를 반환한다.
184+
*/
185+
@Override
186+
public FileSize getDefaultFileSizeUnit() {
187+
return FileSize.find(propRepo.getCommonResource("unit.filesize"));
188+
}
189+
190+
/**
191+
* 기본값으로 설정된 반올림 자릿수를 반환한다.
192+
*/
193+
@Override
194+
public RoundingDigits getDefaultRoundingDigits() {
195+
return RoundingDigits.find(propRepo.getCommonResource("unit.rounding"));
196+
}
197+
198+
/**
199+
* 기본값으로 설정된 사용량 컬럼 UI 타입을 반환한다.
200+
*/
201+
@Override
202+
public UsageUIType getDefaultUsageUIType() {
203+
return UsageUIType.find(propRepo.getCommonResource("usage-ui-type"));
204+
}
173205
}

0 commit comments

Comments
 (0)