Copy csv data into tmp file with updated line referenced by $id
Copy tmp file to csv && remove tmp file
@param $id
@param $entityData
@return bool|string|void
@throws StorageException
540678
private function update($id, $entityData = []) {
        $tmpFile = \tao_helpers_File::createTempDir() . 'store.csv';
        $tmpHandle = fopen($tmpFile, 'w');
        $line = 1;
        $index = 0;

        while (($data = fgetcsv($this->handle, 1000, ";")) !== false) {

            if ($line === 1) {
                $keys = $data;
                if (($index = array_search('id', $keys, true)) === false) {
                    return false;
                }
            }

            if ($data[$index] == $id) {
                foreach($data as $index => $value){
                    if (empty($entityData[$keys[$index]])) {
                        $entityData[$keys[$index]] = $value;
                    }
                }
            }
            else {
                fputcsv($tmpHandle, $data, ';');
            }
            $line++;
        }
        $entityData = array_merge(array_flip($keys), $entityData);
        fputcsv($tmpHandle, $entityData, ';');
        fclose($tmpHandle);
        fclose($this->handle);
        \tao_helpers_File::copy($tmpFile, $this->getOption('filename')) && unlink($tmpFile);
        return;
    }
45364
public function write($id, $session_data)
	{
        if ($id === '' && $session_data === '') {
            return false;
        }

        $result = false;
        $session = $this->_getSession($id);

        if (isset($session)) {
            $result = $session->set('meta', $session_data)->save();
        } else {
            $result = $this->_repository->getEntity()
            ->set('sessionId', $id)
            ->set('meta', $session_data)
            ->save();
        }

        if ($result) {
            $this->_data = $session_data;
        }

		return $result;
	}
642545
public function updateRecord($documentId, $entity, $returnEntity = true)
    {
        if (!is_null($documentId)) {
            $this->deleteById($documentId);
            // detach so odm knows it's gone
            $this->manager->detach($entity);
            $this->manager->clear();
        }

        $entity = $this->manager->merge($entity);

        $this->manager->persist($entity);
        $this->manager->flush($entity);
        $this->manager->detach($entity);

        // Fire ModelEvent
        $this->dispatchModelEvent(ModelEvent::MODEL_EVENT_UPDATE, $entity);

        if ($returnEntity) {
            return $entity;
        }
        return null;
    }
241258
private void updateDeletedObjectsThroughEntityManager(List<String> oids, Long timestamp) {
        for (String id : oids) {
            EDBObject o = new EDBObject(id);
            o.updateTimestamp(timestamp);
            o.setDeleted(true);
            JPAObject j = EDBUtils.convertEDBObjectToJPAObject(o);
            entityManager.persist(j);
        }
    }
949026
protected function doCopy($entityId)
    {
        $copy = $this->find($entityId)->copy();
        $this->save($copy);

        return $copy;
    }
610245
protected function loadAttributesRawData($storeId, array $entityIds, $tableName, array $attributeIds)
    {
        return $this->resourceModel->getAttributesRawData($storeId, $entityIds, $tableName, $attributeIds);
    }
1372342
private function setCachedData($locationId, array $data) {
    if (self::DEBUG_MODE) {
      $this->cacheBackend->set(get_class($this) . '_embed_' . $locationId, $data);
    }
  }
418785
public function write($id, $data)
    {
        $data = [
            $this->options['data_col'] => $data,
            $this->options['time_col'] => (int) time(),
            $this->options['id_col'] => $id,
        ];

        $data = (object) $data;

        $this->db->updateObject($this->options['table'], $data, $this->options['id_col']);

        if ($this->db->getAffectedRows()) {
            return true;
        }

        $this->db->insertObject($this->options['table'], $data, $this->options['id_col']);

        return true;
    }
197428
public function set($entityId, $id, \DateTime $expiryTime) {
        $idEntry = $this->manager->find(IdEntity::class, ['entityId' => $entityId, 'id' => $id]);
        if (null == $idEntry) {
            $idEntry = new IdEntity();
        }
        $idEntry->setEntityId($entityId)
            ->setId($id)
            ->setExpiry($expiryTime);
        $this->manager->persist($idEntry);
        $this->manager->flush();
    }
601576
protected function addOrUpdate(NodeData $nodeData = null)
    {
        $nodeData = ($nodeData === null ? $this : $nodeData);

        // If this NodeData was previously removed and is in live workspace we don't want to add it again to persistence.
        if ($nodeData->isRemoved() && $this->workspace->getBaseWorkspace() === null) {
            // Actually it should be removed from the identity map here.
            if ($this->persistenceManager->isNewObject($nodeData) === false) {
                $this->nodeDataRepository->remove($nodeData);
            }
            return;
        }

        // If the node is marked to be removed but didn't exist in a base workspace yet, we can delete it for real, without creating a shadow node.
        // This optimization cannot be made for shadow nodes which are moved.
        if ($nodeData->isRemoved() && $nodeData->getMovedTo() === null && $this->nodeDataRepository->findOneByIdentifier($nodeData->getIdentifier(), $this->workspace->getBaseWorkspace()) === null) {
            if ($this->persistenceManager->isNewObject($nodeData) === false) {
                $this->nodeDataRepository->remove($nodeData);
            }
            return;
        }

        if ($this->persistenceManager->isNewObject($nodeData)) {
            $this->nodeDataRepository->add($nodeData);
        } else {
            $this->nodeDataRepository->update($nodeData);
        }
    }
