use of com.usthe.manager.pojo.dto.Hierarchy in project hertzbeat by dromara.
the class AppServiceImpl method getAllAppHierarchy.
@Override
public List<Hierarchy> getAllAppHierarchy(String lang) {
List<Hierarchy> hierarchies = new LinkedList<>();
for (Job job : appDefines.values()) {
Hierarchy hierarchyApp = new Hierarchy();
hierarchyApp.setCategory(job.getCategory());
hierarchyApp.setValue(job.getApp());
Map<String, String> nameMap = job.getName();
if (nameMap != null) {
String i18nName = nameMap.get(lang);
if (i18nName == null) {
i18nName = nameMap.values().stream().findFirst().get();
}
hierarchyApp.setLabel(i18nName);
}
List<Hierarchy> hierarchyMetricList = new LinkedList<>();
if (job.getMetrics() != null) {
for (Metrics metrics : job.getMetrics()) {
Hierarchy hierarchyMetric = new Hierarchy();
hierarchyMetric.setValue(metrics.getName());
hierarchyMetric.setLabel(metrics.getName());
List<Hierarchy> hierarchyFieldList = new LinkedList<>();
if (metrics.getFields() != null) {
for (Metrics.Field field : metrics.getFields()) {
Hierarchy hierarchyField = new Hierarchy();
hierarchyField.setValue(field.getField());
hierarchyField.setLabel(field.getField());
hierarchyField.setIsLeaf(true);
hierarchyFieldList.add(hierarchyField);
}
hierarchyMetric.setChildren(hierarchyFieldList);
}
hierarchyMetricList.add(hierarchyMetric);
}
}
hierarchyApp.setChildren(hierarchyMetricList);
hierarchies.add(hierarchyApp);
}
return hierarchies;
}
Aggregations