Adds the to relation stack.

@param relationStack
the relation stack
@param entity
the entity
@param m
the m
762524
protected void addToRelationStack(Map<Object, Object> relationStack, Object entity, EntityMetadata m)
    {
        Object obj = entity;
        if (entity instanceof EnhanceEntity)
        {
            obj = ((EnhanceEntity) entity).getEntity();
        }
        relationStack.put(obj.getClass().getCanonicalName() + "#" + PropertyAccessorHelper.getId(obj, m), obj);

    }
544017
@SuppressWarnings("unchecked")
    private void addCallBackMethod(EntityMetadata metadata, Class<?> jpaAnnotation, CallbackMethod callbackMethod)
    {
        Map<Class<?>, List<? extends CallbackMethod>> callBackMethodsMap = metadata.getCallbackMethodsMap();
        List<CallbackMethod> list = (List<CallbackMethod>) callBackMethodsMap.get(jpaAnnotation);
        if (null == list)
        {
            list = new ArrayList<CallbackMethod>();
            callBackMethodsMap.put(jpaAnnotation, list);
        }
        list.add(callbackMethod);
    }
768370
public void addRelationshipToTarget(final Level level, final RelationshipType type) {
        final TargetRelationship relationship = new TargetRelationship(this, level, type);
        levelRelationships.add(relationship);
        relationships.add(relationship);
    }
1064307
@Override
  public void add(Entity entity) {
    if (entity == null) throw new IllegalArgumentException("Entity cannot be null");
    if (cachedAttributes == null)
      throw new MolgenisDataException(
          "The attribute names are not defined, call writeAttributeNames first");

    int i = 0;
    Row poiRow = sheet.createRow(row++);
    for (Attribute attribute : cachedAttributes) {
      Cell cell = poiRow.createCell(i++, CellType.STRING);
      cell.setCellValue(toValue(entity.get(attribute.getName())));
    }

    entity.getIdValue();
  }
885622
@Override
	public void put(Object entity) {
		if (entity == null) {
			throw new IllegalArgumentException("'entity' must not be [" + entity + "]");
		}
		
		if (operation != null) {
			throw new IllegalStateException("Log [" + operation + "] -> ["
					+ Log.Operation.PUT
					+ "] is not allowed: This operation must be first");
		}
		
		Key id = Keys.create(Translation.toKind(entity.getClass()), Entities.keyValue(entity));
		Entity e = datastore.get(local, id);
		
		if (e != null) {
			throw new EntityExistsException(id);
		}
		
		this.entity = entity;
		operation = Log.Operation.PUT;
	}
216246
public Object recursivelyFindEntities(Object entity, Map<String, Object> relationsMap, EntityMetadata m,
            PersistenceDelegator pd, boolean lazilyLoaded, Map<Object, Object> relationStack)
    {
        return handleAssociation(entity, relationsMap, m, pd, lazilyLoaded, relationStack);

    }
478216
public function build(Entity $entity): void
    {
        $attributes = $entity->getEntityAttributes();

        // We will manually add a relationship for every attribute registered
        // of this entity. Once we know the relation method we have to use,
        // we will just add it to the entityAttributeRelations property.
        foreach ($attributes as $attribute) {
            $relation = $this->getRelationClosure($entity, $attribute);

            $entity->setEntityAttributeRelation($attribute->getAttribute('slug'), $relation);
        }
    }
1116260
public static function setRelations($modelOne, $modelTwo, $relations): void
    {
        $name = [$modelOne, $modelTwo];
        sort($name);
        $name = implode(':', $name);
        // create record in static variable
        self::$relations[$name] = $relations;
    }
448562
public void setStacks(java.util.Collection<Stack> stacks) {
        if (stacks == null) {
            this.stacks = null;
            return;
        }

        this.stacks = new java.util.ArrayList<Stack>(stacks);
    }
718155
private E setRelationEntities(Object enhanceEntity, Client client, EntityMetadata m)
    {
        E result = null;
        if (enhanceEntity != null)
        {
            if (!(enhanceEntity instanceof EnhanceEntity))
            {
                enhanceEntity = new EnhanceEntity(enhanceEntity, PropertyAccessorHelper.getId(enhanceEntity, m), null);
            }

            EnhanceEntity ee = (EnhanceEntity) enhanceEntity;

            result = (E) client.getReader().recursivelyFindEntities(ee.getEntity(), ee.getRelations(), m,
                    persistenceDelegator, false, new HashMap<Object, Object>());
        }
        return result;
    }
68738
public function addRelation($relation)
    {
        $relations = $this->getRelations();
        array_push($relations, $relation);
        $this->setRelations($relations);
    }
302945
public void addCollectionColumnMetadata(CollectionColumnInfo collectionColumnMetadata)
    {
        if (this.collectionColumnMetadatas == null)
        {
            this.collectionColumnMetadatas = new ArrayList<CollectionColumnInfo>();
        }

        if (!collectionColumnMetadatas.contains(collectionColumnMetadata))
        {
            collectionColumnMetadatas.add(collectionColumnMetadata);
        }
    }
