Changeset 18287

Show
Ignore:
Timestamp:
11/02/08 15:17:29 (2 months ago)
Author:
puno
Message:

Update for DocVault? report tool.

DocVault? space usage statistics report.
Reports can be generated:
- for all projects
- for specified projects only
- for all businesses
- for selected businesses only
- for all users
- for selected users only

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tools/docVaultStatistic/file.properties

    r18283 r18287  
    1 is.export=false 
    2 is.language.specified.in.property.file=true 
    3 update.existing.properties=true 
    4 language=es 
    5  
    61server.name=localhost 
    72database.port.number=1521 
     
    94database.user.username=pnet 
    105database.user.password=pnet 
    11 output.filename=export.xls 
    12 output.filename.location=d:/pn 
    13  
    14 input.filename=import.xls 
    15 input.filename.location=d:/pn 
    16  
    17  
    18  
     6output.filename.projects=projects.pdf 
     7output.filename.business=business.pdf 
     8output.filename.users=users.pdf 
     9output.filename.location=e:\temp 
  • trunk/tools/docVaultStatistic/src/net/project/docvault/Main.java

    r18283 r18287  
    2121 
    2222                        Report r = new Report(); 
    23                         r.getStatisticReport(properties); 
     23                        r.getStatisticReport(properties, Report.ReportType.PROJECTS); 
     24                        r.getStatisticReport(properties, Report.ReportType.BUSINESS); 
     25                        r.getStatisticReport(properties, Report.ReportType.USERS); 
    2426                } catch (Exception e) { 
    2527                        e.printStackTrace(); 
  • trunk/tools/docVaultStatistic/src/net/project/docvault/Report.java

    r18283 r18287  
    2929 
    3030        private static final Logger log = Logger.getLogger(Report.class); 
    31  
    32         public void getStatisticReport(Properties properties) { 
    33                 File f = new File(properties.getProperty("output.filename.location") + File.separator + properties.getProperty("output.filename")); 
    34                 // System.out.println("file:" + 
    35                 // properties.getProperty("output.filename.location") + File.separator + 
    36                 // properties.getProperty("output.filename")); 
     31         
     32        public enum ReportType{ 
     33                PROJECTS, 
     34                BUSINESS, 
     35                USERS 
     36        } 
     37 
     38        public void getStatisticReport(Properties properties, ReportType rt) { 
     39                File f = null; 
     40                if (rt == ReportType.PROJECTS){ 
     41                        f = new File(properties.getProperty("output.filename.location") + File.separator + properties.getProperty("output.filename.projects")); 
     42                }else if (rt == ReportType.BUSINESS){ 
     43                        f = new File(properties.getProperty("output.filename.location") + File.separator + properties.getProperty("output.filename.business")); 
     44                }else if (rt == ReportType.USERS){ 
     45                        f = new File(properties.getProperty("output.filename.location") + File.separator + properties.getProperty("output.filename.users")); 
     46                } 
     47                 
     48 
    3749                OutputStream out = null; 
    3850 
     
    5567                        tableHeader.setSpacingAfter(15); 
    5668 
    57                         tableHeader.addCell(new Phrase("DocVault size per project", headerFont)); 
     69                        if (rt == ReportType.PROJECTS){ 
     70                                tableHeader.addCell(new Phrase("DocVault size per project", headerFont)); 
     71                        }else if (rt == ReportType.BUSINESS){ 
     72                                tableHeader.addCell(new Phrase("DocVault size per business", headerFont)); 
     73                        }else if (rt == ReportType.USERS){ 
     74                                tableHeader.addCell(new Phrase("DocVault size per user", headerFont)); 
     75                        } 
     76                         
    5877                        doc.add(tableHeader); 
    59                         List projects = getResults(properties); 
     78                        List projects = getResults(properties, rt); 
    6079                        if (projects != null && projects.size() > 0) { 
    6180 
     
    6887                                table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); 
    6988 
    70                                 table.addCell(new Phrase("Project id", tableFont)); 
    71                                 table.addCell(new Phrase("Project name", tableFont)); 
    72                                 table.addCell(new Phrase("Project size", tableFont)); 
    73  
     89                                if (rt == ReportType.PROJECTS){ 
     90                                        table.addCell(new Phrase("Project id", tableFont)); 
     91                                        table.addCell(new Phrase("Project name", tableFont)); 
     92                                        table.addCell(new Phrase("Documents size", tableFont)); 
     93                                }else if (rt == ReportType.BUSINESS){ 
     94                                        table.addCell(new Phrase("Business id", tableFont)); 
     95                                        table.addCell(new Phrase("Business name", tableFont)); 
     96                                        table.addCell(new Phrase("Documents size", tableFont)); 
     97                                }else if (rt == ReportType.USERS){ 
     98                                        table.addCell(new Phrase("User id", tableFont)); 
     99                                        table.addCell(new Phrase("Username", tableFont)); 
     100                                        table.addCell(new Phrase("Documents size", tableFont)); 
     101                                } 
     102                                 
    74103                                table.setHeaderRows(1); 
    75104                                table.setSpacingAfter(10); 
     
    93122        } 
    94123 
    95         public List getResults(Properties properties) { 
     124        public List getResults(Properties properties, ReportType rt) { 
    96125                List results = new ArrayList(); 
    97126                try { 
     
    107136                        String password = properties.getProperty("database.user.password"); 
    108137                        Connection connection = DriverManager.getConnection(url, username, password); 
    109  
    110                         PreparedStatement ps = connection.prepareStatement("SELECT p.project_id, p.project_name from pn_project_space p where record_status='A' order by p.project_name"); 
    111                         // ps.setString(1, properties.getProperty("project.ids")); 
     138                        PreparedStatement ps = null; 
     139                        if (rt == ReportType.PROJECTS){ 
     140                                ps = connection.prepareStatement("SELECT p.project_id, p.project_name from pn_project_space p order by p.project_name"); 
     141                        }else if (rt == ReportType.BUSINESS){ 
     142                                ps = connection.prepareStatement("select b.business_id, b.business_name from pn_business b order by b.business_name"); 
     143                        }else if (rt == ReportType.USERS){ 
     144                                ps = connection.prepareStatement("select u.user_id, u.username from pn_user u order by u.username"); 
     145                        } 
    112146                        ResultSet rs = ps.executeQuery(); 
    113147                        int i = 0; 
     
    151185                        Statement stmt = connection.createStatement(); 
    152186 
    153                         ResultSet rs = stmt.executeQuery("select repository_path from pn_doc_repository_base   where is_active = 1"); 
     187                        ResultSet rs = stmt.executeQuery("select repository_path from pn_doc_repository_base where is_active = 1"); 
    154188                        int i = 0; 
    155189                        while (rs.next()) {