package com.pre.service.base;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import com.pre.entity.base.Division;
import com.pre.service.exception.PREEJBServiceException;
import com.pre.session.base.DivisionManager;
/**
* Session Bean implementation class DivisionManagerService
*/
@WebService
@Stateless
public class DivisionManagerService {
@EJB
private DivisionManager manager;
/**
* Default constructor.
*/
public DivisionManagerService() {
}
@WebMethod
public void create(@WebParam(name="code") String code) throws PREEJBServiceException{
try{
Division d=new Division();
d.setCode(code);
manager.create(d);
}catch (Exception e) {
throw new PREEJBServiceException(e.getMessage());
}
}
@WebMethod
public long findByCode(@WebParam(name="code") String code) throws PREEJBServiceException{
List<Division> ds=manager.findByCode(code);
if(ds.isEmpty()){
throw new PREEJBServiceException("No such division code=["+code+"]");
}
return ds.get(0).getId();
}
}