/*
* Created on 2005-12-27
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package ;
import ;
import ;
import .*;
import ;
import ;
import ;
import .*;
/**
* @author JOE
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class XMLTodayReportPar {
private static final String TODAYREPORTS = "TodayReports";
private static final String TODAYREPORT = "TodayReport";
private static final String ID = "id";
private static final String NAME = "name";
private static final String REPORT = "Report";
private static final String TABLENAME = "tableName";
private static final String DESCRIPTION = "description";
private static final String HEAD = "Head";
private static final String BODY = "Body";
private static final String STATISTICAL = "Statistical";
private static final String FORWARD = "Forward";
private static final String URL = "url";
private static XMLTodayReports xmltodayReports = null;
/**
* 返回所有的表
* @return XMLTodayReports
*/
String realpath = "";
public XMLTodayReports getXMLTodayReports(String realpath) {
= realpath;
if (xmltodayReports != null) return xmltodayReports;
else {
xmltodayReports = new XMLTodayReports();
try {
SAXBuilder builder = new SAXBuilder();//注册解析器
Element root = null;
String path = realpath + "WEB-INF//i2conf//todayReport//" ;
//String path = "D://Development//TOMCAT//webapps//rebis//WEB-INF//i2conf//todayReport//";
("getrealpath = "+path);
//Document doc = (().getResourceAsStream("..//..//..//..//..//i2conf//report//"));
Document doc = (new File(path));//创建文档,读入XML文件
root = ();
getTodayReports(root, xmltodayReports);
return xmltodayReports;
}
catch (Exception e) {
();
}
return null;
}
}
/**
* 根据表名返回要找的报表信息.
* @param tableName
* @return XMLTable
*/
public XMLTodayReport getXMLTodayReport( String id ) {
if (id != "") {
return (XMLTodayReport) getXMLTodayReports(realpath).getTodayReportByID(id);
} else return null;
}
/**
* 返回TodayReport信息
* @return
*/
public List getAllValue(){
return (List) getXMLTodayReports(realpath).getAllValue();
}
/**
* @param todayReportsElem
* @param xmltodayReports
*/
public void getTodayReports( Element todayReportsElem , XMLTodayReports xmltodayReports) {
List todayReportList = (TODAYREPORT);
for (Iterator it = (); ();) {
Element todayReportEle = (Element) ();
XMLTodayReport xmltodayReport = new XMLTodayReport();
getTodayReport(todayReportEle, xmltodayReport);
(xmltodayReport);
}
}
/**获取TodayReport节点
* @param todayReportElem
* @param xmltodayReport
*/
public void getTodayReport( Element todayReportElem , XMLTodayReport xmltodayReport ) {
((ID));
((NAME));
List todayReportList = (REPORT);
for (Iterator it = (); ();) {
Element ReportEle = (Element) ();
XMLReport xmlReport = new XMLReport();
getReport(ReportEle, xmlReport);
(xmlReport);
}
/**
XMLReport xmlReport = new XMLReport();
getReport((REPORT),xmlReport);
(xmlReport);
*/
}
/**获取Report节点的值
* @param ReportElem
* @param xmlreport
*/
private void getReport(Element ReportElem , XMLReport xmlreport ) {
((TABLENAME));
((DESCRIPTION));
XMLHead xmlHead = new XMLHead();
if((HEAD)==null){
("null");
}else{
getHead((HEAD),xmlHead);
}
(xmlHead);
XMLBody xmlBody = new XMLBody();
getBody((BODY),xmlBody);
(xmlBody);
XMLStatistical xmlStatistical = new XMLStatistical();
if((STATISTICAL)==null){
("null");
}else{
getStatistical((STATISTICAL),xmlStatistical);
}
(xmlStatistical);
XMLForward xmlForward = new XMLForward();
getForward((FORWARD), xmlForward);
(xmlForward);
}
/**
* 获取Head节点的属性值
* @param HeadElem
* @param xmlHead
*/
private void getHead( Element HeadElem , XMLHead xmlHead ) {
(());
}
/**
* 获取Body节点的属性值
* @param BodyElem
* @param xmlBody
*/
private void getBody( Element BodyElem , XMLBody xmlBody ) {
(());
}
/**
* 获取Statistical节点的属性值
* @param StatisticalElem
* @param xmlStatistical
*/
private void getStatistical( Element StatisticalElem , XMLStatistical xmlStatistical ) {
(());
}
/**
* 获取Forward节点的属性值
* @param ForwardElem
* @param xmlForward
*/
private void getForward( Element ForwardElem , XMLForward xmlForward ) {
((URL));
}
public static void main(String[] args){
XMLTodayReportPar par = new XMLTodayReportPar();
XMLTodayReport todayReport = ("1");
("eeee"+());
List todayReportList = ();
for (Iterator iter = (); ();) {
XMLReport xmlReport = (XMLReport) ();
("pppp"+());
("qqqq"+().getHeadSQLValue());
}
}
}
/*
* Created on 2005-12-29
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package ;
import ;
import .* ;
/**
* @author JOE
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class TodayReport implements Serializable{
private String id;
private String name;
private Vector report = new Vector();
public String getID()
{
return id;
}
public void setID(String id)
{
= id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
= name;
}
public Vector getReport()
{
return report;
}
public void setReport(Vector report)
{
= report;
}
}
/*
* Created on 2005-12-27
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package ;
import ;
import ;
import ;
import ;
import ;
//import .*;
/**
* @author JOE
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class XMLTodayReports implements Serializable{
private Map todayReportsMap = new HashMap();//实现了将惟一键映射到特定的值上
List HeadSQLValueList = new ArrayList();
List TodayReportValueList = new ArrayList();
List ReportValueList = new ArrayList();
public Map getTodayReportsMap() {
return ;
}
public void setTodayReportsMap( Map todayReportsMap ) {
= todayReportsMap;
}
public void addXMLTodayReport(XMLTodayReport xmltodayReport){
((),xmltodayReport);//put(object key,object value);
//key=tablename,value=tablename对应的FORMBEAN
}
public XMLTodayReport getTodayReportByID(String id)
{
if(id!=null){
return (XMLTodayReport)(id);
}else{
return null;
}
}
public List getAllValue(){
if(()!=0){
();
}
Object[] keys = ().toArray();
for(int i = 0; i < ; i ++){
XMLTodayReport todayReport =(XMLTodayReport) (keys[i]);
(todayReport);
}
return TodayReportValueList;
}
}
/*
* Created on 2005-12-27
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package ;
import ;
import ;
import ;
import ;
import ;
import ;
import .*;
/**
* @author JOE
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class XMLTodayReport{
private String id;
private String name;
private List TodayReportList = new ArrayList();
private XMLReport xmlReport;
private XMLTodayReport xmlTodayReport;
public String getID() {
return id;
}
public void setID(String id) {
= id;
}
public String getName() {
return name;
}
public void setName(String name) {
= name;
}
public List getTodayReportList() {
return ;
}
public void setTodayReportList( List todayReportList ) {
= todayReportList;
}
public void addXMLReport(XMLReport xmlReport){
(xmlReport);
}
}
/*
* Created on 2005-12-27
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package ;
import ;
import .*;
/**
* @author JOE
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class XMLBody implements Serializable{
private String BodySQLValue;
public String getBodySQLValue(){
return BodySQLValue;
}
public void setBodySQLValue(String BodySQLValue){
= BodySQLValue;
}
}
XMLReport .java
/*
* Created on 2005-12-27
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package ;
import ;
import .*;
/**
* @author JOE
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class XMLReport implements Serializable{
private String tableName;
private String description;
private XMLHead xmlHead;
private XMLBody xmlBody;
private XMLStatistical xmlStatistical;
private XMLForward xmlForward;
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
= tableName;
}
public String getDescription(){
return description;
}
public void setDescription(String description){
= description;
}
public XMLHead getXmlHead() {
return xmlHead;
}
public void setXmlHead(XMLHead xmlHead) {
= xmlHead;
}
public XMLBody getXmlBody() {
return xmlBody;
}
public void setXmlBody(XMLBody xmlBody) {
= xmlBody;
}
public XMLStatistical getXmlStatistical() {
return xmlStatistical;
}
public void setXmlStatistical(XMLStatistical xmlStatistical) {
= xmlStatistical;
}
public XMLForward getXmlForward() {
return xmlForward;
}
public void setXmlForward(XMLForward xmlForward) {
= xmlForward;
}
}
/*
* Created on 2005-12-27
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package ;
import ;
import .*;
/**
* @author JOE
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class XMLHead implements Serializable{
private String HeadSQLValue;
public String getHeadSQLValue(){
return HeadSQLValue;
}
public void setHeadSQLValue(String HeadSQLValue){
= HeadSQLValue;
}
}
XML文件:
<?xml version="1.0" encoding="GB2312"?>
<TodayReports>
<TodayReport name="人员统计表">
<Report tableName="DTPEPOLE_REMAIN_DOWN_ROLL" description="井下现有人员统计表">
<Head>
<![CDATA[SELECT "COMMUNITY_NAME" FROM "DTPEPOLE_REMAIN_DOWN_ROLL" WHERE (GETDATE()-A_P_P_CREATED_DATE)>0 AND (GETDATE()-A_P_P_CREATED_DATE)<1]]>
</Head>
<Body>
<![CDATA[SELECT "UNIT","PLACE","TOTAL","REPORT_PEOPLE" FROM "DTPEPOLE_REMAIN_DOWN_ROLL" WHERE (GETDATE()-A_P_P_CREATED_DATE)>0 AND (GETDATE()-A_P_P_CREATED_DATE)<1]]>
</Body>
<Statistical>
<![CDATA[SELECT sum(total) FROM "DTPEPOLE_REMAIN_DOWN_ROLL" WHERE (GETDATE()-A_P_P_CREATED_DATE)>0 AND (GETDATE()-A_P_P_CREATED_DATE)<1]]>
</Statistical>
<Forward url="DOWN_ROLL"/>
</Report>
</TodayReport>
<TodayReports>