getMetrics function
Future
getMetrics(
- dynamic type,
- dynamic uuid
)
Implementation
Future getMetrics(var type, var uuid) async {
Node? metricNode;
for (var path in Storage.getValuePath) {
try {
metricNode = await Storage.controller
!.get(path);
}on StorageException {
print('?!');
}
try{
var childrenNodes = await metricNode!.getChildren();
var metricNodeIterator = childrenNodes.entries.iterator;
while (metricNodeIterator.moveNext()) {
var normalizationValue = await normalization(metricNodeIterator);
var threatsImpactNode =
await metricNodeIterator.current.value.getValue('threatsImpact');
var threatsImpacts = threatsImpactNode!.getValue('en')!.split(';');
for (var list in threatsImpacts) {
var threatsImpact = list.split(',');
// print(metricNodeIterator.current.value.getValue('flag')!.getValue('en'));
var flagNode =
await metricNodeIterator.current.value.getValue('flag');
if (flagNode!.getValue('en') == '1') {
Node impactNormal = NodeImpl(':pimn', 'gg');
await impactNormal
.addOrUpdateValue(NodeValueImpl('impact', threatsImpact[1]));
await impactNormal.addOrUpdateValue(
NodeValueImpl('normal', normalizationValue.toString()));
//type == types.Devices ? coreValues.devicePositive[threatsImpact[0]]!.add(impactNormal) : coreValues.userPositive[threatsImpact[0]]!.add(impactNormal);
if (type == Types.devices) {
try {
CoreValues.devicePositive[threatsImpact[0]]!.add(impactNormal);
//print(CoreValues.devicePositive);
} catch (e) {
var temp = <Node>[];
temp.add(impactNormal);
CoreValues.devicePositive[threatsImpact[0]] = temp;
//print(CoreValues.devicePositive);
}
} else {
try {
CoreValues.userPositive[threatsImpact[0]]!.add(impactNormal);
//print(CoreValues.userPositive);
} catch (e) {
var temp = <Node>[];
temp.add(impactNormal);
CoreValues.userPositive[threatsImpact[0]] = temp;
//print(CoreValues.userPositive);
}
}
} else {
Node impactNormal = NodeImpl(':nimpn', 'gg');
await impactNormal
.addOrUpdateValue(NodeValueImpl('impact', threatsImpact[1]));
await impactNormal.addOrUpdateValue(
NodeValueImpl('normal', normalizationValue.toString()));
// type == types.Devices ? coreValues.deviceNegative[threatsImpact[0]]!.add(impactNormal) : coreValues.userNegative[threatsImpact[0]]!.add(impactNormal);
if (type == Types.devices) {
try {
CoreValues.deviceNegative[threatsImpact[0]]!.add(impactNormal);
//print(CoreValues.deviceNegative);
} catch (e) {
var temp = <Node>[];
temp.add(impactNormal);
CoreValues.deviceNegative[threatsImpact[0]] = temp;
//print(CoreValues.deviceNegative);
}
} else {
try {
CoreValues.userNegative[threatsImpact[0]]!.add(impactNormal);
//print(CoreValues.userNegative);
} catch (e) {
var temp = <Node>[];
temp.add(impactNormal);
CoreValues.userNegative[threatsImpact[0]] = temp;
//print(CoreValues.userNegative);
}
}
}
}
}
} catch (e) {
print(e);
continue;
}
}
}