function publishSample(sampleInst, subjectModel, event, aspectModel) {
  if (sampleInst.hasOwnProperty('noChange') && sampleInst.noChange === true) {
    return publishSampleNoChange(sampleInst);
  }

  const eventType = event || getSampleEventType(sampleInst);
  let prom;

  // No need to attachAspectSubject if subject and aspect are already attached
  if (sampleInst.hasOwnProperty('subject') &&
    sampleInst.hasOwnProperty('aspect')) {
    prom = Promise.resolve(sampleInst);
  } else {
    prom = rtUtils.attachAspectSubject(sampleInst, subjectModel, aspectModel);
  }

  return prom
    .then((sample) => {
      if (sample) {
        sample.absolutePath = sample.subject.absolutePath; // reqd for filtering
        publishObject(sample, eventType);
        return sample;
      }
    })
    .catch((err) => {
      // Any failure on publish sample must not stop the next promise.
      logger.error('Error to publish sample - ' + err);
      return Promise.resolve();
    });
} // publishSample
/**
 * The sample object needs to be attached its subject object and it also needs
 * a absolutePath field added to it before the sample is published to the redis
 * channel.
 *
 * @param  {Object} sampleInst - The sample instance to be published
 * @param  {Model} subjectModel - The subject model to get the related
 *  subject instance
 * @param  {String} event  - Type of the event that is being published
 * @param  {Model} aspectModel  - The aspect model to get the related
 *  aspect instance
 * @returns {Promise} - which resolves to a sample object
 */
The sample object needs to be attached its subject object and it also needs
a absolutePath field added to it before the sample is published to the redis
channel.


The sample object needs to be attached its subject object and it also needs a absolutePath field added to it before the sample is published to the redis channel .
function publishSample(sampleInst, subjectModel, event, aspectModel) {
  if (sampleInst.hasOwnProperty('noChange') && sampleInst.noChange === true) {
    return publishSampleNoChange(sampleInst);
  }
  const eventType = event || getSampleEventType(sampleInst);
  let prom;
  if (sampleInst.hasOwnProperty('subject') &&
    sampleInst.hasOwnProperty('aspect')) {
    prom = Promise.resolve(sampleInst);
  } else {
    prom = rtUtils.attachAspectSubject(sampleInst, subjectModel, aspectModel);
  }
  return prom
    .then((sample) => {
      if (sample) {
        sample.absolutePath = sample.subject.absolutePath; 
        publishObject(sample, eventType);
        return sample;
      }
    })
    .catch((err) => {
      logger.error('Error to publish sample - ' + err);
      return Promise.resolve();
    });
} 
function publishSample ( sampleInst , subjectModel , event , aspectModel ) { if ( sampleInst . hasOwnProperty ( 'noChange' ) && sampleInst . noChange === true ) { return publishSampleNoChange ( sampleInst ) ; } const eventType = event || getSampleEventType ( sampleInst ) ; let prom ; if ( sampleInst . hasOwnProperty ( 'subject' ) && sampleInst . hasOwnProperty ( 'aspect' ) ) { prom = Promise . resolve ( sampleInst ) ; } else { prom = rtUtils . attachAspectSubject ( sampleInst , subjectModel , aspectModel ) ; } return prom . then ( ( sample ) => { if ( sample ) { sample . absolutePath = sample . subject . absolutePath ; publishObject ( sample , eventType ) ; return sample ; } } ) . catch ( ( err ) => { logger . error ( 'Error to publish sample - ' + err ) ; return Promise . resolve ( ) ; } ) ; }
The sample object needs to be attached its subject object and it also needs
 a absolutePath field added to it before the sample is published to the redis
 channel.
The sample object needs to be attached its subject object and it also needs a absolutePath field added to it before the sample is published to the redis channel .
// No need to attachAspectSubject if subject and aspect are already attached // reqd for filtering // Any failure on publish sample must not stop the next promise. // publishSample