📄 imagerepositoryprocessbean.java
字号:
package cn.myapps.core.image.repository.ejb;
import java.util.Collection;
import org.apache.commons.beanutils.PropertyUtils;
import org.hibernate.StaleObjectStateException;
import cn.myapps.base.dao.DAOFactory;
import cn.myapps.base.dao.IBaseDAO;
import cn.myapps.base.dao.PersistenceUtils;
import cn.myapps.base.dao.ValueObject;
import cn.myapps.base.ejb.BaseProcessBean;
import cn.myapps.core.dynaform.form.action.ImpropriateException;
import cn.myapps.core.image.repository.dao.ImageRepositoryDAO;
public class ImageRepositoryProcessBean extends BaseProcessBean implements
ImageRepositoryProcess {
protected IBaseDAO getDAO() throws Exception {
IBaseDAO dao = DAOFactory.getDefaultDAO(ImageRepositoryVO.class
.getName());
return dao;
}
public ImageRepositoryVO getImageRepositoryByName(String name,
String application) throws Exception {
return ((ImageRepositoryDAO) getDAO()).getImageRepositoryByName(name, application);
}
public Collection getImageRepositoryByModule(String moduleid,
String application) throws Exception {
return ((ImageRepositoryDAO) getDAO())
.getImageRepositoryByModule(moduleid, application);
}
public Collection getImageRepositoryByApplication(String applicationid,
String application) throws Exception {
return ((ImageRepositoryDAO) getDAO())
.getImageRepositoryByApplication(applicationid, application);
}
public ImageRepositoryVO getImageRepositoryByIconURl(String IconURl,
String application) throws Exception {
return ((ImageRepositoryDAO) getDAO())
.getImageRepositoryByIconURl(IconURl, application);
}
public void doUpdate(ValueObject vo) throws Exception {
try {
PersistenceUtils.beginTransaction();
ValueObject po = getDAO().find(vo.getId());
if (((ImageRepositoryVO) vo).getVersion() != ((ImageRepositoryVO) po)
.getVersion())
throw new ImpropriateException("Already having been impropriate by others , can not Save");
((ImageRepositoryVO) vo).setVersion(((ImageRepositoryVO) vo)
.getVersion() + 1);
if (po != null) {
PropertyUtils.copyProperties(po, vo);
getDAO().update(po);
} else {
getDAO().update(vo);
}
PersistenceUtils.commitTransaction();
} catch (ImpropriateException e) {
PersistenceUtils.rollbackTransaction();
throw e;
} catch (Exception e) {
e.printStackTrace();
PersistenceUtils.rollbackTransaction();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -