Sets relation has one

@param mixed $id
@param JSONSimpleStorage $object
@param mixed $foreignId
185068
public function hasOne($id, JSONSimpleStorage $object, $foreignId) {
        // init one filed
        if (!isset($this->one[$id])) {
            $this->one[$id] = [];
        }
        
        // init many field
        if (!isset($object->many[$foreignId])) {
            $object->many[$foreignId] = [];
            $object->many[$foreignId][$this->class] = [];
        } else if (!isset($object->many[$foreignId][$this->class])) {
            $object->many[$foreignId][$this->class] = [];
        }
        
        // set fields
        $this->one[$id][$object->class] = $foreignId;
        if (!in_array($id, $object->many[$foreignId][$this->class])) {
            $object->many[$foreignId][$this->class][] = $id;
        }
        
        // set dirty objects
        self::$dirty[$object->class] = true;
        self::$dirty[$this->class] = true;
    }
1284089
public function setId($parameterIndex, ObjectIdInterface $id)
    {
        $this->setParameter($parameterIndex, $this->escape($id->getId()));
    }
900931
public function setMultipleOfId($id, $relatedId) {
		// find
		$model = $this->get($id);

		if ($model === null) {
			return new NotFound(['message' => 'Skill not found.']);
		}

		// update
		if ($this->doSetMultipleOfId($model, $relatedId)) {
			$this->dispatch(SkillEvent::PRE_MULTIPLE_OF_UPDATE, $model);
			$this->dispatch(SkillEvent::PRE_SAVE, $model);
			$model->save();
			$this->dispatch(SkillEvent::POST_MULTIPLE_OF_UPDATE, $model);
			$this->dispatch(SkillEvent::POST_SAVE, $model);

			return Updated(['model' => $model]);
		}

		return NotUpdated(['model' => $model]);
	}
932808
public function set($id, $value)
    {
        $id = (string) $id;

        $this->validateSet($id);

        if ($type = $this->isDefined($id)) {
            if ($type[0] == ':') {
                $type = substr($type, 1);
                $actualType = $this->getType($value);
                if ($actualType != $type) {
                    throw new WrongTypeException(sprintf('Value for item "%s" in %s container must be of type %s, but %s given.', $id, $this->name, $type, $actualType));
                }
            } else {
                if (!$value instanceof $type) {
                    throw new WrongTypeException(sprintf('Value for item "%s" in %s container must be an instance of %s class, but %s given.', $id, $this->name, $type, $this->getType($value)));
                }
            }
        }

        $this->items[$id] = $value;
    }
166972
public function setSkillId($id, $relatedId) {
		// find
		$model = $this->get($id);

		if ($model === null) {
			return new NotFound(['message' => 'Position not found.']);
		}

		// update
		if ($this->doSetSkillId($model, $relatedId)) {
			$this->dispatch(PositionEvent::PRE_SKILL_UPDATE, $model);
			$this->dispatch(PositionEvent::PRE_SAVE, $model);
			$model->save();
			$this->dispatch(PositionEvent::POST_SKILL_UPDATE, $model);
			$this->dispatch(PositionEvent::POST_SAVE, $model);

			return Updated(['model' => $model]);
		}

		return NotUpdated(['model' => $model]);
	}
178231
protected function duplicateHasOneRelation($sourceObject, $destinationObject, $relation)
    {
        // Check if original object exists
        $item = $sourceObject->getComponent($relation);
        if (!$item->isInDB()) {
            return;
        }

        $clonedItem = $item->duplicate(false);
        $destinationObject->setComponent($relation, $clonedItem);
    }
1078266
public void addObjectId( Object object, ObjectIdSerializer<?> id ) {
        if ( null == mapObjectId ) {
            if ( useEqualityForObjectId ) {
                mapObjectId = new HashMap<Object, ObjectIdSerializer<?>>();
            } else {
                mapObjectId = new IdentityHashMap<Object, ObjectIdSerializer<?>>();
            }
        }
        mapObjectId.put( object, id );
    }
983121
public static function relation($local, $foreign)
    {
        $relations = Config::table($local)->relations();
        if (isset($relations->{$foreign}))
        {
            return true;
        }

        throw new dbException('Relation "' . $local . '" to "' . $foreign . '" doesn\'t exist');
    }
201173
function(api, id, key) {
  // get storage object
  var obj = _getStorageObject(api, id);
  if(obj !== null && key in obj) {
    // remove key
    delete obj[key];

    // see if entry has no keys remaining
    var empty = true;
    for(var prop in obj) {
      empty = false;
      break;
    }
    if(empty) {
      // remove entry entirely if no keys are left
      obj = null;
    }

    // set storage object
    _setStorageObject(api, id, obj);
  }
}
1123172
public void setRelationId(String relationId) {

        try {
            m_relationId = new CmsUUID(relationId);
        } catch (Throwable e) {
            setThrowable(e);
        }
    }
929520
public function setId($id)
    {
        if (is_null($this->id) && ! is_null($id) && ($model = $this->getRepository()->find($id))) {
            $this->id = $id;

            parent::setModel($model);
            $this->getButtons()->setModel($model);
            $this->setModelClass(get_class($model));
        }
    }
1041304
public function setModel($model, $foreignKey, $foreignKeyIds)
    {
        $this->model = $model;
        $this->foreignKey = $foreignKey;
        $this->foreignKeyIds = array_wrap($foreignKeyIds);

        $this->message = "Integrity constraint violation [{$model}] where $foreignKey in (".implode(', ', $foreignKeyIds).')';

        return $this;
    }
1083009
public boolean addRelatedObject(String objectType, String id, String content)
    {
        Map<String, Object> container = new HashMap<String, Object>();
        
        if (objectType != null)
        {
            container.put("objectType", objectType);
        }
        else
        {
            return false;
        }
        if (id != null)
        {
            container.put("id", id);
        }
        if (content != null)
        {
            container.put("content", content);
        }

        related.add(container);
        return true;
    }
1119470
public function set($id, $value, $lock = false)
    {
        parent::set($id, $value);

        if ((bool) $lock) {
            $this->lock($id);
        }
    }
345266
public function set($object, $id = null)
    {
        if (is_array($object)) {
            return $this->setAll($object);
        }

        $this->objects[$object] = $id;
    }
332960
public function setSportId($id, $relatedId) {
		// find
		$model = $this->get($id);

		if ($model === null) {
			return new NotFound(['message' => 'Object not found.']);
		}

		// update
		if ($this->doSetSportId($model, $relatedId)) {
			$this->dispatch(ObjectEvent::PRE_SPORT_UPDATE, $model);
			$this->dispatch(ObjectEvent::PRE_SAVE, $model);
			$model->save();
			$this->dispatch(ObjectEvent::POST_SPORT_UPDATE, $model);
			$this->dispatch(ObjectEvent::POST_SAVE, $model);

			return Updated(['model' => $model]);
		}

		return NotUpdated(['model' => $model]);
	}
246394
public function set($id, $service)
    {
        if (!$this->has($id)) {
            $this->repository->set($id, $service);
        }
    }