Code coverage report for api/user/Participant.js

Statements: 40.91% (9 / 22)      Branches: 5.56% (1 / 18)      Functions: 50% (1 / 2)      Lines: 40.91% (9 / 22)      Ignored: none     

All files » api/user/ » Participant.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 561 1                   1 28 28   28 28     1                                                                     1  
var Speaker = require("./Speaker").Speaker;
var DEFAULT_CORPUS_MODEL = require("./../corpus/corpus.json");
 
/**
 * @class The Participant is a type of Speaker with any additional fields or metadata that a team might use to run their psycholinguistics analyses.
 *
 *
 * @name  Participant
 * @extends Speaker
 * @constructs
 */
var Participant = function Participant(options) {
  Eif (!this._fieldDBtype) {
    this._fieldDBtype = "Participant";
  }
  this.debug("Constructing Participant length: ", options);
  Speaker.apply(this, arguments);
};
 
Participant.prototype = Object.create(Speaker.prototype, /** @lends Participant.prototype */ {
  constructor: {
    value: Participant
  },
 
  api: {
    value: "participants"
  },
 
  defaults: {
    get: function() {
      var doc = {
        fields: []
      };
      try {
        if (this.application && this.application.corpus) {
          if (this.application.corpus.participantFields) {
            doc.fields = this.application.corpus.participantFields.clone();
          } else if (this.application.corpus.speakerFields) {
            doc.fields = this.application.corpus.speakerFields.clone();
          }
        }
      } catch (e) {
        this.warn("Cant get participant fields from the current corpus, instead using defaults.");
        doc.fields = DEFAULT_CORPUS_MODEL.participantFields || DEFAULT_CORPUS_MODEL.speakerFields;
      }
      if (!doc.fields || doc.fields.length === 0) {
        this.warn("There were no corpus specific speaker or participant fiels, instead using defaults");
        doc.fields = DEFAULT_CORPUS_MODEL.participantFields || DEFAULT_CORPUS_MODEL.speakerFields;
      }
      return JSON.parse(JSON.stringify(doc));
    }
  }
 
});
exports.Participant = Participant;