<commit_before>package org.devilry.core.dao;

import org.devilry.core.daointerfaces.DeliveryLocal;
import org.devilry.core.daointerfaces.DeliveryRemote;
import org.devilry.core.entity.AssignmentNode;
import org.devilry.core.entity.Delivery;
import org.devilry.core.entity.DeliveryCandidate;

import javax.ejb.Stateful;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.PersistenceContext;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.util.List;

@Stateful
public class DeliveryImpl implements DeliveryRemote, DeliveryLocal {
	@PersistenceContext(unitName = "DevilryCore")
	protected EntityManager em;

	public DeliveryImpl() {
	}

	protected Delivery getDelivery(long deliveryId) {
		return em.find(Delivery.class, deliveryId);
	}

	public long getAssignment(long deliveryId) {
		return getDelivery(deliveryId).getAssignment().getId();
	}

	
	@SuppressWarnings("unchecked")
	public List<Long> getDeliveryCandidates(long deliveryId) {
		Query q = em.createQuery("SELECT d.id FROM DeliveryCandidate d "
				+ "WHERE d.delivery.id = :id");
		q.setParameter("id", getDelivery(deliveryId).getId());
		return q.getResultList();
	}

	
	@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
	public long create(long assignmentId) {
		Delivery d = new Delivery();
		AssignmentNode a = em.find(AssignmentNode.class, assignmentId);
		d.setAssignment(a);
		em.persist(d);
		em.flush();
		return d.getId();
	}

	
	public long getLastDeliveryCandidate(long deliveryId) {
		Query q = em.createQuery("SELECT d.id FROM DeliveryCandidate d WHERE d.timeOfDelivery = MAX(d.timeOfDelivery)");
		return (Long) q.getSingleResult();
	}

	public long getLastValidDeliveryCandidate(long deliveryId) {
		// TODO Auto-generated method stub
		return 0;
	}

	<commit_msg>Changed unecessary code<commit_after>package org.devilry.core.dao;

import org.devilry.core.daointerfaces.DeliveryLocal;
import org.devilry.core.daointerfaces.DeliveryRemote;
import org.devilry.core.entity.AssignmentNode;
import org.devilry.core.entity.Delivery;
import org.devilry.core.entity.DeliveryCandidate;

import javax.ejb.Stateful;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.PersistenceContext;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.util.List;

@Stateful
public class DeliveryImpl implements DeliveryRemote, DeliveryLocal {
	@PersistenceContext(unitName = "DevilryCore")
	protected EntityManager em;

	public DeliveryImpl() {
	}

	protected Delivery getDelivery(long deliveryId) {
		return em.find(Delivery.class, deliveryId);
	}

	public long getAssignment(long deliveryId) {
		return getDelivery(deliveryId).getAssignment().getId();
	}

	
	@SuppressWarnings("unchecked")
	public List<Long> getDeliveryCandidates(long deliveryId) {
		Query q = em.createQuery("SELECT d.id FROM DeliveryCandidate d "
				+ "WHERE d.delivery.id = :id");
		q.setParameter("id", deliveryId);
		return q.getResultList();
	}

	
	@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
	public long create(long assignmentId) {
		Delivery d = new Delivery();
		AssignmentNode a = em.find(AssignmentNode.class, assignmentId);
		d.setAssignment(a);
		em.persist(d);
		em.flush();
		return d.getId();
	}

	
	public long getLastDeliveryCandidate(long deliveryId) {
		Query q = em.createQuery("SELECT d.id FROM DeliveryCandidate d WHERE d.timeOfDelivery = MAX(d.timeOfDelivery)");
		return (Long) q.getSingleResult();
	}

	public long getLastValidDeliveryCandidate(long deliveryId) {
		// TODO Auto-generated method stub
		return 0;
	}

	
{'fraction_non_alphanumeric': 0.10633668751699756, 'fraction_numerical': 0.0005439216752787598, 'mean_word_length': 5.663043478260869, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2369449', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1171, 'n_words': 236}