/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package framework.beans.report;
import framework.beans.SecuredBean;
import framework.beans.security.BeanRights;
import framework.generic.ClipsServerException;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateful;
import javax.persistence.NoResultException;
import javax.persistence.Query;
import framework.security.RightChecker;
import framework.security.UserRightsSetAbstract;
/**
*
* @author finder
*/
@Stateful(mappedName="clips-beans/ReportSearchBean")
public class ReportSearchBean extends SecuredBean implements ReportSearchBeanRemote {
public static int COMMAND_READ = 0;
@Override
protected void initBeanRights() {
int[] r = new int[1];
r[COMMAND_READ] = RightPresence(UserRightsSetAbstract.EXECUTE_REPORT.id);
rights = new BeanRights(r);
}
@Override
public List<ReportDetail> getList() throws ClipsServerException {
checkCommandAccessibility(COMMAND_READ);
List<ReportDetail> resould = new ArrayList<ReportDetail>();
try {
Query query = manager.createQuery("SELECT a FROM ReportDefinition a" );
@SuppressWarnings("unchecked")
List<ReportDefinition> set = query.getResultList();
for(int i = 0; i < set.size(); i++) {
resould.add(set.get(i).getDetails((RightChecker) this));
}
} catch (NoResultException ex) {
// drop
}
return resould;
}
}