⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reportmanagerejb.java

📁 CRM源码This file describes some issues that should be implemented in future and how it should be imple
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* * Copyright 2006-2007 Queplix Corp. * * Licensed under the Queplix Public License, Version 1.1.1 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.queplix.com/solutions/commercial-open-source/queplix-public-license/ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */package com.queplix.core.modules.eqlext.ejb;import com.queplix.core.error.GenericSystemException;import com.queplix.core.integrator.ActionContext;import com.queplix.core.integrator.security.AccessRightsManager;import com.queplix.core.integrator.security.LogonSession;import com.queplix.core.integrator.security.SecurityException;import com.queplix.core.jxb.entity.Dataset;import com.queplix.core.jxb.entity.Efield;import com.queplix.core.jxb.entity.Entity;import com.queplix.core.modules.config.ejb.EntityViewConfigManagerLocal;import com.queplix.core.modules.config.ejb.EntityViewConfigManagerLocalHome;import com.queplix.core.modules.config.ejb.FocusConfigManagerLocal;import com.queplix.core.modules.config.ejb.FocusConfigManagerLocalHome;import com.queplix.core.modules.config.ejb.UserPropertyManagerLocal;import com.queplix.core.modules.config.ejb.UserPropertyManagerLocalHome;import com.queplix.core.modules.config.error.NoSuchPropertyException;import com.queplix.core.modules.config.jxb.Form;import com.queplix.core.modules.config.utils.SysPropertyManager;import com.queplix.core.modules.eql.error.EQLException;import com.queplix.core.modules.eqlext.jxb.gr.Report;import com.queplix.core.modules.eqlext.jxb.gr.Reportiter;import com.queplix.core.modules.eqlext.jxb.gr.ReqEntity;import com.queplix.core.modules.eqlext.jxb.gr.Reqs;import com.queplix.core.modules.eqlext.jxb.gr.ResDataset;import com.queplix.core.modules.eqlext.jxb.gr.ResField;import com.queplix.core.modules.eqlext.jxb.gr.ResHeader;import com.queplix.core.modules.eqlext.jxb.gr.ResHeaderDataset;import com.queplix.core.modules.eqlext.jxb.gr.ResHeaderField;import com.queplix.core.modules.eqlext.jxb.gr.ResRecord;import com.queplix.core.modules.eqlext.jxb.gr.Ress;import com.queplix.core.modules.eqlext.jxb.gr.types.DataSType;import com.queplix.core.modules.eqlext.utils.EJBCacheActionContext;import com.queplix.core.modules.eqlext.utils.ReportCallbackHnd;import com.queplix.core.modules.eqlext.utils.ReportCallbackHndEvent;import com.queplix.core.modules.eqlext.utils.ReportHelper;import com.queplix.core.modules.eqlext.utils.ReportTransletFactory;import com.queplix.core.modules.jeo.JEObjectHandler;import com.queplix.core.modules.jeo.ejb.JEOManagerLocal;import com.queplix.core.modules.jeo.ejb.JEOManagerLocalHome;import com.queplix.core.modules.jeo.gen.ReportObject;import com.queplix.core.modules.jeo.gen.ReportObjectHandler;import com.queplix.core.modules.jeo.gen.ReportSchedulerObject;import com.queplix.core.modules.jeo.gen.ReportSchedulerObjectHandler;import com.queplix.core.modules.mail.Attachment;import com.queplix.core.modules.mail.MailAddress;import com.queplix.core.modules.mail.MailMessage;import com.queplix.core.modules.mail.ejb.MailManagerLocal;import com.queplix.core.modules.mail.ejb.MailManagerLocalHome;import com.queplix.core.utils.DateHelper;import com.queplix.core.utils.JNDINames;import com.queplix.core.utils.StringHelper;import com.queplix.core.utils.ZipHelper;import com.queplix.core.utils.ejb.AbstractSessionEJB;import com.queplix.core.utils.xml.TransletWrapper;import com.queplix.core.utils.xml.XMLFactory;import com.queplix.core.utils.xml.XMLHelper;import javax.mail.MessagingException;import javax.xml.transform.stream.StreamResult;import javax.xml.transform.stream.StreamSource;import java.io.BufferedOutputStream;import java.io.CharArrayReader;import java.io.CharArrayWriter;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.FileReader;import java.io.IOException;import java.io.OutputStream;import java.io.OutputStreamWriter;import java.io.PrintWriter;import java.io.StringWriter;import java.io.Writer;import java.text.ParseException;import java.util.ArrayList;import java.util.Arrays;import java.util.Date;import java.util.Hashtable;import java.util.List;import java.util.Map;import java.util.zip.GZIPOutputStream;/** * Report Manager session EJB. * * @author [ONZ] Oleg N. Zhovtanyuk * @author [ALB] Andrey Baranov * @version $Revision: 1.9 $ $Date: 2006/09/01 17:10:35 $ */public class ReportManagerEJB        extends AbstractSessionEJB {    // ----------------------------------------------------- constants    // Set GR package size.    private static final int MAX_RECORDS_PER_PAGE =            Integer.parseInt(ReportTransletFactory.getProperty("records_per_page.param"));    // ----------------------------------------------------- variables    // TransletWrapper instance.    private final TransletWrapper transletWrapper = XMLFactory.getTransletWrapper();    // ----------------------------------------------------- public methods    public void ejbCreate() {        INFO("Report Manager EJB created - " + hashCode());    }    /**     * Makes an HTML report and write it to <code>pw</code> stream.     *     * @param ls           user logon session object with security data     * @param report       Report object     * @param transletName translet name     * @param pw           output stream     * @param hnd          callback handler     * @throws EQLException on all EQL errors     */    public void printReport(LogonSession ls,                            Report report,                            String transletName,                            Writer pw,                            ReportCallbackHnd hnd)            throws EQLException {        printReport(ls, report, transletName, null, pw, hnd);    }    /**     * Makes an HTML report and write it to <code>pw</code> stream.     *     * @param ls             user logon session object with security data     * @param report         Report object     * @param transletName   translet name     * @param transletParams parameters for the translet     * @param pw             output stream     * @param hnd            callback handler     * @throws EQLException on all EQL errors     */    public void printReport(LogonSession ls,                            Report report,                            String transletName,                            Map transletParams,                            Writer pw,                            ReportCallbackHnd hnd)            throws EQLException {        File tempFile = null;        FileReader fr = null;        if(getLogger().isDebugEnabled()) {            DEBUG("Print report " + report.getProcessId() + " using translet '" +                    transletName + "'.");        }        try {            // Try to find existing report.            tempFile = ReportHelper.getDataFile(ls, report);            if(!tempFile.isFile() || !tempFile.exists() || transletParams != null) {                // Generate new report.                tempFile = doGenerateReport(ls, report, transletName, transletParams, hnd);            }            // Write report.            fr = new FileReader(tempFile);            char[] buff = new char[1024];            int len = 0;            while((len = fr.read(buff)) != -1) {                pw.write(buff, 0, len);            }        } catch (IOException ex) {            ERROR(ex);            throw new GenericSystemException("IO exception: " + ex.getMessage(), ex);        } finally {            // Don't remove TMP file!!!            // Close stream only.            try {                if(fr != null) {                    fr.close();                }            } catch (Exception ex) {            }        }    }    /**     * Makes an HTML report and write it to <code>os</code> byte stream.     *     * @param ls             user logon session object with security data     * @param report         Report object     * @param transletName   translet name     * @param transletParams parameters for the translet     * @param os             output stream     * @param hnd            callback handler     * @throws EQLException on all EQL errors     */    public void printReport(LogonSession ls,                            Report report,                            String transletName,                            Map transletParams,                            OutputStream os,                            ReportCallbackHnd hnd)            throws EQLException {        File tempFile = null;        FileInputStream in = null;        BufferedOutputStream bufOutStream = null;        if(getLogger().isDebugEnabled()) {            DEBUG("Print report " + report.getProcessId() + " using translet '" +                    transletName + "'.");        }        try {            // Try to find existing report.            tempFile = ReportHelper.getDataFile(ls, report);            if(!tempFile.isFile() || !tempFile.exists() || transletParams != null) {                // Generate new report.                tempFile = doGenerateReport(ls, report, transletName, transletParams, hnd);            }            // Write report.            in = new FileInputStream(tempFile);            bufOutStream = new BufferedOutputStream(new GZIPOutputStream(os));            byte[] buf = new byte[1024];            int len = 0;            while((len = in.read(buf)) > 0) {                bufOutStream.write(buf, 0, len);            }            // Flush buffered stream.            bufOutStream.flush();        } catch (IOException ex) {            ERROR(ex);            throw new GenericSystemException("IO exception: " + ex.getMessage(), ex);        } finally {            // Don't remove TMP file!!!            // Close stream only.            try {                if(bufOutStream != null) {                    bufOutStream.close();                }                if(in != null) {                    in.close();                }            } catch (Exception ex) {            }        }    }    //  NRA code: method to send report in specified format    /*      * No javadoc     * @see #sendReportByMail( long, String, String )     */    public void sendFormattedReportByMail(long reportSchedulerId, String reportFormat)            throws EQLException, MessagingException {        sendReportByMail(reportSchedulerId, null, reportFormat);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -