Add Entity to a collection.
160845
def add_to_collection(self, request, pk=None):
        """"""
        entity = self.get_object()

        # TODO use `self.get_ids` (and elsewhere). Backwards
        # incompatible because raised error's response contains
        # ``detail`` instead of ``error``).
        if 'ids' not in request.data:
            return Response({"error": "`ids` parameter is required"}, status=status.HTTP_400_BAD_REQUEST)

        for collection_id in request.data['ids']:
            self._get_collection_for_user(collection_id, request.user)

        for collection_id in request.data['ids']:
            entity.collections.add(collection_id)

            collection = Collection.objects.get(pk=collection_id)
            for data in entity.data.all():
                collection.data.add(data)

        return Response()
1344602
def register_entity_to_group(self, entity, group):
        '''
        
        '''
        if entity in self._entities:
            if group in self._groups:
                self._groups[group].append(entity)
            else:
                self._groups[group] = [entity]
        else:
            raise UnmanagedEntityError(entity)
864722
def add_entity(self, domain, **kwargs):
        '''  '''

        # Set the entity's mapping func if one was specified
        map_func = kwargs.get('map_func', None)
        if map_func is not None and not callable(kwargs['map_func']):
            if self.entity_mapper is None:
                raise ValueError("Mapping function '%s' specified for Entity "
                                 "'%s', but no entity mapper was passed when "
                                 "initializing the current Layout. Please make"
                                 " sure the 'entity_mapper' argument is set." %
                                 (map_func, kwargs['name']))
            map_func = getattr(self.entity_mapper, kwargs['map_func'])
            kwargs['map_func'] = map_func

        ent = Entity(domain=domain, **kwargs)
        domain.add_entity(ent)

        if ent.mandatory:
            self.mandatory.add(ent.id)

        if ent.directory is not None:
            ent.directory = ent.directory.replace('{{root}}', self.root)

        self.entities[ent.id] = ent
        for alias in ent.aliases:
            self.entities[alias] = ent
        if self.dynamic_getters:
            func = partial(getattr(self, 'get'), target=ent.name,
                           return_type='id')
            func_name = inflect.engine().plural(ent.name)
            setattr(self, 'get_%s' % func_name, func)
110409
function collection(id) {
    if(!this.resource) {
      throw new Error('This Entity does not have a Resource.');
    }

    var path = this.resource.path + '/collections';

    return Resource.constructorFactory(path, EVT.Entity.Collection)
      .call(this.resource.scope, id);
  }
55442
function(entity, options) {
      options = options ? langx.clone(options) : {};
      var wait = options.wait;
      entity = this._prepareEntity(entity, options);
      if (!entity) return false;
      if (!wait) this.add(entity, options);
      var collection = this;
      var success = options.success;
      options.success = function(m, resp, callbackOpts) {
        if (wait) collection.add(m, callbackOpts);
        if (success) success.call(callbackOpts.context, m, resp, callbackOpts);
      };
      entity.save(null, options);
      return entity;
    }
410881
protected void addAssociatedEntitiesToDocument(EntityMetadata metadata, Object entity, Document document,
        MetamodelImpl metaModel) {
        try {
            IndexCollection indexes = metadata.getEntityClazz().getAnnotation(IndexCollection.class);
            if (indexes != null) {
                List<String> columnsNameToBeIndexed = new ArrayList<String>();
                for (com.impetus.kundera.index.Index indexedColumn : indexes.columns()) {
                    Attribute attrib = metaModel.getEntityAttribute(entity.getClass(), indexedColumn.name());
                    columnsNameToBeIndexed.add(((AbstractAttribute) attrib).getJPAColumnName());
                }

                String indexName = metadata.getIndexName();
                List<Relation> relations = metadata.getRelations();
                for (Relation relation : relations) {
                    if (relation.getType().equals(ForeignKey.MANY_TO_ONE)
                        || relation.getType().equals(ForeignKey.ONE_TO_ONE)) {
                        String propertyName = relation.getJoinColumnName(null);
                        if (propertyName != null && columnsNameToBeIndexed.contains(propertyName)) {
                            java.lang.reflect.Field property = relation.getProperty();
                            Object obj = PropertyAccessorHelper.getObject(entity, property);
                            if (obj != null) {
                                EntityMetadata relMetaData = metaModel.getEntityMetadata(obj.getClass());
                                Object id = PropertyAccessorHelper.getId(obj, relMetaData);
                                if (id != null) {
                                    Field luceneField =
                                        new Field(getCannonicalPropertyName(indexName, propertyName), id.toString(),
                                            Field.Store.YES, Field.Index.ANALYZED_NO_NORMS);

                                    document.add(luceneField);
                                } else {
                                    LOG.warn("value is null for field" + property.getName());
                                }
                            }
                        }
                    }
                }
            }
        } catch (PropertyAccessException e) {
            LOG.error("Error in accessing field, Caused by:" + e.getMessage());
            throw new LuceneIndexingException("Error in creating indexes on associated columns", e);
        }
    }
1345015
@SuppressWarnings("unchecked")
    public <T extends IEntity> T add(T entity) throws FMSException {

        IntuitMessage intuitMessage = prepareAdd(entity);

        //execute interceptors
        executeInterceptors(intuitMessage);

        return (T) retrieveEntity(intuitMessage);
    }
107921
public function add()
    {
        $this->request->allowMethod('post');

        $entity = $this->SavedSearches->newEntity();
        $entity = $this->SavedSearches->patchEntity($entity, (array)$this->request->getData());
        $success = (bool)$this->SavedSearches->save($entity);

        $this->set('success', $success);
        $success ?
            $this->set('data', ['id' => $entity->get('id')]) :
            $this->set('error', $entity->getErrors());
        $this->set('_serialize', ['success', 'data', 'error']);
    }
724658
public void insertDocIntoMongoDBCollection(String collection, String document) {

        DBObject dbObject = (DBObject) JSON.parse(document);
        this.dataBase.getCollection(collection).insert(dbObject);

    }
1138012
public function add()
    {

        foreach( func_get_args() as $obj ){

            if( is_object($obj) ) {

                if( $obj instanceof Container ) {

                    if( !$this->checkEntityContainer( $obj, $error ) ) {
                        throw new IncompatibleContainerException($error);
                    }

                    $this->collection = $this->collection + $obj->collection;

                    // if the passed container has a class and we don't, update ours
                    if( isset( $obj->class ) and !isset( $this->class ) ) {
                        $this->class = $obj->class;
                    }

                } elseif( $this->checkEntity( $obj ) ) {

                    $this->collection[spl_object_hash($obj)] = $obj;

                }

            } elseif( is_array( $obj ) ) {

                if( !$this->checkEntityArray( $obj, $error ) ) {
                    throw new IncompatibleContainerException($error);
                }

                foreach ( $obj as $key => $_obj ) {
                    $this->collection[spl_object_hash($_obj)] = $_obj;
                }

            } elseif( is_null( $obj ) ) {

                continue;

            } else {

                throw new BadTypeException( $obj, "Not suitable to go into container" );;

            }

        }

        $this->rewind();

        return $this;
    }
620443
def add_entity(self, entity):
        
        self._ensure_loaded()
        self.entities[str(entity)] = entity
1213853
def add_entity(self,entity):
        
        if self.entity_layer is None:
            self.entity_layer = Centities(type=self.type)
            self.root.append(self.entity_layer.get_node())
        self.entity_layer.add_entity(entity)
1017623
public function add($oEntity)
    {
        $this->checkClass($oEntity);
        $this->values[$oEntity->getCollectionIndex()] = $oEntity;

        return $this;
    }
739471
public function addEntity($entity)
    {
        $this->collection[] = $entity;
        $this->setCount(count($this->collection));

        return $this;
    }
148649
public function addCollection(Collection $collection)
    {
        $metadata = $collection->getDocumentMetadata();
        $this->collectionMapping[$metadata->getName()] = $collection;
    }
1085797
def add_annotation(self, entity, annotation, value):
        '''  '''
        url = self.base_path + 'term/add-annotation'
        data = {'tid': entity['id'],
                'annotation_tid': annotation['id'],
                'value': value,
                'term_version': entity['version'],
                'annotation_term_version': annotation['version']}
        return self.post(url, data)
595531
public void addEntity(String alias, String entityName) {
    EntityType entityType = Model.getType(entityName);
    if (null == entityType) { throw new RuntimeException("cannot find entity type for " + entityName); }
    entityTypes.put(alias, entityType);
  }