1235122
@Override
    public void writeData(String tableName, EntityMetadata m, Object entity, Object rowId,
            List<RelationHolder> relations, boolean showQuery) throws IOException
    {
        HTableInterface hTable = gethTable(tableName);

        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                m.getPersistenceUnit());

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

        Set<Attribute> attributes = entityType.getAttributes();

        if (metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType()))
        {
            rowId = KunderaCoreUtils.prepareCompositeKey(m, rowId);
        }

        HBaseDataWrapper columnWrapper = new HBaseDataWrapper(rowId, new java.util.HashMap<String, Attribute>(),
                entity, null);
        List<HBaseDataWrapper> persistentData = new ArrayList<HBaseDataHandler.HBaseDataWrapper>(attributes.size());

        Map<String, HBaseDataWrapper> columnWrappers = preparePersistentData(tableName, m.getTableName(), entity,
                rowId, metaModel, attributes, columnWrapper, persistentData, showQuery);

        writeColumnData(hTable, entity, columnWrappers);

        for (HBaseDataWrapper wrapper : persistentData)
        {
            hbaseWriter.writeColumns(hTable, wrapper.getColumnFamily(), wrapper.getRowKey(), wrapper.getColumns(),
                    wrapper.getValues(), wrapper.getEntity());
        }

        // Persist relationships as a column in newly created Column family by
        // Kundera
        boolean containsEmbeddedObjectsOnly = columnWrapper.getColumns().isEmpty() && persistentData.isEmpty();

        if (relations != null && !relations.isEmpty())
        {
            hbaseWriter.writeRelations(hTable, rowId, containsEmbeddedObjectsOnly, relations, m.getTableName());
        }

        // add discriminator column
        String discrColumn = ((AbstractManagedType) entityType).getDiscriminatorColumn();
        String discrValue = ((AbstractManagedType) entityType).getDiscriminatorValue();

        // No need to check for empty or blank, as considering it as valid name
        // for nosql!
        if (discrColumn != null && discrValue != null)
        {
            List<RelationHolder> discriminator = new ArrayList<RelationHolder>(1);
            discriminator.add(new RelationHolder(discrColumn, discrValue));
            hbaseWriter.writeRelations(hTable, rowId, containsEmbeddedObjectsOnly, discriminator, m.getTableName());
        }

        puthTable(hTable);
    }
621201
public function saveById($id, $data)
    {
        $id = parent::saveById($id, $data);
        $this->setCacheItem($id, $data);
        return $id;
    }
1185502
public function update($id, array $data)
    {
        $this->validateId($id);

        $entity = $this->getById($id);
        $form   = $this->getEditForm();

        $form->bind($entity);
        $form->setData($data);

        if (!$valid = $form->isValid()) {
            return false;
        }

        $this->updateFromNode($entity);

        $this->getMapper()->save($entity);

        return $entity;
    }
1000123
public function write($id, $data)
    {
        $access = time();
        $this->session_id = (string) $id;
        $this->access = $access;
        $this->data = $data;
        $this->save();

        return true;
    }
266096
public function populate($id, $recipient = null, $backupCodeIdentifier = null, $totpIdentifier = null)
    {
        if (empty($id)) {
            throw new EntityException('No messages id supplied', EntityException::NO_MESSAGE_ID_SUPPLIED);
        }
        if ($recipient === null && $backupCodeIdentifier === null && $totpIdentifier === null) {
            throw new EntityException('No recipient, backup code identifier or totp identifier supplied', EntityException::INVALID_FIELDS);
        }

        $params = [];
        if ($recipient !== null) {
            $params['recipient'] = $recipient;
        }
        if ($backupCodeIdentifier !== null) {
            $params['backupCodeIdentifier'] = $backupCodeIdentifier;
        }
        if ($totpIdentifier !== null) {
            $params['totpIdentifier'] = $totpIdentifier;
        }

        $this->sendApiCall(self::ACTION_RETRIEVE, $this->getCreateUrl() . '/' . urlencode($id) . '?' . http_build_query($params));
    }
359743
public function write($id, $data)
	{
		try
		{
			$query = $this->db->getQuery(true);
			$query->update($this->db->quoteName('#__session'))
				->set($this->db->quoteName('data') . ' = ' . $this->db->quote($data))
				->set($this->db->quoteName('time') . ' = ' . $this->db->quote((int) time()))
				->where($this->db->quoteName('session_id') . ' = ' . $this->db->quote($id));

			// Try to update the session data in the database table.
			$this->db->setQuery($query);

			if (!$this->db->execute())
			{
				return false;
			}

			// Since $this->db->execute did not throw an exception the query was successful.
			// Either the data changed, or the data was identical. In either case we are done.

			return true;
		}
		catch (\Exception $e)
		{
			return false;
		}
	}
1018782
public function write($id, $data)
    {
        // Only store session to disk if data exists or session already
        // existed before (in last case we always want to touch the file
        // to prevent early garbage collection)
        // Note: This logic can be overwritten by the force flag
        if ($data
            || $this->exists
            || $this->force
        ) {
            $file = $this->getPathForSessionId($id);
            file_put_contents($file, $data);
            chmod($file, 0600);
            $this->exists = true;
        }

        return true;
    }