{"size": 1614, "ext": "js", "max_stars_repo_path": "src/modeles/partiesPrenantes.js", "max_stars_repo_name": "JBD75/mon-service-securise", "max_stars_repo_stars_event_min_datetime": "2021-07-27T08:22:13.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T05:57:54.000Z", "max_issues_repo_path": "src/modeles/partiesPrenantes.js", "max_issues_repo_name": "JBD75/mon-service-securise", "max_issues_repo_issues_event_min_datetime": "2021-11-03T14:02:02.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T13:48:10.000Z", "max_forks_repo_path": "src/modeles/partiesPrenantes.js", "max_forks_repo_name": "JBD75/mon-service-securise", "max_forks_repo_forks_event_min_datetime": "2021-11-02T11:11:09.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-03T13:23:29.000Z"}
{"max_stars_count": 2, "max_issues_count": 64, "max_forks_count": 16, "avg_line_length": 31.6470588235, "max_line_length": 99, "alphanum_fraction": 0.7342007435}
const InformationsHomologation = require('./informationsHomologation');

const descriptionPartiePrenante = (partiePrenante, fonction) => {
  const description = [];
  if (partiePrenante) {
    description.push(partiePrenante);
    description.push(fonction ? `(${fonction})` : '(fonction non renseignée)');
  }

  return description.length === 0 ? 'Information non renseignée' : description.join(' ');
};

class PartiesPrenantes extends InformationsHomologation {
  constructor(donneesPartiesPrenantes = {}) {
    super({
      proprietesAtomiquesRequises: [
        'autoriteHomologation',
        'fonctionAutoriteHomologation',
        'piloteProjet',
        'fonctionPiloteProjet',
        'expertCybersecurite',
        'fonctionExpertCybersecurite',
      ],
    });

    this.renseigneProprietes(donneesPartiesPrenantes);
  }

  descriptionEquipePreparation() {
    const membresEquipe = [];
    if (this.piloteProjet) membresEquipe.push(this.descriptionPiloteProjet());
    if (this.expertCybersecurite) membresEquipe.push(this.descriptionExpertCybersecurite());

    return membresEquipe.length === 0 ? 'Information non renseignée' : membresEquipe.join(', ');
  }

  descriptionAutoriteHomologation() {
    return descriptionPartiePrenante(this.autoriteHomologation, this.fonctionAutoriteHomologation);
  }

  descriptionPiloteProjet() {
    return descriptionPartiePrenante(this.piloteProjet, this.fonctionPiloteProjet);
  }

  descriptionExpertCybersecurite() {
    return descriptionPartiePrenante(this.expertCybersecurite, this.fonctionExpertCybersecurite);
  }
}

module.exports = PartiesPrenantes;
