1 23 package org.hammurapi; 24 25 import java.sql.Connection ; 26 import java.sql.SQLException ; 27 import java.sql.Timestamp ; 28 29 import org.hammurapi.results.CompositeResults; 30 import org.hammurapi.results.ReviewResults; 31 32 import com.pavelvlasov.ant.ConnectionEntry; 33 import com.pavelvlasov.convert.CompositeConverter; 34 import com.pavelvlasov.sql.SQLProcessor; 35 36 41 public class HistoryOutput extends ConnectionEntry implements Listener { 42 private String table; 43 private String reportUrl; 44 private String host; 45 private String description; 46 47 public void onReview(ReviewResults reviewResult) { 48 } 50 51 public void onPackage(CompositeResults packageResults) { 52 } 54 55 public void onSummary(final CompositeResults summary, InspectorSet inspectorSet) throws HammurapiException { 56 try { 57 Connection con = getConnection(); 58 try { 59 HistoryImpl history=new HistoryImpl(false); 60 61 history.setCodebase(summary.getCodeBase()); 63 history.setCompilationUnits(summary.size()-summary.getChildren().size()); 64 history.setDescription(description); 65 history.setHasWarnings(summary.hasWarnings() ? 1 : 0); 67 history.setHost(host); 68 history.setMaxSeverity((Integer ) CompositeConverter.getDefaultConverter().convert(summary.getMaxSeverity(), Integer .class, false)); 69 history.setName(summary.getName()); 70 history.setReportDate(new Timestamp (summary.getDate().getTime())); 71 history.setReportUrl(reportUrl); 72 history.setReviews(summary.getReviewsNumber()); 73 history.setViolationLevel(summary.getViolationLevel()); 74 history.setViolations(summary.getViolationsNumber()); 75 history.setWaivedViolations(summary.getWaivedViolationsNumber()); 76 history.setSigma(summary.getSigma()); 77 history.setDpmo(summary.getDPMO()); 78 79 history.insert(new SQLProcessor(con, null), table); 80 } finally { 81 con.close(); 82 } 83 } catch (SQLException e) { 84 throw new HammurapiException(e); 85 } catch (ClassNotFoundException e) { 86 throw new HammurapiException(e); 87 } 88 } 89 90 public void onBegin(InspectorSet inspectorSet) { 91 } 93 94 99 public void setTable(String table) { 100 this.table = table; 101 } 102 103 108 public void setReportUrl(String reportUrl) { 109 this.reportUrl = reportUrl; 110 } 111 112 117 public void setHost(String host) { 118 this.host = host; 119 } 120 121 126 public void setDescription(String description) { 127 this.description=description; 128 } 129 } 130 | Popular Tags |