extensions/xnat/src/components/XNATContourImportMenu/XNATContourImportMenu.js
/**
   * componentDidMount - On mounting, fetch a list of available ROICollections from XNAT.
   *
   * @returns {type}  description
   */
On mounting, fetch a list of available ROICollections from XNAT.
@returns {type}  description
On mounting fetch a list of available ROICollections from XNAT . @returns { type } description
componentDidMount() {
    const sessions = sessionMap.getSession();
    this._subjectId = sessionMap.getSubject();
    this._projectId = sessionMap.getProject();
    const promises = [];
    for (let i = 0; i < sessions.length; i++) {
      const experimentId = sessions[i].experimentId;
      const cancelablePromise = fetchJSON(
        `data/archive/projects/${this._projectId}/subjects/${this._subjectId}/experiments/${experimentId}/assessors?format=json`
      );
      promises.push(cancelablePromise.promise);
      this._cancelablePromises.push(cancelablePromise);
    }
    this._volumeManagementLabels = this._getVolumeManagementLabels();
    Promise.all(promises).then(sessionAssessorLists => {
      const roiCollectionPromises = [];
      for (let i = 0; i < sessionAssessorLists.length; i++) {
        const sessionAssessorList = sessionAssessorLists[i];
        const assessors = sessionAssessorList.ResultSet.Result;
        if (
          !assessors.some(
            assessor => assessor.xsiType === 'icr:roiCollectionData'
          )
        ) {
          continue;
        }
        const experimentId = assessors[0].session_ID;
        for (let i = 0; i < assessors.length; i++) {
          if (assessors[i].xsiType === 'icr:roiCollectionData') {
            const cancelablePromise = fetchJSON(
              `data/archive/projects/${this._projectId}/subjects/${this._subjectId}/experiments/${experimentId}/assessors/${assessors[i].ID}?format=json`
            );
            this._cancelablePromises.push(cancelablePromise);
            roiCollectionPromises.push(cancelablePromise.promise);
          }
        }
      }
      if (!roiCollectionPromises.length) {
        this.setState({ importListReady: true });
        return;
      }
      const importList = [];
      Promise.all(roiCollectionPromises).then(promisesJSON => {
        promisesJSON.forEach(roiCollectionInfo => {
          const data_fields = roiCollectionInfo.items[0].data_fields;
          const referencedScan = this._getReferencedScan(roiCollectionInfo);
          if (
            referencedScan &&
            this._collectionEligibleForImport(roiCollectionInfo)
          ) {
            importList.push({
              collectionType: data_fields.collectionType,
              label: data_fields.label,
              experimentId: data_fields.imageSession_ID,
              experimentLabel: referencedScan.experimentLabel,
              referencedSeriesInstanceUid: referencedScan.seriesInstanceUid,
              referencedSeriesNumber: referencedScan.seriesNumber,
              name: data_fields.name,
              date: data_fields.date,
              time: data_fields.time,
              getFilesUri: `data/archive/experiments/${data_fields.imageSession_ID}/assessors/${data_fields.ID}/files?format=json`,
            });
          }
        });
        const selectedCheckboxes = [];
        for (let i = 0; i < importList.length; i++) {
          selectedCheckboxes.push(true);
        }
        this.setState({
          importList,
          importListReady: true,
          selectedCheckboxes,
        });
      });
    });
  }
componentDidMount ( ) { const sessions = sessionMap . getSession ( ) ; this . _subjectId = sessionMap . getSubject ( ) ; this . _projectId = sessionMap . getProject ( ) ; const promises = [ ] ; for ( let i = 0 ; i < sessions . length ; i ++ ) { const experimentId = sessions [ i ] . experimentId ; const cancelablePromise = fetchJSON ( ` ${ this . _projectId } ${ this . _subjectId } ${ experimentId } ` ) ; promises . push ( cancelablePromise . promise ) ; this . _cancelablePromises . push ( cancelablePromise ) ; } this . _volumeManagementLabels = this . _getVolumeManagementLabels ( ) ; Promise . all ( promises ) . then ( sessionAssessorLists => { const roiCollectionPromises = [ ] ; for ( let i = 0 ; i < sessionAssessorLists . length ; i ++ ) { const sessionAssessorList = sessionAssessorLists [ i ] ; const assessors = sessionAssessorList . ResultSet . Result ; if ( ! assessors . some ( assessor => assessor . xsiType === 'icr:roiCollectionData' ) ) { continue ; } const experimentId = assessors [ 0 ] . session_ID ; for ( let i = 0 ; i < assessors . length ; i ++ ) { if ( assessors [ i ] . xsiType === 'icr:roiCollectionData' ) { const cancelablePromise = fetchJSON ( ` ${ this . _projectId } ${ this . _subjectId } ${ experimentId } ${ assessors [ i ] . ID } ` ) ; this . _cancelablePromises . push ( cancelablePromise ) ; roiCollectionPromises . push ( cancelablePromise . promise ) ; } } } if ( ! roiCollectionPromises . length ) { this . setState ( { importListReady : true } ) ; return ; } const importList = [ ] ; Promise . all ( roiCollectionPromises ) . then ( promisesJSON => { promisesJSON . forEach ( roiCollectionInfo => { const data_fields = roiCollectionInfo . items [ 0 ] . data_fields ; const referencedScan = this . _getReferencedScan ( roiCollectionInfo ) ; if ( referencedScan && this . _collectionEligibleForImport ( roiCollectionInfo ) ) { importList . push ( { collectionType : data_fields . collectionType , label : data_fields . label , experimentId : data_fields . imageSession_ID , experimentLabel : referencedScan . experimentLabel , referencedSeriesInstanceUid : referencedScan . seriesInstanceUid , referencedSeriesNumber : referencedScan . seriesNumber , name : data_fields . name , date : data_fields . date , time : data_fields . time , getFilesUri : ` ${ data_fields . imageSession_ID } ${ data_fields . ID } ` , } ) ; } } ) ; const selectedCheckboxes = [ ] ; for ( let i = 0 ; i < importList . length ; i ++ ) { selectedCheckboxes . push ( true ) ; } this . setState ( { importList , importListReady : true , selectedCheckboxes , } ) ; } ) ; } ) ; }
componentDidMount - On mounting, fetch a list of available ROICollections from XNAT.
componentDidMount - On mounting fetch a list of available ROICollections from XNAT .
//ToDo: do we need this? // if (this.props.id === 'NOT_ACTIVE') { //   this.setState({ importListReady: true }); //   return; // }