deleteSample(sampleName, userName) {
    const cmds = [];
    let parsedSampleName = {};
    try {
      parsedSampleName = parseName(sampleName.toLowerCase());
    } catch (err) {
      return Promise.reject(err);
    }

    const subjAbsPath = parsedSampleName.subject.absolutePath;
    const aspName = parsedSampleName.aspect.name;
    let sampObjToReturn;
    let aspect;
    return redisOps.getHashPromise(sampleType, sampleName)
    .then((sampleObj) => {
      if (!sampleObj) {
        throw new redisErrors.ResourceNotFoundError({
          explanation: 'Sample not found.',
        });
      }

      sampObjToReturn = sampleObj;

      cmds.push(redisOps.getHashCmd(aspectType, aspName));

      // get the aspect to attach it to the sample
      return redisOps.getHashPromise(aspectType, aspName);
    })
    .then((aspObj) => {
      if (!aspObj) {
        throw new redisErrors.ResourceNotFoundError({
          explanation: 'Aspect not found.',
        });
      }

      aspect = sampleStore.arrayObjsStringsToJson(
        aspObj, constants.fieldsToStringify.aspect
      );

      return checkWritePermission(aspect, userName);
    })

    /*
     * Set up and execute the commands to:
     * (1) delete the sample entry from the master list of sample index,
     * (2) delete the aspect from the subAspMap,
     * (3) delete the subject from aspect-to-subject mapping
     * (4) delete the sample hash.
     */
    .then(() => {
      cmds.push(redisOps.delKeyFromIndexCmd(sampleType, sampleName));
      cmds.push(redisOps.delAspFromSubjSetCmd(subjAbsPath, aspName));
      cmds.push(redisOps.delSubFromAspSetCmd(aspName, subjAbsPath));
      cmds.push(redisOps.delHashCmd(sampleType, sampleName));
      return redisOps.executeBatchCmds(cmds);
    })
    .then(() => redisOps.executeBatchCmds(cmds))

    /* Attach aspect and links to sample. */
    .then(() => cleanAddAspectToSample(sampObjToReturn, aspect));
  }
/**
   * Delete sample. Get sample. If found, get aspect, delete sample entry from
   * sample index, delete aspect from subject set and delete sample hash. If
   * sample not found, throw Not found error.
   * @param  {String} sampleName - Sample name
   * @param {String} userName - The user performing the write operation
   * @returns {Promise} - Resolves to a sample object
   */
Delete sample. Get sample. If found, get aspect, delete sample entry from
sample index, delete aspect from subject set and delete sample hash. If
sample not found, throw Not found error.
@param  {String} sampleName - Sample name
@param {String} userName - The user performing the write operation
@returns {Promise} - Resolves to a sample object
Delete sample . Get sample . If found get aspect delete sample entry from sample index delete aspect from subject set and delete sample hash . If sample not found throw Not found error . @param { String } sampleName - Sample name @param { String } userName - The user performing the write operation @returns { Promise } - Resolves to a sample object
deleteSample(sampleName, userName) {
    const cmds = [];
    let parsedSampleName = {};
    try {
      parsedSampleName = parseName(sampleName.toLowerCase());
    } catch (err) {
      return Promise.reject(err);
    }
    const subjAbsPath = parsedSampleName.subject.absolutePath;
    const aspName = parsedSampleName.aspect.name;
    let sampObjToReturn;
    let aspect;
    return redisOps.getHashPromise(sampleType, sampleName)
    .then((sampleObj) => {
      if (!sampleObj) {
        throw new redisErrors.ResourceNotFoundError({
          explanation: 'Sample not found.',
        });
      }
      sampObjToReturn = sampleObj;
      cmds.push(redisOps.getHashCmd(aspectType, aspName));
      return redisOps.getHashPromise(aspectType, aspName);
    })
    .then((aspObj) => {
      if (!aspObj) {
        throw new redisErrors.ResourceNotFoundError({
          explanation: 'Aspect not found.',
        });
      }
      aspect = sampleStore.arrayObjsStringsToJson(
        aspObj, constants.fieldsToStringify.aspect
      );
      return checkWritePermission(aspect, userName);
    })
    .then(() => {
      cmds.push(redisOps.delKeyFromIndexCmd(sampleType, sampleName));
      cmds.push(redisOps.delAspFromSubjSetCmd(subjAbsPath, aspName));
      cmds.push(redisOps.delSubFromAspSetCmd(aspName, subjAbsPath));
      cmds.push(redisOps.delHashCmd(sampleType, sampleName));
      return redisOps.executeBatchCmds(cmds);
    })
    .then(() => redisOps.executeBatchCmds(cmds))
    .then(() => cleanAddAspectToSample(sampObjToReturn, aspect));
  }
deleteSample ( sampleName , userName ) { const cmds = [ ] ; let parsedSampleName = { } ; try { parsedSampleName = parseName ( sampleName . toLowerCase ( ) ) ; } catch ( err ) { return Promise . reject ( err ) ; } const subjAbsPath = parsedSampleName . subject . absolutePath ; const aspName = parsedSampleName . aspect . name ; let sampObjToReturn ; let aspect ; return redisOps . getHashPromise ( sampleType , sampleName ) . then ( ( sampleObj ) => { if ( ! sampleObj ) { throw new redisErrors . ResourceNotFoundError ( { explanation : 'Sample not found.' , } ) ; } sampObjToReturn = sampleObj ; cmds . push ( redisOps . getHashCmd ( aspectType , aspName ) ) ; return redisOps . getHashPromise ( aspectType , aspName ) ; } ) . then ( ( aspObj ) => { if ( ! aspObj ) { throw new redisErrors . ResourceNotFoundError ( { explanation : 'Aspect not found.' , } ) ; } aspect = sampleStore . arrayObjsStringsToJson ( aspObj , constants . fieldsToStringify . aspect ) ; return checkWritePermission ( aspect , userName ) ; } ) . then ( ( ) => { cmds . push ( redisOps . delKeyFromIndexCmd ( sampleType , sampleName ) ) ; cmds . push ( redisOps . delAspFromSubjSetCmd ( subjAbsPath , aspName ) ) ; cmds . push ( redisOps . delSubFromAspSetCmd ( aspName , subjAbsPath ) ) ; cmds . push ( redisOps . delHashCmd ( sampleType , sampleName ) ) ; return redisOps . executeBatchCmds ( cmds ) ; } ) . then ( ( ) => redisOps . executeBatchCmds ( cmds ) ) . then ( ( ) => cleanAddAspectToSample ( sampObjToReturn , aspect ) ) ; }
Delete sample.
Delete sample .
// get the aspect to attach it to the sample /*
     * Set up and execute the commands to:
     * (1) delete the sample entry from the master list of sample index,
     * (2) delete the aspect from the subAspMap,
     * (3) delete the subject from aspect-to-subject mapping
     * (4) delete the sample hash.
     */ /* Attach aspect and links to sample. */