/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package framework.beans.directory.reportType;
import framework.beans.directory.DirectoryBean;
import framework.beans.reportgen.item.ReportgenQuery;
import framework.generic.ClipsServerException;
import framework.generic.EDataIntegrity;
import framework.security.UserRight;
import framework.security.UserRightsSetAbstract;
import javax.ejb.Stateful;
/**
*
* @author lacoste
*/
@Stateful(mappedName="clips-beans/DirectoryReportTypeBean")
public class DirectoryReportTypeBean extends DirectoryBean<ReportType, ReportTypeDetails>
implements DirectoryReportTypeBeanRemote {
public DirectoryReportTypeBean() {
super(ReportType.class, "виды отчетов");
}
@Override
protected UserRight getRightForCreateDirectoryItem() {
return UserRightsSetAbstract.WRITE_REGION_ADMIN_DIRECTORY;
}
@Override
protected UserRight getRightForWriteToDirectory() {
return UserRightsSetAbstract.WRITE_REGION_ADMIN_DIRECTORY;
}
@Override
protected void set(ReportType entity, ReportTypeDetails details) throws ClipsServerException {
ReportType reportType = entity;
ReportTypeDetails item = details;
ReportType reportTypeParent = item.parentItem == 0 ?
null : findEntity(ReportType.class, item.parentItem);
reportType.setTitle(item.title);
if(reportTypeParent != null) {
reportType.setRef(reportTypeParent);
}
}
@Override
protected void onRemove(ReportType entity) throws ClipsServerException {
Field f1[] = { new Field("parent", entity) };
if(getEntityCount(ReportType.class, f1) > 0) {
throw new EDataIntegrity("Удаление невозможно, группа содержит вложенные группы");
}
Field f2[] = { new Field("reportType", entity) };
if(getEntityCount(ReportgenQuery.class, f2) > 0) {
throw new EDataIntegrity("Удаление невозможно, группа содержит вложенные отчеты");
}
}
}