package com.ecolane.mpk.rest;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.ws.rs.POST;
import javax.ws.rs.Path;

import com.ecolane.mpk.persistence.Run;

@Stateless
@LocalBean
@Path("/bug_repro")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class RunRest {
    @PersistenceContext(unitName = "persistence_context")
    protected EntityManager entityManager;

    @POST
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public String createRun() {
        final Run run = new Run();
        entityManager.persist(run);
        return "New run created with ID " + run.getId();
    }
}
