<commit_before><?php
namespace OCA\OwnNotes\Service;

use Exception;

use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;

use OCA\OwnNotes\Db\Note;
use OCA\OwnNotes\Db\NoteMapper;


class NoteService {

    private $mapper;

    public function __construct(NoteMapper $mapper){
        $this->mapper = $mapper;
    }

    public function findAll($userId) {
        return $this->mapper->findAll($userId);
    }

    private function handleException ($e) {
        if ($e instanceof DoesNotExistException ||
            $e instanceof MultipleObjectsReturnedException) {
            throw new NotFoundException($e->getMessage());
        } else {
            throw $e;
        }
    }

    public function find($id, $userId) {
        try {
            return $this->mapper->find($id, $userId);

        // in order to be able to plug in different storage backends like files
        // for instance it is a good idea to turn storage related exceptions
        // into service related exceptions so controllers and service users
        // have to deal with only one type of exception
        } catch(Exception $e) {
            $this->handleException($e);
        }
    }

    public function create($objectId, $clientName, $facture , $userId) {
        $note = new Note();
        $note->setObjectId($objectId);
        $note->setClientName($clientName);
        $note->setFacture($facture);
        $note->setUserId($userId);
        return $this->mapper->insert($note);
    }

    public function update($id, $objectId, $clientName, $facture , $userId) {
        try {
            $note = $this->mapper->find($id, $userId);
            $note->setObjectId($objectId);<commit_msg>update ownnote tab view file 18th<commit_after><?php
namespace OCA\OwnNotes\Service;

use Exception;

use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;

use OCA\OwnNotes\Db\Note;
use OCA\OwnNotes\Db\NoteMapper;


class NoteService {

    private $mapper;

    public function __construct(NoteMapper $mapper){
        $this->mapper = $mapper;
    }

    public function findAll($userId) {
        return $this->mapper->findAll($userId);
    }

    private function handleException ($e) {
        if ($e instanceof DoesNotExistException ||
            $e instanceof MultipleObjectsReturnedException) {
            throw new NotFoundException($e->getMessage());
        } else {
            throw $e;
        }
    }

    public function find($id, $userId) {
        try {
            return $this->mapper->find($id, $userId);

        // in order to be able to plug in different storage backends like files
        // for instance it is a good idea to turn storage related exceptions
        // into service related exceptions so controllers and service users
        // have to deal with only one type of exception
        } catch(Exception $e) {
            $this->handleException($e);
        }
    }

    public function create($objectId, $clientName, $facture , $userId) {
        error_reporting(E_ALL);
        ini_set('display_errors', 1);
        
        $note = new Note();
        $note->setObjectId($objectId);
        $note->setClientName($clientName);
        $note->setFacture($facture);
        $note->setUserId($userId);
        return $this->mapper->insert($note);
    }

    public function update($id, $objectId, $clientName, $facture , $userId) {
        try {
            $note = $this->mapper->find($id, $userId);
            $note->setObjectId($objectId);
{'fraction_non_alphanumeric': 0.11690496215306981, 'fraction_numerical': 0.0008410428931875525, 'mean_word_length': 2.5187376725838266, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2871991', 'n_tokens_mistral': 1019, 'n_tokens_neox': 1007, 'n_words': 259}