Package org.jayasoft.woj.tools.report

Examples of org.jayasoft.woj.tools.report.DLReporter


        String localHostName = getLocalHostName();
        System.out.println("scanning " + settings.getDLDir()+ " on "+localHostName+" -- revision ("+DATE_FORMAT.format(new Date(REVISION_DATE))+")");
       
        DLExplorer explorer = new DLExplorer(settings.getDLDir().getAbsolutePath());
        DLAnalyzer analyzer = new DLAnalyzer(explorer);
        DLReporter reporter = new DLReporter(explorer);
       
        int analysed = 0;
        long total = 0;
        long start = System.currentTimeMillis();
        for (Organisation org : explorer.getOrganisations()) {
            System.out.println("scanning "+org.getName());
            for (Module module : explorer.getModules(org)) {
                System.out.println("\thandling module : " + module.getName());
                System.out.print("\t"+module.getName());
                for (Revision rev: explorer.getRevisions(module)) {
                        System.out.print(" "+rev.getName());
                        File desc = explorer.getRevisionDescriptorFile(rev);
                        RevisionDescriptor previousRd = null;
                        File previousFile = null;
                        if (desc.exists()) {
                            RevisionDescriptor rd = explorer.getDescriptor(rev);
                            long time = rd.getStatusTime();
                            if ("generated".equals(rd.getStatus()) && time  < REVISION_DATE) {
                                previousFile = new File(explorer.getRevisionDir(rev), "woj-crudemod-"+time+".xml");
                                IOHelper.move(desc, previousFile);
                                System.out.print("[DISCARD]");
                                try {
                                    previousRd = new RevisionDescriptor(rev, previousFile, Category.CATEGORIES);
                                    previousRd.readFile();
                                } catch (Exception ex) {
                                    previousRd = null;
                                }
                            }
                        }
                        if (!desc.exists()) {
                            File lock = new File(explorer.getRevisionDir(rev), ".analyze.lock");
                            if (lock.exists()) {
                               
                                String locking = "unknown";
                                try {
                                    locking = IOHelper.readEntirely(lock);
                                } catch (Exception ex) {
                                }
                                System.out.print("[LOCKED-"+locking+"]");
                                continue;
                            }
                            try {
                                IOHelper.writeFile(lock, localHostName);
                            } catch (Exception ex) {
                                System.out.print("[LOCKED--"+ex.getMessage()+"]");
                                continue;
                            }
                            try {
                                RevisionDescriptor rd = analyzer.analyze(rev);
                                rd.save();
                                System.out.print("[ANALYZED]");
                               
                                if (previousRd != null && previousRd.getAllItems().equals(rd.getAllItems())) {
                                    // new analyze lead to same content: we show same last modified timestamp
                                    rd.setLastModified(previousRd.getLastModified());
                                    previousFile.delete();
                                    System.out.print("[SAME]");
                                }
                               
                                reporter.scan(rev);
                                analysed++;
                            } finally {
                                IOHelper.delete(lock);
                            }
                        } else {
                            RevisionDescriptor rd = explorer.getDescriptor(rev);
                            System.out.print("[EXIST-"+rd.getStatus()+"-"+DATE_FORMAT.format(new Date(rd.getStatusTime()))+"]");                       
                        }
                        total++;
                }
                System.out.println();
            }
        }
        long duration = System.currentTimeMillis() - start;
        System.out.println("\nbatch analyse finished: "+total+" revisions found, "+analysed+" analysed in "+duration+"ms");

        String outputFileName = settings.getLogsDir().getPath()+"/dl-analyze-report.html";
        System.out.println("\nreporting to "+outputFileName);
        File outputFile = new File(outputFileName);
        if (outputFile.getParentFile() != null) {
            outputFile.getParentFile().mkdirs();
        }
        PrintStream out = new PrintStream(outputFile);
        reporter.report(out);
        out.close();
    }
View Full Code Here

TOP

Related Classes of org.jayasoft.woj.tools.report.DLReporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.