Last active
August 29, 2015 14:09
-
-
Save gitbricho/f6de607ac1902f00724a to your computer and use it in GitHub Desktop.
health : com.itrane.healthcare.service.VodServiceImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class VodServiceImpl implements VodService { | |
@Resource | |
private VodRepository vodRepository; | |
@Resource | |
private VitalRepository vitalRepository; | |
@PersistenceContext | |
private EntityManager em; | |
public VodServiceImpl() {} | |
public VodServiceImpl(VodRepository repo) { | |
this.vodRepository = repo; | |
} | |
@Override | |
public EntityManager getEm() { | |
return em; | |
} | |
@Override | |
@Transactional | |
public Vod create(Vod vod) { | |
return vodRepository.save(vod); | |
} | |
@Override | |
@Transactional(rollbackFor=VodNotFound.class) | |
public Vod update(Vod vod) { | |
for(Vital vt: vod.getVitals()) { | |
if (vt.getSokuteiJikan() != null) { | |
vitalRepository.save(vt); | |
} | |
} | |
return vodRepository.save(vod); | |
} | |
@Override | |
@Transactional(rollbackFor=VodNotFound.class) | |
public Vod delete(long id) throws VodNotFound { | |
Vod deletedVod = vodRepository.findOne(id); | |
if (deletedVod == null) | |
throw new VodNotFound(); | |
vodRepository.delete(deletedVod); | |
return deletedVod; | |
} | |
@Override | |
public List<Vod> findBySokuteiBi(String sokuteiBi) { | |
return vodRepository.findBySokuteiBi(sokuteiBi); | |
} | |
@Override | |
public List<Vod> findBySokuteiBiBetween(String sokuteiBi1, String sokuteiBi2) { | |
return vodRepository.findBySokuteiBiBetween(sokuteiBi1, sokuteiBi2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment