|
2 | 2 |
|
3 | 3 | import java.util.ArrayList; |
4 | 4 | import java.util.Arrays; |
| 5 | +import java.util.HashMap; |
5 | 6 | import java.util.List; |
6 | 7 | import java.util.Map; |
7 | | -import java.util.Spliterator; |
8 | | -import java.util.Spliterators; |
9 | 8 | import java.util.regex.Matcher; |
10 | 9 | import java.util.regex.Pattern; |
11 | 10 | import java.util.stream.Collectors; |
12 | | -import java.util.stream.StreamSupport; |
13 | 11 |
|
| 12 | +import org.apache.commons.configuration2.PropertiesConfiguration; |
14 | 13 | import org.apache.commons.lang3.StringUtils; |
15 | 14 |
|
16 | 15 | import root.core.domain.JdbcConnectionInfo; |
17 | 16 | import root.core.domain.JschConnectionInfo; |
18 | 17 | import root.core.domain.MonitoringYN; |
19 | 18 | import root.core.domain.MonitoringYN.MonitoringTypeAndYN; |
20 | 19 | import root.core.domain.enums.MonitoringType; |
| 20 | +import root.core.domain.enums.RoundingDigits; |
| 21 | +import root.core.domain.enums.UsageUIType; |
21 | 22 | import root.core.repository.constracts.PropertyRepository; |
22 | 23 | import root.core.service.contracts.PropertyService; |
| 24 | +import root.utils.UnitUtils.FileSize; |
23 | 25 |
|
24 | 26 | public class FilePropertyService implements PropertyService { |
25 | 27 |
|
@@ -124,13 +126,20 @@ private List<MonitoringYN> getMonitoringYNList(List<String> aliasList, List<Moni |
124 | 126 |
|
125 | 127 | @Override |
126 | 128 | 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; |
134 | 143 | } |
135 | 144 |
|
136 | 145 | @Override |
@@ -170,4 +179,27 @@ public List<JschConnectionInfo> getJschConnInfoList(List<String> serverNames) { |
170 | 179 | Collectors.mapping(serverName -> propRepo.getJschConnectionInfo(serverName), Collectors.toList())); |
171 | 180 | } |
172 | 181 |
|
| 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 | + } |
173 | 205 | } |
0 commit comments