function removeRelatedSamples(subject, seq) {
  let samples = [];
  return redisOps.deleteSampleKeys(subAspMapType, subject.absolutePath)
  .then((_samples) => {
    samples = _samples;

    // get aspects from subaspmap mapping for this subject
    return redisOps.executeCommand(
      redisOps.getSubjAspMapMembers(subject.absolutePath));
  })
  .then((aspectNames) => redisOps.executeBatchCmds(
    redisOps.deleteSubjectFromAspectResourceMaps(
      aspectNames, subject.absolutePath)))
  .then(() => redisOps.deleteKey(subAspMapType, subject.absolutePath))
  .then(() => {
    const promises = [];

    // publish the samples only if the sequelize object seq is available
    if (seq && samples.length) {
      samples.forEach((sample) => {
        /*
         * publishSample attaches the subject and the aspect by fetching it
         * either from the database or redis. Deleted subject will not be found
         * when called from the afterDelete and afterUpdate hookes. So, attach
         * the subject here before publishing the sample.
         */
        if (sample) {
          sample.subject = subject;
          promises.push(publishSample(sample, null, sampleEvent.del,
            seq.models.Aspect));
        }
      });
    }

    return Promise.all(promises);
  });
} // removeRelatedSamples
/**
 * Deletes all the sample entries related to a subject. The sample delete events
 * are also sent. The following are deleted
 * 1. subject from aspect to subject mappings
 * 2. subject to aspect mapping -> samsto:subaspmap:absolutePath
 * 3. sample entry in samsto:samples (samsto:samples:oldAbsPath|*)
 * 4. sample hash samsto:samples:oldAbsPath|*
 * @param {Object} subject - The subject object
 * @param {Object} seq - The sequelize object
 * @returns {Promise} which resolves to the deleted samples.
 */
Deletes all the sample entries related to a subject. The sample delete events
are also sent. The following are deleted
1. subject from aspect to subject mappings
2. subject to aspect mapping -> samsto:subaspmap:absolutePath
3. sample entry in samsto:samples (samsto:samples:oldAbsPath|*)
4. sample hash samsto:samples:oldAbsPath|
@param {Object} subject - The subject object
@param {Object} seq - The sequelize object
@returns {Promise} which resolves to the deleted samples.
Deletes all the sample entries related to a subject . The sample delete events are also sent . The following are deleted 1 . subject from aspect to subject mappings 2 . subject to aspect mapping - > samsto : subaspmap : absolutePath 3 . sample entry in samsto : samples ( samsto : samples : oldAbsPath| * ) 4 . sample hash samsto : samples : oldAbsPath| @param { Object } subject - The subject object @param { Object } seq - The sequelize object @returns { Promise } which resolves to the deleted samples .
function removeRelatedSamples(subject, seq) {
  let samples = [];
  return redisOps.deleteSampleKeys(subAspMapType, subject.absolutePath)
  .then((_samples) => {
    samples = _samples;
    return redisOps.executeCommand(
      redisOps.getSubjAspMapMembers(subject.absolutePath));
  })
  .then((aspectNames) => redisOps.executeBatchCmds(
    redisOps.deleteSubjectFromAspectResourceMaps(
      aspectNames, subject.absolutePath)))
  .then(() => redisOps.deleteKey(subAspMapType, subject.absolutePath))
  .then(() => {
    const promises = [];
    if (seq && samples.length) {
      samples.forEach((sample) => {
        if (sample) {
          sample.subject = subject;
          promises.push(publishSample(sample, null, sampleEvent.del,
            seq.models.Aspect));
        }
      });
    }
    return Promise.all(promises);
  });
} 
function removeRelatedSamples ( subject , seq ) { let samples = [ ] ; return redisOps . deleteSampleKeys ( subAspMapType , subject . absolutePath ) . then ( ( _samples ) => { samples = _samples ; return redisOps . executeCommand ( redisOps . getSubjAspMapMembers ( subject . absolutePath ) ) ; } ) . then ( ( aspectNames ) => redisOps . executeBatchCmds ( redisOps . deleteSubjectFromAspectResourceMaps ( aspectNames , subject . absolutePath ) ) ) . then ( ( ) => redisOps . deleteKey ( subAspMapType , subject . absolutePath ) ) . then ( ( ) => { const promises = [ ] ; if ( seq && samples . length ) { samples . forEach ( ( sample ) => { if ( sample ) { sample . subject = subject ; promises . push ( publishSample ( sample , null , sampleEvent . del , seq . models . Aspect ) ) ; } } ) ; } return Promise . all ( promises ) ; } ) ; }
Deletes all the sample entries related to a subject.
Deletes all the sample entries related to a subject .
// get aspects from subaspmap mapping for this subject // publish the samples only if the sequelize object seq is available /*
         * publishSample attaches the subject and the aspect by fetching it
         * either from the database or redis. Deleted subject will not be found
         * when called from the afterDelete and afterUpdate hookes. So, attach
         * the subject here before publishing the sample.
         */ // removeRelatedSamples