1227368
protected void addRelationsToThriftRow(EntityMetadata metadata, ThriftRow tf, List<RelationHolder> relations) {
        if (relations != null) {
            long timestamp = generator.getTimestamp();
            MetamodelImpl metaModel =
                (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(metadata.getPersistenceUnit());
            for (RelationHolder rh : relations) {
                String linkName = rh.getRelationName();
                Object linkValue = rh.getRelationValue();

                if (linkName != null && linkValue != null) {
                    if (metaModel.getEmbeddables(metadata.getEntityClazz()).isEmpty()) {
                        if (metadata.isCounterColumnType()) {
                            CounterColumn col = populateCounterFkey(linkName, linkValue);
                            tf.addCounterColumn(col);
                        } else {
                            Column col = populateFkey(linkName, linkValue, timestamp);
                            tf.addColumn(col);
                        }

                    } else {
                        if (metadata.isCounterColumnType()) {
                            CounterSuperColumn counterSuperColumn = new CounterSuperColumn();
                            counterSuperColumn.setName(linkName.getBytes());
                            CounterColumn column = populateCounterFkey(linkName, linkValue);
                            counterSuperColumn.addToColumns(column);
                            tf.addCounterSuperColumn(counterSuperColumn);
                        } else {
                            SuperColumn superColumn = new SuperColumn();
                            superColumn.setName(linkName.getBytes());
                            Column column = populateFkey(linkName, linkValue, timestamp);
                            superColumn.addToColumns(column);
                            tf.addSuperColumn(superColumn);
                        }
                    }
                }
            }
        }
    }
74030
private Object handleAssociation(final Object entity, final Map<String, Object> relationsMap,
            final EntityMetadata m, final PersistenceDelegator pd, boolean lazilyloaded,
            Map<Object, Object> relationStack)
    {

        for (Relation relation : m.getRelations())
        {
            if (relation != null)
            {
                ForeignKey relationType = relation.getType();

                Object relationalObject = PropertyAccessorHelper.getObject(entity, relation.getProperty());

                if (KunderaCoreUtils.isEmptyOrNull(relationalObject)
                        || ProxyHelper.isProxyOrCollection(relationalObject))
                {
                    onRelation(entity, relationsMap, m, pd, relation, relationType, lazilyloaded, relationStack);
                } // a bit of hack for neo4j only
                else if (!ProxyHelper.isProxyOrCollection(relationalObject)
                        && Map.class.isAssignableFrom(relationalObject.getClass()))
                {
                    Map relationalMap = (Map) relationalObject;
                    for (Map.Entry entry : (Set<Map.Entry>) relationalMap.entrySet())
                    {
                        Object entityObject = entry.getValue();
                        if (entityObject != null)
                        {
                            EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
                                    entityObject.getClass());
                            PersistenceCacheManager.addEntityToPersistenceCache(entityObject, pd,
                                    PropertyAccessorHelper.getId(entityObject, metadata));
                        }
                    }
                }
            }
        }
        return entity;
    }
769770
protected void computeEntityViaColumns(EntityMetadata m, boolean isRelation, List<String> relations,
        List<Object> entities, Map<ByteBuffer, List<Column>> qResults) {
        MetamodelImpl metaModel =
            (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());

        EntityType entityType = metaModel.entity(m.getEntityClazz());

        List<AbstractManagedType> subManagedType = ((AbstractManagedType) entityType).getSubManagedType();

        for (ByteBuffer key : qResults.keySet()) {
            onColumn(m, isRelation, relations, entities, qResults.get(key), subManagedType, key);
        }
    }
948921
def add(self, relation):
        
        cached = _CachedRelation(relation)
        logger.debug('Adding relation: {!s}'.format(cached))
        logger.debug('before adding: {}'.format(
            pprint.pformat(self.dump_graph()))
        )
        with self.lock:
            self._setdefault(cached)
        logger.debug('after adding: {}'.format(
            pprint.pformat(self.dump_graph()))
        )
928754
private void setRelationToEntity(Object entity, Object relationEntity, Relation relation)
    {
        if (relation.getTargetEntity().isAssignableFrom(getEntity(relationEntity).getClass()))
        {

            if (relation.isUnary())
            {
                PropertyAccessorHelper.set(entity, relation.getProperty(), getEntity(relationEntity));
            }
            else
            {
                Object associationObject = PropertyAccessorHelper.getObject(entity, relation.getProperty());
                if (associationObject == null || ProxyHelper.isProxyOrCollection(associationObject))
                {
                    associationObject = PropertyAccessorHelper.getCollectionInstance(relation.getProperty());
                    PropertyAccessorHelper.set(entity, relation.getProperty(), associationObject);
                }

                ((Collection) associationObject).add(getEntity(relationEntity));
            }
        }
    }