runIndicator function

Future runIndicator(
  1. dynamic indicatorID,
  2. dynamic loggerLevel
)

Implementation

Future runIndicator(var indicatorID, var loggerLevel) async {

  ///Set logging level
  ///info  - normal information
  ///debug - investigate errors
  loggerLevel != 'debug'? Logger.level = Level.info : Logger.level = Level.debug;
  logger.i("loggerLevel =>"+ Logger.level.toString());

  ///Initialization
  await Storage().initStorageController();
  Storage().setIndicatorUUID = indicatorID;
  logger.i("indicator ID =>"+ Storage.geigerIndicatorUUID);

  ///Check current user, device UUID
  await getCurrentUUID();

  ///Parsing ':Global:threats' Node
  ///Normal threats -> GEIGER threats (12)
  ///GEIGER threats (12) defined by CERT
  await generateThreats();

  ///Prepare metrics about company profile(type) => (based, enabler, dependent)
  ///':Global:profiles'
  await getProfiles();

  ///Prepare metrics about recommendation each threat
  ///':Global:Recommendation'
  await getRecommendation();

  ///check indicator score nodes whether exist or not
  ///if does not exist, create indicator score nodes (user, device, aggregate, MSE)
  await checkExistNodes();

  ///To check exist metric data - when application run multiple time
  ///plugin UUID required to get metric data from Storage
  logger.d('Check Plugin Information => ${await Storage.controller.dump(':Devices:${Storage.deviceUUID}')}');
  await getSensorDataPath();

  ///Set the trigger to get data for calculation using Local Storage Listener
  await setValueListener();


///geiger User Risk Score
  ///Get exist user metrics from Local Data Storage
  await getExistMetrics(Types.users);
  ///Update geiger user risk score
  await updateScoreNode(Types.userScoreNodePath, Types.geigerScoreUser,Types.users);
  ///Update geiger user recommendations
  await updateRecommendationNode(Types.userScoreNodePath,Types.recommendations,Types.users);

///geiger Device Risk Score
  ///Get exist device metrics from Local Data Storage
  await getExistMetrics(Types.devices);
  ///Update geiger device risk score
  await updateScoreNode(Types.deviceScoreNodePath, Types.geigerScoreDevice,Types.devices);
  ///Update geiger device recommendations
  await updateRecommendationNode(Types.deviceScoreNodePath,Types.recommendations,Types.devices);

///geiger Aggregate Risk Score (total risk score)
  ///(Current User score {1} + Current Device score {1} + Paired Aggregate Score of devices {0...*})
  ///Prepare latest current user, device risk score and paired device
  await getScoreAll();
  ///Calculate aggregate risk score refer prepared metrics
  await crtAggregateScore();
  ///Update geiger aggregate risk score (total score)
  await updateScoreNode(Types.userScoreNodePath, Types.geigerScoreAggregate,Types.users);

///geiger SME Risk Score (company risk score)
  ///(Current User score {1} + Current Device score {1} + Paired Aggregate Score of employees {0...*})
  ///Prepare latest paired employee risk score
  ///it only works when current user is CEO
  await getEmployeesSharedScore();

  ///Calculate aggregate risk score refer prepared metrics
  await crtAggregateScore();

  ///Update geiger MSE score
  ///it also only works when current user is CEO
  await updateScoreMSENode();

}