1 23 package org.hammurapi.results.persistent.jdbc; 24 25 import java.sql.SQLException ; 26 27 import org.hammurapi.HammurapiException; 28 import org.hammurapi.Violation; 29 import org.hammurapi.ViolationFilter; 30 import org.hammurapi.results.persistent.jdbc.sql.BaselineViolation; 31 import org.hammurapi.results.persistent.jdbc.sql.ResultsEngine; 32 33 import com.pavelvlasov.config.Component; 34 import com.pavelvlasov.config.ConfigurationException; 35 import com.pavelvlasov.review.Signed; 36 37 41 public class BaselineViolationFilter implements ViolationFilter, Component { 42 43 private String reportName; 44 private ResultsEngine resultsEngine; 45 46 public boolean accept(Violation violation) throws HammurapiException { 47 if (violation.getDescriptor()!=null && violation.getSource() instanceof Signed) 48 try { 49 String signature = ((Signed) violation.getSource()).getSignature(); 50 if (signature!=null) { 51 BaselineViolation bv = resultsEngine.getBaselineViolation( 52 reportName, 53 violation.getDescriptor().getName(), 54 signature); 55 if (bv!=null) { 56 return false; 57 } 58 } 59 } catch (SQLException e) { 60 throw new HammurapiException("Cannot obtain baseline violation", e); 61 } 62 return true; 63 } 64 65 public void start() throws ConfigurationException { 66 ResultsFactory resultsFactory = ((ResultsFactory) org.hammurapi.results.ResultsFactory.getInstance()); 67 reportName = resultsFactory.getName(); 68 resultsEngine = resultsFactory.getResultsEngine(); 69 } 70 71 public void stop() throws ConfigurationException { 72 } 74 75 public void setOwner(Object owner) { 76 } 78 79 } 80 | Popular Tags |