Finds the metadata associated with the given collection's first id property
 Remarks: This is used for single item lookup queries using the ID, e.g. Products(1), not complex primary keys

 @param [String] collection_name the name of the collection
18088
def find_id_metadata(collection_name)
    collection_data = @collections.fetch(collection_name)
    class_metadata = @class_metadata.fetch(collection_data[:type].to_s)
    key = class_metadata.select{|k,h| h.is_key }.collect{|k,h| h.name }[0]
    class_metadata[key]
  end
1187426
def collection_name(self, value):
        
        self._collection_name = value
        self.collection = self.db[value]
870391
def get_items(self, collection_uri):
        

        cname = os.path.split(collection_uri)[1]
        return self.search_metadata("collection_name:%s" % cname)
821876
def get_item_ids_metadata(self):
        """"""
        metadata = dict(self._item_ids_metadata)
        metadata.update({'existing_id_values': self.my_osid_object_form._my_map['itemIds']})
        return Metadata(**metadata)
250025
def get(self, key):
        """"""
        doc = self._collection.find_one({'_id': key})
        if doc:
            doc.pop('_id')
            return doc
1190159
def get_metadata(self, key, counter_id):
        
        with self._lock:
            metadata = self._metadata[key]
            try:
                return metadata[counter_id]
            except KeyError:
                raise MetadataNotFoundError("No metadata for counter id '{}' found in the cache.".format(counter_id))
346664
def related(self, collection_id):
        
        url = "/collections/%s/related" % collection_id
        result = self._get(url)
        return CollectionModel.parse_list(result)
720314
def object_model_name
        item = object

        is_collection = item.is_a?(Array)
        item = item.first if is_collection

        name = item.class.name.underscore

        name = name.pluralize if is_collection

        name.split("/").last
      end
1229206
def _check_existence_by_collection(self, container, item_name):
        '''
        '''

        coll = container.get_collection()
        for item in coll:
            if item.name == item_name:
                return True
        return False
156235
def get_collection(self, key=None, name=None):
        
        if name is not None:
            logger.warn("TowerTensorHandle.get_collection(name=..) was renamed to (key=..) !")
            key = name
        return self._ctx.get_collection_in_tower(key)
748267
def collection_attributes(*attrs)
      @collection_attributes ||= []
      if attrs.any?
        @collection_attributes.map!(&:to_sym).concat(attrs).uniq!
        @collection_attributes.each { |a| setup_collection(a) }
      end
      @collection_attributes
    end
1141547
def getColumnListForQuery( id, name )
      clistForQuery = nil
      if id
         query = lookupQuery( id )
      elsif name
         query = lookupQueryByName( name )
      end
      if query and query.elements["qyclst"]
         clistForQuery = query.elements["qyclst"].text.dup
      end
      clistForQuery
   end
69518
def get_collection_name(cls):
        '''
        
        '''
        if hasattr(cls, '_meta'):
            np = getattr(cls._meta, 'namespace', None)
            cname = getattr(cls._meta, 'name', None)
            if np:
                return '{}.{}'.format(np, cname or cls.__name__.lower())
        return cname or cls.__name__.lower()
847916
def _get_collection_item(collection_id, dataset_id):
    
    collection_item = db.DBSession.query(DatasetCollectionItem).\
            filter(DatasetCollectionItem.collection_id==collection_id,
                   DatasetCollectionItem.dataset_id==dataset_id).first()
    return collection_item
822155
def items_by_id(cls, ids, collection):
        
        col = cls.collection(collection)
        items = []
        base_url = urljoin(config.API_URL, 'collections/%s/items' % collection)
        for id in ids:
            try:
                items.append(Item(cls.query(urljoin(base_url, id))))
            except SatSearchError as err:
                pass
        return Items(items, collections=[col])
719700
def _find_matching_collections_externally(collections, record):
    
    index, doc_type = RecordIndexer().record_to_index(record)
    body = {"doc": record.dumps()}
    results = current_search_client.percolate(
        index=index,
        doc_type=doc_type,
        allow_no_indices=True,
        ignore_unavailable=True,
        body=body
    )
    prefix_len = len('collection-')
    for match in results['matches']:
        collection_name = match['_id']
        if collection_name.startswith('collection-'):
            name = collection_name[prefix_len:]
            if name in collections:
                yield collections[name]['ancestors']
    raise StopIteration
479816
def _get_collection(self, collection_name):
        
        try:
            return self._database[collection_name]
        except InvalidName as ex:
            raise DataSourceError("Cannot access MongoDB collection %s!"
                                  % collection_name) from ex
        except Exception as ex:
            raise DataSourceError("Unexpected error when accessing MongoDB"
                                  "collection %s!"
                                  % collection_name) from ex