getRecommendations property

Future<List<GeigerRecommendation>> getRecommendations

from return list of recommendations from localStorage

Implementation

Future<List<GeigerRecommendation>> get getRecommendations async {
  List<Recommendations> r = [];
  List<GeigerRecommendation> gR = [];
  _node = await _storageController.get(":Global:recommendations");
  print(_node);
  for (String recId
      in await _node!.getChildNodesCsv().then((value) => value.split(','))) {
    Node recNode =
        await _storageController.get(":Global:recommendations:$recId");
    print(recNode);
    String json = await recNode
        .getValue("relatedThreat")
        .then((value) => value!.getValue("en")!);

    List<Threat> threats = Threat.convertFromJson(json);
    r.add(Recommendations(
      recommendationId: recId,
      recommendationType: await recNode
          .getValue("recommendationType")
          .then((value) => value!.getValue("en")!),
      description: DescriptionShortLong(
          shortDescription: await recNode
              .getValue("short")
              .then((value) => value!.getValue("en")!),
          longDescription: await recNode
              .getValue("long")
              .then((value) => value!.getValue("en")!)),
    ));
    for (Threat threat in threats) {
      gR.add(GeigerRecommendation(threat: threat, recommendations: r));
    }
  }
  return gR;
}