<commit_before>package com.github.aureliano.edocs.service.bean;

import java.util.List;

import com.github.aureliano.edocs.common.persistence.DataPagination;
import com.github.aureliano.edocs.common.persistence.IPersistenceManager;
import com.github.aureliano.edocs.common.persistence.PersistenceService;
import com.github.aureliano.edocs.domain.entity.Document;
import com.github.aureliano.edocs.domain.entity.User;
import com.github.aureliano.edocs.service.helper.ServiceHelper;

public class DocumentServiceBean implements IServiceBean {

	private IPersistenceManager pm;
	
	public DocumentServiceBean() {
		this.pm = PersistenceService.instance().getPersistenceManager();
	}

	public Document findDocumentById(Integer id) {
		return this.pm.find(Document.class, id);
	}
	
	public List<Document> findDocumentsByOwner(User owner) {
		Document document = new Document().withOwner(owner);
		return this.pm.search(new DataPagination<Document>().withEntity(document));
	}
	
	public void logicalDeletion(Document document) {
		Document entity = this.findDocumentById(document.getId()).withDeleted(true);
		ServiceHelper.executeActionInsideTransaction(entity, true);
	}
}<commit_msg>Implementation of logicalDeletion service method.<commit_after>package com.github.aureliano.edocs.service.bean;

import java.util.List;
import java.util.logging.Logger;

import com.github.aureliano.edocs.common.persistence.DataPagination;
import com.github.aureliano.edocs.common.persistence.IPersistenceManager;
import com.github.aureliano.edocs.common.persistence.PersistenceService;
import com.github.aureliano.edocs.domain.entity.Document;
import com.github.aureliano.edocs.domain.entity.User;
import com.github.aureliano.edocs.service.helper.ServiceHelper;

public class DocumentServiceBean implements IServiceBean {

	private static final Logger logger = Logger.getLogger(DocumentServiceBean.class.getName());
	
	private IPersistenceManager pm;
	
	public DocumentServiceBean() {
		this.pm = PersistenceService.instance().getPersistenceManager();
	}

	public Document findDocumentById(Integer id) {
		return this.pm.find(Document.class, id);
	}
	
	public List<Document> findDocumentsByOwner(User owner) {
		Document document = new Document().withOwner(owner);
		return this.pm.search(new DataPagination<Document>().withEntity(document));
	}
	
	public void logicalDeletion(Document document) {
		Document entity = this.findDocumentById(document.getId());
		if (entity.getDeleted()) {
			logger.warning("Ignoring logical deletion of document " + entity.getId() + " because it is already logically deleted.");
			return;
		}
		
		entity.withDeleted(true);
		ServiceHelper.executeActionInsideTransaction(entity, true);
	}
}
{'fraction_non_alphanumeric': 0.1069182389937107, 'fraction_numerical': 0.0, 'mean_word_length': 6.172413793103448, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2409857', 'n_tokens_mistral': 844, 'n_tokens_neox': 781, 'n_words': 138}