def mergeGlobal(self, ch, ids, mergetype, res):

    # get the size of the image and cube
    resolution = int(res)
    # ID to merge annotations into 
    mergeid = ids[0]
    
    # Turned off for now( Will's request)
    #if len(self.annoIdx.getIndex(int(mergeid),resolution)) == 0:
    #  raise OCPCAError(ids[0] + " not a valid annotation id. This id does not have paint data")
  
    # Get the list of cubeindexes for the Ramon objects
    listofidxs = set()
    addindex = []
    # RB!!!! do this for all ids, promoting the exceptions of the merge id
    for annid in ids:
      if annid == mergeid:
        continue
      # Get the Annotation index for that id
      curindex = self.annoIdx.getIndex(ch, annid,resolution)
      # Final list of index which has to be updated in idx table
      addindex = np.union1d(addindex,curindex)
      # Merge the annotations in the cubes for the current id
      listofidxs = set(curindex)
      for key in listofidxs:
        cube = self.getCube (ch, key,resolution)
        if ch.getExceptions() == EXCEPTION_TRUE:
          oldexlist = self.getExceptions( ch, key, resolution, annid ) 
          self.kvio.deleteExceptions ( ch, key, resolution, annid )
        #
        # RB!!!!! this next line is wrong!  the problem is that
        #  we are merging all annotations.  So at the end, there
        #  need to be no exceptions left.  This line will leave
        #  exceptions with the same value as the annotation.
        #  Just delete the exceptions
        #
        # Ctype optimized version for mergeCube
        ocplib.mergeCube_ctype ( cube.data, mergeid, annid )
        self.putCube ( ch, key, resolution, cube )
        
      # Delete annotation and all it's meta data from the database
      #
      # RB!!!!! except for the merge annotation
      if annid != mergeid:
        try:
          # reordered because paint data no longer exists
          #KL TODO Merge for all resolutions and then delete for all of them.
          self.annoIdx.deleteIndexResolution(ch, annid,resolution)
          #self.annoIdx.deleteIndex(annid,resolution)
          self.deleteAnnotation (ch, annid, '' )
        except:
          logger.warning("Failed to delete annotation {} during merge.".format(annid))
    self.annoIdx.updateIndex(ch, mergeid,addindex,resolution)     
    self.kvio.commit()
    
    return "Merged Id's {} into {}".format(ids, mergeid)
Global merge routine.  Converts a list of ids into the merge id at a given resolution.
dataset/ETHPy150Open neurodata/ndstore/ocpca/ocpcadb.py/OCPCADB.mergeGlobal